From 44ad51c7b0b53a0f256db2a64a20cf5c9fa94716 Mon Sep 17 00:00:00 2001 From: "WANGFAN\\wangf" <15871339963@163.com> Date: Tue, 8 Apr 2025 22:16:17 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=B7=AF=E7=94=B1=E6=A0=91=E6=89=81?= =?UTF-8?q?=E5=B9=B3=E5=8C=96=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hooks/useMenuMethod.ts | 9 +- src/lang/index.ts | 14 +- src/layout/layout-mixing/index.vue | 16 +- src/mock/_data/system_menu.ts | 2092 ++++++++++--------- src/mock/_utils.ts | 34 +- src/mock/system/menu.ts | 16 +- src/typings/global.d.ts | 3 + src/views/i18n/{i18n.vue => show/index.vue} | 66 +- src/views/system/account/account.vue | 4 +- src/views/system/dictionary/dictionary.vue | 4 +- src/views/system/division/division.vue | 2 +- src/views/system/menu/menu.vue | 202 +- vite.config.ts | 2 +- 13 files changed, 1303 insertions(+), 1161 deletions(-) rename src/views/i18n/{i18n.vue => show/index.vue} (95%) diff --git a/src/hooks/useMenuMethod.ts b/src/hooks/useMenuMethod.ts index de85910..1ca1018 100644 --- a/src/hooks/useMenuMethod.ts +++ b/src/hooks/useMenuMethod.ts @@ -6,21 +6,22 @@ export const useMenuMethod = () => { /** * 多级菜单的显示隐藏 * @param {Menu.MenuOptions} item 菜单的item - * @returns 若多级菜单有children,并且不隐藏,返回true,否则返回false + * @returns type:1为目录,并且不隐藏,返回true,否则返回false */ const menuShow = (item: Menu.MenuOptions) => { - if (item.children && item.children?.length > 0 && !item.meta.hide) return true; + if (item.meta.type == 1 && !item.meta.hide) return true; return false; }; /** * 单级菜单的显示隐藏 * @param {Menu.MenuOptions} item 菜单的item - * @returns 若单级菜单不隐藏,返回true,否则返回false + * @returns type:2为菜单,并且单级菜单不隐藏,返回true,否则返回false */ const aMenuShow = (item: Menu.MenuOptions) => { - if (!item.meta.hide) return true; + if (item.meta.type == 2 && !item.meta.hide) return true; return false; }; + return { menuShow, aMenuShow diff --git a/src/lang/index.ts b/src/lang/index.ts index da27061..18a4398 100644 --- a/src/lang/index.ts +++ b/src/lang/index.ts @@ -21,7 +21,19 @@ const i18n = createI18n({ legacy: false, // Composition API模式需要设为false globalInjection: true, // 全局生效: $ locale: getLang(), // 默认语言 - messages // 数据源 + messages, // 数据源 + missing: (_: string, key: string) => { + return removeBeforeFirstDot(key); + } }); +/** + * @param { string } str 国际化key + * @returns 去掉第一个点之前的字符串,例如:"menu.home" => "home" + */ +function removeBeforeFirstDot(str: string) { + const dotIndex = str.indexOf("."); + return dotIndex >= 0 ? str.slice(dotIndex + 1) : "未定义"; +} + export default i18n; diff --git a/src/layout/layout-mixing/index.vue b/src/layout/layout-mixing/index.vue index 14ea636..1030837 100644 --- a/src/layout/layout-mixing/index.vue +++ b/src/layout/layout-mixing/index.vue @@ -22,7 +22,7 @@ :popup-max-height="600" >