fix: 静态路由菜单国际化/切换刷新
This commit is contained in:
@@ -85,7 +85,7 @@ const breadcrumb = computed(() => {
|
||||
.map(item => {
|
||||
return {
|
||||
path: item.path,
|
||||
breadcrumbName: item.meta.title || '-',
|
||||
breadcrumbName: fnLocale(item.meta.title || '-'),
|
||||
};
|
||||
});
|
||||
});
|
||||
@@ -120,6 +120,16 @@ function fnComponentSetName(component: any, to: any) {
|
||||
// 清空导航栏标签
|
||||
tabsStore.clear();
|
||||
|
||||
/**
|
||||
* 国际化翻译转换
|
||||
*/
|
||||
function fnLocale(title: string) {
|
||||
if (title.indexOf('router.') !== -1) {
|
||||
title = t(title);
|
||||
}
|
||||
return title;
|
||||
}
|
||||
|
||||
//
|
||||
onMounted(() => {
|
||||
// fnGetServerTime();
|
||||
@@ -186,6 +196,7 @@ document.addEventListener('visibilitychange', function () {
|
||||
v-bind="proConfig"
|
||||
:iconfont-url="scriptUrl"
|
||||
:sider-width="208"
|
||||
:locale="(fnLocale as any)"
|
||||
>
|
||||
<!--插槽-菜单头-->
|
||||
<template #menuHeaderRender>
|
||||
|
||||
@@ -92,6 +92,16 @@ function fnTabClose(path: string) {
|
||||
router.push(to);
|
||||
}
|
||||
|
||||
/**
|
||||
* 国际化翻译转换
|
||||
*/
|
||||
function fnLocale(title: string) {
|
||||
if (title.indexOf('router.') !== -1) {
|
||||
title = t(title);
|
||||
}
|
||||
return title;
|
||||
}
|
||||
|
||||
/**监听当前路由添加到导航标签列表 */
|
||||
watch(router.currentRoute, v => tabsStore.tabOpen(v), { immediate: true });
|
||||
</script>
|
||||
@@ -120,7 +130,7 @@ watch(router.currentRoute, v => tabsStore.tabOpen(v), { immediate: true });
|
||||
<template #tab>
|
||||
<span>
|
||||
<IconFont :type="tab.icon" style="margin: 0"></IconFont>
|
||||
{{ tab.title }}
|
||||
{{ fnLocale(tab.title) }}
|
||||
</span>
|
||||
</template>
|
||||
</a-tab-pane>
|
||||
|
||||
Reference in New Issue
Block a user