diff --git a/src/plugins/element-plus-icons.ts b/src/plugins/element-plus-icons.ts index 8dd2ac04..d912cdbe 100644 --- a/src/plugins/element-plus-icons.ts +++ b/src/plugins/element-plus-icons.ts @@ -1,6 +1,8 @@ import type { App } from "vue" import * as ElementPlusIconsVue from "@element-plus/icons-vue" +export type TElementPlusIconName = keyof typeof ElementPlusIconsVue + export function installElementPlusIcons(app: App) { // 注册所有 Element Plus Icon for (const [key, component] of Object.entries(ElementPlusIconsVue)) { diff --git a/src/router/index.ts b/src/router/index.ts index 58ef2eac..d270e6b6 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -160,7 +160,7 @@ export const constantRoutes: RouteRecordRaw[] = [ path: "/link", meta: { title: "文档链接", - elIcon: "link" + elIcon: "Link" }, children: [ { @@ -196,7 +196,7 @@ export const dynamicRoutes: RouteRecordRaw[] = [ name: "Permission", meta: { title: "权限演示", - elIcon: "lock", + elIcon: "Lock", // 可以在根路由中设置角色 roles: ["admin", "editor"], alwaysShow: true diff --git a/types/vue-router.d.ts b/types/vue-router.d.ts index f604d226..78399aa5 100644 --- a/types/vue-router.d.ts +++ b/types/vue-router.d.ts @@ -1,3 +1,4 @@ +import type { TElementPlusIconName } from "@/plugins/element-plus-icons" import type { TSvgIconName } from "@@/components/SvgIcon/index.vue" import "vue-router" @@ -16,7 +17,7 @@ declare module "vue-router" { /** * @description 设置该路由的图标,直接使用 Element Plus 的 Icon(与 svgIcon 同时设置时,svgIcon 将优先生效) */ - elIcon?: string + elIcon?: TElementPlusIconName /** * @description 默认 false,设置 true 的时候该路由不会在侧边栏出现 */