import type { Menu } from '#/api/system/menu/model'; import { computed, defineComponent, type PropType } from 'vue'; import { Tag } from 'ant-design-vue'; export default defineComponent({ name: 'TreeItem', props: { data: { required: true, type: Object as PropType, }, }, setup(props, { expose }) { expose(); interface TagProp { color: string; text: string; } const menuTagProp = computed(() => { // 正则判断是否为链接 if (/^https?:\/\/[^\s/$.?#].\S*$/i.test(props.data.path)) { return { color: 'pink', text: '外链' }; } const type = props.data.menuType; if (type === 'M') return { color: 'green', text: '目录' }; if (type === 'C') return { color: 'blue', text: '菜单' }; if (type === 'F') return { color: '', text: '按钮' }; return { color: 'error', text: '未知' }; }); return () => (
{props.data.menuName} {menuTagProp.value.text}
); }, });