mirror of
https://github.com/m-xlsea/ruoyi-plus-soybean.git
synced 2025-09-24 07:49:47 +08:00
fix(components): 修复菜单选择标签渲染问题
This commit is contained in:
@ -4,6 +4,7 @@ import type { TreeOption, TreeSelectInst, TreeSelectProps } from 'naive-ui';
|
||||
import { useBoolean } from '@sa/hooks';
|
||||
import { fetchGetMenuTreeSelect } from '@/service/api/system';
|
||||
import SvgIcon from '@/components/custom/svg-icon.vue';
|
||||
import { $t } from '@/locales';
|
||||
|
||||
defineOptions({ name: 'MenuTree' });
|
||||
|
||||
@ -60,6 +61,14 @@ watch([expandAll, options], ([newVal]) => {
|
||||
}
|
||||
});
|
||||
|
||||
function renderLabel({ option }: { option: TreeOption }) {
|
||||
let label = option.label;
|
||||
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-');
|
||||
let icon = renderLocalIcon ? undefined : String(option.icon ?? 'material-symbols:buttons-alt-outline-rounded');
|
||||
@ -163,6 +172,7 @@ defineExpose({
|
||||
:loading="loading"
|
||||
virtual-scroll
|
||||
check-strategy="all"
|
||||
:render-label="renderLabel"
|
||||
:render-prefix="renderPrefix"
|
||||
v-bind="attrs"
|
||||
/>
|
||||
|
Reference in New Issue
Block a user