From 861ab093cc1c337381eaead34c5d77ee6aed9a2a Mon Sep 17 00:00:00 2001 From: Fine Date: Wed, 12 Jul 2023 17:49:26 +0800 Subject: [PATCH] feat: update menus --- src/layout/components/SideBar.vue | 8 +++++--- src/router/alarm.ts | 2 +- src/router/dashboard.ts | 6 +++--- src/router/layer.ts | 6 ++++++ src/router/marketplace.ts | 2 +- src/router/settings.ts | 2 +- src/store/modules/app.ts | 1 + src/views/Marketplace.vue | 8 ++++---- 8 files changed, 22 insertions(+), 13 deletions(-) diff --git a/src/layout/components/SideBar.vue b/src/layout/components/SideBar.vue index 69658e9e..2bf51b0c 100644 --- a/src/layout/components/SideBar.vue +++ b/src/layout/components/SideBar.vue @@ -36,14 +36,14 @@ limitations under the License. --> - {{ menu.meta.title }} + {{ t(menu.meta.i18nKey) }} - {{ m.meta && m.meta.title }} + {{ t(m.meta && m.meta.i18nKey) }} @@ -56,7 +56,7 @@ limitations under the License. --> @@ -70,10 +70,12 @@ limitations under the License. --> import { ref, watch } from "vue"; import type { RouteRecordRaw } from "vue-router"; import { useRouter, useRoute } from "vue-router"; + import { useI18n } from "vue-i18n"; import Icon from "@/components/Icon.vue"; import { useAppStoreWithOut } from "@/store/modules/app"; /*global Recordable*/ + const { t } = useI18n(); const appStore = useAppStoreWithOut(); const router = useRouter(); const name = ref(String(router.currentRoute.value.name)); diff --git a/src/router/alarm.ts b/src/router/alarm.ts index 950101e4..dc5e19e2 100644 --- a/src/router/alarm.ts +++ b/src/router/alarm.ts @@ -22,7 +22,7 @@ export const routesAlarm: Array = [ path: "", name: "Alarm", meta: { - title: "Alerting", + i18nKey: "alarm", icon: "spam", hasGroup: false, activate: true, diff --git a/src/router/dashboard.ts b/src/router/dashboard.ts index f0a46812..8ced30cf 100644 --- a/src/router/dashboard.ts +++ b/src/router/dashboard.ts @@ -23,7 +23,7 @@ export const routesDashboard: Array = [ component: Layout, name: "Dashboard", meta: { - title: "Dashboards", + i18nKey: "dashboards", icon: "dashboard_customize", hasGroup: true, activate: true, @@ -34,7 +34,7 @@ export const routesDashboard: Array = [ component: () => import("@/views/dashboard/List.vue"), name: "List", meta: { - title: "Dashboard List", + i18nKey: "dashboardList", activate: true, }, }, @@ -43,7 +43,7 @@ export const routesDashboard: Array = [ component: () => import("@/views/dashboard/New.vue"), name: "New", meta: { - title: "New Dashboard", + i18nKey: "dashboardNew", activate: true, }, }, diff --git a/src/router/layer.ts b/src/router/layer.ts index e453ea73..ec9c98e2 100644 --- a/src/router/layer.ts +++ b/src/router/layer.ts @@ -31,6 +31,8 @@ async function layerDashboards() { title: item.title, hasGroup: item.hasGroup, activate: item.activate, + descKey: item.descKey, + i18nKey: item.i18nKey, }, children: item.subItems && item.subItems.length ? [] : undefined, }; @@ -43,6 +45,8 @@ async function layerDashboards() { layer: child.layer, icon: child.icon || "cloud_queue", activate: child.activate, + descKey: child.descKey, + i18nKey: child.i18nKey, }, component: () => import("@/views/Layer.vue"), }; @@ -68,6 +72,8 @@ async function layerDashboards() { layer: item.layer, icon: item.icon, activate: item.activate, + descKey: item.descKey, + i18nKey: item.i18nKey, }, component: () => import("@/views/Layer.vue"), }, diff --git a/src/router/marketplace.ts b/src/router/marketplace.ts index c6fcde65..56196d82 100644 --- a/src/router/marketplace.ts +++ b/src/router/marketplace.ts @@ -22,7 +22,7 @@ export const routesMarketplace: Array = [ path: "", name: "Marketplace", meta: { - title: "Marketplace", + i18nKey: "marketplace", icon: "marketplace", hasGroup: false, activate: true, diff --git a/src/router/settings.ts b/src/router/settings.ts index 864853eb..11a78251 100644 --- a/src/router/settings.ts +++ b/src/router/settings.ts @@ -22,7 +22,7 @@ export const routesSettings: Array = [ path: "", name: "Settings", meta: { - title: "Settings", + i18nKey: "settings", icon: "settings", hasGroup: false, activate: true, diff --git a/src/store/modules/app.ts b/src/store/modules/app.ts index 6703767a..ede73ea5 100644 --- a/src/store/modules/app.ts +++ b/src/store/modules/app.ts @@ -175,6 +175,7 @@ export const appStore = defineStore({ const id = `${item.title.replace(/\s+/g, "-")}`; item.name = `${id}-${index}${sub}`; item.path = `/${t}/${id}`; + item.descKey = `${item.i18nKey}_desc`; return item; }); } diff --git a/src/views/Marketplace.vue b/src/views/Marketplace.vue index d1e3682f..5893e1b0 100644 --- a/src/views/Marketplace.vue +++ b/src/views/Marketplace.vue @@ -25,10 +25,10 @@ limitations under the License. --> >
- {{ menu.title }} + {{ t(menu.i18nKey) }}
-
{{ menu.description }}
+
{{ t(menu.descKey) }}
{{ t("document") }} @@ -37,9 +37,9 @@ limitations under the License. -->
-
{{ item.title }}
+
{{ t(item.i18nKey) }}
-
{{ item.description }}
+
{{ t(item.descKey) }}
{{ t("document") }}