@tarojs/plugin-platform-harmony-ets 4.0.0-alpha.36 → 4.0.0-alpha.37
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/apis/base/weapp/life-cycle.ts +1 -1
- package/dist/apis/framework/index.ts +1 -1
- package/dist/apis/media/image/index.ts +135 -124
- package/dist/apis/route/index.ts +2 -1
- package/dist/apis/ui/background.ts +1 -1
- package/dist/apis/ui/navigation-bar/index.ts +1 -1
- package/dist/apis/ui/tab-bar.ts +2 -1
- package/dist/components-harmony-ets/button.ets +1 -1
- package/dist/components-harmony-ets/checkbox.ets +2 -1
- package/dist/components-harmony-ets/form.ets +1 -0
- package/dist/components-harmony-ets/index.ets +90 -37
- package/dist/components-harmony-ets/input.ets +2 -2
- package/dist/components-harmony-ets/label.ets +2 -1
- package/dist/components-harmony-ets/listView.ets +1 -1
- package/dist/components-harmony-ets/movableArea.ets +3 -3
- package/dist/components-harmony-ets/navigationBar.ets +1 -1
- package/dist/components-harmony-ets/pageMeta.ets +1 -1
- package/dist/components-harmony-ets/pseudo.ets +1 -1
- package/dist/components-harmony-ets/radio.ets +3 -2
- package/dist/components-harmony-ets/scrollList.ets +2 -2
- package/dist/components-harmony-ets/scrollView.ets +1 -1
- package/dist/components-harmony-ets/slider.ets +1 -1
- package/dist/components-harmony-ets/style.ets +6 -7
- package/dist/components-harmony-ets/swiper.ets +1 -1
- package/dist/components-harmony-ets/switch.ets +1 -1
- package/dist/components-harmony-ets/text.ets +2 -2
- package/dist/components-harmony-ets/utils/helper.ets +2 -2
- package/dist/components-harmony-ets/utils/styles.ets +6 -5
- package/dist/components-harmony-ets/video.ets +1 -1
- package/dist/components-harmony-ets/view.ets +2 -1
- package/dist/components-harmony-ets/webView.ets +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/runtime-ets/bom/document.ts +2 -1
- package/dist/runtime-ets/bom/getComputedStyle.ts +2 -1
- package/dist/runtime-ets/bom/navigator.ts +21 -1
- package/dist/runtime-ets/bom/raf.ts +37 -1
- package/dist/runtime-ets/bom/window.ts +5 -4
- package/dist/runtime-ets/constant.ts +10 -17
- package/dist/runtime-ets/current.ts +1 -0
- package/dist/runtime-ets/dom/document.ts +1 -1
- package/dist/runtime-ets/dom/element/canvas.ts +2 -3
- package/dist/runtime-ets/dom/element/element.ts +5 -6
- package/dist/runtime-ets/dom/element/movableView.ts +8 -12
- package/dist/runtime-ets/dom/eventTarget.ts +1 -1
- package/dist/runtime-ets/dom/node.ts +3 -2
- package/dist/runtime-ets/index.ts +7 -21
- package/dist/runtime-ets/interface/index.ts +0 -6
- package/dist/runtime-ets/utils/index.ts +6 -4
- package/dist/runtime-framework/react/app.ts +2 -1
- package/dist/runtime-framework/react/hooks.ts +1 -1
- package/dist/runtime-framework/react/native-page.ts +15 -44
- package/dist/runtime-framework/react/page.ts +2 -1
- package/dist/runtime-framework/solid/app.ts +2 -1
- package/dist/runtime-framework/solid/hooks.ts +1 -1
- package/dist/runtime-framework/solid/page.ts +2 -1
- package/dist/runtime-utils.js +166 -134
- package/dist/runtime-utils.js.map +1 -1
- package/dist/runtime.js +166 -134
- package/dist/runtime.js.map +1 -1
- package/package.json +9 -9
- package/dist/runtime-ets/bom/URL.ts +0 -2
- package/dist/runtime-ets/bom/history.ts +0 -1
- package/dist/runtime-ets/bom/location.ts +0 -1
- package/dist/runtime-ets/dom/event-source.ts +0 -1
- package/dist/runtime-ets/emitter/emitter.ts +0 -1
- package/dist/runtime-ets/env.ts +0 -1
- package/dist/runtime-ets/utils/router.ts +0 -9
package/dist/runtime.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { isFunction, isString, isArray, isObject, isNull, isNumber, isUndefined, queryToJson, PLATFORM_TYPE, singleQuote, internalComponents, mergeReconciler, mergeInternalComponents } from '@tarojs/shared';
|
|
2
2
|
import _display from '@ohos.display';
|
|
3
|
-
import {
|
|
4
|
-
import '@ohos.abilityAccessCtrl';
|
|
3
|
+
import { Current, eventCenter, window, eventSource, hooks, document as document$1, getPageScrollerOrNode, findChildNodeWithDFS, setNodeEventCallbackAndTriggerComponentUpdate, AREA_CHANGE_EVENT_NAME, disconnectEvent, VISIBLE_CHANGE_EVENT_NAME, getCurrentInstance } from '@tarojs/runtime';
|
|
4
|
+
import abilityAccessCtrl from '@ohos.abilityAccessCtrl';
|
|
5
5
|
import ConfigurationConstant from '@ohos.app.ability.ConfigurationConstant';
|
|
6
6
|
import deviceInfo from '@ohos.deviceInfo';
|
|
7
7
|
import i18n from '@ohos.i18n';
|
|
8
8
|
import errorManager from '@ohos.app.ability.errorManager';
|
|
9
|
+
import { eventCenter as eventCenter$1, Events, History } from '@tarojs/runtime/dist/runtime.esm';
|
|
9
10
|
import sensor from '@ohos.sensor';
|
|
10
11
|
import batteryInfo, { BatteryChargeState } from '@ohos.batteryInfo';
|
|
11
12
|
import pasteboard from '@ohos.pasteboard';
|
|
@@ -175,6 +176,21 @@ const validateParams = function (name, params, schema) {
|
|
|
175
176
|
}
|
|
176
177
|
};
|
|
177
178
|
|
|
179
|
+
function requestPermissions(permissions) {
|
|
180
|
+
return new Promise((resolve, reject) => {
|
|
181
|
+
const context = getContext(Current === null || Current === void 0 ? void 0 : Current.page);
|
|
182
|
+
const atManager = abilityAccessCtrl.createAtManager();
|
|
183
|
+
atManager.requestPermissionsFromUser(context, permissions, (err, _) => {
|
|
184
|
+
if (err) {
|
|
185
|
+
// eslint-disable-next-line prefer-promise-reject-errors
|
|
186
|
+
reject(`[Taro] 请求用户授权 ${permissions.join('、')} 失败:${JSON.stringify(err)}`);
|
|
187
|
+
}
|
|
188
|
+
else {
|
|
189
|
+
resolve();
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
});
|
|
193
|
+
}
|
|
178
194
|
function object2String(obj) {
|
|
179
195
|
let str = '';
|
|
180
196
|
for (const item in obj) {
|
|
@@ -447,7 +463,7 @@ const launchOptions = {
|
|
|
447
463
|
function initLaunchOptions(options = {}) {
|
|
448
464
|
Object.assign(launchOptions, options);
|
|
449
465
|
}
|
|
450
|
-
eventCenter.once('__taroRouterLaunch', initLaunchOptions);
|
|
466
|
+
eventCenter$1.once('__taroRouterLaunch', initLaunchOptions);
|
|
451
467
|
// 生命周期
|
|
452
468
|
const getLaunchOptionsSync = () => launchOptions;
|
|
453
469
|
const getEnterOptionsSync = () => launchOptions;
|
|
@@ -2263,6 +2279,12 @@ const chooseMedia = function (options) {
|
|
|
2263
2279
|
});
|
|
2264
2280
|
};
|
|
2265
2281
|
|
|
2282
|
+
const READ_IMAGEVIDEO_PERMISSIONS = 'ohos.permission.READ_IMAGEVIDEO';
|
|
2283
|
+
const READ_MEDIA_PERMISSIONS = 'ohos.permission.READ_MEDIA';
|
|
2284
|
+
const WRITE_MEDIA_PERMISSIONS = 'ohos.permission.WRITE_MEDIA';
|
|
2285
|
+
const MEDIA_LOCATION_PERMISSIONS = 'ohos.permission.MEDIA_LOCATION';
|
|
2286
|
+
const IMAGE_PERMISSION = [READ_IMAGEVIDEO_PERMISSIONS, READ_MEDIA_PERMISSIONS, WRITE_MEDIA_PERMISSIONS, MEDIA_LOCATION_PERMISSIONS];
|
|
2287
|
+
|
|
2266
2288
|
// HarmonyOS 图片模块首批接口从API version 7开始支持。
|
|
2267
2289
|
// HarmonyOS 文档链接:https://developer.harmonyos.com/cn/docs/documentation/doc-references/js-apis-image-0000001122977382
|
|
2268
2290
|
// WX 文档链接:https://developers.weixin.qq.com/miniprogram/dev/api/media/image/wx.saveImageToPhotosAlbum.html
|
|
@@ -2338,143 +2360,153 @@ function saveImage(compressedImageData, compressedImageUri) {
|
|
|
2338
2360
|
}
|
|
2339
2361
|
const compressImage = function (options) {
|
|
2340
2362
|
return new Promise((resolve, reject) => {
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
catch (error) {
|
|
2345
|
-
const res = { errMsg: error.message };
|
|
2346
|
-
return callAsyncFail(reject, res, options);
|
|
2347
|
-
}
|
|
2348
|
-
const { src, quality = 80, compressedWidth, compressedHeight } = options;
|
|
2349
|
-
const srcAfterCompress = src.includes('_after_compress') ? src : src.split('.').join('_after_compress.');
|
|
2350
|
-
const file = fs.openSync(src, fs.OpenMode.READ_ONLY);
|
|
2351
|
-
// const stat = fs.statSync(file.fd)
|
|
2352
|
-
// console.log('[Taro] 压缩前图片的大小为:', stat.size)
|
|
2353
|
-
const source = image.createImageSource(file.fd);
|
|
2354
|
-
if (isNull(source)) {
|
|
2355
|
-
const createImageSourceError = { errMsg: 'compressImage fail: createImageSource has failed.' };
|
|
2356
|
-
callAsyncFail(reject, createImageSourceError, options);
|
|
2357
|
-
return;
|
|
2358
|
-
}
|
|
2359
|
-
const width = source.getImageInfoSync().size.width;
|
|
2360
|
-
const height = source.getImageInfoSync().size.height;
|
|
2361
|
-
let wantWidth = compressedWidth || compressedHeight || 0;
|
|
2362
|
-
let wantHeight = compressedHeight || compressedWidth || 0;
|
|
2363
|
-
if (width > wantWidth || height > wantHeight) {
|
|
2364
|
-
const heightRatio = height / wantHeight;
|
|
2365
|
-
const widthRatio = width / wantWidth;
|
|
2366
|
-
const finalRatio = heightRatio < widthRatio ? heightRatio : widthRatio;
|
|
2367
|
-
wantWidth = Math.round(width / finalRatio);
|
|
2368
|
-
wantHeight = Math.round(height / finalRatio);
|
|
2369
|
-
}
|
|
2370
|
-
const decodingOptions = {
|
|
2371
|
-
editable: true,
|
|
2372
|
-
desiredPixelFormat: image.PixelMapFormat.RGBA_8888,
|
|
2373
|
-
desiredSize: { width: wantWidth, height: wantHeight }
|
|
2374
|
-
};
|
|
2375
|
-
source.createPixelMap(decodingOptions, (error, pixelMap) => {
|
|
2376
|
-
if (error !== undefined) {
|
|
2377
|
-
fs.closeSync(file);
|
|
2378
|
-
const res = { errMsg: error };
|
|
2379
|
-
callAsyncFail(reject, res, options);
|
|
2363
|
+
requestPermissions(IMAGE_PERMISSION).then(() => {
|
|
2364
|
+
try {
|
|
2365
|
+
validateParams('compressImage', options, compressImageSchema);
|
|
2380
2366
|
}
|
|
2381
|
-
|
|
2382
|
-
const
|
|
2383
|
-
|
|
2367
|
+
catch (error) {
|
|
2368
|
+
const res = { errMsg: error.message };
|
|
2369
|
+
return callAsyncFail(reject, res, options);
|
|
2370
|
+
}
|
|
2371
|
+
const { src, quality = 80, compressedWidth, compressedHeight } = options;
|
|
2372
|
+
const srcAfterCompress = src.includes('_after_compress') ? src : src.split('.').join('_after_compress.');
|
|
2373
|
+
const file = fs.openSync(src, fs.OpenMode.READ_ONLY);
|
|
2374
|
+
// const stat = fs.statSync(file.fd)
|
|
2375
|
+
// console.log('[Taro] 压缩前图片的大小为:', stat.size)
|
|
2376
|
+
const source = image.createImageSource(file.fd);
|
|
2377
|
+
if (isNull(source)) {
|
|
2378
|
+
const createImageSourceError = { errMsg: 'compressImage fail: createImageSource has failed.' };
|
|
2379
|
+
callAsyncFail(reject, createImageSourceError, options);
|
|
2380
|
+
return;
|
|
2381
|
+
}
|
|
2382
|
+
const width = source.getImageInfoSync().size.width;
|
|
2383
|
+
const height = source.getImageInfoSync().size.height;
|
|
2384
|
+
let wantWidth = compressedWidth || compressedHeight || 0;
|
|
2385
|
+
let wantHeight = compressedHeight || compressedWidth || 0;
|
|
2386
|
+
if (width > wantWidth || height > wantHeight) {
|
|
2387
|
+
const heightRatio = height / wantHeight;
|
|
2388
|
+
const widthRatio = width / wantWidth;
|
|
2389
|
+
const finalRatio = heightRatio < widthRatio ? heightRatio : widthRatio;
|
|
2390
|
+
wantWidth = Math.round(width / finalRatio);
|
|
2391
|
+
wantHeight = Math.round(height / finalRatio);
|
|
2392
|
+
}
|
|
2393
|
+
const decodingOptions = {
|
|
2394
|
+
editable: true,
|
|
2395
|
+
desiredPixelFormat: image.PixelMapFormat.RGBA_8888,
|
|
2396
|
+
desiredSize: { width: wantWidth, height: wantHeight }
|
|
2397
|
+
};
|
|
2398
|
+
source.createPixelMap(decodingOptions, (error, pixelMap) => {
|
|
2399
|
+
if (error !== undefined) {
|
|
2384
2400
|
fs.closeSync(file);
|
|
2385
|
-
const
|
|
2386
|
-
callAsyncFail(reject,
|
|
2387
|
-
return;
|
|
2401
|
+
const res = { errMsg: error };
|
|
2402
|
+
callAsyncFail(reject, res, options);
|
|
2388
2403
|
}
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2404
|
+
else {
|
|
2405
|
+
const packer = image.createImagePacker(file.fd);
|
|
2406
|
+
if (isNull(packer)) {
|
|
2407
|
+
fs.closeSync(file);
|
|
2408
|
+
const createImagePackerError = { errMsg: 'compressImage fail: createImagePacker has failed.' };
|
|
2409
|
+
callAsyncFail(reject, createImagePackerError, options);
|
|
2410
|
+
return;
|
|
2411
|
+
}
|
|
2412
|
+
const isPNG = src.endsWith('.png');
|
|
2413
|
+
const packingOptionsOHOS = {
|
|
2414
|
+
format: isPNG ? 'image/png' : 'image/jpeg',
|
|
2415
|
+
quality: quality
|
|
2416
|
+
};
|
|
2417
|
+
packer.packing(pixelMap, packingOptionsOHOS).then((value) => {
|
|
2418
|
+
fs.closeSync(file);
|
|
2419
|
+
saveImage(value, srcAfterCompress).then(result => {
|
|
2420
|
+
callAsyncSuccess(resolve, { tempFilePath: result.imageUri }, options);
|
|
2421
|
+
});
|
|
2422
|
+
}).catch((error) => {
|
|
2423
|
+
fs.closeSync(file);
|
|
2424
|
+
callAsyncFail(reject, error, options);
|
|
2398
2425
|
});
|
|
2399
|
-
}
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2426
|
+
}
|
|
2427
|
+
});
|
|
2428
|
+
}, (error) => {
|
|
2429
|
+
const res = { errMsg: error };
|
|
2430
|
+
return callAsyncFail(reject, res, options);
|
|
2404
2431
|
});
|
|
2405
2432
|
});
|
|
2406
2433
|
};
|
|
2407
2434
|
const chooseImage = function (options) {
|
|
2408
2435
|
return new Promise((resolve, reject) => {
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
catch (error) {
|
|
2413
|
-
const res = { errMsg: error.message };
|
|
2414
|
-
return callAsyncFail(reject, res, options);
|
|
2415
|
-
}
|
|
2416
|
-
const { count = 9 } = options;
|
|
2417
|
-
const photoViewPicker = new picker.PhotoViewPicker();
|
|
2418
|
-
let sizeType = options.sizeType;
|
|
2419
|
-
if (!sizeType || !sizeType.length) {
|
|
2420
|
-
sizeType = ['compressed', 'original'];
|
|
2421
|
-
}
|
|
2422
|
-
photoSelectOptions.maxSelectNumber = count; // 选择媒体文件的最大数目
|
|
2423
|
-
photoSelectOptions.MIMEType = picker.PhotoViewMIMETypes.IMAGE_TYPE; // 过滤选择媒体文件类型为IMAGE
|
|
2424
|
-
photoViewPicker.select(photoSelectOptions).then((photoSelectResult) => {
|
|
2425
|
-
const result = {};
|
|
2426
|
-
const isOrigin = photoSelectResult.isOriginalPhoto;
|
|
2427
|
-
if (isOrigin) {
|
|
2428
|
-
const tempFilePaths = [];
|
|
2429
|
-
const tempFiles = photoSelectResult.photoUris.map(uri => {
|
|
2430
|
-
const file = fs.openSync(uri, fs.OpenMode.READ_ONLY);
|
|
2431
|
-
const stat = fs.statSync(file.fd);
|
|
2432
|
-
const size = stat.size;
|
|
2433
|
-
fs.closeSync(file);
|
|
2434
|
-
tempFilePaths.push(uri);
|
|
2435
|
-
return {
|
|
2436
|
-
size,
|
|
2437
|
-
path: uri,
|
|
2438
|
-
};
|
|
2439
|
-
});
|
|
2440
|
-
result.tempFiles = tempFiles;
|
|
2441
|
-
result.tempFilePaths = tempFilePaths;
|
|
2442
|
-
callAsyncSuccess(resolve, result, options);
|
|
2436
|
+
requestPermissions(IMAGE_PERMISSION).then(() => {
|
|
2437
|
+
try {
|
|
2438
|
+
validateParams('chooseImage', options, chooseImageSchema);
|
|
2443
2439
|
}
|
|
2444
|
-
|
|
2445
|
-
const
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2440
|
+
catch (error) {
|
|
2441
|
+
const res = { errMsg: error.message };
|
|
2442
|
+
return callAsyncFail(reject, res, options);
|
|
2443
|
+
}
|
|
2444
|
+
const { count = 9 } = options;
|
|
2445
|
+
const photoViewPicker = new picker.PhotoViewPicker();
|
|
2446
|
+
let sizeType = options.sizeType;
|
|
2447
|
+
if (!sizeType || !sizeType.length) {
|
|
2448
|
+
sizeType = ['compressed', 'original'];
|
|
2449
|
+
}
|
|
2450
|
+
photoSelectOptions.maxSelectNumber = count; // 选择媒体文件的最大数目
|
|
2451
|
+
photoSelectOptions.MIMEType = picker.PhotoViewMIMETypes.IMAGE_TYPE; // 过滤选择媒体文件类型为IMAGE
|
|
2452
|
+
photoViewPicker.select(photoSelectOptions).then((photoSelectResult) => {
|
|
2453
|
+
const result = {};
|
|
2454
|
+
const isOrigin = photoSelectResult.isOriginalPhoto;
|
|
2455
|
+
if (isOrigin) {
|
|
2456
|
+
const tempFilePaths = [];
|
|
2457
|
+
const tempFiles = photoSelectResult.photoUris.map(uri => {
|
|
2459
2458
|
const file = fs.openSync(uri, fs.OpenMode.READ_ONLY);
|
|
2460
2459
|
const stat = fs.statSync(file.fd);
|
|
2461
2460
|
const size = stat.size;
|
|
2462
2461
|
fs.closeSync(file);
|
|
2462
|
+
tempFilePaths.push(uri);
|
|
2463
2463
|
return {
|
|
2464
2464
|
size,
|
|
2465
2465
|
path: uri,
|
|
2466
2466
|
};
|
|
2467
2467
|
});
|
|
2468
|
-
result.tempFilePaths = tempFilePaths;
|
|
2469
2468
|
result.tempFiles = tempFiles;
|
|
2469
|
+
result.tempFilePaths = tempFilePaths;
|
|
2470
2470
|
callAsyncSuccess(resolve, result, options);
|
|
2471
|
-
}
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2471
|
+
}
|
|
2472
|
+
else {
|
|
2473
|
+
const actions = photoSelectResult.photoUris.map(uri => {
|
|
2474
|
+
return new Promise(resolve => {
|
|
2475
|
+
compressImage({
|
|
2476
|
+
src: uri,
|
|
2477
|
+
compressedWidth: getSystemInfoSync().screenWidth / 2,
|
|
2478
|
+
compressedHeight: getSystemInfoSync().screenHeight / 2,
|
|
2479
|
+
success: (compressResult) => {
|
|
2480
|
+
resolve(compressResult.tempFilePath);
|
|
2481
|
+
}
|
|
2482
|
+
});
|
|
2483
|
+
});
|
|
2484
|
+
});
|
|
2485
|
+
Promise.all(actions).then(tempFilePaths => {
|
|
2486
|
+
const tempFiles = tempFilePaths.map(uri => {
|
|
2487
|
+
const file = fs.openSync(uri, fs.OpenMode.READ_ONLY);
|
|
2488
|
+
const stat = fs.statSync(file.fd);
|
|
2489
|
+
const size = stat.size;
|
|
2490
|
+
fs.closeSync(file);
|
|
2491
|
+
return {
|
|
2492
|
+
size,
|
|
2493
|
+
path: uri,
|
|
2494
|
+
};
|
|
2495
|
+
});
|
|
2496
|
+
result.tempFilePaths = tempFilePaths;
|
|
2497
|
+
result.tempFiles = tempFiles;
|
|
2498
|
+
callAsyncSuccess(resolve, result, options);
|
|
2499
|
+
}).catch(error => {
|
|
2500
|
+
const res = { errMsg: error };
|
|
2501
|
+
return callAsyncFail(reject, res, options);
|
|
2502
|
+
});
|
|
2503
|
+
}
|
|
2504
|
+
}).catch((error) => {
|
|
2505
|
+
callAsyncFail(reject, error, options);
|
|
2506
|
+
});
|
|
2507
|
+
}, (error) => {
|
|
2508
|
+
const res = { errMsg: error };
|
|
2509
|
+
return callAsyncFail(reject, res, options);
|
|
2478
2510
|
});
|
|
2479
2511
|
});
|
|
2480
2512
|
};
|
|
@@ -3315,7 +3347,7 @@ const switchTab = (options) => {
|
|
|
3315
3347
|
}
|
|
3316
3348
|
if (((_a = stack[stack.length - 1]) === null || _a === void 0 ? void 0 : _a.path) === url) {
|
|
3317
3349
|
// Note: 当前为 Tab 页时,触发 switch 事件
|
|
3318
|
-
eventCenter.trigger('__taroSwitchTab', { url, params });
|
|
3350
|
+
eventCenter$1.trigger('__taroSwitchTab', { url, params });
|
|
3319
3351
|
router.getLength() > 1 && router.clear();
|
|
3320
3352
|
}
|
|
3321
3353
|
else if (stack.some(item => item.path === url)) {
|
|
@@ -3740,7 +3772,7 @@ function setBackgroundColor(options) {
|
|
|
3740
3772
|
const { success, fail, complete } = options || {};
|
|
3741
3773
|
const handle = new MethodHandler({ name: 'setBackgroundColor', success, fail, complete });
|
|
3742
3774
|
return new Promise((resolve, reject) => {
|
|
3743
|
-
eventCenter.trigger('__taroPageStyle', {
|
|
3775
|
+
eventCenter$1.trigger('__taroPageStyle', {
|
|
3744
3776
|
backgroundColor: options.backgroundColorBottom || options.backgroundColor,
|
|
3745
3777
|
backgroundColorContext: options.backgroundColorTop || options.backgroundColor
|
|
3746
3778
|
});
|
|
@@ -3887,7 +3919,7 @@ const setNavigationBarTitle = function (options) {
|
|
|
3887
3919
|
const { success, fail, complete } = options || {};
|
|
3888
3920
|
const handle = new MethodHandler({ name: 'setNavigationBarTitle', success, fail, complete });
|
|
3889
3921
|
return new Promise((resolve, reject) => {
|
|
3890
|
-
eventCenter.trigger('__taroNavigationStyle', {
|
|
3922
|
+
eventCenter$1.trigger('__taroNavigationStyle', {
|
|
3891
3923
|
title: options.title,
|
|
3892
3924
|
});
|
|
3893
3925
|
return handle.success({}, { resolve, reject });
|
|
@@ -3897,7 +3929,7 @@ const setNavigationBarColor = function (options) {
|
|
|
3897
3929
|
const { success, fail, complete } = options || {};
|
|
3898
3930
|
const handle = new MethodHandler({ name: 'setNavigationBarColor', success, fail, complete });
|
|
3899
3931
|
return new Promise((resolve, reject) => {
|
|
3900
|
-
eventCenter.trigger('__taroNavigationStyle', {
|
|
3932
|
+
eventCenter$1.trigger('__taroNavigationStyle', {
|
|
3901
3933
|
animation: options.animation,
|
|
3902
3934
|
backgroundColor: options.backgroundColor,
|
|
3903
3935
|
frontColor: options.frontColor,
|
|
@@ -3909,7 +3941,7 @@ const showNavigationBarLoading = function (options) {
|
|
|
3909
3941
|
const { success, fail, complete } = options || {};
|
|
3910
3942
|
const handle = new MethodHandler({ name: 'showNavigationBarLoading', success, fail, complete });
|
|
3911
3943
|
return new Promise((resolve, reject) => {
|
|
3912
|
-
eventCenter.trigger('__taroNavigationStyle', {
|
|
3944
|
+
eventCenter$1.trigger('__taroNavigationStyle', {
|
|
3913
3945
|
loading: true,
|
|
3914
3946
|
});
|
|
3915
3947
|
return handle.success({}, { resolve, reject });
|
|
@@ -3919,7 +3951,7 @@ const hideNavigationBarLoading = function (options) {
|
|
|
3919
3951
|
const { success, fail, complete } = options || {};
|
|
3920
3952
|
const handle = new MethodHandler({ name: 'hideNavigationBarLoading', success, fail, complete });
|
|
3921
3953
|
return new Promise((resolve, reject) => {
|
|
3922
|
-
eventCenter.trigger('__taroNavigationStyle', {
|
|
3954
|
+
eventCenter$1.trigger('__taroNavigationStyle', {
|
|
3923
3955
|
loading: false,
|
|
3924
3956
|
});
|
|
3925
3957
|
return handle.success({}, { resolve, reject });
|
|
@@ -3929,7 +3961,7 @@ const hideHomeButton = function (options) {
|
|
|
3929
3961
|
const { success, fail, complete } = options || {};
|
|
3930
3962
|
const handle = new MethodHandler({ name: 'hideHomeButton', success, fail, complete });
|
|
3931
3963
|
return new Promise((resolve, reject) => {
|
|
3932
|
-
eventCenter.trigger('__taroNavigationStyle', {
|
|
3964
|
+
eventCenter$1.trigger('__taroNavigationStyle', {
|
|
3933
3965
|
home: false,
|
|
3934
3966
|
});
|
|
3935
3967
|
return handle.success({}, { resolve, reject });
|
|
@@ -4068,7 +4100,7 @@ const toggleTabBar = function (type) {
|
|
|
4068
4100
|
else {
|
|
4069
4101
|
const isShow = type === 'show';
|
|
4070
4102
|
const event = isShow ? '__taroShowTabBar' : '__taroHideTabBar';
|
|
4071
|
-
eventCenter.trigger(event, {
|
|
4103
|
+
eventCenter$1.trigger(event, {
|
|
4072
4104
|
animation: options === null || options === void 0 ? void 0 : options.animation,
|
|
4073
4105
|
});
|
|
4074
4106
|
(_b = page.$set) === null || _b === void 0 ? void 0 : _b.call(page, 'isShowTaroTabBar', isShow);
|
|
@@ -4100,7 +4132,7 @@ const setTabBarStyle = function (options = {}) {
|
|
|
4100
4132
|
data.backgroundColor = options.backgroundColor;
|
|
4101
4133
|
if (options.borderStyle)
|
|
4102
4134
|
data.borderStyle = options.borderStyle;
|
|
4103
|
-
eventCenter.trigger('__taroSetTabBarStyle', options);
|
|
4135
|
+
eventCenter$1.trigger('__taroSetTabBarStyle', options);
|
|
4104
4136
|
(_b = page.$set) === null || _b === void 0 ? void 0 : _b.call(page, 'taroTabBar', data);
|
|
4105
4137
|
callAsyncSuccess(resolve, res, options);
|
|
4106
4138
|
}
|
|
@@ -4132,7 +4164,7 @@ const setTabBarItem = function (options) {
|
|
|
4132
4164
|
...currentData.list.slice(index + 1)
|
|
4133
4165
|
];
|
|
4134
4166
|
const data = Object.assign({}, currentData, { list });
|
|
4135
|
-
eventCenter.trigger('__taroSetTabBarItem', options);
|
|
4167
|
+
eventCenter$1.trigger('__taroSetTabBarItem', options);
|
|
4136
4168
|
(_b = page.$set) === null || _b === void 0 ? void 0 : _b.call(page, 'taroTabBar', data);
|
|
4137
4169
|
callAsyncSuccess(resolve, res, options);
|
|
4138
4170
|
}
|
|
@@ -4141,7 +4173,7 @@ const setTabBarItem = function (options) {
|
|
|
4141
4173
|
function showTabBarRedDot(options) {
|
|
4142
4174
|
const res = { errMsg: 'showTabBarRedDot:ok' };
|
|
4143
4175
|
return new Promise((resolve) => {
|
|
4144
|
-
eventCenter.trigger('__taroShowTabBarRedDotHandler', {
|
|
4176
|
+
eventCenter$1.trigger('__taroShowTabBarRedDotHandler', {
|
|
4145
4177
|
index: (options === null || options === void 0 ? void 0 : options.index) || 0,
|
|
4146
4178
|
});
|
|
4147
4179
|
callAsyncSuccess(resolve, res, options);
|
|
@@ -4150,7 +4182,7 @@ function showTabBarRedDot(options) {
|
|
|
4150
4182
|
function hideTabBarRedDot(options) {
|
|
4151
4183
|
const res = { errMsg: 'hideTabBarRedDot:ok' };
|
|
4152
4184
|
return new Promise((resolve) => {
|
|
4153
|
-
eventCenter.trigger('__taroHideTabBarRedDotHandler', {
|
|
4185
|
+
eventCenter$1.trigger('__taroHideTabBarRedDotHandler', {
|
|
4154
4186
|
index: (options === null || options === void 0 ? void 0 : options.index) || 0,
|
|
4155
4187
|
});
|
|
4156
4188
|
callAsyncSuccess(resolve, res, options);
|
|
@@ -4160,7 +4192,7 @@ function setTabBarBadge(options) {
|
|
|
4160
4192
|
const res = { errMsg: 'setTabBarBadge:ok' };
|
|
4161
4193
|
return new Promise((resolve) => {
|
|
4162
4194
|
const text = (options === null || options === void 0 ? void 0 : options.text) || '';
|
|
4163
|
-
eventCenter.trigger('__taroSetTabBarBadge', {
|
|
4195
|
+
eventCenter$1.trigger('__taroSetTabBarBadge', {
|
|
4164
4196
|
index: (options === null || options === void 0 ? void 0 : options.index) || 0,
|
|
4165
4197
|
text: text.replace(/[\u0391-\uFFE5]/g, 'aa').length > 4 ? '...' : text,
|
|
4166
4198
|
});
|
|
@@ -4170,7 +4202,7 @@ function setTabBarBadge(options) {
|
|
|
4170
4202
|
function removeTabBarBadge(options) {
|
|
4171
4203
|
const res = { errMsg: 'removeTabBarBadge:ok' };
|
|
4172
4204
|
return new Promise((resolve) => {
|
|
4173
|
-
eventCenter.trigger('__taroRemoveTabBarBadge', {
|
|
4205
|
+
eventCenter$1.trigger('__taroRemoveTabBarBadge', {
|
|
4174
4206
|
index: (options === null || options === void 0 ? void 0 : options.index) || 0,
|
|
4175
4207
|
});
|
|
4176
4208
|
callAsyncSuccess(resolve, res, options);
|
|
@@ -4666,7 +4698,7 @@ var apis = /*#__PURE__*/Object.freeze({
|
|
|
4666
4698
|
disableAlertBeforeUnload: disableAlertBeforeUnload,
|
|
4667
4699
|
downloadFile: downloadFile,
|
|
4668
4700
|
enableAlertBeforeUnload: enableAlertBeforeUnload,
|
|
4669
|
-
eventCenter: eventCenter,
|
|
4701
|
+
eventCenter: eventCenter$1,
|
|
4670
4702
|
exitMiniProgram: exitMiniProgram,
|
|
4671
4703
|
exitVoIPChat: exitVoIPChat,
|
|
4672
4704
|
faceVerifyForPay: faceVerifyForPay,
|