diff --git a/openhis-ui-vue3/src/layout/components/Settings/index.vue b/openhis-ui-vue3/src/layout/components/Settings/index.vue index 7158f19b1..6ec221f93 100755 --- a/openhis-ui-vue3/src/layout/components/Settings/index.vue +++ b/openhis-ui-vue3/src/layout/components/Settings/index.vue @@ -127,6 +127,7 @@ import useAppStore from '@/store/modules/app' import useSettingsStore from '@/store/modules/settings' import usePermissionStore from '@/store/modules/permission' +import useUserStore from '@/store/modules/user' import { handleThemeStyle } from '@/utils/theme' const { proxy } = getCurrentInstance() @@ -192,7 +193,7 @@ watch(() => navType.value, val => { function saveSetting() { proxy.$modal.loading("正在保存到本地,请稍候...") if (!tagsViewPersist.value) { - proxy.$cache.local.remove('tags-view-visited') + proxy.$cache.local.remove('tags-view-visited-' + (useUserStore().id || 'anonymous')) } let layoutSetting = { "topNav": storeSettings.value.topNav, @@ -212,7 +213,7 @@ function saveSetting() { } function resetSetting() { - proxy.$cache.local.remove('tags-view-visited') + proxy.$cache.local.remove('tags-view-visited-' + (useUserStore().id || 'anonymous')) proxy.$modal.loading("正在清除设置缓存并刷新,请稍候...") localStorage.removeItem("layout-setting") setTimeout("window.location.reload()", 1000) diff --git a/openhis-ui-vue3/src/permission.js b/openhis-ui-vue3/src/permission.js index 870b2f904..62b1ef16b 100755 --- a/openhis-ui-vue3/src/permission.js +++ b/openhis-ui-vue3/src/permission.js @@ -10,6 +10,7 @@ import useLockStore from '@/store/modules/lock' import useSettingsStore from '@/store/modules/settings' import usePermissionStore from '@/store/modules/permission' import useNoticeStore from '@/store/modules/notice' +import useTagsViewStore from '@/store/modules/tagsView' // 全局变量,用于控制公告弹窗只显示一次 let hasShownNoticePopup = false @@ -56,6 +57,7 @@ router.beforeEach(async (to, from) => { } }) useNoticeStore().startPolling() + useTagsViewStore().loadPersistedViews() return { ...to, replace: true } } catch (err) { console.error('路由加载失败:', err) diff --git a/openhis-ui-vue3/src/store/modules/tagsView.js b/openhis-ui-vue3/src/store/modules/tagsView.js index 213743a9f..97a7aaaaf 100755 --- a/openhis-ui-vue3/src/store/modules/tagsView.js +++ b/openhis-ui-vue3/src/store/modules/tagsView.js @@ -1,7 +1,11 @@ import cache from '@/plugins/cache' import useSettingsStore from '@/store/modules/settings' +import useUserStore from '@/store/modules/user' -const PERSIST_KEY = 'tags-view-visited' +function getPersistKey() { + const userId = useUserStore().id || 'anonymous' + return 'tags-view-visited-' + userId +} function isPersistEnabled() { return useSettingsStore().tagsViewPersist @@ -10,15 +14,15 @@ function isPersistEnabled() { function saveVisitedViews(views) { if (!isPersistEnabled()) return const toSave = views.filter(v => !(v.meta && v.meta.affix)).map(v => ({ path: v.path, fullPath: v.fullPath, name: v.name, title: v.title, query: v.query, meta: v.meta })) - cache.local.setJSON(PERSIST_KEY, toSave) + cache.local.setJSON(getPersistKey(), toSave) } function loadVisitedViews() { - return cache.local.getJSON(PERSIST_KEY) || [] + return cache.local.getJSON(getPersistKey()) || [] } function clearVisitedViews() { - cache.local.remove(PERSIST_KEY) + cache.local.remove(getPersistKey()) } const useTagsViewStore = defineStore(