From ad3bfa8692eb6f15aaf73009121ec9b1a5c47183 Mon Sep 17 00:00:00 2001 From: qkiroc <30946345+qkiroc@users.noreply.github.com> Date: Tue, 23 May 2023 20:47:52 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=9B=BE=E6=A0=87?= =?UTF-8?q?=E9=80=89=E6=8B=A9=E7=BB=84=E4=BB=B6=E6=97=A0=E6=B3=95=E6=B8=B2?= =?UTF-8?q?=E6=9F=93iconfont=20(#6974)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: qinhaoyan <30946345+qinhaoyan@users.noreply.github.com> --- packages/amis-ui/scss/components/form/_icon-select.scss | 3 +++ packages/amis-ui/src/components/icons.tsx | 5 +++++ packages/amis/src/renderers/Form/IconSelect.tsx | 8 +++++++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/packages/amis-ui/scss/components/form/_icon-select.scss b/packages/amis-ui/scss/components/form/_icon-select.scss index 84b119e22..dd40eafc5 100644 --- a/packages/amis-ui/scss/components/form/_icon-select.scss +++ b/packages/amis-ui/scss/components/form/_icon-select.scss @@ -66,6 +66,9 @@ height: 100%; } } + &-iconfont { + margin-right: var(--sizes-size-4); + } } &-wrapper { diff --git a/packages/amis-ui/src/components/icons.tsx b/packages/amis-ui/src/components/icons.tsx index 3f5d93c1d..4383baa28 100644 --- a/packages/amis-ui/src/components/icons.tsx +++ b/packages/amis-ui/src/components/icons.tsx @@ -278,6 +278,9 @@ export function Icon({ const Component = getIcon(icon); const isURLIcon = typeof icon === 'string' && icon?.indexOf('.') !== -1; + const isIconfont = + typeof icon === 'string' && + (~icon?.indexOf('iconfont') || ~icon?.indexOf('fa')); return Component ? ( <> @@ -293,6 +296,8 @@ export function Icon({ ) : isURLIcon ? ( + ) : isIconfont ? ( + ) : ( 没有 icon {icon} ); diff --git a/packages/amis/src/renderers/Form/IconSelect.tsx b/packages/amis/src/renderers/Form/IconSelect.tsx index 1a86cc7d9..f5641ae3a 100644 --- a/packages/amis/src/renderers/Form/IconSelect.tsx +++ b/packages/amis/src/renderers/Form/IconSelect.tsx @@ -147,7 +147,13 @@ export default class IconSelectControl extends React.PureComponent< dangerouslySetInnerHTML={{__html: SvgStr[0].replace(/\\"/g, '"')}} > ) : ( - + ) ) : null}