style: update image code, #5531

pull/4757/head
tangjinzhou 2022-04-22 19:18:20 +08:00
parent bc3843b774
commit ab90e3fa08
4 changed files with 11 additions and 15 deletions

View File

@ -22,7 +22,7 @@ Previewable image.
| placeholder | Load placeholder, use default placeholder when set `true` | boolean \| slot | - | 2.0.0 | | placeholder | Load placeholder, use default placeholder when set `true` | boolean \| slot | - | 2.0.0 |
| preview | preview config, disabled when `false` | boolean \| [previewType](#previewType) | true | 2.0.0 | | preview | preview config, disabled when `false` | boolean \| [previewType](#previewType) | true | 2.0.0 |
| src | Image path | string | - | 2.0.0 | | src | Image path | string | - | 2.0.0 |
| previewMask | custom mask | boolean \| function \| slot | - | 3.2.0 | | previewMask | custom mask | false \| function \| slot | - | 3.2.0 |
| width | Image width | string \| number | - | 2.0.0 | | width | Image width | string \| number | - | 2.0.0 |
### events ### events

View File

@ -41,24 +41,20 @@ const Image = defineComponent<ImageProps>({
return () => { return () => {
const imageLocale = configProvider.locale?.Image || defaultLocale.Image; const imageLocale = configProvider.locale?.Image || defaultLocale.Image;
const defaultPreviewMask = () => (
<div class={`${prefixCls.value}-mask-info`}>
<EyeOutlined />
{imageLocale?.preview}
</div>
);
const { previewMask = slots.previewMask || defaultPreviewMask } = props;
return ( return (
<ImageInternal <ImageInternal
{...{ ...attrs, ...props, prefixCls: prefixCls.value }} {...{ ...attrs, ...props, prefixCls: prefixCls.value }}
preview={mergedPreview.value} preview={mergedPreview.value}
v-slots={{ v-slots={{
...slots, ...slots,
previewMask: previewMask: typeof previewMask === 'function' ? previewMask : null,
props.previewMask === false
? null
: props.previewMask ??
slots.previewMask ??
(() => (
<div class={`${prefixCls.value}-mask-info`}>
<EyeOutlined />
{imageLocale?.preview}
</div>
)),
}} }}
></ImageInternal> ></ImageInternal>
); );

View File

@ -23,7 +23,7 @@ cover: https://gw.alipayobjects.com/zos/antfincdn/D1dXz9PZqa/image.svg
| placeholder | 加载占位, 为 `true` 时使用默认占位 | boolean \| slot | - | 2.0.0 | | placeholder | 加载占位, 为 `true` 时使用默认占位 | boolean \| slot | - | 2.0.0 |
| preview | 预览参数,为 `false` 时禁用 | boolean \| [previewType](#previewType) | true | 2.0.0 | | preview | 预览参数,为 `false` 时禁用 | boolean \| [previewType](#previewType) | true | 2.0.0 |
| src | 图片地址 | string | - | 2.0.0 | | src | 图片地址 | string | - | 2.0.0 |
| previewMask | 自定义 mask | boolean \| function \| slot | - | 3.2.0 | | previewMask | 自定义 mask | false \| function \| slot | - | 3.2.0 |
| width | 图像宽度 | string \| number | - | 2.0.0 | | width | 图像宽度 | string \| number | - | 2.0.0 |
### 事件 ### 事件

View File

@ -33,7 +33,7 @@ export const imageProps = () => ({
prefixCls: String, prefixCls: String,
previewPrefixCls: String, previewPrefixCls: String,
previewMask: { previewMask: {
type: [Boolean, Function] as PropType<boolean | (() => any)>, type: [Boolean, Function] as PropType<false | (() => any)>,
default: undefined, default: undefined,
}, },
placeholder: PropTypes.any, placeholder: PropTypes.any,