@ecoding/components.antd 0.4.8 → 0.4.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -84,12 +84,14 @@ const MultipleImgUpload = (props) => {
84
84
  }
85
85
  return buildURL(props.action(), props.actionParams);
86
86
  }, [props.actionParams, props.action]);
87
- const getBase64 = (file) => new Promise((resolve, reject) => {
88
- const reader = new FileReader();
89
- reader.readAsDataURL(file);
90
- reader.onload = () => resolve(reader.result);
91
- reader.onerror = (error) => reject(error);
92
- });
87
+ const getBase64 = (file) => {
88
+ return new Promise((resolve, reject) => {
89
+ const reader = new FileReader();
90
+ reader.readAsDataURL(file);
91
+ reader.onload = () => resolve(reader.result);
92
+ reader.onerror = (error) => reject(error);
93
+ });
94
+ };
93
95
  const handlePreview = (file) => __awaiter(void 0, void 0, void 0, function* () {
94
96
  if (!file.url && !file.preview) {
95
97
  file.preview = yield getBase64(file.originFileObj);
@@ -138,46 +140,38 @@ const MultipleImgUpload = (props) => {
138
140
  }
139
141
  if (ary.indexOf(file.type.toLowerCase().replace(/image\//g, "")) === -1) {
140
142
  message.error(`支持图片格式为:${ary.join(",")}`);
141
- reject();
142
- return;
143
+ return Upload.LIST_IGNORE;
143
144
  }
144
145
  const isLt2M = file.size / 1024 / 1024 < (props.opts.size || 1);
145
146
  if (!isLt2M) {
146
147
  message.error(`图片大小必须小于${props.opts.size} MB`);
147
- reject();
148
- return;
148
+ return Upload.LIST_IGNORE;
149
149
  }
150
150
  const base64 = yield getBase64(file);
151
151
  const wh = yield getImgwh(base64);
152
152
  if (props.opts.w && props.opts.w !== wh.w) {
153
153
  message.error(`图片宽度不符合 ${props.opts.w}px`);
154
- reject();
155
- return;
154
+ return Upload.LIST_IGNORE;
156
155
  }
157
156
  if (props.opts.h && props.opts.h !== wh.h) {
158
157
  message.error(`图片高度不符合 ${props.opts.h}px`);
159
- reject();
160
- return;
158
+ return Upload.LIST_IGNORE;
161
159
  }
162
160
  if (props.opts.maxH && props.opts.maxH < wh.h) {
163
161
  message.error(`图片高度不能大于 ${props.opts.maxH}px`);
164
- reject();
165
- return;
162
+ return Upload.LIST_IGNORE;
166
163
  }
167
164
  if (props.opts.minH && props.opts.minH > wh.h) {
168
165
  message.error(`图片高度不能小于 ${props.opts.minH}px`);
169
- reject();
170
- return;
166
+ return Upload.LIST_IGNORE;
171
167
  }
172
168
  if (props.opts.maxW && props.opts.maxW < wh.w) {
173
169
  message.error(`图片宽度不能大于 ${props.opts.maxW}px`);
174
- reject();
175
- return;
170
+ return Upload.LIST_IGNORE;
176
171
  }
177
172
  if (props.opts.minW && props.opts.minW > wh.w) {
178
173
  message.error(`图片宽度不能小于 ${props.opts.minW}px`);
179
- reject();
180
- return;
174
+ return Upload.LIST_IGNORE;
181
175
  }
182
176
  if (props.opts.ratioW && props.opts.ratioH) {
183
177
  // 保留2位小数进行比例计算
@@ -185,8 +179,7 @@ const MultipleImgUpload = (props) => {
185
179
  const targetRatio = Number((props.opts.ratioW / props.opts.ratioH).toFixed(2));
186
180
  if (ratio !== targetRatio) {
187
181
  message.error(`图片宽度与高度比例必须是 ${props.opts.ratioW} x ${props.opts.ratioH}`);
188
- reject();
189
- return;
182
+ return Upload.LIST_IGNORE;
190
183
  }
191
184
  }
192
185
  resolve();
@@ -194,9 +187,6 @@ const MultipleImgUpload = (props) => {
194
187
  }, []);
195
188
  return (React.createElement(React.Fragment, null,
196
189
  props.showMessage && (React.createElement(Alert, { className: 'mb20', message: props.message ? props.message : (React.createElement(Flex, { gap: 10, wrap: true },
197
- React.createElement("div", null,
198
- i18n ? i18n.$t("global.batch.upload", "批量上传") : "批量上传",
199
- ";"),
200
190
  maxCount ? (React.createElement("div", null,
201
191
  i18n ? i18n.$t("global.max.count", "最多张数") : "最多张数",
202
192
  "\uFF1A",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ecoding/components.antd",
3
- "version": "0.4.8",
3
+ "version": "0.4.9",
4
4
  "author": "cxc",
5
5
  "homepage": "",
6
6
  "license": "MIT",
@@ -47,5 +47,5 @@
47
47
  "antd": "5.27.0",
48
48
  "axios": "^1.1.2"
49
49
  },
50
- "gitHead": "471c40c8bcb78fc7d088b1d7005cc6c2961a743f"
50
+ "gitHead": "835237e04f3c997c585c52bde578d4c2add265ee"
51
51
  }