refactor: custom icon

This commit is contained in:
张传龙
2022-08-27 11:46:34 +08:00
parent 2f1b747243
commit 0cefadc2a5
15 changed files with 1024 additions and 12 deletions

View File

@@ -5,14 +5,14 @@
:key="item.path"
@click="handleBreadClick(item.path)"
>
<component :is="renderIcon(item.meta?.icon, { size: 16 })" v-if="item.meta?.icon" />
<component :is="getIcon(item.meta)" />
{{ item.meta.title }}
</n-breadcrumb-item>
</n-breadcrumb>
</template>
<script setup>
import { renderIcon } from '@/utils/icon'
import { renderCustomIcon, renderIcon } from '@/utils/icon'
const router = useRouter()
const route = useRoute()
@@ -21,4 +21,10 @@ function handleBreadClick(path) {
if (path === route.path) return
router.push(path)
}
function getIcon(meta) {
if (meta?.customIcon) return renderCustomIcon(meta.customIcon, { size: 18 })
if (meta?.icon) return renderIcon(meta.icon, { size: 18 })
return null
}
</script>