From 1a4d61cc171493631e88d20f6c45b840c27d24c8 Mon Sep 17 00:00:00 2001 From: Li Kui <90845831+likui628@users.noreply.github.com> Date: Tue, 13 Aug 2024 21:30:14 +0800 Subject: [PATCH] fix: type `Component` is not assignable to `RouteMeta` (#4140) * fix: type `Component` is not assignable to `RouteMeta` * fix: ci fail --- packages/@core/base/typings/src/menu-record.ts | 4 +++- packages/@core/base/typings/src/vue-router.d.ts | 2 +- .../@core/ui-kit/menu-ui/src/interface/index.ts | 10 +++------- packages/@core/ui-kit/menu-ui/src/sub-menu.vue | 6 ------ .../shadcn-ui/src/components/breadcrumb/types.ts | 4 +++- packages/effects/layouts/src/widgets/breadcrumb.vue | 13 +------------ 6 files changed, 11 insertions(+), 28 deletions(-) diff --git a/packages/@core/base/typings/src/menu-record.ts b/packages/@core/base/typings/src/menu-record.ts index 0ea0a0b8..9cb18dcc 100644 --- a/packages/@core/base/typings/src/menu-record.ts +++ b/packages/@core/base/typings/src/menu-record.ts @@ -1,5 +1,7 @@ import type { RouteRecordRaw } from 'vue-router'; +import type { Component } from 'vue'; + /** * 扩展路由原始对象 */ @@ -44,7 +46,7 @@ interface MenuRecordRaw extends MenuRecordBadgeRaw { /** * 图标名 */ - icon?: string; + icon?: Component | string; /** * 菜单名 */ diff --git a/packages/@core/base/typings/src/vue-router.d.ts b/packages/@core/base/typings/src/vue-router.d.ts index 65a3d503..ba6407d7 100644 --- a/packages/@core/base/typings/src/vue-router.d.ts +++ b/packages/@core/base/typings/src/vue-router.d.ts @@ -68,7 +68,7 @@ interface RouteMeta { /** * 图标(菜单/tab) */ - icon?: string; + icon?: Component | string; /** * iframe 地址 */ diff --git a/packages/@core/ui-kit/menu-ui/src/interface/index.ts b/packages/@core/ui-kit/menu-ui/src/interface/index.ts index e9d868f3..99422e8e 100644 --- a/packages/@core/ui-kit/menu-ui/src/interface/index.ts +++ b/packages/@core/ui-kit/menu-ui/src/interface/index.ts @@ -1,6 +1,6 @@ import type { MenuRecordBadgeRaw, ThemeModeType } from '@vben-core/typings'; -import type { Ref } from 'vue'; +import type { Component, Ref } from 'vue'; interface MenuProps { /** @@ -61,7 +61,7 @@ interface SubMenuProps extends MenuRecordBadgeRaw { /** * @zh_CN 图标 */ - icon?: string; + icon?: Component | string; /** * @zh_CN submenu 名称 */ @@ -80,7 +80,7 @@ interface MenuItemProps extends MenuRecordBadgeRaw { /** * @zh_CN 图标 */ - icon?: string; + icon?: Component | string; /** * @zh_CN menuitem 名称 */ @@ -93,10 +93,6 @@ interface MenuItemRegistered { path: string; } -// export interface MenuItemClicked { -// name: string; -// } - interface MenuItemClicked { parentPaths: string[]; path: string; diff --git a/packages/@core/ui-kit/menu-ui/src/sub-menu.vue b/packages/@core/ui-kit/menu-ui/src/sub-menu.vue index 4773700a..b0108dc9 100644 --- a/packages/@core/ui-kit/menu-ui/src/sub-menu.vue +++ b/packages/@core/ui-kit/menu-ui/src/sub-menu.vue @@ -31,12 +31,6 @@ const hasChildren = computed(() => { Reflect.has(menu, 'children') && !!menu.children && menu.children.length > 0 ); }); - -// function menuIcon(menu: MenuRecordRaw) { -// return props.activePath === menu.path -// ? menu.activeIcon || menu.icon -// : menu.icon; -// }