perf: 优化国际化,路由不再传i18n字段,平台自动读取根目录locales文件夹下文件进行国际化匹配

This commit is contained in:
xiaoxian521
2022-05-11 15:25:01 +08:00
parent f35dea840e
commit 9067d88c3b
37 changed files with 411 additions and 430 deletions

View File

@@ -115,11 +115,8 @@ router.beforeEach((to: toRouteType, _from, next) => {
if (!item.meta.title) return "";
const Title = getConfig().Title;
if (Title)
document.title = `${transformI18n(
item.meta.title,
item.meta?.i18n
)} | ${Title}`;
else document.title = transformI18n(item.meta.title, item.meta?.i18n);
document.title = `${transformI18n(item.meta.title)} | ${Title}`;
else document.title = transformI18n(item.meta.title);
});
if (name) {
if (_from?.name) {

View File

@@ -8,7 +8,6 @@ const ableRouter = {
meta: {
icon: "ubuntu-fill",
title: $t("menus.hsAble"),
i18n: true,
rank: 4
},
children: [
@@ -17,8 +16,7 @@ const ableRouter = {
name: "reWatermark",
component: () => import("/@/views/able/watermark.vue"),
meta: {
title: $t("menus.hsWatermark"),
i18n: true
title: $t("menus.hsWatermark")
}
},
{
@@ -26,8 +24,7 @@ const ableRouter = {
name: "rePrint",
component: () => import("/@/views/able/print.vue"),
meta: {
title: $t("menus.hsPrint"),
i18n: true
title: $t("menus.hsPrint")
}
},
{
@@ -35,8 +32,7 @@ const ableRouter = {
name: "reIconSelect",
component: () => import("/@/views/able/icon-select.vue"),
meta: {
title: $t("menus.hsIconSelect"),
i18n: true
title: $t("menus.hsIconSelect")
}
},
{
@@ -44,8 +40,7 @@ const ableRouter = {
name: "reTimeline",
component: () => import("/@/views/able/timeline.vue"),
meta: {
title: $t("menus.hsTimeline"),
i18n: true
title: $t("menus.hsTimeline")
}
},
{
@@ -53,8 +48,7 @@ const ableRouter = {
name: "reMenuTree",
component: () => import("/@/views/able/menu-tree.vue"),
meta: {
title: $t("menus.hsMenuTree"),
i18n: true
title: $t("menus.hsMenuTree")
}
},
{
@@ -62,8 +56,7 @@ const ableRouter = {
name: "reLineTree",
component: () => import("/@/views/able/line-tree.vue"),
meta: {
title: $t("menus.hsLineTree"),
i18n: true
title: $t("menus.hsLineTree")
}
},
{
@@ -71,8 +64,7 @@ const ableRouter = {
name: "reAntTabs",
component: () => import("/@/views/able/ant-tabs.vue"),
meta: {
title: $t("menus.hsAntTabs"),
i18n: true
title: $t("menus.hsAntTabs")
}
},
{
@@ -80,8 +72,7 @@ const ableRouter = {
name: "reAntAnchor",
component: () => import("/@/views/able/ant-anchor.vue"),
meta: {
title: $t("menus.hsAntAnchor"),
i18n: true
title: $t("menus.hsAntAnchor")
}
},
{
@@ -89,8 +80,7 @@ const ableRouter = {
name: "reAntTreeSelect",
component: () => import("/@/views/able/ant-treeSelect.vue"),
meta: {
title: $t("menus.hsAntTreeSelect"),
i18n: true
title: $t("menus.hsAntTreeSelect")
}
},
{
@@ -98,8 +88,7 @@ const ableRouter = {
name: "reDebounce",
component: () => import("/@/views/able/debounce.vue"),
meta: {
title: $t("menus.hsDebounce"),
i18n: true
title: $t("menus.hsDebounce")
}
},
{
@@ -107,8 +96,7 @@ const ableRouter = {
name: "reBarcode",
component: () => import("/@/views/able/barcode.vue"),
meta: {
title: $t("menus.hsBarcode"),
i18n: true
title: $t("menus.hsBarcode")
}
},
{
@@ -116,8 +104,7 @@ const ableRouter = {
name: "reQrcode",
component: () => import("/@/views/able/qrcode.vue"),
meta: {
title: $t("menus.hsQrcode"),
i18n: true
title: $t("menus.hsQrcode")
}
},
{
@@ -125,8 +112,7 @@ const ableRouter = {
name: "reCascader",
component: () => import("/@/views/able/cascader.vue"),
meta: {
title: $t("menus.hsCascader"),
i18n: true
title: $t("menus.hsCascader")
}
},
{
@@ -134,8 +120,7 @@ const ableRouter = {
name: "reSwiper",
component: () => import("/@/views/able/swiper.vue"),
meta: {
title: $t("menus.hsSwiper"),
i18n: true
title: $t("menus.hsSwiper")
}
}
]

View File

@@ -8,7 +8,6 @@ const aboutRouter = {
meta: {
icon: "question-line",
title: $t("menus.hsAbout"),
i18n: true,
rank: 15
},
children: [
@@ -17,8 +16,7 @@ const aboutRouter = {
name: "reAbout",
component: () => import("/@/views/about/index.vue"),
meta: {
title: $t("menus.hsAbout"),
i18n: true
title: $t("menus.hsAbout")
}
}
]

View File

@@ -8,7 +8,6 @@ const componentsRouter = {
meta: {
icon: "menu",
title: $t("menus.hscomponents"),
i18n: true,
rank: 5
},
children: [
@@ -17,8 +16,7 @@ const componentsRouter = {
name: "video",
component: () => import("/@/views/components/video/index.vue"),
meta: {
title: $t("menus.hsvideo"),
i18n: true
title: $t("menus.hsvideo")
}
},
{
@@ -28,7 +26,6 @@ const componentsRouter = {
meta: {
title: $t("menus.hsmap"),
keepAlive: true,
i18n: true,
transition: {
name: "fade"
}
@@ -40,7 +37,6 @@ const componentsRouter = {
component: () => import("/@/views/components/draggable/index.vue"),
meta: {
title: $t("menus.hsdraggable"),
i18n: true,
transition: {
enterTransition: "animate__zoomIn",
leaveTransition: "animate__zoomOut"
@@ -54,7 +50,6 @@ const componentsRouter = {
component: () => import("/@/views/components/split-pane/index.vue"),
meta: {
title: $t("menus.hssplitPane"),
i18n: true,
extraIcon: {
svg: true,
name: "team-iconxinpinrenqiwang"
@@ -66,8 +61,7 @@ const componentsRouter = {
name: "button",
component: () => import("/@/views/components/button/index.vue"),
meta: {
title: $t("menus.hsbutton"),
i18n: true
title: $t("menus.hsbutton")
}
},
{
@@ -75,8 +69,7 @@ const componentsRouter = {
name: "cropping",
component: () => import("/@/views/components/cropping/index.vue"),
meta: {
title: $t("menus.hscropping"),
i18n: true
title: $t("menus.hscropping")
}
},
{
@@ -84,8 +77,7 @@ const componentsRouter = {
name: "countTo",
component: () => import("/@/views/components/count-to/index.vue"),
meta: {
title: $t("menus.hscountTo"),
i18n: true
title: $t("menus.hscountTo")
}
},
{
@@ -93,8 +85,7 @@ const componentsRouter = {
name: "selector",
component: () => import("/@/views/components/selector/index.vue"),
meta: {
title: $t("menus.hsselector"),
i18n: true
title: $t("menus.hsselector")
}
},
{
@@ -102,8 +93,7 @@ const componentsRouter = {
name: "seamlessScroll",
component: () => import("/@/views/components/seamless-scroll/index.vue"),
meta: {
title: $t("menus.hsseamless"),
i18n: true
title: $t("menus.hsseamless")
}
},
{
@@ -111,8 +101,7 @@ const componentsRouter = {
name: "contextmenu",
component: () => import("/@/views/components/contextmenu/index.vue"),
meta: {
title: $t("menus.hscontextmenu"),
i18n: true
title: $t("menus.hscontextmenu")
}
}
]

View File

@@ -8,7 +8,6 @@ const editorRouter = {
meta: {
icon: "edit",
title: $t("menus.hseditor"),
i18n: true,
rank: 2
},
children: [
@@ -18,7 +17,6 @@ const editorRouter = {
component: () => import("/@/views/editor/index.vue"),
meta: {
title: $t("menus.hseditor"),
i18n: true,
keepAlive: true
}
}

View File

@@ -8,7 +8,6 @@ const errorRouter = {
meta: {
icon: "information-line",
title: $t("menus.hserror"),
i18n: true,
rank: 9
},
children: [
@@ -17,8 +16,7 @@ const errorRouter = {
name: "403",
component: () => import("/@/views/error/403.vue"),
meta: {
title: $t("menus.hsfourZeroOne"),
i18n: true
title: $t("menus.hsfourZeroOne")
}
},
{
@@ -26,8 +24,7 @@ const errorRouter = {
name: "404",
component: () => import("/@/views/error/404.vue"),
meta: {
title: $t("menus.hsfourZeroFour"),
i18n: true
title: $t("menus.hsfourZeroFour")
}
},
{
@@ -35,8 +32,7 @@ const errorRouter = {
name: "500",
component: () => import("/@/views/error/500.vue"),
meta: {
title: $t("menus.hsFive"),
i18n: true
title: $t("menus.hsFive")
}
}
]

View File

@@ -8,7 +8,6 @@ const flowChartRouter = {
meta: {
icon: "set-up",
title: $t("menus.hsflowChart"),
i18n: true,
rank: 1
},
children: [
@@ -17,8 +16,7 @@ const flowChartRouter = {
name: "flowChart",
component: () => import("/@/views/flow-chart/index.vue"),
meta: {
title: $t("menus.hsflowChart"),
i18n: true
title: $t("menus.hsflowChart")
}
}
]

View File

@@ -8,7 +8,6 @@ const formDesignRouter = {
meta: {
icon: "terminal-window-line",
title: $t("menus.hsFormDesign"),
i18n: true,
rank: 2
},
children: [
@@ -17,8 +16,7 @@ const formDesignRouter = {
name: "formDesign",
component: () => import("/@/views/form-design/index.vue"),
meta: {
title: $t("menus.hsFormDesign"),
i18n: true
title: $t("menus.hsFormDesign")
}
}
]

View File

@@ -8,7 +8,6 @@ const guideRouter = {
meta: {
icon: "guide",
title: $t("menus.hsguide"),
i18n: true,
rank: 14
},
children: [
@@ -17,8 +16,7 @@ const guideRouter = {
name: "reGuide",
component: () => import("/@/views/guide/index.vue"),
meta: {
title: $t("menus.hsguide"),
i18n: true
title: $t("menus.hsguide")
}
}
]

View File

@@ -9,7 +9,6 @@ const homeRouter = {
meta: {
icon: "home-filled",
title: $t("menus.hshome"),
i18n: true,
rank: 0
},
children: [
@@ -18,8 +17,7 @@ const homeRouter = {
name: "welcome",
component: () => import("/@/views/welcome.vue"),
meta: {
title: $t("menus.hshome"),
i18n: true
title: $t("menus.hshome")
}
}
]

View File

@@ -8,7 +8,6 @@ const ableRouter = {
meta: {
icon: "list-check",
title: $t("menus.hsList"),
i18n: true,
rank: 12
},
children: [
@@ -19,7 +18,6 @@ const ableRouter = {
meta: {
icon: "card",
title: $t("menus.hsListCard"),
i18n: true,
showParent: true
}
}

View File

@@ -8,7 +8,6 @@ const nestedRouter = {
meta: {
title: $t("menus.hsmenus"),
icon: "histogram",
i18n: true,
rank: 6
},
children: [
@@ -16,7 +15,6 @@ const nestedRouter = {
path: "/nested/menu1",
meta: {
title: $t("menus.hsmenu1"),
i18n: true,
keepAlive: true
},
redirect: "/nested/menu1/menu1-1",
@@ -27,7 +25,6 @@ const nestedRouter = {
name: "Menu1-1",
meta: {
title: $t("menus.hsmenu1-1"),
i18n: true,
keepAlive: true
}
},
@@ -36,7 +33,6 @@ const nestedRouter = {
redirect: "/nested/menu1/menu1-2/menu1-2-1",
meta: {
title: $t("menus.hsmenu1-2"),
i18n: true,
keepAlive: true
},
children: [
@@ -47,7 +43,6 @@ const nestedRouter = {
name: "Menu1-2-1",
meta: {
title: $t("menus.hsmenu1-2-1"),
i18n: true,
keepAlive: true
}
},
@@ -59,7 +54,6 @@ const nestedRouter = {
meta: {
title: $t("menus.hsmenu1-2-2"),
keepAlive: true,
i18n: true,
extraIcon: {
svg: true,
name: "team-iconxinpinrenqiwang"
@@ -74,7 +68,6 @@ const nestedRouter = {
name: "Menu1-3",
meta: {
title: $t("menus.hsmenu1-3"),
i18n: true,
keepAlive: true
}
}
@@ -86,7 +79,6 @@ const nestedRouter = {
component: () => import("/@/views/nested/menu2/index.vue"),
meta: {
title: $t("menus.hsmenu2"),
i18n: true,
keepAlive: true
}
}

View File

@@ -8,7 +8,6 @@ const pptRouter = {
meta: {
icon: "ppt",
title: "PPT",
i18n: false,
rank: 3
},
children: [
@@ -18,7 +17,6 @@ const pptRouter = {
component: IFrame,
meta: {
title: "PPT",
i18n: false,
frameSrc: "https://pipipi-pikachu.github.io/PPTist/",
extraIcon: {
svg: true,

View File

@@ -9,7 +9,6 @@ const remainingRouter = [
meta: {
title: $t("menus.hslogin"),
showLink: false,
i18n: true,
rank: 101
}
},
@@ -19,7 +18,6 @@ const remainingRouter = [
meta: {
icon: "home-filled",
title: $t("menus.hshome"),
i18n: true,
showLink: false,
rank: 104
},

View File

@@ -8,7 +8,6 @@ const resultRouter = {
meta: {
icon: "checkbox-circle-line",
title: $t("menus.hsResult"),
i18n: true,
rank: 8
},
children: [
@@ -17,8 +16,7 @@ const resultRouter = {
name: "reSuccess",
component: () => import("/@/views/result/success.vue"),
meta: {
title: $t("menus.hsSuccess"),
i18n: true
title: $t("menus.hsSuccess")
}
},
{
@@ -26,8 +24,7 @@ const resultRouter = {
name: "reFail",
component: () => import("/@/views/result/fail.vue"),
meta: {
title: $t("menus.hsFail"),
i18n: true
title: $t("menus.hsFail")
}
}
]