feat: 优化路由持久化

This commit is contained in:
algerkong
2023-12-27 21:44:55 +08:00
parent d04aeef40b
commit f5d097e975
3 changed files with 16 additions and 12 deletions

View File

@@ -12,12 +12,12 @@
<div class="main-content bg-black" :native-scrollbar="false">
<n-message-provider>
<router-view class="main-page" v-slot="{ Component }">
<!-- <keep-alive>
<component :is="Component" v-if="$route.meta.keepAlive" />
<keep-alive>
<component :is="Component" />
</keep-alive>
<component :is="Component" v-if="!$route.meta.keepAlive" />-->
<!-- <component :is="Component" v-if="!$route.meta.keepAlive" />
<component :is="Component" />
<component :is="Component" /> -->
</router-view>
</n-message-provider>
</div>

View File

@@ -43,12 +43,14 @@ if (route.query.type) {
watch(
() => route.query,
async newParams => {
const params = {
tag: newParams.type || '',
limit: 30,
before: 0
if(newParams.type){
const params = {
tag: newParams.type || '',
limit: 30,
before: 0
}
loadList(newParams.type);
}
loadList(newParams.type);
}
)

View File

@@ -33,11 +33,13 @@ const loadPage = async () => {
const { data: recordData } = await getUserRecord(user.userId)
recordList.value = recordData.allData
}
loadPage()
watch(() => router.currentRoute.value, (to) => {
if (to.path === "/user") {
loadPage()
}
})
const isShowList = ref(false)
const list = ref<Playlist>()