菜单国际化优化
parent
e4424ba3b1
commit
0db23723fb
|
@ -10,6 +10,7 @@
|
|||
import { BasicDrawer, useDrawerInner } from '/@/components/Drawer';
|
||||
import { list, saveOrUpdateMenu } from './menu.api';
|
||||
import { useDrawerAdaptiveWidth } from '/@/hooks/jeecg/useAdaptiveWidth';
|
||||
import { useI18n } from "/@/hooks/web/useI18n";
|
||||
// 声明Emits
|
||||
const emit = defineEmits(['success', 'register']);
|
||||
const { adaptiveWidth } = useDrawerAdaptiveWidth();
|
||||
|
@ -41,7 +42,9 @@
|
|||
updateSchema([
|
||||
{
|
||||
field: 'parentId',
|
||||
componentProps: { treeData },
|
||||
// update-begin--author:liaozhiyang---date:20240306---for:【QQYUN-8379】菜单管理页菜单国际化
|
||||
componentProps: { treeData: translateMenu(treeData, 'name') },
|
||||
// update-end--author:liaozhiyang---date:20240306---for:【QQYUN-8379】菜单管理页菜单国际化
|
||||
},
|
||||
{
|
||||
field: 'name',
|
||||
|
@ -113,4 +116,26 @@
|
|||
}
|
||||
//update-end---author:wangshuai ---date:20230204 for:[QQYUN-4058]菜单添加智能化处理------------
|
||||
}
|
||||
|
||||
/**
|
||||
* 2024-03-06
|
||||
* liaozhiyang
|
||||
* 翻译菜单名称
|
||||
*/
|
||||
function translateMenu(data, key) {
|
||||
if (data?.length) {
|
||||
const { t } = useI18n();
|
||||
data.forEach((item) => {
|
||||
if (item[key]) {
|
||||
if (item[key].includes("t('") && t) {
|
||||
item[key] = new Function('t', `return ${item[key]}`)(t);
|
||||
}
|
||||
}
|
||||
if (item.children?.length) {
|
||||
translateMenu(item.children, key);
|
||||
}
|
||||
});
|
||||
}
|
||||
return data;
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -39,11 +39,13 @@
|
|||
import { columns,searchFormSchema } from './menu.data';
|
||||
import { list, deleteMenu, batchDeleteMenu } from './menu.api';
|
||||
import { useDefIndexStore } from "@/store/modules/defIndex";
|
||||
import { useI18n } from "/@/hooks/web/useI18n";
|
||||
|
||||
const checkedKeys = ref<Array<string | number>>([]);
|
||||
const showFooter = ref(true);
|
||||
const [registerDrawer, { openDrawer }] = useDrawer();
|
||||
const [registerDrawer1, { openDrawer: openDataRule }] = useDrawer();
|
||||
const { t } = useI18n();
|
||||
|
||||
// 自定义菜单名称列渲染
|
||||
columns[0].customRender = function ({text, record}) {
|
||||
|
@ -51,6 +53,11 @@
|
|||
if (isDefIndex) {
|
||||
text += '(默认首页)'
|
||||
}
|
||||
// update-begin--author:liaozhiyang---date:20240306---for:【QQYUN-8379】菜单管理页菜单国际化
|
||||
if (text.includes("t('") && t) {
|
||||
return new Function('t', `return ${text}`)(t);
|
||||
}
|
||||
// update-end--author:liaozhiyang---date:20240306---for:【QQYUN-8379】菜单管理页菜单国际化
|
||||
return text
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue