[web] Use named route for search pages

Switching to named routes in order to reduce future maintenance.
This commit is contained in:
Alain Nussbaumer
2023-07-12 22:39:21 +02:00
parent 845f111c29
commit 6f1f53007d
6 changed files with 19 additions and 18 deletions

View File

@@ -27,7 +27,7 @@
<navbar-item-link v-if="is_visible_files" :to="{ name: 'files' }">
<mdicon class="icon" name="folder-open" size="16" />
</navbar-item-link>
<navbar-item-link v-if="is_visible_search" :to="{ name: 'search' }">
<navbar-item-link v-if="is_visible_search" :to="{ name: search_name }">
<mdicon class="icon" name="magnify" size="16" />
</navbar-item-link>
<div
@@ -96,7 +96,7 @@
<mdicon class="icon" name="folder-open" size="16" />
<b v-text="$t('navigation.files')" />
</navbar-item-link>
<navbar-item-link :to="{ name: 'search' }">
<navbar-item-link :to="{ name: search_name }">
<mdicon class="icon" name="magnify" size="16" />
<b v-text="$t('navigation.search')" />
</navbar-item-link>
@@ -229,6 +229,12 @@ export default {
}
},
search_name: {
get() {
return 'search-' + this.$store.state.search_source
}
},
zindex() {
if (this.show_player_menu) {
return 'z-index: 20'

View File

@@ -7,7 +7,7 @@
<ul>
<li
:class="{
'is-active': $store.state.search_path === '/search/library'
'is-active': $store.state.search_source === 'library'
}"
>
<a @click="search_library">
@@ -17,7 +17,7 @@
</li>
<li
:class="{
'is-active': $store.state.search_path === '/search/spotify'
'is-active': $store.state.search_source === 'spotify'
}"
>
<a @click="search_spotify">
@@ -62,17 +62,17 @@ export default {
methods: {
search_library() {
this.$store.commit(types.SEARCH_PATH, '/search/library')
this.$store.commit(types.SEARCH_SOURCE, 'library')
this.$router.push({
path: this.$store.state.search_path,
name: 'search-library',
query: this.route_query
})
},
search_spotify() {
this.$store.commit(types.SEARCH_PATH, '/search/spotify')
this.$store.commit(types.SEARCH_SOURCE, 'spotify')
this.$router.push({
path: this.$store.state.search_path,
name: 'search-spotify',
query: this.route_query
})
}