feat: 菜单离线图标(未完成)

This commit is contained in:
dap
2024-11-06 17:57:25 +08:00
parent 272777f84f
commit cce6117157
6 changed files with 69 additions and 4 deletions

View File

@@ -1,7 +1,7 @@
<script setup lang="ts">
import { type Component, computed } from 'vue';
import { IconDefault, IconifyIcon } from '@vben-core/icons';
import { IconDefault, IconifyIcon, IconifyOfflineIcon } from '@vben-core/icons';
import {
isFunction,
isHttpUrl,
@@ -13,6 +13,7 @@ const props = defineProps<{
// 没有是否显示默认图标
fallback?: boolean;
icon?: Component | Function | string;
offline?: boolean;
}>();
const isRemoteIcon = computed(() => {
@@ -28,6 +29,15 @@ const isComponent = computed(() => {
<template>
<component :is="icon as Component" v-if="isComponent" v-bind="$attrs" />
<img v-else-if="isRemoteIcon" :src="icon as string" v-bind="$attrs" />
<IconifyIcon v-else-if="icon" v-bind="$attrs" :icon="icon as string" />
<IconifyOfflineIcon
v-else-if="icon && offline"
v-bind="$attrs"
:icon="icon as string"
/>
<IconifyIcon
v-else-if="icon && !offline"
v-bind="$attrs"
:icon="icon as string"
/>
<IconDefault v-else-if="fallback" v-bind="$attrs" />
</template>