From 5ecae394e55e964da167eda3bafffe127c86b5ba Mon Sep 17 00:00:00 2001 From: miaoxinyu01 Date: Tue, 5 Sep 2023 15:35:36 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E5=9B=BE=E7=89=87=E7=BC=A9=E7=95=A5?= =?UTF-8?q?=E5=9B=BE=E5=8D=A0=E4=BD=8D=E5=9B=BE=E5=9C=B0=E5=9D=80=E6=A0=8F?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0fx;=E5=8D=A0=E4=BD=8D=E5=9B=BE=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E5=8F=96fx=E5=8F=98=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/amis-editor/src/plugin/Image.tsx | 5 ++--- packages/amis/src/renderers/Image.tsx | 9 +++++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/packages/amis-editor/src/plugin/Image.tsx b/packages/amis-editor/src/plugin/Image.tsx index f958724b4..1354bb1e6 100644 --- a/packages/amis-editor/src/plugin/Image.tsx +++ b/packages/amis-editor/src/plugin/Image.tsx @@ -84,9 +84,8 @@ export class ImagePlugin extends BasePlugin { isUnderField ? null - : getSchemaTpl('imageUrl', { + : getSchemaTpl('formulaControl', { name: 'src', - type: 'input-text', label: '缩略图地址', description: '如果已绑定字段名,可以不用设置,支持用变量。' }), @@ -119,7 +118,7 @@ export class ImagePlugin extends BasePlugin { hiddenOn: 'this.enlargeAble', clearValueOnHidden: true }, - getSchemaTpl('imageUrl', { + getSchemaTpl('formulaControl', { name: 'defaultImage', label: tipedLabel('占位图', '无数据时显示的图片') }) diff --git a/packages/amis/src/renderers/Image.tsx b/packages/amis/src/renderers/Image.tsx index 60362c57a..b413c0b56 100644 --- a/packages/amis/src/renderers/Image.tsx +++ b/packages/amis/src/renderers/Image.tsx @@ -506,6 +506,11 @@ export class ImageField extends React.Component { let value = finnalSrc || getPropValue(this.props); const finnalHref = href ? filter(href, data, '| raw') : ''; + const defaultValue = defaultImage + ? filter(defaultImage, data, '| raw') + : ''; + let defaultImageValue = defaultValue || getPropValue(this.props); + return (
{ thumbClassName={thumbClassName} height={height} width={width} - src={value ? value : defaultImage} + src={value ? value : defaultImageValue} href={finnalHref} title={filter(title, data)} caption={filter(imageCaption, data)} thumbMode={thumbMode} thumbRatio={thumbRatio} originalSrc={filter(originalSrc, data, '| raw') ?? value} - enlargeAble={enlargeAble && value !== defaultImage} + enlargeAble={enlargeAble && value !== defaultImageValue} onEnlarge={this.handleEnlarge} imageMode={imageMode} imageControlClassName={imageControlClassName}