Template
1
0
mirror of https://github.com/un-pany/v3-admin-vite.git synced 2025-04-20 19:09:21 +08:00

fix: 修复 <transition> 和 <keep-alive> 组合使用导致的页面空白

This commit is contained in:
pany 2023-08-24 14:08:43 +08:00
parent 86f11d42b8
commit db3de00fcf
3 changed files with 23 additions and 0 deletions

View File

@ -3,6 +3,7 @@ import { useUserStoreHook } from "@/store/modules/user"
import { usePermissionStoreHook } from "@/store/modules/permission"
import { ElMessage } from "element-plus"
import { getToken } from "@/utils/cache/cookies"
import { fixBlankPage } from "@/utils/fix-blank-page"
import routeSettings from "@/config/route"
import isWhiteList from "@/config/white-list"
import NProgress from "nprogress"
@ -11,6 +12,7 @@ import "nprogress/nprogress.css"
NProgress.configure({ showSpinner: false })
router.beforeEach(async (to, _from, next) => {
fixBlankPage()
NProgress.start()
const userStore = useUserStoreHook()
const permissionStore = usePermissionStoreHook()

View File

@ -1,4 +1,5 @@
import { ref, watchEffect } from "vue"
import store from "@/store"
import { defineStore } from "pinia"
import { useSettingsStore } from "./settings"
import { type RouteLocationNormalized } from "vue-router"
@ -93,3 +94,8 @@ export const useTagsViewStore = defineStore("tags-view", () => {
delAllCachedViews
}
})
/** 在 setup 外使用 */
export function useTagsViewStoreHook() {
return useTagsViewStore(store)
}

View File

@ -0,0 +1,15 @@
import { useTagsViewStoreHook } from "@/store/modules/tags-view"
/**
* <transition> <keep-alive> 使
* Vue BUGhttps://github.com/vuejs/core/issues/7121
* 使
* 1.
* 2. TS
* 3.
* 4.
*/
export const fixBlankPage = () => {
const tagsViewStore = useTagsViewStoreHook()
tagsViewStore.cachedViews = [...tagsViewStore.cachedViews]
}