fix:国际化切换时候的刷新

This commit is contained in:
PZ688 2025-03-25 02:29:32 +08:00
parent caf2abd9bf
commit 03b0eeec58
3 changed files with 14 additions and 3 deletions

View File

@ -119,6 +119,7 @@ import { SysAuthApi, SysNoticeApi, SysUpgradeApi, SysUserApi } from '/@/api-serv
import { languageList, getCountryCode } from '/@/i18n';
import FlagIcon from 'vue3-flag-icons';
import type { CountryCode } from 'vue3-flag-icons';
import { useRoutesList } from '/@/stores/routesList';
//
const UserNews = defineAsyncComponent(() => import('/@/layout/navBars/topBar/userNews.vue'));
@ -126,6 +127,7 @@ const Search = defineAsyncComponent(() => import('/@/layout/navBars/topBar/searc
const OnlineUser = defineAsyncComponent(() => import('/@/views/system/onlineUser/index.vue'));
const ChangePassword = defineAsyncComponent(() => import('/@/views/system/user/component/changePassword.vue'));
const UpgradeInfo = defineAsyncComponent(() => import('/@/views/system/upgrade/component/upgradeInfo.vue'));
const routeStores = useRoutesList();
//
const { locale, t } = useI18n();
@ -248,9 +250,12 @@ const onLanguageChange = (lang: string) => {
locale.value = lang;
other.useTitle();
initI18nOrSize('globalI18n', 'disabledI18n');
// window.location.reload();
//
// mittBus.emit('onCurrentContextmenuClick', { contextMenuClickId: 3 });
refreshCurrentTabpage();
};
//tabpage.
const refreshCurrentTabpage = () => {
mittBus.emit('onCurrentContextmenuClick', { ...routeStores.currentRoute, contextMenuClickId: 0 });
};
// /i18n

View File

@ -24,6 +24,7 @@ import { initBackEndControlRoutes } from '/@/router/backEnd';
const storesThemeConfig = useThemeConfig(pinia);
const { themeConfig } = storeToRefs(storesThemeConfig);
const { isRequestRoutes } = themeConfig.value;
const routeStores = useRoutesList();
/**
* Vue 使
@ -95,6 +96,7 @@ export function formatTwoStageRoutes(arr: any) {
// 路由加载前
router.beforeEach(async (to, from, next) => {
NProgress.configure({ showSpinner: false });
routeStores.setCurrentRoute(to as unknown as RouteItem); //记录最新当前路由对象.
if (to.meta.title) NProgress.start();
const token = Session.get('token');
if (to.meta.isPublic && !token) {

View File

@ -11,8 +11,12 @@ export const useRoutesList = defineStore('routesList', {
routesList: [],
isColumnsMenuHover: false,
isColumnsNavHover: false,
currentRoute: null,
}),
actions: {
setCurrentRoute(route: RouteItem) {
this.currentRoute = route;
},
async setRoutesList(data: Array<string>) {
this.routesList = data;
},