将Search的语法糖进行修改。
This commit is contained in:
parent
d4d94ddbee
commit
a8bb11fa66
@ -12,8 +12,8 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script setup>
|
||||||
import { useRoute, useRouter } from '@common/utils/vueRouter'
|
import { onBeforeRouteUpdate, useRoute, useRouter } from '@common/utils/vueRouter'
|
||||||
import { searchText } from '@renderer/store/search/state'
|
import { searchText } from '@renderer/store/search/state'
|
||||||
import { getSearchSetting, setSearchSetting } from '@renderer/utils/data'
|
import { getSearchSetting, setSearchSetting } from '@renderer/utils/data'
|
||||||
import { sources as _sources } from '@renderer/store/search/music'
|
import { sources as _sources } from '@renderer/store/search/music'
|
||||||
@ -57,25 +57,17 @@ const verifyQueryParams = async(to, from, next) => {
|
|||||||
setSearchSetting({ source: _source, type: _type })
|
setSearchSetting({ source: _source, type: _type })
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
const route = useRoute()
|
||||||
components: {
|
const router = useRouter()
|
||||||
MusicList,
|
router.beforeEach((to, from, next) => verifyQueryParams(to, from, next))
|
||||||
SongListList,
|
onBeforeRouteUpdate((to, from, next) => verifyQueryParams(to, from, next))
|
||||||
BlankView,
|
const sources = _sources.map(id => {
|
||||||
},
|
|
||||||
beforeRouteEnter: verifyQueryParams,
|
|
||||||
beforeRouteUpdate: verifyQueryParams,
|
|
||||||
setup() {
|
|
||||||
const route = useRoute()
|
|
||||||
const router = useRouter()
|
|
||||||
|
|
||||||
const sources = _sources.map(id => {
|
|
||||||
return {
|
return {
|
||||||
id,
|
id,
|
||||||
label: sourceNames.value[id],
|
label: sourceNames.value[id],
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
const handleSourceChange = (id) => {
|
const handleSourceChange = (id) => {
|
||||||
router.replace({
|
router.replace({
|
||||||
path: route.path,
|
path: route.path,
|
||||||
query: {
|
query: {
|
||||||
@ -84,15 +76,15 @@ export default {
|
|||||||
page: 1,
|
page: 1,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const searchTypes = computed(() => {
|
const searchTypes = computed(() => {
|
||||||
return [
|
return [
|
||||||
{ label: window.i18n.t('search__type_music'), id: 'music' },
|
{ label: window.i18n.t('search__type_music'), id: 'music' },
|
||||||
{ label: window.i18n.t('search__type_songlist'), id: 'songlist' },
|
{ label: window.i18n.t('search__type_songlist'), id: 'songlist' },
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
const handleTypeChange = (type) => {
|
const handleTypeChange = (type) => {
|
||||||
router.replace({
|
router.replace({
|
||||||
path: route.path,
|
path: route.path,
|
||||||
query: {
|
query: {
|
||||||
@ -101,26 +93,10 @@ export default {
|
|||||||
page: 1,
|
page: 1,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return {
|
|
||||||
sources,
|
|
||||||
source,
|
|
||||||
handleSourceChange,
|
|
||||||
searchTypes,
|
|
||||||
searchType,
|
|
||||||
handleTypeChange,
|
|
||||||
page,
|
|
||||||
searchText,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="less" module>
|
<style lang="less" module scoped>
|
||||||
.container {
|
.container {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-flow: column nowrap;
|
flex-flow: column nowrap;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user