[web] Fix the search page source when clicking the search menu

This commit is contained in:
Alain Nussbaumer 2024-04-03 17:46:33 +02:00
parent 4946c0e43c
commit 31661edc03
5 changed files with 9 additions and 13 deletions

View File

@ -134,7 +134,7 @@ export default {
computed: { computed: {
search_name: { search_name: {
get() { get() {
return `search-${this.$store.state.search_source}` return this.$store.state.search_source
} }
}, },
show_audiobooks() { show_audiobooks() {

View File

@ -7,7 +7,7 @@
<ul> <ul>
<li <li
:class="{ :class="{
'is-active': $store.state.search_source === 'library' 'is-active': $route.name === 'search-library'
}" }"
> >
<a @click="search_library"> <a @click="search_library">
@ -17,7 +17,7 @@
</li> </li>
<li <li
:class="{ :class="{
'is-active': $store.state.search_source === 'spotify' 'is-active': $route.name === 'search-spotify'
}" }"
> >
<a @click="search_spotify"> <a @click="search_spotify">
@ -34,8 +34,6 @@
</template> </template>
<script> <script>
import * as types from '@/store/mutation_types'
export default { export default {
name: 'TabsSearch', name: 'TabsSearch',
props: { query: { default: '', type: String } }, props: { query: { default: '', type: String } },
@ -59,7 +57,6 @@ export default {
methods: { methods: {
search_library() { search_library() {
this.$store.commit(types.SEARCH_SOURCE, 'library')
this.$router.push({ this.$router.push({
name: 'search-library', name: 'search-library',
query: this.route_query query: this.route_query
@ -67,7 +64,6 @@ export default {
}, },
search_spotify() { search_spotify() {
this.$store.commit(types.SEARCH_SOURCE, 'spotify')
this.$router.push({ this.$router.push({
name: 'search-spotify', name: 'search-spotify',
query: this.route_query query: this.route_query

View File

@ -77,6 +77,7 @@
</template> </template>
<script> <script>
import * as types from '@/store/mutation_types'
import ContentWithHeading from '@/templates/ContentWithHeading.vue' import ContentWithHeading from '@/templates/ContentWithHeading.vue'
import { GroupedList } from '@/lib/GroupedList' import { GroupedList } from '@/lib/GroupedList'
import ListAlbums from '@/components/ListAlbums.vue' import ListAlbums from '@/components/ListAlbums.vue'
@ -146,6 +147,7 @@ export default {
}, },
mounted() { mounted() {
this.$store.commit(types.SEARCH_SOURCE, this.$route.name)
this.search(this.$route) this.search(this.$route)
}, },
@ -155,7 +157,6 @@ export default {
return return
} }
this.$router.push({ this.$router.push({
name: 'search-library',
query: { query: {
limit: 3, limit: 3,
offset: 0, offset: 0,
@ -171,7 +172,6 @@ export default {
}, },
open_search(type) { open_search(type) {
this.$router.push({ this.$router.push({
name: 'search-library',
query: { query: this.$route.query.query, type } query: { query: this.$route.query.query, type }
}) })
}, },

View File

@ -73,6 +73,7 @@
</template> </template>
<script> <script>
import * as types from '@/store/mutation_types'
import ContentWithHeading from '@/templates/ContentWithHeading.vue' import ContentWithHeading from '@/templates/ContentWithHeading.vue'
import ListAlbumsSpotify from '@/components/ListAlbumsSpotify.vue' import ListAlbumsSpotify from '@/components/ListAlbumsSpotify.vue'
import ListArtistsSpotify from '@/components/ListArtistsSpotify.vue' import ListArtistsSpotify from '@/components/ListArtistsSpotify.vue'
@ -134,6 +135,7 @@ export default {
}, },
mounted() { mounted() {
this.$store.commit(types.SEARCH_SOURCE, this.$route.name)
this.query = this.$route.query this.query = this.$route.query
this.search() this.search()
}, },
@ -144,12 +146,11 @@ export default {
return return
} }
this.$router.push({ this.$router.push({
name: 'search-spotify',
query: { query: {
limit: 3, limit: 3,
offset: 0, offset: 0,
query: this.search_query, query: this.search_query,
type: 'track,artist,album,playlist,audiobook,podcast' type: this.search_types.join()
} }
}) })
this.$refs.search_field.blur() this.$refs.search_field.blur()
@ -160,7 +161,6 @@ export default {
}, },
open_search(type) { open_search(type) {
this.$router.push({ this.$router.push({
name: 'search-spotify',
query: { query: this.$route.query.query, type } query: { query: this.$route.query.query, type }
}) })
}, },

View File

@ -54,7 +54,7 @@ export default createStore({
}, },
recent_searches: [], recent_searches: [],
rss_count: {}, rss_count: {},
search_source: 'library', search_source: 'search-library',
settings: { settings: {
categories: [] categories: []
}, },