Template
1
0
mirror of https://github.com/un-pany/v3-admin-vite.git synced 2025-04-20 19:09:21 +08:00

perf: 代码优化 新增 global-components.d.ts 全局注册组件的类型文件

This commit is contained in:
pany 2023-06-21 10:28:04 +08:00
parent 75eadd2094
commit 07bde250ff
3 changed files with 13 additions and 3 deletions

View File

@ -44,7 +44,7 @@ watchEffect((onCleanup) => {
<template>
<div @click="handleClick">
<el-tooltip effect="dark" :content="tips" placement="bottom">
<svg-icon :name="isFullscreen ? 'fullscreen-exit' : 'fullscreen'" />
<SvgIcon :name="isFullscreen ? 'fullscreen-exit' : 'fullscreen'" />
</el-tooltip>
</div>
</template>

View File

@ -62,7 +62,7 @@ const resolvePath = (routePath: string) => {
<template v-if="!alwaysShowRootMenu && theOnlyOneChild && !theOnlyOneChild.children">
<SidebarItemLink v-if="theOnlyOneChild.meta" :to="resolvePath(theOnlyOneChild.path)">
<el-menu-item :index="resolvePath(theOnlyOneChild.path)">
<svg-icon v-if="theOnlyOneChild.meta.svgIcon" :name="theOnlyOneChild.meta.svgIcon" />
<SvgIcon v-if="theOnlyOneChild.meta.svgIcon" :name="theOnlyOneChild.meta.svgIcon" />
<component v-else-if="theOnlyOneChild.meta.elIcon" :is="theOnlyOneChild.meta.elIcon" class="el-icon" />
<template v-if="theOnlyOneChild.meta.title" #title>
{{ theOnlyOneChild.meta.title }}
@ -72,7 +72,7 @@ const resolvePath = (routePath: string) => {
</template>
<el-sub-menu v-else :index="resolvePath(props.item.path)" teleported>
<template #title>
<svg-icon v-if="props.item.meta?.svgIcon" :name="props.item.meta.svgIcon" />
<SvgIcon v-if="props.item.meta?.svgIcon" :name="props.item.meta.svgIcon" />
<component v-else-if="props.item.meta?.elIcon" :is="props.item.meta.elIcon" class="el-icon" />
<span v-if="props.item.meta?.title">{{ props.item.meta.title }}</span>
</template>

10
types/global-components.d.ts vendored Normal file
View File

@ -0,0 +1,10 @@
import SvgIcon from "@/components/SvgIcon/index.vue"
/** 由 app.component 全局注册的组件需要在这里声明 TS 类型才能获得 Volar 插件提供的类型提示) */
declare module "vue" {
export interface GlobalComponents {
SvgIcon: typeof SvgIcon
}
}
export {}