@cloudbase/weda-ui-mp 3.18.2 → 3.18.3

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.
@@ -126,9 +126,14 @@ Component({
126
126
  let tempFilePaths = files.tempFilePaths;
127
127
  if (typeof callbacks?.beforeUpload === 'function') {
128
128
  try {
129
+ const mgr = wx.getFileSystemManager();
130
+
129
131
  const ret = await callbacks.beforeUpload({
130
132
  tempFilePaths: tempFilePaths,
131
- base64Uri: files.contents.map((content) => `data:image/jpg;base64,${wx.arrayBufferToBase64(content)}`),
133
+ base64Uri: files.tempFiles.map((f) => {
134
+ const content = mgr.readFileSync(f.tempFilePath);
135
+ return `data:;base64,${wx.arrayBufferToBase64(content)}`;
136
+ }),
132
137
  });
133
138
  if (typeof ret === 'boolean') {
134
139
  shouldUploadToCos = ret;
@@ -174,7 +179,7 @@ Component({
174
179
  // 这里返回的东西会在uploadSuccess回调函数中获取到
175
180
  // https://github.com/wechat-miniprogram/weui-miniprogram/blob/a3630575910302e3b94e69fcef266d2b509de650/src/components/uploader/uploader.ts#L149
176
181
  // 写死的从返回值的 .urls 获取展示用的url来用。一定要将tempFilePaths透传下去,否则会重新加载然后出现闪白
177
- return { urls: files.tempFilePaths, cloudUrls };
182
+ return { urls: files.tempFilePaths, cloudUrls, file: files.tempFiles };
178
183
  } catch (e) {
179
184
  wx.showModal({
180
185
  title: '上传失败,请重试',
@@ -193,6 +198,7 @@ Component({
193
198
  // 小程序自带tempURL 不需要调用 tcb.getTempFileURL 获取
194
199
  this.triggerEvent('success', {
195
200
  value: this.properties.single ? urls[0] : urls,
201
+ file: e.detail.file,
196
202
  });
197
203
  const newUrls = [...this.data.cloudFile, ...urls];
198
204
  this.setData({
@@ -176,25 +176,13 @@ Component({
176
176
  });
177
177
  },
178
178
  commonFile: function (tempFiles) {
179
- // 获取文件内容
180
- const mgr = wx.getFileSystemManager();
181
- const contents = tempFiles.map((item) => {
182
- const fileContent = mgr.readFileSync(item?.tempFilePath);
183
-
184
- return fileContent;
185
- });
186
179
  const obj = {
187
180
  tempFilePaths: tempFiles.map((item) => item.tempFilePath),
188
181
  tempFiles: tempFiles,
189
- contents,
190
182
  };
191
- // 触发选中的事件,开发者根据内容来上传文件,上传了把上传的结果反馈到files属性里面
192
- this.triggerEvent('select', obj, {});
193
- const files = tempFiles.map((item, i) => ({
183
+ const files = tempFiles.map((item) => ({
194
184
  loading: true,
195
- url:
196
- item.tempFilePaths ||
197
- `data:image/jpg;base64,${wx.arrayBufferToBase64(contents[i])}`,
185
+ url: item.tempFilePath,
198
186
  }));
199
187
  if (!files || !files.length) return;
200
188
  if (typeof this.data.upload === 'function') {
@@ -230,7 +218,7 @@ Component({
230
218
  type: 3,
231
219
  errMsg: 'upload file fail, urls not found',
232
220
  },
233
- {}
221
+ {},
234
222
  );
235
223
  }
236
224
  })
@@ -252,7 +240,7 @@ Component({
252
240
  errMsg: 'upload file fail',
253
241
  error: err,
254
242
  },
255
- {}
243
+ {},
256
244
  );
257
245
  });
258
246
  }
@@ -101,7 +101,7 @@ Component({
101
101
  },
102
102
  showMessageCard: {
103
103
  type: Boolean,
104
- value: 'false',
104
+ value: false,
105
105
  },
106
106
  appParameter: {
107
107
  type: String,
@@ -121,9 +121,7 @@ Component({
121
121
  switch (this.data._formType) {
122
122
  case 'submit': {
123
123
  // 调用父级表单容器的提交
124
- parentForm = this.$widget.closest(
125
- (w) => w.getConfig?.().componentType === 'form'
126
- );
124
+ parentForm = this.$widget.closest((w) => w.getConfig?.().componentType === 'form');
127
125
  if (parentForm.submit) {
128
126
  parentForm.submit();
129
127
  return;
@@ -136,9 +134,7 @@ Component({
136
134
  }
137
135
  case 'reset': {
138
136
  // 调用父级表单容器的重置
139
- parentForm = this.$widget.closest(
140
- (w) => w.getConfig?.().componentType === 'form'
141
- );
137
+ parentForm = this.$widget.closest((w) => w.getConfig?.().componentType === 'form');
142
138
  if (parentForm.reset) {
143
139
  parentForm.reset();
144
140
  return;
@@ -154,16 +150,7 @@ Component({
154
150
  }
155
151
  },
156
152
  updateWidgetAPI() {
157
- const {
158
- text,
159
- theme,
160
- variant,
161
- size,
162
- block,
163
- disabled,
164
- formType,
165
- openType,
166
- } = this.data;
153
+ const { text, theme, variant, size, block, disabled, formType, openType } = this.data;
167
154
 
168
155
  this.setReadonlyAttributes &&
169
156
  this.setReadonlyAttributes({
@@ -210,18 +197,14 @@ Component({
210
197
  let _size = PROPS_VALUE_MAP.size[size] || size;
211
198
  let _theme = PROPS_VALUE_MAP.theme[theme] || theme;
212
199
  let _icon = loading ? 'td:loading' : icon;
213
- let _iconType =
214
- iconType === 'none' && loading ? 'text-with-icon' : iconType;
200
+ let _iconType = iconType === 'none' && loading ? 'text-with-icon' : iconType;
215
201
 
216
202
  // 枚举转换
217
203
  _theme = convertLegacyEnum(_theme, WD_BUTTON_THEME);
218
204
  _size = convertLegacyEnum(_size, WD_BUTTON_SIZE);
219
205
  _iconType = convertLegacyEnum(_iconType, WD_BUTTON_ICON_TYPE);
220
206
  const _variant = convertLegacyEnum(variant, WD_BUTTON_VARIANT);
221
- const _iconPosition = convertLegacyEnum(
222
- iconPosition,
223
- WD_BUTTON_ICON_POSITION
224
- );
207
+ const _iconPosition = convertLegacyEnum(iconPosition, WD_BUTTON_ICON_POSITION);
225
208
  const _formType = convertLegacyEnum(formType, WD_BUTTON_TYPE);
226
209
 
227
210
  const classes = {
@@ -249,12 +232,9 @@ Component({
249
232
  // icon样式
250
233
  const iconCls = classNames({
251
234
  [`${classPrefix}-btn__icon`]: true,
252
- [`${classPrefix}-btn__before-icon`]:
253
- iconType === 'text-with-icon' && _iconPosition === 'before',
254
- [`${classPrefix}-btn__after-icon`]:
255
- iconType === 'text-with-icon' && _iconPosition === 'after',
256
- [`${classPrefix}-icon--inherit`]:
257
- style?.fontSize && iconSource === 'inner',
235
+ [`${classPrefix}-btn__before-icon`]: iconType === 'text-with-icon' && _iconPosition === 'before',
236
+ [`${classPrefix}-btn__after-icon`]: iconType === 'text-with-icon' && _iconPosition === 'after',
237
+ [`${classPrefix}-icon--inherit`]: style?.fontSize && iconSource === 'inner',
258
238
  });
259
239
  this.setData({ cls, iconCls, textCls, _icon, _iconType, _formType });
260
240
  },
@@ -67,7 +67,7 @@ Component({
67
67
  this.setData({ visible: false });
68
68
  },
69
69
  menuClick(params) {
70
- this.triggerEvent('menuClick', params);
70
+ this.triggerEvent('menuClick', { ...params, item: params.detail?.item });
71
71
  },
72
72
  },
73
73
  });
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "miniprogram": "./",
4
4
  "packageManager": "yarn@3.0.2",
5
5
  "dependencies": {},
6
- "version": "3.18.2",
6
+ "version": "3.18.3",
7
7
  "main": "./",
8
8
  "publishConfig": {
9
9
  "access": "public"