diff --git a/src/components/search.vue b/src/components/search.vue index b049bc6..5496721 100644 --- a/src/components/search.vue +++ b/src/components/search.vue @@ -138,7 +138,7 @@ export default { goSearch(keywords) { this.searchHistorys.push({ first: keywords }) storage.set(SEARCH_HISTORY_KEY, this.searchHistorys) - this.$router.push(`/search/${keywords}`) + this.$router.push(`/search/songs/${keywords}`) this.searchPanelShow = false }, async onClickSong(item) { diff --git a/src/page/search/index.vue b/src/page/search/index.vue index b47ce4d..e802f54 100644 --- a/src/page/search/index.vue +++ b/src/page/search/index.vue @@ -11,6 +11,7 @@
@@ -57,15 +58,19 @@ export default { data() { return { count: 0, - activeTabIndex: 0 + activeTabIndex: tabs.findIndex( + ({ key }) => key === this.$route.params.type + ) } }, methods: { onUpdateCount(count) { this.count = count + }, + onTabChange() { + this.$router.push(`/search/${this.currentTab.key}/${this.keywords}`) } }, - computed: { currentTab() { return tabs[this.activeTabIndex] diff --git a/src/router.js b/src/router.js index 93d3df8..7d6c139 100644 --- a/src/router.js +++ b/src/router.js @@ -67,7 +67,7 @@ export default new Router({ component: PlaylistDetail, }, { - path: '/search/:keywords', + path: '/search/:type/:keywords', name: 'search', component: Search, props: true,