fix: 切换时区后,页面不刷新 (#7085)

* fix: 切换时区后,页面不刷新

* fix: keep-alive 的页面,i18n 和 timezone 不更新
This commit is contained in:
yuhengshen
2026-01-10 14:10:27 +08:00
committed by GitHub
parent 9480f8272a
commit 343d8a1c1e

View File

@@ -14,7 +14,7 @@ import {
updatePreferences,
usePreferences,
} from '@vben/preferences';
import { useAccessStore } from '@vben/stores';
import { useAccessStore, useTabbarStore, useTimezoneStore } from '@vben/stores';
import { cloneDeep, mapTree } from '@vben/utils';
import { VbenAdminLayout } from '@vben-core/layout-ui';
@@ -52,6 +52,7 @@ const {
theme,
} = usePreferences();
const accessStore = useAccessStore();
const timezoneStore = useTimezoneStore();
const { refresh } = useRefresh();
const sidebarTheme = computed(() => {
@@ -187,9 +188,19 @@ watch(
},
);
const tabbarStore = useTabbarStore();
function refreshAll() {
tabbarStore.cachedTabs.clear();
refresh();
}
// 语言更新后,刷新页面
// i18n.global.locale会在preference.app.locale变更之后才会更新因此watchpreference.app.locale是不合适的刷新页面时可能语言配置尚未完全加载完成
watch(i18n.global.locale, refresh, { flush: 'post' });
watch(i18n.global.locale, refreshAll, { flush: 'post' });
// 时区更新后,刷新页面
watch(() => timezoneStore.timezone, refreshAll, { flush: 'post' });
const slots: SetupContext['slots'] = useSlots();
const headerSlots = computed(() => {