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

34 lines
688 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()
"
2023-10-16 10:58:51 +00:00
class="el-icon app-icon"
2023-10-13 08:11:54 +00:00
>
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
2023-10-18 11:06:22 +00:00
<style lang="scss" scoped></style>