feat(other): 新增菜单字典多语言适配 SQL

This commit is contained in:
xlsea
2025-06-18 22:58:48 +08:00
parent 27f061957e
commit 0f33f4a301
7 changed files with 65 additions and 32 deletions

View File

@ -234,6 +234,12 @@ const local: App.I18n.Schema = {
exception_404: '404',
exception_500: '500'
},
menu: {
system_tenant: 'Tenant Management',
system_log: 'Log Management',
'monitor_snail-job': 'Job Management',
monitor_admin: 'Admin Monitor'
},
dict: {
sys_user_sex: {
male: 'Male',

View File

@ -221,7 +221,7 @@ const local: App.I18n.Schema = {
system_notice: '通知公告',
'social-callback': '单点登录回调',
system_oss: '文件管理',
'system_oss-config': 'OSS配置',
'system_oss-config': 'OSS 配置',
monitor_cache: '缓存监控',
monitor_online: '在线用户',
'user-center': '个人中心',
@ -234,6 +234,12 @@ const local: App.I18n.Schema = {
exception_404: '404',
exception_500: '500'
},
menu: {
system_tenant: '租户管理',
system_log: '日志管理',
'monitor_snail-job': '任务调度中心',
monitor_admin: 'Admin 监控'
},
dict: {
sys_user_sex: {
male: '男',

View File

@ -94,7 +94,7 @@ export const useRouteStore = defineStore(SetupStoreId.Route, () => {
// eslint-disable-next-line complexity
function parseRouter(route: ElegantConstRoute, parent?: ElegantConstRoute) {
route.meta = route.meta ? route.meta : { title: route.name };
if (route.meta.title.startsWith('route.')) {
if (route.meta.title.startsWith('route.') || route.meta.title.startsWith('menu.')) {
route.meta.i18nKey = route.meta.title as App.I18n.I18nKey;
}
const isLayout = route.component === 'Layout';

View File

@ -467,6 +467,7 @@ declare namespace App {
};
};
route: Record<I18nRouteKey, string>;
menu: Record<string, string>;
dict: Record<string, Record<string, string>>;
page: {
common: {

View File

@ -108,6 +108,14 @@ async function handleDeleteMenu(id?: CommonType.IdType) {
getMeunTree();
}
function renderLabel({ option }: { option: TreeOption }) {
let label = String(option.menuName);
if (label?.startsWith('route.') || label?.startsWith('menu.')) {
label = $t(label as App.I18n.I18nKey);
}
return <div>{label}</div>;
}
function renderPrefix({ option }: { option: TreeOption }) {
const renderLocalIcon = String(option.icon).startsWith('local-icon-');
const icon = renderLocalIcon ? undefined : String(option.icon);
@ -347,6 +355,7 @@ const btnColumns: DataTableColumns<Api.System.Menu> = [
label-field="menuName"
virtual-scroll
checkable
:render-label="renderLabel"
:render-prefix="renderPrefix"
:render-suffix="renderSuffix"
@update:selected-keys="(_: Array<string & number>, option: Array<TreeOption | null>) => handleClickTree(option)"
@ -420,7 +429,11 @@ const btnColumns: DataTableColumns<Api.System.Menu> = [
<DictTag size="small" :value="currentMenu.status" dict-code="sys_normal_disable" />
</NDescriptionsItem>
<NDescriptionsItem :label="$t('page.system.menu.menuName')">
{{ currentMenu.menuName }}
{{
currentMenu.menuName?.startsWith('route.') || currentMenu.menuName?.startsWith('menu.')
? $t(currentMenu.menuName)
: currentMenu.menuName
}}
</NDescriptionsItem>
<NDescriptionsItem v-if="isMenu" :label="$t('page.system.menu.component')">
{{ currentMenu.component }}