fix: 修复菜单图标选择器公网依赖和空白显示

- 使用本地 Iconify 图标数据并补齐菜单常用图标

- 修复未知图标降级和弹出层触发器结构
This commit is contained in:
2026-07-21 14:40:47 +08:00
parent 791649c7d5
commit 4c28eaf393
8 changed files with 198 additions and 69 deletions

View File

@@ -3,7 +3,7 @@ import type { Component } from 'vue';
import { computed } from 'vue';
import { IconDefault, IconifyIcon } from '@easyflow-core/icons';
import { IconDefault, IconifyIcon, isLocalIcon } from '@easyflow-core/icons';
import {
isFunction,
isHttpUrl,
@@ -21,6 +21,12 @@ const isRemoteIcon = computed(() => {
return isString(props.icon) && isHttpUrl(props.icon);
});
const isUnavailableIcon = computed(() => {
return (
isString(props.icon) && !isRemoteIcon.value && !isLocalIcon(props.icon)
);
});
const isComponent = computed(() => {
const { icon } = props;
return !isString(icon) && (isObject(icon) || isFunction(icon));
@@ -30,6 +36,10 @@ 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" />
<IconifyIcon
v-else-if="icon && !isUnavailableIcon"
v-bind="$attrs"
:icon="icon as string"
/>
<IconDefault v-else-if="fallback" v-bind="$attrs" />
</template>

View File

@@ -22,6 +22,7 @@ interface Props extends PopoverRootProps {
contentClass?: ClassType;
contentProps?: PopoverContentProps;
triggerClass?: ClassType;
triggerAsChild?: boolean;
}
const props = withDefaults(defineProps<Props>(), {});
@@ -34,6 +35,7 @@ const delegatedProps = computed(() => {
contentClass: _,
contentProps: _cProps,
triggerClass: _tClass,
triggerAsChild: _tAsChild,
...delegated
} = props;
@@ -45,16 +47,15 @@ const forwarded = useForwardPropsEmits(delegatedProps, emits);
<template>
<PopoverRoot v-bind="forwarded">
<PopoverTrigger :class="triggerClass">
<PopoverTrigger :class="triggerClass" :as-child="triggerAsChild">
<slot name="trigger"></slot>
<PopoverContent
:class="contentClass"
class="side-content z-popup"
v-bind="contentProps"
>
<slot></slot>
</PopoverContent>
</PopoverTrigger>
<PopoverContent
:class="contentClass"
class="side-content z-popup"
v-bind="contentProps"
>
<slot></slot>
</PopoverContent>
</PopoverRoot>
</template>