perf: 代码优化 新增 global-components.d.ts 全局注册组件的类型文件
This commit is contained in:
parent
75eadd2094
commit
07bde250ff
@ -44,7 +44,7 @@ watchEffect((onCleanup) => {
|
|||||||
<template>
|
<template>
|
||||||
<div @click="handleClick">
|
<div @click="handleClick">
|
||||||
<el-tooltip effect="dark" :content="tips" placement="bottom">
|
<el-tooltip effect="dark" :content="tips" placement="bottom">
|
||||||
<svg-icon :name="isFullscreen ? 'fullscreen-exit' : 'fullscreen'" />
|
<SvgIcon :name="isFullscreen ? 'fullscreen-exit' : 'fullscreen'" />
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
@ -62,7 +62,7 @@ const resolvePath = (routePath: string) => {
|
|||||||
<template v-if="!alwaysShowRootMenu && theOnlyOneChild && !theOnlyOneChild.children">
|
<template v-if="!alwaysShowRootMenu && theOnlyOneChild && !theOnlyOneChild.children">
|
||||||
<SidebarItemLink v-if="theOnlyOneChild.meta" :to="resolvePath(theOnlyOneChild.path)">
|
<SidebarItemLink v-if="theOnlyOneChild.meta" :to="resolvePath(theOnlyOneChild.path)">
|
||||||
<el-menu-item :index="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" />
|
<component v-else-if="theOnlyOneChild.meta.elIcon" :is="theOnlyOneChild.meta.elIcon" class="el-icon" />
|
||||||
<template v-if="theOnlyOneChild.meta.title" #title>
|
<template v-if="theOnlyOneChild.meta.title" #title>
|
||||||
{{ theOnlyOneChild.meta.title }}
|
{{ theOnlyOneChild.meta.title }}
|
||||||
@ -72,7 +72,7 @@ const resolvePath = (routePath: string) => {
|
|||||||
</template>
|
</template>
|
||||||
<el-sub-menu v-else :index="resolvePath(props.item.path)" teleported>
|
<el-sub-menu v-else :index="resolvePath(props.item.path)" teleported>
|
||||||
<template #title>
|
<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" />
|
<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>
|
<span v-if="props.item.meta?.title">{{ props.item.meta.title }}</span>
|
||||||
</template>
|
</template>
|
||||||
|
10
types/global-components.d.ts
vendored
Normal file
10
types/global-components.d.ts
vendored
Normal 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 {}
|
Loading…
x
Reference in New Issue
Block a user