diff --git a/src/components/Icon/src/IconPicker.vue b/src/components/Icon/src/IconPicker.vue index d236b669..b7b7fc69 100644 --- a/src/components/Icon/src/IconPicker.vue +++ b/src/components/Icon/src/IconPicker.vue @@ -1,10 +1,11 @@ @@ -78,6 +88,7 @@ import { useI18n } from '/@/hooks/web/useI18n'; import svgIcons from 'virtual:svg-icons-names'; import { copyText } from '/@/utils/copyTextToClipboard'; + // 没有使用别名引入,是因为WebStorm当前版本还不能正确识别,会报unused警告 const AInput = Input; const APopover = Popover; @@ -85,15 +96,8 @@ const AEmpty = Empty; function getIcons() { - const data = iconsData as any; - const prefix: string = data?.prefix ?? ''; - let result: string[] = []; - if (prefix) { - result = (data?.icons ?? []).map((item) => `${prefix}:${item}`); - } else if (Array.isArray(iconsData)) { - result = iconsData as string[]; - } - return result; + const prefix = iconsData.prefix; + return iconsData.icons.map((icon) => `${prefix}:${icon}`); } function getSvgIcons() { @@ -116,6 +120,11 @@ mode: 'iconify', }); + // Don't inherit FormItem disabled、placeholder... + defineOptions({ + inheritAttrs: false, + }); + const emit = defineEmits(['change', 'update:value']); const isSvgMode = props.mode === 'svg'; @@ -124,6 +133,13 @@ const currentSelect = ref(''); const visible = ref(false); const currentList = ref(icons); + const trigger = ref(); + + const triggerPopover = () => { + if (trigger.value) { + trigger.value.click(); + } + }; const { t } = useI18n(); const { prefixCls } = useDesign('icon-picker'); @@ -143,10 +159,9 @@ () => currentSelect.value, (v) => { emit('update:value', v); - return emit('change', v); + emit('change', v); }, ); - function handlePageChange(page: number) { setCurrentPage(page); } @@ -177,6 +192,10 @@ padding: 0; } + .ant-input { + cursor: pointer; + } + &-popover { width: 300px;