比较完美完成返回滚动实现

This commit is contained in:
zilong
2021-11-04 20:09:27 +08:00
parent e16176d6ea
commit f0e5ea4363
14 changed files with 535 additions and 95 deletions

View File

@@ -22,6 +22,7 @@ import {
NMessageProvider,
} from "naive-ui";
import router from "./router";
// import { CloudCircleSharp } from "@vicons/ionicons5";
const store = useStore();
@@ -44,6 +45,16 @@ store.commit("loadSettings");
store.state.settings.playing = false; //默认停止播放
store.commit("loadCaches");
// onMounted(() => {
// window.addEventListener('popstate', popstate, false);
// })
// const popstate = (event)=>{
// console.log('popstate--',event);
// }
// onUnmounted(() => {
// window.removeEventListener('popstate',pop)
// })
// router.replace('/discover/recommend')
const showPlaying = ref(false); //是否显示播放列表
@@ -60,14 +71,15 @@ watch(
}
)
//处理route消息
const routeToken = pubsub.subscribe("router", (msg, data) => {
switch (msg) {
case "router.beforeEach":
case "router.afterEach":
store.commit("saveSettings", {
currentRoute: data.to.fullPath,
});
// store.commit("saveSettings", {
// currentRoute: data.to.fullPath,
// });
break;
}
});
@@ -140,9 +152,9 @@ const hideWins = (e) => {
</div>
<div id="main">
<router-view v-slot="{ Component, route }">
<keep-alive exclude="FM,Friends">
<!-- <keep-alive exclude="FM,Friends"> -->
<component :is="Component" />
</keep-alive>
<!-- </keep-alive> -->
</router-view>
<!-- <router-view v-slot="{ Component, route }">
<keep-alive v-if="route.meta.keepAlive">