From 0eaf133a8dc4bc7549ffb052a2e2919af2f8d8c5 Mon Sep 17 00:00:00 2001 From: chenqi Date: Thu, 4 Jun 2026 16:14:40 +0800 Subject: [PATCH] =?UTF-8?q?feat(layout):=20=E5=AE=9E=E7=8E=B0=E6=A0=87?= =?UTF-8?q?=E7=AD=BE=E9=A1=B5=E8=A7=86=E5=9B=BE=E6=8C=89=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E6=8C=81=E4=B9=85=E5=8C=96=E5=AD=98=E5=82=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 引入用户模块以支持用户标识获取 - 修改标签页缓存键名格式为 tags-view-visited-[userId] - 在应用启动时自动加载当前用户的标签页视图 - 确保不同用户间的标签页视图数据隔离 - 保留匿名用户的支持逻辑 - 在设置重置时清理对应用户的缓存数据 --- .../src/layout/components/Settings/index.vue | 5 +++-- openhis-ui-vue3/src/permission.js | 2 ++ openhis-ui-vue3/src/store/modules/tagsView.js | 12 ++++++++---- 3 files changed, 13 insertions(+), 6 deletions(-) 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(