From 2f284d31c3b83b71f1f96f06afbfd0b6da4bd1bd Mon Sep 17 00:00:00 2001 From: xingyu Date: Mon, 24 Apr 2023 19:54:54 +0800 Subject: [PATCH] feat: add renderIcon --- src/components/Table/src/hooks/useRender.ts | 6 ++++++ src/views/system/menu/menu.data.ts | 4 +--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/components/Table/src/hooks/useRender.ts b/src/components/Table/src/hooks/useRender.ts index 85d04903..5ac41366 100644 --- a/src/components/Table/src/hooks/useRender.ts +++ b/src/components/Table/src/hooks/useRender.ts @@ -1,4 +1,5 @@ import { DictTag } from '@/components/DictTag' +import Icon from '@/components/Icon' import { Image, Tag } from 'ant-design-vue' import dayjs from 'dayjs' import { h } from 'vue' @@ -58,5 +59,10 @@ export const useRender = { }) } return '' + }, + renderIcon: (text) => { + if (text) { + return h(Icon, { icon: text }) + } } } diff --git a/src/views/system/menu/menu.data.ts b/src/views/system/menu/menu.data.ts index 3080de04..457e1112 100644 --- a/src/views/system/menu/menu.data.ts +++ b/src/views/system/menu/menu.data.ts @@ -1,9 +1,7 @@ -import Icon from '@/components/Icon' import { listSimpleMenus } from '@/api/system/menu' import { BasicColumn, FormSchema, useRender } from '@/components/Table' import { DICT_TYPE, getIntDictOptions } from '@/utils/dict' import { SystemMenuTypeEnum } from '@/enums/systemEnum' -import { h } from 'vue' export const columns: BasicColumn[] = [ { @@ -25,7 +23,7 @@ export const columns: BasicColumn[] = [ dataIndex: 'icon', width: 60, customRender: ({ record }) => { - return h(Icon, { icon: record.icon }) + return useRender.renderIcon(record.icon) } }, {