@tarojs/taro-h5 3.5.11 → 3.6.0-beta.1
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.
- package/dist/api/device/clipboard.js +2 -1
- package/dist/api/location/chooseLocation.js +4 -4
- package/dist/api/location/getLocation.js +2 -2
- package/dist/api/media/image/chooseImage.js +2 -2
- package/dist/api/media/image/getImageInfo.js +2 -2
- package/dist/api/media/image/previewImage.js +2 -1
- package/dist/api/media/video/index.js +2 -2
- package/dist/api/network/request/index.js +9 -8
- package/dist/api/network/websocket/index.d.ts +1 -1
- package/dist/api/network/websocket/index.js +3 -3
- package/dist/api/network/websocket/socketTask.js +7 -6
- package/dist/api/taro.js +2 -1
- package/dist/api/ui/navigation-bar/index.d.ts +1 -1
- package/dist/api/ui/pull-down-refresh.js +4 -4
- package/dist/api/ui/scroll/index.js +3 -3
- package/dist/api/ui/tab-bar.js +16 -16
- package/dist/api/wxml/MediaQueryObserver.js +4 -3
- package/dist/api/wxml/nodesRef.d.ts +1 -0
- package/dist/api/wxml/selectorQuery.js +3 -2
- package/dist/index.cjs.d.ts +2 -2
- package/dist/index.cjs.js +81 -75
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.d.ts +2 -2
- package/dist/index.esm.js +80 -74
- package/dist/index.esm.js.map +1 -1
- package/dist/taroApis.d.ts +2 -2
- package/dist/utils/handler.d.ts +8 -3
- package/dist/utils/handler.js +20 -10
- package/dist/utils/index.js +3 -2
- package/dist/utils/valid.d.ts +1 -2
- package/dist/utils/valid.js +0 -3
- package/package.json +9 -4
- package/types/global.d.ts +1 -0
package/dist/index.esm.d.ts
CHANGED
|
@@ -551,7 +551,7 @@ declare function onSocketOpen(): void;
|
|
|
551
551
|
declare function onSocketMessage(): void;
|
|
552
552
|
declare function onSocketError(): void;
|
|
553
553
|
declare function onSocketClose(): void;
|
|
554
|
-
declare function connectSocket(options
|
|
554
|
+
declare function connectSocket(options?: Taro.connectSocket.Option): Promise<unknown>;
|
|
555
555
|
declare function closeSocket(): void;
|
|
556
556
|
// 帐号信息
|
|
557
557
|
declare const getAccountInfoSync: (option?: {}, ...args: any[]) => Promise<Partial<TaroGeneral.CallbackResult> & Record<string, unknown> & TaroGeneral.CallbackResult>;
|
|
@@ -686,7 +686,7 @@ declare const disableAlertBeforeUnload: (option?: {}, ...args: any[]) => Promise
|
|
|
686
686
|
declare const getMenuButtonBoundingClientRect: (option?: {}, ...args: any[]) => Promise<Partial<TaroGeneral.CallbackResult> & Record<string, unknown> & TaroGeneral.CallbackResult>;
|
|
687
687
|
// 导航栏
|
|
688
688
|
declare const showNavigationBarLoading: (option?: {}, ...args: any[]) => Promise<Partial<TaroGeneral.CallbackResult> & Record<string, unknown> & TaroGeneral.CallbackResult>;
|
|
689
|
-
declare function setNavigationBarTitle(options
|
|
689
|
+
declare function setNavigationBarTitle(options?: Taro.setNavigationBarTitle.Option): Promise<Partial<TaroGeneral.CallbackResult> & Record<string, unknown> & TaroGeneral.CallbackResult>;
|
|
690
690
|
/**
|
|
691
691
|
* 设置页面导航条颜色
|
|
692
692
|
*/
|
package/dist/index.esm.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import Taro from '@tarojs/api';
|
|
2
2
|
import { history, navigateBack, navigateTo, reLaunch, redirectTo, getCurrentPages, switchTab } from '@tarojs/router';
|
|
3
3
|
export { getCurrentPages, history, navigateBack, navigateTo, reLaunch, redirectTo, switchTab } from '@tarojs/router';
|
|
4
|
+
import { isFunction } from '@tarojs/shared';
|
|
4
5
|
import { addLeadingSlash, stripBasename, getHomePage } from '@tarojs/router/dist/utils';
|
|
5
6
|
import { hooks, Current as Current$1 } from '@tarojs/runtime';
|
|
6
7
|
import { fromByteArray, toByteArray } from 'base64-js';
|
|
@@ -11,30 +12,38 @@ import jsonpRetry from 'jsonp-retry';
|
|
|
11
12
|
|
|
12
13
|
class MethodHandler {
|
|
13
14
|
constructor({ name, success, fail, complete }) {
|
|
15
|
+
this.isHandlerError = false;
|
|
14
16
|
this.methodName = name;
|
|
15
17
|
this.__success = success;
|
|
16
18
|
this.__fail = fail;
|
|
17
19
|
this.__complete = complete;
|
|
20
|
+
this.isHandlerError = isFunction(this.__complete) || isFunction(this.__fail);
|
|
18
21
|
}
|
|
19
|
-
success(res = {},
|
|
22
|
+
success(res = {}, promise = {}) {
|
|
20
23
|
if (!res.errMsg) {
|
|
21
24
|
res.errMsg = `${this.methodName}:ok`;
|
|
22
25
|
}
|
|
23
|
-
|
|
24
|
-
|
|
26
|
+
isFunction(this.__success) && this.__success(res);
|
|
27
|
+
isFunction(this.__complete) && this.__complete(res);
|
|
28
|
+
const { resolve = Promise.resolve.bind(Promise) } = promise;
|
|
25
29
|
return resolve(res);
|
|
26
30
|
}
|
|
27
|
-
fail(res = {},
|
|
31
|
+
fail(res = {}, promise = {}) {
|
|
28
32
|
if (!res.errMsg) {
|
|
29
33
|
res.errMsg = `${this.methodName}:fail`;
|
|
30
34
|
}
|
|
31
35
|
else {
|
|
32
36
|
res.errMsg = `${this.methodName}:fail ${res.errMsg}`;
|
|
33
37
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
+
if (!isProd) {
|
|
39
|
+
console.error(res.errMsg);
|
|
40
|
+
}
|
|
41
|
+
isFunction(this.__fail) && this.__fail(res);
|
|
42
|
+
isFunction(this.__complete) && this.__complete(res);
|
|
43
|
+
const { resolve = Promise.resolve.bind(Promise), reject = Promise.reject.bind(Promise) } = promise;
|
|
44
|
+
return this.isHandlerError
|
|
45
|
+
? resolve(res)
|
|
46
|
+
: reject(res);
|
|
38
47
|
}
|
|
39
48
|
}
|
|
40
49
|
class CallbackManager {
|
|
@@ -78,12 +87,12 @@ class CallbackManager {
|
|
|
78
87
|
*/
|
|
79
88
|
this.trigger = (...args) => {
|
|
80
89
|
this.callbacks.forEach(opt => {
|
|
81
|
-
if (
|
|
90
|
+
if (isFunction(opt)) {
|
|
82
91
|
opt(...args);
|
|
83
92
|
}
|
|
84
93
|
else {
|
|
85
94
|
const { callback, ctx } = opt;
|
|
86
|
-
|
|
95
|
+
isFunction(callback) && callback.call(ctx, ...args);
|
|
87
96
|
}
|
|
88
97
|
});
|
|
89
98
|
};
|
|
@@ -135,9 +144,6 @@ function debounce(fn, ms = 250, scope) {
|
|
|
135
144
|
};
|
|
136
145
|
}
|
|
137
146
|
|
|
138
|
-
function isFunction(obj) {
|
|
139
|
-
return typeof obj === 'function';
|
|
140
|
-
}
|
|
141
147
|
const VALID_COLOR_REG = /^#[0-9a-fA-F]{6}$/;
|
|
142
148
|
const isValidColor = (color) => {
|
|
143
149
|
return VALID_COLOR_REG.test(color);
|
|
@@ -282,7 +288,7 @@ function processOpenApi({ name, defaultOptions, standardMethod, formatOptions =
|
|
|
282
288
|
// @ts-ignore
|
|
283
289
|
const targetApi = (_a = window === null || window === void 0 ? void 0 : window.wx) === null || _a === void 0 ? void 0 : _a[name];
|
|
284
290
|
const opts = formatOptions(Object.assign({}, defaultOptions, options));
|
|
285
|
-
if (
|
|
291
|
+
if (isFunction(targetApi)) {
|
|
286
292
|
return new Promise((resolve, reject) => {
|
|
287
293
|
['fail', 'success', 'complete'].forEach(k => {
|
|
288
294
|
opts[k] = preRef => {
|
|
@@ -299,7 +305,7 @@ function processOpenApi({ name, defaultOptions, standardMethod, formatOptions =
|
|
|
299
305
|
});
|
|
300
306
|
});
|
|
301
307
|
}
|
|
302
|
-
else if (
|
|
308
|
+
else if (isFunction(standardMethod)) {
|
|
303
309
|
return standardMethod(opts);
|
|
304
310
|
}
|
|
305
311
|
else {
|
|
@@ -1486,7 +1492,7 @@ const setClipboardData = ({ data, success, fail, complete }) => __awaiter(void 0
|
|
|
1486
1492
|
* iOS < 10 的系统可能无法使用编程方式访问剪贴板,参考:
|
|
1487
1493
|
* https://stackoverflow.com/questions/34045777/copy-to-clipboard-using-javascript-in-ios/34046084
|
|
1488
1494
|
*/
|
|
1489
|
-
if (
|
|
1495
|
+
if (isFunction(document.execCommand)) {
|
|
1490
1496
|
const textarea = document.createElement('textarea');
|
|
1491
1497
|
textarea.readOnly = true;
|
|
1492
1498
|
textarea.value = data;
|
|
@@ -1946,9 +1952,9 @@ const getLocationByW3CApi = (options) => {
|
|
|
1946
1952
|
/** 调用结果,自动补充 */
|
|
1947
1953
|
errMsg: ''
|
|
1948
1954
|
};
|
|
1949
|
-
handle.success(result, resolve);
|
|
1955
|
+
handle.success(result, { resolve, reject });
|
|
1950
1956
|
}, (error) => {
|
|
1951
|
-
handle.fail({ errMsg: error.message }, reject);
|
|
1957
|
+
handle.fail({ errMsg: error.message }, { resolve, reject });
|
|
1952
1958
|
}, positionOptions);
|
|
1953
1959
|
});
|
|
1954
1960
|
};
|
|
@@ -2046,7 +2052,7 @@ const chooseLocation = ({ success, fail, complete, mapOpts } = {}) => {
|
|
|
2046
2052
|
console.warn('chooseLocation api 依赖腾讯地图定位api,需要在 defineConstants 中配置 LOCATION_APIKEY');
|
|
2047
2053
|
return handle.fail({
|
|
2048
2054
|
errMsg: 'LOCATION_APIKEY needed'
|
|
2049
|
-
}, reject);
|
|
2055
|
+
}, { resolve, reject });
|
|
2050
2056
|
}
|
|
2051
2057
|
const onMessage = event => {
|
|
2052
2058
|
// 接收位置信息,用户选择确认位置点后选点组件会触发该事件,回传用户的位置信息
|
|
@@ -2065,14 +2071,14 @@ const chooseLocation = ({ success, fail, complete, mapOpts } = {}) => {
|
|
|
2065
2071
|
chooser.remove();
|
|
2066
2072
|
}, 300);
|
|
2067
2073
|
if (res) {
|
|
2068
|
-
return handle.fail(res, reject);
|
|
2074
|
+
return handle.fail(res, { resolve, reject });
|
|
2069
2075
|
}
|
|
2070
2076
|
else {
|
|
2071
2077
|
if (chooseLocation.latitude && chooseLocation.longitude) {
|
|
2072
|
-
return handle.success(chooseLocation, resolve);
|
|
2078
|
+
return handle.success(chooseLocation, { resolve, reject });
|
|
2073
2079
|
}
|
|
2074
2080
|
else {
|
|
2075
|
-
return handle.fail({}, reject);
|
|
2081
|
+
return handle.fail({}, { resolve, reject });
|
|
2076
2082
|
}
|
|
2077
2083
|
}
|
|
2078
2084
|
}, key, mapOpts);
|
|
@@ -2329,12 +2335,12 @@ const getImageInfo = (options) => {
|
|
|
2329
2335
|
width: image.naturalWidth,
|
|
2330
2336
|
height: image.naturalHeight,
|
|
2331
2337
|
path: getBase64Image(image) || src
|
|
2332
|
-
}, resolve);
|
|
2338
|
+
}, { resolve, reject });
|
|
2333
2339
|
};
|
|
2334
2340
|
image.onerror = (e) => {
|
|
2335
2341
|
handle.fail({
|
|
2336
2342
|
errMsg: e.message
|
|
2337
|
-
}, reject);
|
|
2343
|
+
}, { resolve, reject });
|
|
2338
2344
|
};
|
|
2339
2345
|
image.src = src;
|
|
2340
2346
|
});
|
|
@@ -2361,7 +2367,7 @@ const previewImage = (options) => __awaiter(void 0, void 0, void 0, function* ()
|
|
|
2361
2367
|
item.appendChild(div);
|
|
2362
2368
|
// Note: 等待图片加载完后返回,会导致轮播被卡住
|
|
2363
2369
|
resolve(item);
|
|
2364
|
-
if (
|
|
2370
|
+
if (isFunction(loadFail)) {
|
|
2365
2371
|
image.addEventListener('error', (err) => {
|
|
2366
2372
|
loadFail({ errMsg: err.message });
|
|
2367
2373
|
});
|
|
@@ -2466,7 +2472,7 @@ const chooseImage = function (options) {
|
|
|
2466
2472
|
el.removeAttribute('capture');
|
|
2467
2473
|
}
|
|
2468
2474
|
}
|
|
2469
|
-
return new Promise(resolve => {
|
|
2475
|
+
return new Promise((resolve, reject) => {
|
|
2470
2476
|
const TaroMouseEvents = document.createEvent('MouseEvents');
|
|
2471
2477
|
TaroMouseEvents.initEvent('click', true, true);
|
|
2472
2478
|
if (el) {
|
|
@@ -2485,7 +2491,7 @@ const chooseImage = function (options) {
|
|
|
2485
2491
|
(_a = res.tempFilePaths) === null || _a === void 0 ? void 0 : _a.push(url);
|
|
2486
2492
|
(_b = res.tempFiles) === null || _b === void 0 ? void 0 : _b.push({ path: url, size: item.size, type: item.type, originalFileObj: item });
|
|
2487
2493
|
});
|
|
2488
|
-
handle.success(res, resolve);
|
|
2494
|
+
handle.success(res, { resolve, reject });
|
|
2489
2495
|
target.value = '';
|
|
2490
2496
|
}
|
|
2491
2497
|
};
|
|
@@ -2553,7 +2559,7 @@ const chooseVideo = (options) => {
|
|
|
2553
2559
|
inputEl.setAttribute('accept', 'video/*');
|
|
2554
2560
|
inputEl.setAttribute('style', 'position: fixed; top: -4000px; left: -3000px; z-index: -300;');
|
|
2555
2561
|
document.body.appendChild(inputEl);
|
|
2556
|
-
return new Promise(resolve => {
|
|
2562
|
+
return new Promise((resolve, reject) => {
|
|
2557
2563
|
const TaroMouseEvents = document.createEvent('MouseEvents');
|
|
2558
2564
|
TaroMouseEvents.initEvent('click', true, true);
|
|
2559
2565
|
inputEl.dispatchEvent(TaroMouseEvents);
|
|
@@ -2574,7 +2580,7 @@ const chooseVideo = (options) => {
|
|
|
2574
2580
|
res.size = event.total;
|
|
2575
2581
|
res.height = videoEl.videoHeight;
|
|
2576
2582
|
res.width = videoEl.videoHeight;
|
|
2577
|
-
return handle.success(res, resolve);
|
|
2583
|
+
return handle.success(res, { resolve, reject });
|
|
2578
2584
|
};
|
|
2579
2585
|
};
|
|
2580
2586
|
if (file) {
|
|
@@ -2855,13 +2861,13 @@ function _request(options) {
|
|
|
2855
2861
|
.then(data => {
|
|
2856
2862
|
res.statusCode = 200;
|
|
2857
2863
|
res.data = data;
|
|
2858
|
-
|
|
2859
|
-
|
|
2864
|
+
isFunction(success) && success(res);
|
|
2865
|
+
isFunction(complete) && complete(res);
|
|
2860
2866
|
return res;
|
|
2861
2867
|
})
|
|
2862
2868
|
.catch(err => {
|
|
2863
|
-
|
|
2864
|
-
|
|
2869
|
+
isFunction(fail) && fail(err);
|
|
2870
|
+
isFunction(complete) && complete(res);
|
|
2865
2871
|
return Promise.reject(err);
|
|
2866
2872
|
});
|
|
2867
2873
|
}
|
|
@@ -2929,13 +2935,13 @@ function _request(options) {
|
|
|
2929
2935
|
})
|
|
2930
2936
|
.then(data => {
|
|
2931
2937
|
res.data = data;
|
|
2932
|
-
|
|
2933
|
-
|
|
2938
|
+
isFunction(success) && success(res);
|
|
2939
|
+
isFunction(complete) && complete(res);
|
|
2934
2940
|
return res;
|
|
2935
2941
|
})
|
|
2936
2942
|
.catch(err => {
|
|
2937
|
-
|
|
2938
|
-
|
|
2943
|
+
isFunction(fail) && fail(err);
|
|
2944
|
+
isFunction(complete) && complete(res);
|
|
2939
2945
|
err.statusCode = res.statusCode;
|
|
2940
2946
|
err.errMsg = err.message;
|
|
2941
2947
|
return Promise.reject(err);
|
|
@@ -3124,14 +3130,14 @@ class SocketTask {
|
|
|
3124
3130
|
if (this.readyState !== 1) {
|
|
3125
3131
|
const res = { errMsg: 'SocketTask.send:fail SocketTask.readState is not OPEN' };
|
|
3126
3132
|
console.error(res.errMsg);
|
|
3127
|
-
|
|
3128
|
-
|
|
3133
|
+
isFunction(fail) && fail(res);
|
|
3134
|
+
isFunction(complete) && complete(res);
|
|
3129
3135
|
return Promise.reject(res);
|
|
3130
3136
|
}
|
|
3131
3137
|
this.ws.send(data);
|
|
3132
3138
|
const res = { errMsg: 'sendSocketMessage:ok' };
|
|
3133
|
-
|
|
3134
|
-
|
|
3139
|
+
isFunction(success) && success(res);
|
|
3140
|
+
isFunction(complete) && complete(res);
|
|
3135
3141
|
return Promise.resolve(res);
|
|
3136
3142
|
}
|
|
3137
3143
|
close(opts = {}) {
|
|
@@ -3143,8 +3149,8 @@ class SocketTask {
|
|
|
3143
3149
|
this._destroyWhenClose && this._destroyWhenClose();
|
|
3144
3150
|
this.ws.close();
|
|
3145
3151
|
const res = { errMsg: 'closeSocket:ok' };
|
|
3146
|
-
|
|
3147
|
-
|
|
3152
|
+
isFunction(success) && success(res);
|
|
3153
|
+
isFunction(complete) && complete(res);
|
|
3148
3154
|
return Promise.resolve(res);
|
|
3149
3155
|
}
|
|
3150
3156
|
onOpen(func) {
|
|
@@ -3202,13 +3208,13 @@ function connectSocket(options) {
|
|
|
3202
3208
|
correct: 'String',
|
|
3203
3209
|
wrong: url
|
|
3204
3210
|
})
|
|
3205
|
-
}, reject);
|
|
3211
|
+
}, { resolve, reject });
|
|
3206
3212
|
}
|
|
3207
3213
|
// options.url must be invalid
|
|
3208
3214
|
if (!url.startsWith('ws://') && !url.startsWith('wss://')) {
|
|
3209
3215
|
return handle.fail({
|
|
3210
3216
|
errMsg: `request:fail invalid url "${url}"`
|
|
3211
|
-
}, reject);
|
|
3217
|
+
}, { resolve, reject });
|
|
3212
3218
|
}
|
|
3213
3219
|
// protocols must be array
|
|
3214
3220
|
const _protocols = Array.isArray(protocols) ? protocols : null;
|
|
@@ -3216,7 +3222,7 @@ function connectSocket(options) {
|
|
|
3216
3222
|
if (socketTasks.length > 1) {
|
|
3217
3223
|
return handle.fail({
|
|
3218
3224
|
errMsg: '同时最多发起 2 个 socket 请求,更多请参考文档。'
|
|
3219
|
-
}, reject);
|
|
3225
|
+
}, { resolve, reject });
|
|
3220
3226
|
}
|
|
3221
3227
|
const task = new SocketTask(url, _protocols);
|
|
3222
3228
|
task._destroyWhenClose = function () {
|
|
@@ -4570,8 +4576,8 @@ const startPullDownRefresh = function ({ success, fail, complete } = {}) {
|
|
|
4570
4576
|
const handle = new MethodHandler({ name: 'startPullDownRefresh', success, fail, complete });
|
|
4571
4577
|
return new Promise((resolve, reject) => {
|
|
4572
4578
|
Taro.eventCenter.trigger('__taroStartPullDownRefresh', {
|
|
4573
|
-
successHandler: (res = {}) => handle.success(res, resolve),
|
|
4574
|
-
errorHandler: (res = {}) => handle.fail(res, reject)
|
|
4579
|
+
successHandler: (res = {}) => handle.success(res, { resolve, reject }),
|
|
4580
|
+
errorHandler: (res = {}) => handle.fail(res, { resolve, reject })
|
|
4575
4581
|
});
|
|
4576
4582
|
});
|
|
4577
4583
|
};
|
|
@@ -4582,8 +4588,8 @@ const stopPullDownRefresh = function ({ success, fail, complete } = {}) {
|
|
|
4582
4588
|
const handle = new MethodHandler({ name: 'stopPullDownRefresh', success, fail, complete });
|
|
4583
4589
|
return new Promise((resolve, reject) => {
|
|
4584
4590
|
Taro.eventCenter.trigger('__taroStopPullDownRefresh', {
|
|
4585
|
-
successHandler: (res = {}) => handle.success(res, resolve),
|
|
4586
|
-
errorHandler: (res = {}) => handle.fail(res, reject)
|
|
4591
|
+
successHandler: (res = {}) => handle.success(res, { resolve, reject }),
|
|
4592
|
+
errorHandler: (res = {}) => handle.fail(res, { resolve, reject })
|
|
4587
4593
|
});
|
|
4588
4594
|
});
|
|
4589
4595
|
};
|
|
@@ -4602,7 +4608,7 @@ const pageScrollTo = ({ scrollTop, selector = '', offsetTop = 0, duration = 300,
|
|
|
4602
4608
|
if (scrollTop === undefined && !selector) {
|
|
4603
4609
|
return handle.fail({
|
|
4604
4610
|
errMsg: 'scrollTop" 或 "selector" 需要其之一'
|
|
4605
|
-
}, reject);
|
|
4611
|
+
}, { resolve, reject });
|
|
4606
4612
|
}
|
|
4607
4613
|
const id = (_b = (_a = Current$1.page) === null || _a === void 0 ? void 0 : _a.path) === null || _b === void 0 ? void 0 : _b.replace(/([^a-z0-9\u00a0-\uffff_-])/ig, '\\$1');
|
|
4608
4614
|
const el = (id
|
|
@@ -4656,7 +4662,7 @@ const pageScrollTo = ({ scrollTop, selector = '', offsetTop = 0, duration = 300,
|
|
|
4656
4662
|
}, FRAME_DURATION);
|
|
4657
4663
|
}
|
|
4658
4664
|
else {
|
|
4659
|
-
return handle.success({}, resolve);
|
|
4665
|
+
return handle.success({}, { resolve, reject });
|
|
4660
4666
|
}
|
|
4661
4667
|
};
|
|
4662
4668
|
scroll();
|
|
@@ -4664,7 +4670,7 @@ const pageScrollTo = ({ scrollTop, selector = '', offsetTop = 0, duration = 300,
|
|
|
4664
4670
|
catch (e) {
|
|
4665
4671
|
return handle.fail({
|
|
4666
4672
|
errMsg: e.message
|
|
4667
|
-
}, reject);
|
|
4673
|
+
}, { resolve, reject });
|
|
4668
4674
|
}
|
|
4669
4675
|
});
|
|
4670
4676
|
};
|
|
@@ -4701,8 +4707,8 @@ const showTabBarRedDot = (options) => {
|
|
|
4701
4707
|
return new Promise((resolve, reject) => {
|
|
4702
4708
|
Taro.eventCenter.trigger('__taroShowTabBarRedDotHandler', {
|
|
4703
4709
|
index,
|
|
4704
|
-
successHandler: (res = {}) => handle.success(res, resolve),
|
|
4705
|
-
errorHandler: (res = {}) => handle.fail(res, reject)
|
|
4710
|
+
successHandler: (res = {}) => handle.success(res, { resolve, reject }),
|
|
4711
|
+
errorHandler: (res = {}) => handle.fail(res, { resolve, reject })
|
|
4706
4712
|
});
|
|
4707
4713
|
});
|
|
4708
4714
|
};
|
|
@@ -4731,8 +4737,8 @@ const showTabBar = (options = {}) => {
|
|
|
4731
4737
|
return new Promise((resolve, reject) => {
|
|
4732
4738
|
Taro.eventCenter.trigger('__taroShowTabBar', {
|
|
4733
4739
|
animation,
|
|
4734
|
-
successHandler: (res = {}) => handle.success(res, resolve),
|
|
4735
|
-
errorHandler: (res = {}) => handle.fail(res, reject)
|
|
4740
|
+
successHandler: (res = {}) => handle.success(res, { resolve, reject }),
|
|
4741
|
+
errorHandler: (res = {}) => handle.fail(res, { resolve, reject })
|
|
4736
4742
|
});
|
|
4737
4743
|
});
|
|
4738
4744
|
};
|
|
@@ -4783,8 +4789,8 @@ const setTabBarStyle = (options = {}) => {
|
|
|
4783
4789
|
selectedColor,
|
|
4784
4790
|
backgroundColor,
|
|
4785
4791
|
borderStyle,
|
|
4786
|
-
successHandler: (res = {}) => handle.success(res, resolve),
|
|
4787
|
-
errorHandler: (res = {}) => handle.fail(res, reject)
|
|
4792
|
+
successHandler: (res = {}) => handle.success(res, { resolve, reject }),
|
|
4793
|
+
errorHandler: (res = {}) => handle.fail(res, { resolve, reject })
|
|
4788
4794
|
});
|
|
4789
4795
|
});
|
|
4790
4796
|
};
|
|
@@ -4816,8 +4822,8 @@ const setTabBarItem = (options) => {
|
|
|
4816
4822
|
text,
|
|
4817
4823
|
iconPath,
|
|
4818
4824
|
selectedIconPath,
|
|
4819
|
-
successHandler: (res = {}) => handle.success(res, resolve),
|
|
4820
|
-
errorHandler: (res = {}) => handle.fail(res, reject)
|
|
4825
|
+
successHandler: (res = {}) => handle.success(res, { resolve, reject }),
|
|
4826
|
+
errorHandler: (res = {}) => handle.fail(res, { resolve, reject })
|
|
4821
4827
|
});
|
|
4822
4828
|
});
|
|
4823
4829
|
};
|
|
@@ -4856,8 +4862,8 @@ const setTabBarBadge = (options) => {
|
|
|
4856
4862
|
Taro.eventCenter.trigger('__taroSetTabBarBadge', {
|
|
4857
4863
|
index,
|
|
4858
4864
|
text,
|
|
4859
|
-
successHandler: (res = {}) => handle.success(res, resolve),
|
|
4860
|
-
errorHandler: (res = {}) => handle.fail(res, reject)
|
|
4865
|
+
successHandler: (res = {}) => handle.success(res, { resolve, reject }),
|
|
4866
|
+
errorHandler: (res = {}) => handle.fail(res, { resolve, reject })
|
|
4861
4867
|
});
|
|
4862
4868
|
});
|
|
4863
4869
|
};
|
|
@@ -4886,8 +4892,8 @@ const removeTabBarBadge = (options) => {
|
|
|
4886
4892
|
return new Promise((resolve, reject) => {
|
|
4887
4893
|
Taro.eventCenter.trigger('__taroRemoveTabBarBadge', {
|
|
4888
4894
|
index,
|
|
4889
|
-
successHandler: (res = {}) => handle.success(res, resolve),
|
|
4890
|
-
errorHandler: (res = {}) => handle.fail(res, reject)
|
|
4895
|
+
successHandler: (res = {}) => handle.success(res, { resolve, reject }),
|
|
4896
|
+
errorHandler: (res = {}) => handle.fail(res, { resolve, reject })
|
|
4891
4897
|
});
|
|
4892
4898
|
});
|
|
4893
4899
|
};
|
|
@@ -4916,8 +4922,8 @@ const hideTabBarRedDot = (options) => {
|
|
|
4916
4922
|
return new Promise((resolve, reject) => {
|
|
4917
4923
|
Taro.eventCenter.trigger('__taroHideTabBarRedDotHandler', {
|
|
4918
4924
|
index,
|
|
4919
|
-
successHandler: (res = {}) => handle.success(res, resolve),
|
|
4920
|
-
errorHandler: (res = {}) => handle.fail(res, reject)
|
|
4925
|
+
successHandler: (res = {}) => handle.success(res, { resolve, reject }),
|
|
4926
|
+
errorHandler: (res = {}) => handle.fail(res, { resolve, reject })
|
|
4921
4927
|
});
|
|
4922
4928
|
});
|
|
4923
4929
|
};
|
|
@@ -4946,8 +4952,8 @@ const hideTabBar = (options = {}) => {
|
|
|
4946
4952
|
return new Promise((resolve, reject) => {
|
|
4947
4953
|
Taro.eventCenter.trigger('__taroHideTabBar', {
|
|
4948
4954
|
animation,
|
|
4949
|
-
successHandler: (res = {}) => handle.success(res, resolve),
|
|
4950
|
-
errorHandler: (res = {}) => handle.fail(res, reject)
|
|
4955
|
+
successHandler: (res = {}) => handle.success(res, { resolve, reject }),
|
|
4956
|
+
errorHandler: (res = {}) => handle.fail(res, { resolve, reject })
|
|
4951
4957
|
});
|
|
4952
4958
|
});
|
|
4953
4959
|
};
|
|
@@ -5115,7 +5121,7 @@ class MediaQueryObserver {
|
|
|
5115
5121
|
callback({ matches: ev.matches });
|
|
5116
5122
|
};
|
|
5117
5123
|
callback({ matches: this._mediaQueryObserver.matches });
|
|
5118
|
-
// 兼容旧浏览器中MediaQueryList尚未继承于EventTarget导致不存在'addEventListener'
|
|
5124
|
+
// 兼容旧浏览器中 MediaQueryList 尚未继承于 EventTarget 导致不存在 'addEventListener'
|
|
5119
5125
|
if ('addEventListener' in this._mediaQueryObserver) {
|
|
5120
5126
|
this._mediaQueryObserver.addEventListener('change', this._listener);
|
|
5121
5127
|
}
|
|
@@ -5127,7 +5133,7 @@ class MediaQueryObserver {
|
|
|
5127
5133
|
// 停止监听,销毁媒体查询对象
|
|
5128
5134
|
disconnect() {
|
|
5129
5135
|
if (this._mediaQueryObserver && this._listener) {
|
|
5130
|
-
// 兼容旧浏览器中MediaQueryList尚未继承于EventTarget导致不存在'removeEventListener'
|
|
5136
|
+
// 兼容旧浏览器中 MediaQueryList 尚未继承于 EventTarget 导致不存在 'removeEventListener'
|
|
5131
5137
|
if ('removeEventListener' in this._mediaQueryObserver) {
|
|
5132
5138
|
this._mediaQueryObserver.removeEventListener('change', this._listener);
|
|
5133
5139
|
}
|
|
@@ -5363,9 +5369,9 @@ class SelectorQuery {
|
|
|
5363
5369
|
const _queueCb = this._queueCb;
|
|
5364
5370
|
res.forEach((item, index) => {
|
|
5365
5371
|
const cb = _queueCb[index];
|
|
5366
|
-
|
|
5372
|
+
isFunction(cb) && cb.call(this, item);
|
|
5367
5373
|
});
|
|
5368
|
-
|
|
5374
|
+
isFunction(cb) && cb.call(this, res);
|
|
5369
5375
|
});
|
|
5370
5376
|
return this;
|
|
5371
5377
|
}
|
|
@@ -5418,7 +5424,7 @@ const requirePlugin = permanentlyNotSupport('requirePlugin');
|
|
|
5418
5424
|
const pxTransform = function (size) {
|
|
5419
5425
|
const options = taro.config;
|
|
5420
5426
|
const baseFontSize = options.baseFontSize || 20;
|
|
5421
|
-
const designWidth = ((input = 0) =>
|
|
5427
|
+
const designWidth = ((input = 0) => isFunction(options.designWidth)
|
|
5422
5428
|
? options.designWidth(input)
|
|
5423
5429
|
: options.designWidth);
|
|
5424
5430
|
const rootValue = (input = 0) => baseFontSize / options.deviceRatio[designWidth(input)] * 2;
|