fix:国际化切换时候的刷新
This commit is contained in:
parent
caf2abd9bf
commit
03b0eeec58
@ -119,6 +119,7 @@ import { SysAuthApi, SysNoticeApi, SysUpgradeApi, SysUserApi } from '/@/api-serv
|
|||||||
import { languageList, getCountryCode } from '/@/i18n';
|
import { languageList, getCountryCode } from '/@/i18n';
|
||||||
import FlagIcon from 'vue3-flag-icons';
|
import FlagIcon from 'vue3-flag-icons';
|
||||||
import type { CountryCode } 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'));
|
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 OnlineUser = defineAsyncComponent(() => import('/@/views/system/onlineUser/index.vue'));
|
||||||
const ChangePassword = defineAsyncComponent(() => import('/@/views/system/user/component/changePassword.vue'));
|
const ChangePassword = defineAsyncComponent(() => import('/@/views/system/user/component/changePassword.vue'));
|
||||||
const UpgradeInfo = defineAsyncComponent(() => import('/@/views/system/upgrade/component/upgradeInfo.vue'));
|
const UpgradeInfo = defineAsyncComponent(() => import('/@/views/system/upgrade/component/upgradeInfo.vue'));
|
||||||
|
const routeStores = useRoutesList();
|
||||||
|
|
||||||
// 定义变量内容
|
// 定义变量内容
|
||||||
const { locale, t } = useI18n();
|
const { locale, t } = useI18n();
|
||||||
@ -248,9 +250,12 @@ const onLanguageChange = (lang: string) => {
|
|||||||
locale.value = lang;
|
locale.value = lang;
|
||||||
other.useTitle();
|
other.useTitle();
|
||||||
initI18nOrSize('globalI18n', 'disabledI18n');
|
initI18nOrSize('globalI18n', 'disabledI18n');
|
||||||
// window.location.reload();
|
refreshCurrentTabpage();
|
||||||
// 关闭全部标签页
|
};
|
||||||
// mittBus.emit('onCurrentContextmenuClick', { contextMenuClickId: 3 });
|
|
||||||
|
//刷新当前tabpage.
|
||||||
|
const refreshCurrentTabpage = () => {
|
||||||
|
mittBus.emit('onCurrentContextmenuClick', { ...routeStores.currentRoute, contextMenuClickId: 0 });
|
||||||
};
|
};
|
||||||
|
|
||||||
// 初始化组件大小/i18n
|
// 初始化组件大小/i18n
|
||||||
|
|||||||
@ -24,6 +24,7 @@ import { initBackEndControlRoutes } from '/@/router/backEnd';
|
|||||||
const storesThemeConfig = useThemeConfig(pinia);
|
const storesThemeConfig = useThemeConfig(pinia);
|
||||||
const { themeConfig } = storeToRefs(storesThemeConfig);
|
const { themeConfig } = storeToRefs(storesThemeConfig);
|
||||||
const { isRequestRoutes } = themeConfig.value;
|
const { isRequestRoutes } = themeConfig.value;
|
||||||
|
const routeStores = useRoutesList();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建一个可以被 Vue 应用程序使用的路由实例
|
* 创建一个可以被 Vue 应用程序使用的路由实例
|
||||||
@ -95,6 +96,7 @@ export function formatTwoStageRoutes(arr: any) {
|
|||||||
// 路由加载前
|
// 路由加载前
|
||||||
router.beforeEach(async (to, from, next) => {
|
router.beforeEach(async (to, from, next) => {
|
||||||
NProgress.configure({ showSpinner: false });
|
NProgress.configure({ showSpinner: false });
|
||||||
|
routeStores.setCurrentRoute(to as unknown as RouteItem); //记录最新当前路由对象.
|
||||||
if (to.meta.title) NProgress.start();
|
if (to.meta.title) NProgress.start();
|
||||||
const token = Session.get('token');
|
const token = Session.get('token');
|
||||||
if (to.meta.isPublic && !token) {
|
if (to.meta.isPublic && !token) {
|
||||||
|
|||||||
@ -11,8 +11,12 @@ export const useRoutesList = defineStore('routesList', {
|
|||||||
routesList: [],
|
routesList: [],
|
||||||
isColumnsMenuHover: false,
|
isColumnsMenuHover: false,
|
||||||
isColumnsNavHover: false,
|
isColumnsNavHover: false,
|
||||||
|
currentRoute: null,
|
||||||
}),
|
}),
|
||||||
actions: {
|
actions: {
|
||||||
|
setCurrentRoute(route: RouteItem) {
|
||||||
|
this.currentRoute = route;
|
||||||
|
},
|
||||||
async setRoutesList(data: Array<string>) {
|
async setRoutesList(data: Array<string>) {
|
||||||
this.routesList = data;
|
this.routesList = data;
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user