mirror of
https://gitee.com/baidu/amis.git
synced 2024-11-30 02:48:55 +08:00
图片选择器增加裁剪配置
This commit is contained in:
parent
e389050762
commit
2eba390dad
@ -386,6 +386,8 @@ app.listen(8080, function () {});
|
||||
| fixedSize | `boolean` | | 是否开启固定尺寸,若开启,需同时设置 fixedSizeClassName |
|
||||
| fixedSizeClassName | `string` | | 开启固定尺寸时,根据此值控制展示尺寸。例如`h-30`,即图片框高为 h-30,AMIS 将自动缩放比率设置默认图所占位置的宽度,最终上传图片根据此尺寸对应缩放。 |
|
||||
| initAutoFill | `boolean` | `false` | 表单反显时是否执行 autoFill |
|
||||
| dropCrop | `boolean` | `true` | 图片上传后是否进入裁剪模式 |
|
||||
| initCrop | `boolean` | `false` | 图片选择器初始化后是否立即进入裁剪模式 |
|
||||
|
||||
### Limit 属性表
|
||||
|
||||
|
@ -242,6 +242,16 @@ export interface ImageControlSchema extends FormBaseControlSchema {
|
||||
*/
|
||||
initAutoFill?: boolean;
|
||||
|
||||
/**
|
||||
* 初始化时是否打开裁剪模式
|
||||
*/
|
||||
initCrop?: boolean;
|
||||
|
||||
/**
|
||||
* 图片上传完毕是否进入裁剪模式
|
||||
*/
|
||||
dropCrop?: boolean;
|
||||
|
||||
/**
|
||||
* 默认占位图图片地址
|
||||
*/
|
||||
@ -327,7 +337,8 @@ export default class ImageControl extends React.Component<
|
||||
extractValue: false,
|
||||
delimiter: ',',
|
||||
autoUpload: true,
|
||||
multiple: false
|
||||
multiple: false,
|
||||
dropCrop: true
|
||||
};
|
||||
|
||||
static formatFileSize(
|
||||
@ -454,6 +465,10 @@ export default class ImageControl extends React.Component<
|
||||
? this.syncAutoFill()
|
||||
: addHook(this.syncAutoFill, 'init');
|
||||
}
|
||||
|
||||
if (this.props.initCrop && this.files.length){
|
||||
this.editImage(0);
|
||||
}
|
||||
}
|
||||
|
||||
componentDidUpdate(prevProps: ImageProps) {
|
||||
@ -873,9 +888,9 @@ export default class ImageControl extends React.Component<
|
||||
}
|
||||
|
||||
handleDrop(files: Array<FileX>) {
|
||||
const {multiple, crop} = this.props;
|
||||
const {multiple, crop, dropCrop} = this.props;
|
||||
|
||||
if (crop && !multiple) {
|
||||
if (crop && !multiple && dropCrop) {
|
||||
const file = files[0] as any;
|
||||
if (!file.preview || !file.url) {
|
||||
file.preview = window.URL.createObjectURL(file);
|
||||
|
Loading…
Reference in New Issue
Block a user