mirror of
https://github.com/un-pany/v3-admin-vite.git
synced 2025-04-21 03:19:19 +08:00
fix: 第一个缓存页面加载时不触发 onActivated 钩子 (#214)
Co-authored-by: pany <939630029@qq.com>
This commit is contained in:
parent
ffb6cb3a11
commit
13a53cc994
@ -65,7 +65,7 @@ const initTags = () => {
|
||||
affixTags = filterAffixTags(permissionStore.routes)
|
||||
for (const tag of affixTags) {
|
||||
// 必须含有 name 属性
|
||||
tag.name && tagsViewStore.addVisitedView(tag)
|
||||
tag.name && tagsViewStore.addVisitedView(tag, true)
|
||||
}
|
||||
}
|
||||
|
||||
@ -153,12 +153,13 @@ watch(visible, (value) => {
|
||||
value ? document.body.addEventListener("click", closeMenu) : document.body.removeEventListener("click", closeMenu)
|
||||
})
|
||||
|
||||
/** 监听路由变化 */
|
||||
listenerRouteChange((route) => {
|
||||
addTags(route)
|
||||
}, true)
|
||||
|
||||
onMounted(() => {
|
||||
initTags()
|
||||
/** 监听路由变化 */
|
||||
listenerRouteChange(async (route) => {
|
||||
addTags(route)
|
||||
}, true)
|
||||
})
|
||||
</script>
|
||||
|
||||
|
@ -18,7 +18,7 @@ export const useTagsViewStore = defineStore("tags-view", () => {
|
||||
})
|
||||
|
||||
//#region add
|
||||
const addVisitedView = (view: TagView) => {
|
||||
const addVisitedView = (view: TagView, isUnshift: boolean = false) => {
|
||||
// 检查是否已经存在相同的 visitedView
|
||||
const index = visitedViews.value.findIndex((v) => v.path === view.path)
|
||||
if (index !== -1) {
|
||||
@ -26,7 +26,7 @@ export const useTagsViewStore = defineStore("tags-view", () => {
|
||||
visitedViews.value[index].fullPath !== view.fullPath && (visitedViews.value[index] = { ...view })
|
||||
} else {
|
||||
// 添加新的 visitedView
|
||||
visitedViews.value.push({ ...view })
|
||||
isUnshift ? visitedViews.value.unshift({ ...view }) : visitedViews.value.push({ ...view })
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user