From 6319defeca535ff01b93fb15ac0124b26dd6ced4 Mon Sep 17 00:00:00 2001 From: ClariS <1457715339@qq.com> Date: Fri, 29 Nov 2024 22:58:50 +0800 Subject: [PATCH] =?UTF-8?q?types:=20=E8=B7=AF=E7=94=B1=E4=B8=AD=20elIcon?= =?UTF-8?q?=20=E5=B1=9E=E6=80=A7=E6=B7=BB=E5=8A=A0=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/element-plus-icons.ts | 2 ++ src/router/index.ts | 4 ++-- types/vue-router.d.ts | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) 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 的时候该路由不会在侧边栏出现 */