feat: 路由的 icon 配置项支持 Element Plus 的 Icon (#19)

This commit is contained in:
Arman
2022-09-30 17:41:47 +08:00
committed by GitHub
parent 80fc1c21e8
commit 5c0a8379c2
4 changed files with 34 additions and 13 deletions

View File

@@ -71,7 +71,8 @@ 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.icon" :name="theOnlyOneChild.meta.icon" />
<svg-icon v-if="theOnlyOneChild.meta.svgIcon" :name="theOnlyOneChild.meta.svgIcon" />
<component v-else-if="theOnlyOneChild.meta.elIcon" class="el-icon" :is="theOnlyOneChild.meta.elIcon" />
<template v-if="theOnlyOneChild.meta.title" #title>
{{ theOnlyOneChild.meta.title }}
</template>
@@ -80,7 +81,8 @@ const resolvePath = (routePath: string) => {
</template>
<el-sub-menu v-else :index="resolvePath(props.item.path)" popper-append-to-body>
<template #title>
<svg-icon v-if="props.item.meta && props.item.meta.icon" :name="props.item.meta.icon" />
<svg-icon v-if="props.item.meta && props.item.meta.svgIcon" :name="props.item.meta.svgIcon" />
<component v-else-if="props.item.meta && props.item.meta.elIcon" class="el-icon" :is="props.item.meta.elIcon" />
<span v-if="props.item.meta && props.item.meta.title">{{ props.item.meta.title }}</span>
</template>
<template v-if="props.item.children">
@@ -99,11 +101,15 @@ const resolvePath = (routePath: string) => {
<style lang="scss" scoped>
.svg-icon {
margin-right: 20px;
margin-right: 8px;
min-width: 1em;
font-size: 16px;
}
.el-icon {
width: 1em;
height: 1em;
margin-right: 8px;
}
.simple-mode {
&.first-level {
:deep(.el-sub-menu) {