feat: use title instead of i18nKey for menus. (#303)

This commit is contained in:
Fine0830 2023-07-22 14:06:31 +08:00 committed by GitHub
parent 3bdd1d1c67
commit 169793bdff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 14 additions and 4 deletions

View File

@ -36,14 +36,16 @@ limitations under the License. -->
<Icon size="lg" :iconName="menu.meta.icon" /> <Icon size="lg" :iconName="menu.meta.icon" />
</el-icon> </el-icon>
<span class="title" :class="isCollapse ? 'collapse' : ''"> <span class="title" :class="isCollapse ? 'collapse' : ''">
{{ t(menu.meta.i18nKey) }} {{ te(menu.meta.i18nKey) ? t(menu.meta.i18nKey) : menu.meta.title }}
</span> </span>
</router-link> </router-link>
</template> </template>
<el-menu-item-group> <el-menu-item-group>
<el-menu-item v-for="(m, idx) in filterMenus(menu.children)" :index="m.name" :key="idx"> <el-menu-item v-for="(m, idx) in filterMenus(menu.children)" :index="m.name" :key="idx">
<router-link class="items" :to="m.path"> <router-link class="items" :to="m.path">
<span class="title">{{ t(m.meta && m.meta.i18nKey) }}</span> <span class="title">
{{ m.meta && (te(m.meta.i18nKey) ? t(m.meta.i18nKey) : m.meta.title) }}
</span>
</router-link> </router-link>
</el-menu-item> </el-menu-item>
</el-menu-item-group> </el-menu-item-group>
@ -56,7 +58,9 @@ limitations under the License. -->
</el-icon> </el-icon>
<template #title> <template #title>
<router-link class="items menu-title" :to="menu.children[0].path"> <router-link class="items menu-title" :to="menu.children[0].path">
<span class="title">{{ t(menu.meta.i18nKey) }}</span> <span class="title">
{{ te(menu.meta.i18nKey) ? t(menu.meta.i18nKey) : menu.meta.title }}
</span>
</router-link> </router-link>
</template> </template>
</el-menu-item> </el-menu-item>
@ -75,7 +79,7 @@ limitations under the License. -->
import { useAppStoreWithOut } from "@/store/modules/app"; import { useAppStoreWithOut } from "@/store/modules/app";
/*global Recordable*/ /*global Recordable*/
const { t } = useI18n(); const { t, te } = useI18n();
const appStore = useAppStoreWithOut(); const appStore = useAppStoreWithOut();
const router = useRouter(); const router = useRouter();
const name = ref<string>(String(router.currentRoute.value.name)); const name = ref<string>(String(router.currentRoute.value.name));

View File

@ -26,6 +26,7 @@ export const routesAlarm: Array<RouteRecordRaw> = [
icon: "spam", icon: "spam",
hasGroup: false, hasGroup: false,
activate: true, activate: true,
title: "Alerting",
}, },
component: Layout, component: Layout,
children: [ children: [

View File

@ -27,6 +27,7 @@ export const routesDashboard: Array<RouteRecordRaw> = [
icon: "dashboard_customize", icon: "dashboard_customize",
hasGroup: true, hasGroup: true,
activate: true, activate: true,
title: "Dashboards",
}, },
children: [ children: [
{ {
@ -36,6 +37,7 @@ export const routesDashboard: Array<RouteRecordRaw> = [
meta: { meta: {
i18nKey: "dashboardList", i18nKey: "dashboardList",
activate: true, activate: true,
title: "Dashboard List",
}, },
}, },
{ {
@ -45,6 +47,7 @@ export const routesDashboard: Array<RouteRecordRaw> = [
meta: { meta: {
i18nKey: "dashboardNew", i18nKey: "dashboardNew",
activate: true, activate: true,
title: "New Dashboard",
}, },
}, },
{ {

View File

@ -26,6 +26,7 @@ export const routesMarketplace: Array<RouteRecordRaw> = [
icon: "marketplace", icon: "marketplace",
hasGroup: false, hasGroup: false,
activate: true, activate: true,
title: "Marketplace",
}, },
component: Layout, component: Layout,
children: [ children: [

View File

@ -26,6 +26,7 @@ export const routesSettings: Array<RouteRecordRaw> = [
icon: "settings", icon: "settings",
hasGroup: false, hasGroup: false,
activate: true, activate: true,
title: "Settings",
}, },
component: Layout, component: Layout,
children: [ children: [