1
0
mirror of https://github.com/zclzone/vue-naive-admin.git synced 2026-04-26 04:04:08 +08:00

fix: keepAlive

This commit is contained in:
张传龙
2023-07-11 15:07:37 +08:00
parent d49af8b574
commit d702a6703b
5 changed files with 33 additions and 48 deletions

View File

@@ -5,34 +5,17 @@ const isDark = useDark()
export const useAppStore = defineStore('app', {
state() {
return {
reloadFlag: true,
collapsed: false,
/** keepAlive路由的key重新赋值可重置keepAlive */
aliveKeys: {},
isDark,
}
},
actions: {
async reloadPage() {
$loadingBar.start()
this.reloadFlag = false
await nextTick()
this.reloadFlag = true
setTimeout(() => {
document.documentElement.scrollTo({ left: 0, top: 0 })
$loadingBar.finish()
}, 100)
},
switchCollapsed() {
this.collapsed = !this.collapsed
},
setCollapsed(collapsed) {
this.collapsed = collapsed
},
setAliveKeys(key, val) {
this.aliveKeys[key] = val
},
/** 设置暗黑模式 */
setDark(isDark) {
this.isDark = isDark