From dbe31eb1dca83e74c52742fc6a9d1d4a8d86680f Mon Sep 17 00:00:00 2001 From: paynezhuang Date: Fri, 26 Apr 2024 20:00:23 +0800 Subject: [PATCH] feat(projects): add menu route field --- src/locales/langs/en-us.ts | 8 +- src/locales/langs/zh-cn.ts | 8 +- src/typings/api.d.ts | 14 + src/typings/app.d.ts | 6 + src/typings/components.d.ts | 3 + .../menu/modules/menu-operate-drawer.vue | 265 +++++++++++++----- src/views/manage/menu/modules/shared.ts | 18 ++ 7 files changed, 257 insertions(+), 65 deletions(-) diff --git a/src/locales/langs/en-us.ts b/src/locales/langs/en-us.ts index e07a63098..3d0a88a3d 100644 --- a/src/locales/langs/en-us.ts +++ b/src/locales/langs/en-us.ts @@ -355,12 +355,15 @@ const local: App.I18n.Schema = { localIcon: 'Local Icon', iconTypeTitle: 'Icon Type', order: 'Order', + constant: 'Constant', keepAlive: 'Keep Alive', href: 'Href', hideInMenu: 'Hide In Menu', activeMenu: 'Active Menu', multiTab: 'Multi Tab', fixedIndexInTab: 'Fixed Index In Tab', + roles: 'Roles', + query: 'Query Params', button: 'Button', buttonCode: 'Button Code', buttonDesc: 'Button Desc', @@ -380,10 +383,13 @@ const local: App.I18n.Schema = { keepAlive: 'Please select whether to cache route', href: 'Please enter href', hideInMenu: 'Please select whether to hide menu', - activeMenu: 'Please enter the route name of the highlighted menu', + activeMenu: 'Please select route name of the highlighted menu', multiTab: 'Please select whether to support multiple tabs', fixedInTab: 'Please select whether to fix in the tab', fixedIndexInTab: 'Please enter the index fixed in the tab', + roles: 'Please select roles', + queryKey: 'Please enter route parameter Key', + queryValue: 'Please enter route parameter Value', button: 'Please select whether it is a button', buttonCode: 'Please enter button code', buttonDesc: 'Please enter button description', diff --git a/src/locales/langs/zh-cn.ts b/src/locales/langs/zh-cn.ts index 091180d45..14373c6f1 100644 --- a/src/locales/langs/zh-cn.ts +++ b/src/locales/langs/zh-cn.ts @@ -355,12 +355,15 @@ const local: App.I18n.Schema = { localIcon: '本地图标', iconTypeTitle: '图标类型', order: '排序', + constant: '常量路由', keepAlive: '缓存路由', href: '外链', hideInMenu: '隐藏菜单', activeMenu: '高亮的菜单', multiTab: '支持多页签', fixedIndexInTab: '固定在页签中的序号', + roles: '角色', + query: '路由参数', button: '按钮', buttonCode: '按钮编码', buttonDesc: '按钮描述', @@ -380,10 +383,13 @@ const local: App.I18n.Schema = { keepAlive: '请选择是否缓存路由', href: '请输入外链', hideInMenu: '请选择是否隐藏菜单', - activeMenu: '请输入高亮的菜单的路由名称', + activeMenu: '请选择高亮的菜单的路由名称', multiTab: '请选择是否支持多标签', fixedInTab: '请选择是否固定在页签中', fixedIndexInTab: '请输入固定在页签中的序号', + roles: '请选择角色', + queryKey: '请输入路由参数Key', + queryValue: '请输入路由参数Value', button: '请选择是否按钮', buttonCode: '请输入按钮编码', buttonDesc: '请输入按钮描述', diff --git a/src/typings/api.d.ts b/src/typings/api.d.ts index 50e84c6dd..b81b1424d 100644 --- a/src/typings/api.d.ts +++ b/src/typings/api.d.ts @@ -198,6 +198,12 @@ declare namespace Api { order: number; /** whether to cache the route */ keepAlive?: boolean; + /** + * Is constant route + * + * Does not need to login, and the route is defined in the front-end + */ + constant?: boolean; /** outer link */ href?: string; /** whether to hide the route in the menu */ @@ -215,8 +221,16 @@ declare namespace Api { multiTab?: boolean; /** If set, the route will be fixed in tabs, and the value is the order of fixed tabs */ fixedIndexInTab?: number; + /** if set query parameters, it will be automatically carried when entering the route */ + query: Record; /** menu buttons */ buttons?: MenuButton[]; + /** + * Roles of the route + * + * Route can be accessed if the current user has at least one of the roles + */ + roles?: string[]; /** children menu */ children?: Menu[]; }>; diff --git a/src/typings/app.d.ts b/src/typings/app.d.ts index 8cb9888e6..643d7eca3 100644 --- a/src/typings/app.d.ts +++ b/src/typings/app.d.ts @@ -539,12 +539,15 @@ declare namespace App { localIcon: string; iconTypeTitle: string; order: string; + constant: string; keepAlive: string; href: string; hideInMenu: string; activeMenu: string; multiTab: string; fixedIndexInTab: string; + roles: string; + query: string; button: string; buttonCode: string; buttonDesc: string; @@ -568,6 +571,9 @@ declare namespace App { multiTab: string; fixedInTab: string; fixedIndexInTab: string; + roles: string; + queryKey: string; + queryValue: string; button: string; buttonCode: string; buttonDesc: string; diff --git a/src/typings/components.d.ts b/src/typings/components.d.ts index c426abcfd..2ea652082 100644 --- a/src/typings/components.d.ts +++ b/src/typings/components.d.ts @@ -19,9 +19,11 @@ declare module 'vue' { IconAntDesignSettingOutlined: typeof import('~icons/ant-design/setting-outlined')['default'] IconGridiconsFullscreen: typeof import('~icons/gridicons/fullscreen')['default'] IconGridiconsFullscreenExit: typeof import('~icons/gridicons/fullscreen-exit')['default'] + 'IconIc:roundPlus': typeof import('~icons/ic/round-plus')['default'] IconIcRoundDelete: typeof import('~icons/ic/round-delete')['default'] IconIcRoundPlus: typeof import('~icons/ic/round-plus')['default'] IconIcRoundRefresh: typeof import('~icons/ic/round-refresh')['default'] + IconIcRoundRemove: typeof import('~icons/ic/round-remove')['default'] IconIcRoundSearch: typeof import('~icons/ic/round-search')['default'] IconLocalBanner: typeof import('~icons/local/banner')['default'] IconLocalLogo: typeof import('~icons/local/logo')['default'] @@ -49,6 +51,7 @@ declare module 'vue' { NDrawer: typeof import('naive-ui')['NDrawer'] NDrawerContent: typeof import('naive-ui')['NDrawerContent'] NDropdown: typeof import('naive-ui')['NDropdown'] + NDynamicInput: typeof import('naive-ui')['NDynamicInput'] NEmpty: typeof import('naive-ui')['NEmpty'] NForm: typeof import('naive-ui')['NForm'] NFormItem: typeof import('naive-ui')['NFormItem'] diff --git a/src/views/manage/menu/modules/menu-operate-drawer.vue b/src/views/manage/menu/modules/menu-operate-drawer.vue index 28587d66c..dd29c34a7 100644 --- a/src/views/manage/menu/modules/menu-operate-drawer.vue +++ b/src/views/manage/menu/modules/menu-operate-drawer.vue @@ -1,12 +1,20 @@