UnisKB/ui/src/components/icons/AppIcon.vue

42 lines
760 B
Vue
Raw Normal View History

2023-09-15 09:40:35 +00:00
<template>
2023-10-13 08:11:54 +00:00
<component
v-if="isIconfont"
:is="
Object.keys(iconMap).includes(iconName)
? iconMap[iconName].iconReader()
: iconMap['404'].iconReader()
"
class="app-icon"
>
2023-09-15 09:40:35 +00:00
</component>
2023-10-13 08:11:54 +00:00
<el-icon v-else-if="iconName">
<component :is="iconName" />
</el-icon>
2023-09-15 09:40:35 +00:00
</template>
<script setup lang="ts">
2023-10-13 08:11:54 +00:00
import { computed } from 'vue'
import { iconMap } from '@/components/icons/index'
defineOptions({ name: 'AppIcon' })
2023-09-15 09:40:35 +00:00
2023-10-13 08:11:54 +00:00
const props = withDefaults(
defineProps<{
iconName?: string
}>(),
{
iconName: '404'
}
)
2023-09-15 09:40:35 +00:00
2023-10-13 08:11:54 +00:00
const isIconfont = computed(() => props.iconName?.includes('app-'))
2023-09-15 09:40:35 +00:00
</script>
2023-10-13 08:11:54 +00:00
<style lang="scss" scoped>
.app-icon {
line-height: 1em;
svg {
height: 1em;
width: 1em;
}
}
</style>