diff --git a/src/constants/business.ts b/src/constants/business.ts index c404ee8f..a84d7420 100644 --- a/src/constants/business.ts +++ b/src/constants/business.ts @@ -20,3 +20,10 @@ export const menuTypeRecord: Record }; export const menuTypeOptions = transformRecordToOption(menuTypeRecord); + +export const menuIconTypeRecord: Record = { + '1': 'page.manage.menu.iconType.iconify', + '2': 'page.manage.menu.iconType.local' +}; + +export const menuIconTypeOptions = transformRecordToOption(menuIconTypeRecord); diff --git a/src/locales/langs/en-us.ts b/src/locales/langs/en-us.ts index b4d9abbb..866bd1d6 100644 --- a/src/locales/langs/en-us.ts +++ b/src/locales/langs/en-us.ts @@ -305,6 +305,8 @@ const local: App.I18n.Schema = { }, menu: { title: 'Menu List', + id: 'ID', + parentId: 'Parent ID', menuType: 'Menu Type', menuName: 'Menu Name', routeName: 'Route Name', @@ -314,6 +316,7 @@ const local: App.I18n.Schema = { i18nKey: 'I18n Key', icon: 'Icon', localIcon: 'Local Icon', + iconTypeTitle: 'Icon Type', order: 'Order', keepAlive: 'Keep Alive', href: 'Href', @@ -333,8 +336,8 @@ const local: App.I18n.Schema = { page: 'Please select page component', layout: 'Please select layout component', i18nKey: 'Please enter i18n key', - icon: 'Please enter icon', - localIcon: 'Please select local icon', + icon: 'Please enter iconify name', + localIcon: 'Please enter local icon name', order: 'Please enter order', keepAlive: 'Please select whether to cache route', href: 'Please enter href', @@ -354,6 +357,10 @@ const local: App.I18n.Schema = { type: { directory: 'Directory', menu: 'Menu' + }, + iconType: { + iconify: 'Iconify Icon', + local: 'Local Icon' } } } diff --git a/src/locales/langs/zh-cn.ts b/src/locales/langs/zh-cn.ts index 6eb2a101..36ebb58a 100644 --- a/src/locales/langs/zh-cn.ts +++ b/src/locales/langs/zh-cn.ts @@ -305,6 +305,8 @@ const local: App.I18n.Schema = { }, menu: { title: '菜单列表', + id: 'ID', + parentId: '父级菜单ID', menuType: '菜单类型', menuName: '菜单名称', routeName: '路由名称', @@ -314,6 +316,7 @@ const local: App.I18n.Schema = { i18nKey: '国际化key', icon: '图标', localIcon: '本地图标', + iconTypeTitle: '图标类型', order: '排序', keepAlive: '缓存路由', href: '外链', @@ -354,6 +357,10 @@ const local: App.I18n.Schema = { type: { directory: '目录', menu: '菜单' + }, + iconType: { + iconify: 'iconify图标', + local: '本地图标' } } } diff --git a/src/typings/api.d.ts b/src/typings/api.d.ts index 492f477e..03a70e78 100644 --- a/src/typings/api.d.ts +++ b/src/typings/api.d.ts @@ -171,6 +171,8 @@ declare namespace Api { type IconType = '1' | '2'; type Menu = Common.CommonRecord<{ + /** parent menu id */ + parentId: number; /** menu type */ menuType: MenuType; /** menu name */ diff --git a/src/typings/app.d.ts b/src/typings/app.d.ts index ea1249d7..5297610e 100644 --- a/src/typings/app.d.ts +++ b/src/typings/app.d.ts @@ -492,6 +492,8 @@ declare namespace App { }; menu: { title: string; + id: string; + parentId: string; menuType: string; menuName: string; routeName: string; @@ -501,6 +503,7 @@ declare namespace App { i18nKey: string; icon: string; localIcon: string; + iconTypeTitle: string; order: string; keepAlive: string; href: string; @@ -542,6 +545,10 @@ declare namespace App { directory: string; menu: string; }; + iconType: { + iconify: string; + local: string; + }; }; }; }; diff --git a/src/utils/icon.ts b/src/utils/icon.ts new file mode 100644 index 00000000..2e18729e --- /dev/null +++ b/src/utils/icon.ts @@ -0,0 +1,9 @@ +export function getLocalIcons() { + const svgIcons = import.meta.glob('/src/assets/svg-icon/*.svg'); + + const keys = Object.keys(svgIcons) + .map(item => item.split('/').at(-1)?.replace('.svg', '') || '') + .filter(Boolean); + + return keys; +} diff --git a/src/views/manage/menu/index.vue b/src/views/manage/menu/index.vue index da663af8..4d43263a 100644 --- a/src/views/manage/menu/index.vue +++ b/src/views/manage/menu/index.vue @@ -37,19 +37,15 @@ const { columns, filteredColumns, data, loading, pagination, getData } = useTabl width: 48 }, { - key: 'index', - title: $t('common.index'), - width: 120, - render: (_, index) => { - return {getIndex(index)}; - }, + key: 'id', + title: $t('page.manage.menu.id'), align: 'center' }, { key: 'menuType', title: $t('page.manage.menu.menuType'), align: 'center', - width: 120, + width: 80, render: row => { const tagMap: Record = { 1: 'default', @@ -107,7 +103,7 @@ const { columns, filteredColumns, data, loading, pagination, getData } = useTabl key: 'status', title: $t('page.manage.menu.menuStatus'), align: 'center', - width: 120, + width: 80, render: row => { if (row.status === null) { return null; @@ -127,7 +123,7 @@ const { columns, filteredColumns, data, loading, pagination, getData } = useTabl key: 'hideInMenu', title: $t('page.manage.menu.hideInMenu'), align: 'center', - width: 100, + width: 80, render: row => { const hide: CommonType.YesOrNo = row.hideInMenu ? 'Y' : 'N'; @@ -141,11 +137,17 @@ const { columns, filteredColumns, data, loading, pagination, getData } = useTabl return {label}; } }, + { + key: 'parentId', + title: $t('page.manage.menu.parentId'), + width: 90, + align: 'center' + }, { key: 'order', title: $t('page.manage.menu.order'), align: 'center', - width: 80 + width: 60 }, { key: 'operate', @@ -219,12 +221,6 @@ async function handleDelete(id: number) { getData(); } - -function getIndex(index: number) { - const { page = 0, pageSize = 10 } = pagination; - - return String((page - 1) * pageSize + index + 1); -}