@cloudbase/weda-ui-mp 3.17.0 → 3.17.2

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.
@@ -119,7 +119,7 @@ Component({
119
119
  autoplay = this.properties.autoplay,
120
120
  loop = this.properties.loop,
121
121
  playbackRate = this.properties.playbackRate,
122
- startTime = this.properties.startTime
122
+ startTime = this.properties.startTime,
123
123
  ) {
124
124
  let { audioInstance } = this.data;
125
125
  if (audioInstance) {
@@ -194,15 +194,11 @@ Component({
194
194
  durationStr: calcTime(this.data.audioInstance?.duration),
195
195
  });
196
196
  this.updateWidgetAPI();
197
+ this.triggerEvent('audioReady', { audioInstance: this.data.audioInstance });
197
198
  }, 0);
198
199
  });
199
200
 
200
201
  this.setData({ audioInstance, currentTimeStr: calcTime(startTime) });
201
-
202
- // eslint-disable-next-line rulesdir/no-timer
203
- setTimeout(() => {
204
- this.triggerEvent('audioReady', { audioInstance });
205
- }, 0);
206
202
  this.updateWidgetAPI();
207
203
  },
208
204
  setPlayState(played) {
@@ -228,10 +224,7 @@ Component({
228
224
  },
229
225
  fastForward({ time } = {}) {
230
226
  this.seek({
231
- position: Math.min(
232
- this.data.audioInstance?.currentTime + time,
233
- this.data.audioInstance?.duration
234
- ),
227
+ position: Math.min(this.data.audioInstance?.currentTime + time, this.data.audioInstance?.duration),
235
228
  });
236
229
  },
237
230
  backward({ time } = {}) {
@@ -260,13 +253,7 @@ Component({
260
253
 
261
254
  this.setData({ cls });
262
255
  },
263
- 'src,autoplay,loop,playbackRate,startTime': function (
264
- src,
265
- autoplay,
266
- loop,
267
- playbackRate,
268
- startTime
269
- ) {
256
+ 'src,autoplay,loop,playbackRate,startTime': function (src, autoplay, loop, playbackRate, startTime) {
270
257
  this.init(src, autoplay, loop, playbackRate, startTime);
271
258
  },
272
259
  },
@@ -1,3 +1,5 @@
1
+ import { WdCompError } from '../../utils/error';
2
+
1
3
  // father-son 是老的,新的叫many-one
2
4
  const SINGLE_SELECT_FORMATS = [
3
5
  'many-one',
@@ -12,21 +14,14 @@ const SINGLE_SELECT_FORMATS = [
12
14
 
13
15
  const MULTI_SELECT_FORMATS = ['many-many', 'one-many'];
14
16
 
15
- export function convertRemoteValueToFormData(
16
- dataSourceType,
17
- dataSourceProfile,
18
- fetchedInitialValues
19
- ) {
17
+ export function convertRemoteValueToFormData(dataSourceType, dataSourceProfile, fetchedInitialValues) {
20
18
  if (dataSourceType === 'experssion') {
21
19
  return fetchedInitialValues;
22
20
  }
23
21
  const result = Object.keys(fetchedInitialValues).reduce((acc, field) => {
24
22
  const format = dataSourceProfile?.schema?.properties?.[field]?.format;
25
23
  acc[field] = fetchedInitialValues[field];
26
- if (
27
- [...SINGLE_SELECT_FORMATS, 'father-son'].includes(format) &&
28
- fetchedInitialValues[field]['_id']
29
- ) {
24
+ if ([...SINGLE_SELECT_FORMATS, 'father-son'].includes(format) && fetchedInitialValues[field]['_id']) {
30
25
  acc[field] = fetchedInitialValues[field]['_id'];
31
26
  }
32
27
  if (MULTI_SELECT_FORMATS.includes(format)) {
@@ -37,13 +32,7 @@ export function convertRemoteValueToFormData(
37
32
  return result;
38
33
  }
39
34
 
40
- export function convertFormDataToSubmitParams(
41
- dataSourceProfile,
42
- formData,
43
- formType,
44
- _id,
45
- fields
46
- ) {
35
+ export function convertFormDataToSubmitParams(dataSourceProfile, formData, formType, _id, fields) {
47
36
  const data = Object.keys(formData).reduce((acc, cur) => {
48
37
  if (!fields.includes(cur)) return acc;
49
38
  const format = dataSourceProfile.schema?.properties?.[cur]?.format;
@@ -54,6 +43,17 @@ export function convertFormDataToSubmitParams(
54
43
  if (MULTI_SELECT_FORMATS.includes(format)) {
55
44
  acc[cur] = acc[cur]?.map((_id) => ({ _id }));
56
45
  }
46
+ if ('x-json' === format && typeof formData[cur] === 'string') {
47
+ try {
48
+ acc[cur] = formData[cur] ? JSON.parse(formData[cur]) : null;
49
+ } catch (error) {
50
+ const err = new WdCompError(`字段 ${cur} 的 JSON 格式错误,请检查`, {
51
+ code: 'WdForm.submit.jsonParse',
52
+ original: error,
53
+ });
54
+ console.warn(err.code, err);
55
+ }
56
+ }
57
57
  return acc;
58
58
  }, {});
59
59
  const result = {
@@ -1,6 +1,6 @@
1
1
  <image id="{{id}}" style="{{style}}" class="wd-image {{clsx}} wd-mp-image" src="{{realSrc}}" alt="{{alt}}" mode="{{imgMode}}" lazy-load="{{lazyLoad}}" show-menu-by-longpress="{{showMenuByLongpress}}" bindtap="onImgTap" bindload="load" binderror="error" />
2
- <root-portal>
3
- <view wx:if="{{showImg}}" class="wd-image-preview-container wd-image-mask" bindtap="onMaskClick">
2
+ <root-portal wx:if="{{showImg}}">
3
+ <view class="wd-image-preview-container wd-image-mask" bindtap="onMaskClick">
4
4
  <view bindtap="onCloseClick" class="wd-image-mask__close-btn">
5
5
  <icon class="wd-image-mask__icon-close"></icon>
6
6
  </view>
@@ -156,12 +156,21 @@ Component({
156
156
  'name, value, label, required, visible, disabled, readOnly, sourceType': function () {
157
157
  this.updateWidgetAPI();
158
158
  },
159
- 'disabled,sourceType,maxUploadCount,sizeType,single': function (disabled, sourceType, maxUploadCount, sizeType) {
159
+ 'disabled,sourceType,maxUploadCount,sizeType,maxSize,single': function (
160
+ disabled,
161
+ sourceType,
162
+ maxUploadCount,
163
+ sizeType,
164
+ maxSize,
165
+ single,
166
+ ) {
160
167
  const config = {
161
168
  disabled,
162
169
  sourceType,
163
170
  maxUploadCount,
164
171
  sizeType,
172
+ maxSize,
173
+ single,
165
174
  };
166
175
  this.setConfig(config);
167
176
  },
@@ -194,8 +203,8 @@ Component({
194
203
  lifetimes: {
195
204
  attached: function () {
196
205
  this.initValue();
197
- const { disabled, sourceType, sizeType } = this.data;
198
- this.setConfig({ disabled, maxDuration: 60, sourceType, sizeType });
206
+ const { disabled, sourceType, sizeType, maxSize } = this.data;
207
+ this.setConfig({ disabled, maxDuration: 60, sourceType, sizeType, maxSize });
199
208
 
200
209
  this.updateWidgetAPI();
201
210
  },
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "miniprogram": "./",
4
4
  "packageManager": "yarn@3.0.2",
5
5
  "dependencies": {},
6
- "version": "3.17.0",
6
+ "version": "3.17.2",
7
7
  "main": "./",
8
8
  "publishConfig": {
9
9
  "access": "public"