qsh-webview-sdk 2.3.0 → 2.3.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/index.d.ts +74 -10
- package/dist/qsh-webview-sdk.es.js +1268 -995
- package/dist/qsh-webview-sdk.es.js.map +1 -1
- package/dist/qsh-webview-sdk.umd.js +35 -1
- package/dist/qsh-webview-sdk.umd.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,71 +1,71 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
1
|
+
var Xt = Object.defineProperty, Zt = Object.defineProperties;
|
|
2
|
+
var Qt = Object.getOwnPropertyDescriptors;
|
|
3
|
+
var Ze = Object.getOwnPropertySymbols;
|
|
4
|
+
var er = Object.prototype.hasOwnProperty, tr = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var Le = (t, e, r) => e in t ? Xt(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r, g = (t, e) => {
|
|
6
6
|
for (var r in e || (e = {}))
|
|
7
|
-
|
|
8
|
-
if (
|
|
9
|
-
for (var r of
|
|
10
|
-
|
|
7
|
+
er.call(e, r) && Le(t, r, e[r]);
|
|
8
|
+
if (Ze)
|
|
9
|
+
for (var r of Ze(e))
|
|
10
|
+
tr.call(e, r) && Le(t, r, e[r]);
|
|
11
11
|
return t;
|
|
12
|
-
},
|
|
13
|
-
var
|
|
14
|
-
var
|
|
15
|
-
var a = (
|
|
12
|
+
}, m = (t, e) => Zt(t, Qt(e));
|
|
13
|
+
var B = (t, e, r) => Le(t, typeof e != "symbol" ? e + "" : e, r);
|
|
14
|
+
var h = (t, e, r) => new Promise((n, i) => {
|
|
15
|
+
var a = (d) => {
|
|
16
16
|
try {
|
|
17
|
-
|
|
17
|
+
u(r.next(d));
|
|
18
18
|
} catch (O) {
|
|
19
19
|
i(O);
|
|
20
20
|
}
|
|
21
|
-
}, o = (
|
|
21
|
+
}, o = (d) => {
|
|
22
22
|
try {
|
|
23
|
-
|
|
23
|
+
u(r.throw(d));
|
|
24
24
|
} catch (O) {
|
|
25
25
|
i(O);
|
|
26
26
|
}
|
|
27
|
-
},
|
|
28
|
-
|
|
27
|
+
}, u = (d) => d.done ? n(d.value) : Promise.resolve(d.value).then(a, o);
|
|
28
|
+
u((r = r.apply(t, e)).next());
|
|
29
29
|
});
|
|
30
|
-
function
|
|
30
|
+
function me() {
|
|
31
31
|
return typeof window != "undefined" ? window : void 0;
|
|
32
32
|
}
|
|
33
|
-
function
|
|
33
|
+
function Ue() {
|
|
34
34
|
return typeof navigator == "undefined" ? "" : navigator.userAgent || "";
|
|
35
35
|
}
|
|
36
|
-
function
|
|
37
|
-
const t =
|
|
36
|
+
function A() {
|
|
37
|
+
const t = me();
|
|
38
38
|
if (!t) return !1;
|
|
39
39
|
if (t.__wxjs_environment === "miniprogram" || t.wx && t.wx.miniProgram)
|
|
40
40
|
return !0;
|
|
41
|
-
const e =
|
|
41
|
+
const e = Ue();
|
|
42
42
|
return !!(e && /micromessenger/i.test(e) && /miniProgram/i.test(e));
|
|
43
43
|
}
|
|
44
|
-
function
|
|
45
|
-
const t =
|
|
44
|
+
function Se() {
|
|
45
|
+
const t = me();
|
|
46
46
|
return !!(t && t.plus);
|
|
47
47
|
}
|
|
48
|
-
function
|
|
49
|
-
const t =
|
|
48
|
+
function Ne() {
|
|
49
|
+
const t = me();
|
|
50
50
|
return !!(t && (t.__dcloud_weex_postMessage || t.__dcloud_weex_));
|
|
51
51
|
}
|
|
52
|
-
function
|
|
53
|
-
const t =
|
|
52
|
+
function Re() {
|
|
53
|
+
const t = me();
|
|
54
54
|
return !!(t && (t.__uniapp_x_postMessage || t.__uniapp_x_));
|
|
55
55
|
}
|
|
56
|
-
function
|
|
57
|
-
const t =
|
|
56
|
+
function be() {
|
|
57
|
+
const t = Ue();
|
|
58
58
|
return /uni-app/i.test(t);
|
|
59
59
|
}
|
|
60
|
-
function
|
|
61
|
-
const t =
|
|
60
|
+
function We() {
|
|
61
|
+
const t = Ue();
|
|
62
62
|
return /Html5Plus/i.test(t);
|
|
63
63
|
}
|
|
64
|
-
function
|
|
65
|
-
return
|
|
64
|
+
function st() {
|
|
65
|
+
return be() || We();
|
|
66
66
|
}
|
|
67
|
-
function
|
|
68
|
-
const t =
|
|
67
|
+
function Q() {
|
|
68
|
+
const t = me();
|
|
69
69
|
if (!t) return !1;
|
|
70
70
|
if (t.__offline_bridge_postMessage) return !0;
|
|
71
71
|
try {
|
|
@@ -75,31 +75,31 @@ function H() {
|
|
|
75
75
|
}
|
|
76
76
|
return !1;
|
|
77
77
|
}
|
|
78
|
-
function
|
|
79
|
-
return
|
|
80
|
-
}
|
|
81
|
-
let
|
|
82
|
-
function
|
|
83
|
-
return
|
|
84
|
-
isWeixinMiniProgram:
|
|
85
|
-
isAppPlus:
|
|
86
|
-
isNvue:
|
|
87
|
-
isUvue:
|
|
88
|
-
isUniApp:
|
|
89
|
-
isHtml5Plus:
|
|
90
|
-
isUniAppWebView:
|
|
91
|
-
isOfflineWebview:
|
|
92
|
-
type:
|
|
93
|
-
}),
|
|
94
|
-
}
|
|
95
|
-
const l =
|
|
78
|
+
function rr() {
|
|
79
|
+
return Re() ? "uvue" : Ne() ? "nvue" : A() ? "weixin" : Q() ? "offline" : Se() ? "plus" : st() ? "webview" : be() ? "UniApp" : "h5";
|
|
80
|
+
}
|
|
81
|
+
let ye = null;
|
|
82
|
+
function oe(t = !1) {
|
|
83
|
+
return ye && !t || (ye = {
|
|
84
|
+
isWeixinMiniProgram: A(),
|
|
85
|
+
isAppPlus: Se(),
|
|
86
|
+
isNvue: Ne(),
|
|
87
|
+
isUvue: Re(),
|
|
88
|
+
isUniApp: be(),
|
|
89
|
+
isHtml5Plus: We(),
|
|
90
|
+
isUniAppWebView: st(),
|
|
91
|
+
isOfflineWebview: Q(),
|
|
92
|
+
type: rr()
|
|
93
|
+
}), ye;
|
|
94
|
+
}
|
|
95
|
+
const l = oe(), x = {
|
|
96
96
|
PLATFORM_NOT_SUPPORTED: "PLATFORM_NOT_SUPPORTED",
|
|
97
97
|
API_CALL_FAILED: "API_CALL_FAILED",
|
|
98
98
|
BRIDGE_NOT_READY: "BRIDGE_NOT_READY",
|
|
99
99
|
INVALID_PARAMETERS: "INVALID_PARAMETERS",
|
|
100
100
|
NETWORK_ERROR: "NETWORK_ERROR"
|
|
101
101
|
};
|
|
102
|
-
class
|
|
102
|
+
class N extends Error {
|
|
103
103
|
/**
|
|
104
104
|
* 构造函数
|
|
105
105
|
* @param {string} type - 错误类型
|
|
@@ -108,7 +108,7 @@ class R extends Error {
|
|
|
108
108
|
* @param {Error} [originalError] - 原始错误对象
|
|
109
109
|
*/
|
|
110
110
|
constructor(e, r, n = {}, i = null) {
|
|
111
|
-
super(r), this.name = "QshError", this.type = e, this.context = n, this.originalError = i, this.timestamp = (/* @__PURE__ */ new Date()).toISOString(), Error.captureStackTrace && Error.captureStackTrace(this,
|
|
111
|
+
super(r), this.name = "QshError", this.type = e, this.context = n, this.originalError = i, this.timestamp = (/* @__PURE__ */ new Date()).toISOString(), Error.captureStackTrace && Error.captureStackTrace(this, N);
|
|
112
112
|
}
|
|
113
113
|
/**
|
|
114
114
|
* 转换为 JSON 格式
|
|
@@ -156,13 +156,13 @@ const C = class C {
|
|
|
156
156
|
*/
|
|
157
157
|
static handleApiError(e, r = {}) {
|
|
158
158
|
let n;
|
|
159
|
-
return e instanceof
|
|
160
|
-
|
|
159
|
+
return e instanceof N ? n = e : e instanceof Error ? n = new N(
|
|
160
|
+
x.API_CALL_FAILED,
|
|
161
161
|
e.message,
|
|
162
162
|
r,
|
|
163
163
|
e
|
|
164
|
-
) : n = new
|
|
165
|
-
|
|
164
|
+
) : n = new N(
|
|
165
|
+
x.API_CALL_FAILED,
|
|
166
166
|
String(e),
|
|
167
167
|
r
|
|
168
168
|
), C.logError(n), C.notifyCallbacks(n), n;
|
|
@@ -174,8 +174,8 @@ const C = class C {
|
|
|
174
174
|
* @returns {QshError} 错误对象
|
|
175
175
|
*/
|
|
176
176
|
static handlePlatformNotSupported(e, r) {
|
|
177
|
-
const n = new
|
|
178
|
-
|
|
177
|
+
const n = new N(
|
|
178
|
+
x.PLATFORM_NOT_SUPPORTED,
|
|
179
179
|
`API "${r}" is not supported on platform "${e}"`,
|
|
180
180
|
{ platformType: e, apiName: r }
|
|
181
181
|
);
|
|
@@ -187,8 +187,8 @@ const C = class C {
|
|
|
187
187
|
* @returns {QshError} 错误对象
|
|
188
188
|
*/
|
|
189
189
|
static handleBridgeNotReady(e) {
|
|
190
|
-
const r = new
|
|
191
|
-
|
|
190
|
+
const r = new N(
|
|
191
|
+
x.BRIDGE_NOT_READY,
|
|
192
192
|
`Bridge is not ready when calling "${e}"`,
|
|
193
193
|
{ apiName: e }
|
|
194
194
|
);
|
|
@@ -203,8 +203,8 @@ const C = class C {
|
|
|
203
203
|
* @returns {QshError} 错误对象
|
|
204
204
|
*/
|
|
205
205
|
static handleInvalidParameters(e, r, n, i) {
|
|
206
|
-
const a = new
|
|
207
|
-
|
|
206
|
+
const a = new N(
|
|
207
|
+
x.INVALID_PARAMETERS,
|
|
208
208
|
`Invalid parameter "${r}" in "${e}": expected ${n}, got ${typeof i}`,
|
|
209
209
|
{ apiName: e, paramName: r, expectedType: n, actualValue: i }
|
|
210
210
|
);
|
|
@@ -230,7 +230,7 @@ const C = class C {
|
|
|
230
230
|
* @returns {Promise} Promise 对象
|
|
231
231
|
*/
|
|
232
232
|
static safeExecuteAsync(n) {
|
|
233
|
-
return
|
|
233
|
+
return h(this, arguments, function* (e, r = {}) {
|
|
234
234
|
try {
|
|
235
235
|
return yield e();
|
|
236
236
|
} catch (i) {
|
|
@@ -277,22 +277,22 @@ const C = class C {
|
|
|
277
277
|
return function(r, n, i) {
|
|
278
278
|
const a = i.value;
|
|
279
279
|
return i.value = function(...o) {
|
|
280
|
-
return C.safeExecute(() => a.apply(this, o),
|
|
280
|
+
return C.safeExecute(() => a.apply(this, o), m(g({}, e), { method: n, target: r.constructor.name }));
|
|
281
281
|
}, i;
|
|
282
282
|
};
|
|
283
283
|
}
|
|
284
284
|
};
|
|
285
|
-
|
|
286
|
-
let
|
|
287
|
-
const
|
|
285
|
+
B(C, "isDebugMode", !1), B(C, "errorCallbacks", []);
|
|
286
|
+
let f = C;
|
|
287
|
+
const L = {
|
|
288
288
|
UNINITIALIZED: "uninitialized",
|
|
289
289
|
INITIALIZING: "initializing",
|
|
290
290
|
READY: "ready",
|
|
291
291
|
ERROR: "error"
|
|
292
292
|
};
|
|
293
|
-
class
|
|
293
|
+
class nr {
|
|
294
294
|
constructor() {
|
|
295
|
-
this.state =
|
|
295
|
+
this.state = L.UNINITIALIZED, this.readyPromise = null, this.readyCallbacks = [], this.errorCallbacks = [], this.initializationError = null, this.handleBridgeReady = this.handleBridgeReady.bind(this), this.handleInitializationError = this.handleInitializationError.bind(this);
|
|
296
296
|
}
|
|
297
297
|
/**
|
|
298
298
|
* 获取当前状态
|
|
@@ -306,21 +306,21 @@ class Jt {
|
|
|
306
306
|
* @returns {boolean} 是否就绪
|
|
307
307
|
*/
|
|
308
308
|
isReady() {
|
|
309
|
-
return this.state ===
|
|
309
|
+
return this.state === L.READY;
|
|
310
310
|
}
|
|
311
311
|
/**
|
|
312
312
|
* 检查是否正在初始化
|
|
313
313
|
* @returns {boolean} 是否正在初始化
|
|
314
314
|
*/
|
|
315
315
|
isInitializing() {
|
|
316
|
-
return this.state ===
|
|
316
|
+
return this.state === L.INITIALIZING;
|
|
317
317
|
}
|
|
318
318
|
/**
|
|
319
319
|
* 检查是否出错
|
|
320
320
|
* @returns {boolean} 是否出错
|
|
321
321
|
*/
|
|
322
322
|
hasError() {
|
|
323
|
-
return this.state ===
|
|
323
|
+
return this.state === L.ERROR;
|
|
324
324
|
}
|
|
325
325
|
/**
|
|
326
326
|
* 获取初始化错误
|
|
@@ -344,10 +344,10 @@ class Jt {
|
|
|
344
344
|
* @returns {Promise<void>} 初始化 Promise
|
|
345
345
|
*/
|
|
346
346
|
startInitialization(e) {
|
|
347
|
-
return
|
|
348
|
-
if (this.state !==
|
|
347
|
+
return h(this, null, function* () {
|
|
348
|
+
if (this.state !== L.UNINITIALIZED)
|
|
349
349
|
return this.waitForReady();
|
|
350
|
-
this.state =
|
|
350
|
+
this.state = L.INITIALIZING;
|
|
351
351
|
try {
|
|
352
352
|
yield e(), this.handleBridgeReady();
|
|
353
353
|
} catch (r) {
|
|
@@ -361,11 +361,11 @@ class Jt {
|
|
|
361
361
|
* @private
|
|
362
362
|
*/
|
|
363
363
|
handleBridgeReady() {
|
|
364
|
-
this.state ===
|
|
364
|
+
this.state === L.INITIALIZING && (this.state = L.READY, this.readyCallbacks.forEach((e) => {
|
|
365
365
|
try {
|
|
366
366
|
e();
|
|
367
367
|
} catch (r) {
|
|
368
|
-
|
|
368
|
+
f.handleApiError(r, { context: "StateManager.handleBridgeReady" });
|
|
369
369
|
}
|
|
370
370
|
}), this.readyCallbacks = [], this.errorCallbacks = []);
|
|
371
371
|
}
|
|
@@ -375,11 +375,11 @@ class Jt {
|
|
|
375
375
|
* @private
|
|
376
376
|
*/
|
|
377
377
|
handleInitializationError(e) {
|
|
378
|
-
this.state =
|
|
378
|
+
this.state = L.ERROR, this.initializationError = e, this.errorCallbacks.forEach((r) => {
|
|
379
379
|
try {
|
|
380
380
|
r(e);
|
|
381
381
|
} catch (n) {
|
|
382
|
-
|
|
382
|
+
f.handleApiError(n, { context: "StateManager.handleInitializationError" });
|
|
383
383
|
}
|
|
384
384
|
}), this.readyCallbacks = [], this.errorCallbacks = [];
|
|
385
385
|
}
|
|
@@ -387,7 +387,7 @@ class Jt {
|
|
|
387
387
|
* 重置状态管理器(用于测试或重新初始化)
|
|
388
388
|
*/
|
|
389
389
|
reset() {
|
|
390
|
-
this.state =
|
|
390
|
+
this.state = L.UNINITIALIZED, this.readyPromise = null, this.readyCallbacks = [], this.errorCallbacks = [], this.initializationError = null;
|
|
391
391
|
}
|
|
392
392
|
/**
|
|
393
393
|
* 添加状态变化监听器
|
|
@@ -402,7 +402,7 @@ class Jt {
|
|
|
402
402
|
const n = () => {
|
|
403
403
|
this.state === e && r(this.state);
|
|
404
404
|
};
|
|
405
|
-
return e ===
|
|
405
|
+
return e === L.READY ? this.readyCallbacks.push(n) : e === L.ERROR && this.errorCallbacks.push(n), () => {
|
|
406
406
|
const i = this.readyCallbacks.indexOf(n);
|
|
407
407
|
i > -1 && this.readyCallbacks.splice(i, 1);
|
|
408
408
|
const a = this.errorCallbacks.indexOf(n);
|
|
@@ -423,52 +423,52 @@ class Jt {
|
|
|
423
423
|
};
|
|
424
424
|
}
|
|
425
425
|
}
|
|
426
|
-
const
|
|
426
|
+
const X = new nr(), at = () => X.waitForReady(), ir = () => X.isReady(), sr = () => X.getState(), y = {
|
|
427
427
|
ERROR: 0,
|
|
428
428
|
WARN: 1,
|
|
429
429
|
INFO: 2,
|
|
430
430
|
DEBUG: 3,
|
|
431
431
|
TRACE: 4
|
|
432
|
-
},
|
|
433
|
-
[
|
|
434
|
-
[
|
|
435
|
-
[
|
|
436
|
-
[
|
|
437
|
-
[
|
|
438
|
-
},
|
|
432
|
+
}, ue = {
|
|
433
|
+
[y.ERROR]: "ERROR",
|
|
434
|
+
[y.WARN]: "WARN",
|
|
435
|
+
[y.INFO]: "INFO",
|
|
436
|
+
[y.DEBUG]: "DEBUG",
|
|
437
|
+
[y.TRACE]: "TRACE"
|
|
438
|
+
}, p = class p {
|
|
439
439
|
// 可注入的外部 reporter
|
|
440
440
|
/**
|
|
441
441
|
* 设置日志级别
|
|
442
442
|
* @param {number} level - 日志级别
|
|
443
443
|
*/
|
|
444
444
|
static setLevel(e) {
|
|
445
|
-
e >=
|
|
445
|
+
e >= y.ERROR && e <= y.TRACE && (p.currentLevel = e, p.log(y.INFO, "Logger", `日志级别设置为: ${ue[e]}`));
|
|
446
446
|
}
|
|
447
447
|
/**
|
|
448
448
|
* 启用开发模式(显示所有日志)
|
|
449
449
|
*/
|
|
450
450
|
static enableDevMode() {
|
|
451
|
-
|
|
451
|
+
p.setLevel(y.DEBUG), p.log(y.INFO, "Logger", "开发模式已启用");
|
|
452
452
|
}
|
|
453
453
|
/**
|
|
454
454
|
* 启用生产模式(只显示错误和警告)
|
|
455
455
|
*/
|
|
456
456
|
static enableProdMode() {
|
|
457
|
-
|
|
457
|
+
p.setLevel(y.WARN), p.log(y.INFO, "Logger", "生产模式已启用");
|
|
458
458
|
}
|
|
459
459
|
/**
|
|
460
460
|
* 启用特定模块的日志
|
|
461
461
|
* @param {string} module - 模块名称
|
|
462
462
|
*/
|
|
463
463
|
static enableModule(e) {
|
|
464
|
-
|
|
464
|
+
p.enabledModules.add(e), p.log(y.INFO, "Logger", `模块日志已启用: ${e}`);
|
|
465
465
|
}
|
|
466
466
|
/**
|
|
467
467
|
* 禁用特定模块的日志
|
|
468
468
|
* @param {string} module - 模块名称
|
|
469
469
|
*/
|
|
470
470
|
static disableModule(e) {
|
|
471
|
-
|
|
471
|
+
p.enabledModules.delete(e), p.log(y.INFO, "Logger", `模块日志已禁用: ${e}`);
|
|
472
472
|
}
|
|
473
473
|
/**
|
|
474
474
|
* 检查是否应该记录日志
|
|
@@ -478,7 +478,7 @@ const q = new Jt(), He = () => q.waitForReady(), Ht = () => q.isReady(), Yt = ()
|
|
|
478
478
|
* @private
|
|
479
479
|
*/
|
|
480
480
|
static shouldLog(e, r) {
|
|
481
|
-
return e >
|
|
481
|
+
return e > p.currentLevel ? !1 : r && p.enabledModules.size > 0 ? p.enabledModules.has(r) : !0;
|
|
482
482
|
}
|
|
483
483
|
/**
|
|
484
484
|
* 核心日志记录方法
|
|
@@ -489,9 +489,9 @@ const q = new Jt(), He = () => q.waitForReady(), Ht = () => q.isReady(), Yt = ()
|
|
|
489
489
|
* @private
|
|
490
490
|
*/
|
|
491
491
|
static log(e, r, n, ...i) {
|
|
492
|
-
if (!
|
|
492
|
+
if (!p.shouldLog(e, r))
|
|
493
493
|
return;
|
|
494
|
-
const a = (/* @__PURE__ */ new Date()).toISOString(), o =
|
|
494
|
+
const a = (/* @__PURE__ */ new Date()).toISOString(), o = ue[e], u = r ? `[${r}]` : "", d = `${p.prefix} ${u} ${n}`, O = {
|
|
495
495
|
timestamp: a,
|
|
496
496
|
level: e,
|
|
497
497
|
levelName: o,
|
|
@@ -499,12 +499,12 @@ const q = new Jt(), He = () => q.waitForReady(), Ht = () => q.isReady(), Yt = ()
|
|
|
499
499
|
message: n,
|
|
500
500
|
args: i
|
|
501
501
|
};
|
|
502
|
-
if (
|
|
502
|
+
if (p.addToHistory(O), typeof p.reporter == "function")
|
|
503
503
|
try {
|
|
504
|
-
|
|
505
|
-
} catch (
|
|
504
|
+
p.reporter(O);
|
|
505
|
+
} catch (R) {
|
|
506
506
|
}
|
|
507
|
-
|
|
507
|
+
p.outputToConsole(e, d, ...i);
|
|
508
508
|
}
|
|
509
509
|
/**
|
|
510
510
|
* 添加日志到历史记录
|
|
@@ -512,7 +512,7 @@ const q = new Jt(), He = () => q.waitForReady(), Ht = () => q.isReady(), Yt = ()
|
|
|
512
512
|
* @private
|
|
513
513
|
*/
|
|
514
514
|
static addToHistory(e) {
|
|
515
|
-
|
|
515
|
+
p.logHistory.push(e), p.logHistory.length > p.maxHistorySize && p.logHistory.shift();
|
|
516
516
|
}
|
|
517
517
|
/**
|
|
518
518
|
* 输出到控制台
|
|
@@ -526,17 +526,17 @@ const q = new Jt(), He = () => q.waitForReady(), Ht = () => q.isReady(), Yt = ()
|
|
|
526
526
|
return;
|
|
527
527
|
const i = n && n.length > 0;
|
|
528
528
|
switch (e) {
|
|
529
|
-
case
|
|
529
|
+
case y.ERROR:
|
|
530
530
|
i ? console.error(r, ...n) : console.error(r);
|
|
531
531
|
break;
|
|
532
|
-
case
|
|
532
|
+
case y.WARN:
|
|
533
533
|
i ? console.warn(r, ...n) : console.warn(r);
|
|
534
534
|
break;
|
|
535
|
-
case
|
|
535
|
+
case y.INFO:
|
|
536
536
|
i ? console.info(r, ...n) : console.info(r);
|
|
537
537
|
break;
|
|
538
|
-
case
|
|
539
|
-
case
|
|
538
|
+
case y.DEBUG:
|
|
539
|
+
case y.TRACE:
|
|
540
540
|
i ? console.log(r, ...n) : console.log(r);
|
|
541
541
|
break;
|
|
542
542
|
}
|
|
@@ -548,7 +548,7 @@ const q = new Jt(), He = () => q.waitForReady(), Ht = () => q.isReady(), Yt = ()
|
|
|
548
548
|
* @param {any[]} args - 额外参数
|
|
549
549
|
*/
|
|
550
550
|
static error(e, r, ...n) {
|
|
551
|
-
|
|
551
|
+
p.log(y.ERROR, e, r, ...n);
|
|
552
552
|
}
|
|
553
553
|
/**
|
|
554
554
|
* 警告级别日志
|
|
@@ -557,7 +557,7 @@ const q = new Jt(), He = () => q.waitForReady(), Ht = () => q.isReady(), Yt = ()
|
|
|
557
557
|
* @param {any[]} args - 额外参数
|
|
558
558
|
*/
|
|
559
559
|
static warn(e, r, ...n) {
|
|
560
|
-
|
|
560
|
+
p.log(y.WARN, e, r, ...n);
|
|
561
561
|
}
|
|
562
562
|
/**
|
|
563
563
|
* 信息级别日志
|
|
@@ -566,7 +566,7 @@ const q = new Jt(), He = () => q.waitForReady(), Ht = () => q.isReady(), Yt = ()
|
|
|
566
566
|
* @param {any[]} args - 额外参数
|
|
567
567
|
*/
|
|
568
568
|
static info(e, r, ...n) {
|
|
569
|
-
|
|
569
|
+
p.log(y.INFO, e, r, ...n);
|
|
570
570
|
}
|
|
571
571
|
/**
|
|
572
572
|
* 调试级别日志
|
|
@@ -575,7 +575,7 @@ const q = new Jt(), He = () => q.waitForReady(), Ht = () => q.isReady(), Yt = ()
|
|
|
575
575
|
* @param {any[]} args - 额外参数
|
|
576
576
|
*/
|
|
577
577
|
static debug(e, r, ...n) {
|
|
578
|
-
|
|
578
|
+
p.log(y.DEBUG, e, r, ...n);
|
|
579
579
|
}
|
|
580
580
|
/**
|
|
581
581
|
* 跟踪级别日志
|
|
@@ -584,7 +584,7 @@ const q = new Jt(), He = () => q.waitForReady(), Ht = () => q.isReady(), Yt = ()
|
|
|
584
584
|
* @param {any[]} args - 额外参数
|
|
585
585
|
*/
|
|
586
586
|
static trace(e, r, ...n) {
|
|
587
|
-
|
|
587
|
+
p.log(y.TRACE, e, r, ...n);
|
|
588
588
|
}
|
|
589
589
|
/**
|
|
590
590
|
* 获取日志历史
|
|
@@ -592,13 +592,13 @@ const q = new Jt(), He = () => q.waitForReady(), Ht = () => q.isReady(), Yt = ()
|
|
|
592
592
|
* @returns {Array} 日志条目数组
|
|
593
593
|
*/
|
|
594
594
|
static getHistory(e) {
|
|
595
|
-
return e && e > 0 ?
|
|
595
|
+
return e && e > 0 ? p.logHistory.slice(-e) : [...p.logHistory];
|
|
596
596
|
}
|
|
597
597
|
/**
|
|
598
598
|
* 清空日志历史
|
|
599
599
|
*/
|
|
600
600
|
static clearHistory() {
|
|
601
|
-
|
|
601
|
+
p.logHistory = [], p.log(y.INFO, "Logger", "日志历史已清空");
|
|
602
602
|
}
|
|
603
603
|
/**
|
|
604
604
|
* 获取日志统计信息
|
|
@@ -606,15 +606,15 @@ const q = new Jt(), He = () => q.waitForReady(), Ht = () => q.isReady(), Yt = ()
|
|
|
606
606
|
*/
|
|
607
607
|
static getStats() {
|
|
608
608
|
const e = {
|
|
609
|
-
currentLevel:
|
|
610
|
-
currentLevelName:
|
|
611
|
-
enabledModules: Array.from(
|
|
612
|
-
historySize:
|
|
613
|
-
maxHistorySize:
|
|
609
|
+
currentLevel: p.currentLevel,
|
|
610
|
+
currentLevelName: ue[p.currentLevel],
|
|
611
|
+
enabledModules: Array.from(p.enabledModules),
|
|
612
|
+
historySize: p.logHistory.length,
|
|
613
|
+
maxHistorySize: p.maxHistorySize
|
|
614
614
|
}, r = {};
|
|
615
|
-
for (const n of Object.keys(
|
|
616
|
-
r[
|
|
617
|
-
return
|
|
615
|
+
for (const n of Object.keys(ue))
|
|
616
|
+
r[ue[n]] = 0;
|
|
617
|
+
return p.logHistory.forEach((n) => {
|
|
618
618
|
r[n.levelName]++;
|
|
619
619
|
}), e.levelCounts = r, e;
|
|
620
620
|
}
|
|
@@ -624,7 +624,7 @@ const q = new Jt(), He = () => q.waitForReady(), Ht = () => q.isReady(), Yt = ()
|
|
|
624
624
|
* @returns {string} JSON 字符串
|
|
625
625
|
*/
|
|
626
626
|
static exportToJSON(e) {
|
|
627
|
-
const r =
|
|
627
|
+
const r = p.getHistory(e), n = p.getStats();
|
|
628
628
|
return JSON.stringify({
|
|
629
629
|
exportTime: (/* @__PURE__ */ new Date()).toISOString(),
|
|
630
630
|
stats: n,
|
|
@@ -638,11 +638,11 @@ const q = new Jt(), He = () => q.waitForReady(), Ht = () => q.isReady(), Yt = ()
|
|
|
638
638
|
*/
|
|
639
639
|
static createModuleLogger(e) {
|
|
640
640
|
return {
|
|
641
|
-
error: (r, ...n) =>
|
|
642
|
-
warn: (r, ...n) =>
|
|
643
|
-
info: (r, ...n) =>
|
|
644
|
-
debug: (r, ...n) =>
|
|
645
|
-
trace: (r, ...n) =>
|
|
641
|
+
error: (r, ...n) => p.error(e, r, ...n),
|
|
642
|
+
warn: (r, ...n) => p.warn(e, r, ...n),
|
|
643
|
+
info: (r, ...n) => p.info(e, r, ...n),
|
|
644
|
+
debug: (r, ...n) => p.debug(e, r, ...n),
|
|
645
|
+
trace: (r, ...n) => p.trace(e, r, ...n)
|
|
646
646
|
};
|
|
647
647
|
}
|
|
648
648
|
/**
|
|
@@ -650,14 +650,14 @@ const q = new Jt(), He = () => q.waitForReady(), Ht = () => q.isReady(), Yt = ()
|
|
|
650
650
|
* @param {(entry: any) => void|null} reporter
|
|
651
651
|
*/
|
|
652
652
|
static setReporter(e) {
|
|
653
|
-
|
|
653
|
+
p.reporter = typeof e == "function" ? e : null;
|
|
654
654
|
}
|
|
655
655
|
};
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
let
|
|
656
|
+
B(p, "currentLevel", y.ERROR), // 生产环境默认只显示错误
|
|
657
|
+
B(p, "enabledModules", /* @__PURE__ */ new Set()), // 启用日志的模块
|
|
658
|
+
B(p, "logHistory", []), // 日志历史(最多保留1000条)
|
|
659
|
+
B(p, "maxHistorySize", 1e3), B(p, "prefix", "[QSH-SDK]"), B(p, "reporter", null);
|
|
660
|
+
let M = p;
|
|
661
661
|
if (typeof window != "undefined") {
|
|
662
662
|
const t = window.location && (window.location.hostname === "localhost" || window.location.hostname === "127.0.0.1" || window.location.hostname.includes("192.168.")), e = window.location && (window.location.search.includes("debug=true") || window.location.search.includes("qsh_debug=1"));
|
|
663
663
|
let r = !1;
|
|
@@ -665,16 +665,16 @@ if (typeof window != "undefined") {
|
|
|
665
665
|
r = localStorage && localStorage.getItem("qsh_debug") === "true";
|
|
666
666
|
} catch (n) {
|
|
667
667
|
}
|
|
668
|
-
(t || e || r) &&
|
|
668
|
+
(t || e || r) && M.enableDevMode();
|
|
669
669
|
}
|
|
670
|
-
const E =
|
|
671
|
-
function
|
|
672
|
-
if (!
|
|
670
|
+
const E = M.createModuleLogger("Bridge"), w = M.createModuleLogger("Platform"), s = M.createModuleLogger("API"), D = M.createModuleLogger("State"), Oe = /complete|loaded|interactive/;
|
|
671
|
+
function ar(t) {
|
|
672
|
+
if (!Q()) return !1;
|
|
673
673
|
E.debug("检测到离线包环境,开始初始化");
|
|
674
674
|
const e = () => {
|
|
675
675
|
t();
|
|
676
676
|
};
|
|
677
|
-
if (
|
|
677
|
+
if (Oe.test(document.readyState))
|
|
678
678
|
E.debug("离线包环境 DOM 已就绪,立即初始化"), setTimeout(e, 0);
|
|
679
679
|
else {
|
|
680
680
|
E.debug("离线包环境,等待 DOMContentLoaded");
|
|
@@ -686,31 +686,31 @@ function Xt(t) {
|
|
|
686
686
|
}
|
|
687
687
|
return !0;
|
|
688
688
|
}
|
|
689
|
-
function
|
|
690
|
-
return
|
|
689
|
+
function or(t) {
|
|
690
|
+
return be() || We() ? (E.debug("检测到 APP 环境,开始初始化"), window.__uniapp_x_postMessage || window.__uniapp_x_ || window.__dcloud_weex_postMessage || window.__dcloud_weex_ ? (E.debug("NVUE/UVUE 环境,等待 DOMContentLoaded"), document.addEventListener("DOMContentLoaded", t)) : window.plus && Oe.test(document.readyState) ? (E.debug("Plus 环境已就绪,立即初始化"), setTimeout(t, 0)) : window.plus ? (E.debug("Plus 环境,等待 plusready 事件"), document.addEventListener("plusready", t)) : Oe.test(document.readyState) ? setTimeout(t, 0) : document.addEventListener("DOMContentLoaded", t, { once: !0 }), !0) : !1;
|
|
691
691
|
}
|
|
692
|
-
function
|
|
692
|
+
function cr(t) {
|
|
693
693
|
return window.wx && window.wx.miniProgram ? (E.debug("检测到微信小程序环境,开始初始化"), window.WeixinJSBridge && window.WeixinJSBridge.invoke ? (E.debug("微信 JSBridge 已就绪,立即初始化"), setTimeout(t, 0)) : (E.debug("微信 JSBridge 未就绪,等待 WeixinJSBridgeReady 事件"), document.addEventListener("WeixinJSBridgeReady", t)), !0) : !1;
|
|
694
694
|
}
|
|
695
|
-
function
|
|
696
|
-
return E.info("开始初始化 JSBridge"),
|
|
695
|
+
function ur(t) {
|
|
696
|
+
return E.info("开始初始化 JSBridge"), ar(t) ? (E.info("使用离线包环境初始化"), !0) : or(t) ? (E.info("使用 APP 环境初始化"), !0) : cr(t) ? (E.info("使用微信小程序环境初始化"), !0) : (E.debug("使用默认 H5 环境初始化"), Oe.test(document.readyState) ? (E.debug("DOM 已就绪,立即初始化"), setTimeout(t, 0)) : (E.debug("DOM 未就绪,等待 DOMContentLoaded"), document.addEventListener("DOMContentLoaded", t)), !0);
|
|
697
697
|
}
|
|
698
|
-
function
|
|
699
|
-
return
|
|
698
|
+
function lr() {
|
|
699
|
+
return X.waitForReady();
|
|
700
700
|
}
|
|
701
|
-
function
|
|
702
|
-
return
|
|
701
|
+
function ot() {
|
|
702
|
+
return X.startInitialization(() => h(null, null, function* () {
|
|
703
703
|
return new Promise((t, e) => {
|
|
704
704
|
const r = () => {
|
|
705
705
|
t();
|
|
706
706
|
}, n = (i) => {
|
|
707
|
-
const a =
|
|
707
|
+
const a = f.handleApiError(i, {
|
|
708
708
|
context: "bridge initialization"
|
|
709
709
|
});
|
|
710
710
|
e(a);
|
|
711
711
|
};
|
|
712
712
|
try {
|
|
713
|
-
|
|
713
|
+
ur(() => {
|
|
714
714
|
r();
|
|
715
715
|
});
|
|
716
716
|
} catch (i) {
|
|
@@ -719,55 +719,55 @@ function Ye() {
|
|
|
719
719
|
});
|
|
720
720
|
}));
|
|
721
721
|
}
|
|
722
|
-
const
|
|
722
|
+
const S = {
|
|
723
723
|
UNINITIALIZED: "uninitialized",
|
|
724
724
|
CONFIGURING: "configuring",
|
|
725
725
|
CONFIGURED: "configured",
|
|
726
726
|
ERROR: "error"
|
|
727
727
|
};
|
|
728
|
-
function
|
|
728
|
+
function k() {
|
|
729
729
|
return typeof window == "undefined" || !window.wx ? !1 : typeof window.wx.config == "function" && typeof window.wx.ready == "function" && typeof window.wx.error == "function";
|
|
730
730
|
}
|
|
731
|
-
class
|
|
731
|
+
class fr {
|
|
732
732
|
constructor() {
|
|
733
|
-
this.state =
|
|
733
|
+
this.state = S.UNINITIALIZED, this.configPromise = null, this.readyCallbacks = [], this.errorCallbacks = [], this.lastError = null, this.runtimeConfig = {
|
|
734
734
|
clientId: null,
|
|
735
735
|
isProd: !1
|
|
736
736
|
}, this.CONFIG_API_URL = this.getConfigApiUrl(this.runtimeConfig.isProd), this.DEFAULT_JS_API_LIST = ["chooseImage", "uploadImage", "previewImage", "downloadImage", "getLocalImgData", "scanQRCode", "getLocation", "openLocation", "updateAppMessageShareData", "updateTimelineShareData"], this.DEFAULT_OPEN_TAG_LIST = ["wx-open-launch-weapp", "wx-open-launch-app"], this.handleConfigSuccess = this.handleConfigSuccess.bind(this), this.handleConfigError = this.handleConfigError.bind(this);
|
|
737
737
|
}
|
|
738
738
|
configure(e = {}) {
|
|
739
739
|
if (!e || typeof e != "object" || Array.isArray(e))
|
|
740
|
-
throw new
|
|
741
|
-
|
|
740
|
+
throw new N(
|
|
741
|
+
x.INVALID_PARAMETERS,
|
|
742
742
|
"config参数异常",
|
|
743
743
|
{ config: e }
|
|
744
744
|
);
|
|
745
745
|
if (!Object.prototype.hasOwnProperty.call(e, "clientId"))
|
|
746
746
|
throw this.createMissingClientIdError();
|
|
747
747
|
if (typeof e.clientId != "string" || !e.clientId.trim())
|
|
748
|
-
throw new
|
|
749
|
-
|
|
748
|
+
throw new N(
|
|
749
|
+
x.INVALID_PARAMETERS,
|
|
750
750
|
"clientId参数异常",
|
|
751
751
|
{ clientId: e.clientId }
|
|
752
752
|
);
|
|
753
753
|
if (Object.prototype.hasOwnProperty.call(e, "isProd") && typeof e.isProd != "boolean")
|
|
754
|
-
throw new
|
|
755
|
-
|
|
754
|
+
throw new N(
|
|
755
|
+
x.INVALID_PARAMETERS,
|
|
756
756
|
"isProd参数异常",
|
|
757
757
|
{ isProd: e.isProd }
|
|
758
758
|
);
|
|
759
759
|
const r = e.clientId.trim(), n = e.isProd === !0, i = r !== this.runtimeConfig.clientId || n !== this.runtimeConfig.isProd;
|
|
760
|
-
return this.runtimeConfig =
|
|
760
|
+
return this.runtimeConfig = m(g({}, this.runtimeConfig), {
|
|
761
761
|
clientId: r,
|
|
762
762
|
isProd: n
|
|
763
|
-
}), this.CONFIG_API_URL = this.getConfigApiUrl(n), (this.state ===
|
|
763
|
+
}), this.CONFIG_API_URL = this.getConfigApiUrl(n), (this.state === S.ERROR || i && (this.state === S.CONFIGURING || this.state === S.CONFIGURED)) && this.reset(), w.info("Updated Weixin runtime config", {
|
|
764
764
|
clientId: this.runtimeConfig.clientId,
|
|
765
765
|
isProd: this.runtimeConfig.isProd,
|
|
766
766
|
configApiUrl: this.CONFIG_API_URL
|
|
767
767
|
}), this.getRuntimeConfig();
|
|
768
768
|
}
|
|
769
769
|
getRuntimeConfig() {
|
|
770
|
-
return
|
|
770
|
+
return g({}, this.runtimeConfig);
|
|
771
771
|
}
|
|
772
772
|
hasClientId() {
|
|
773
773
|
return typeof this.runtimeConfig.clientId == "string" && this.runtimeConfig.clientId.length > 0;
|
|
@@ -776,8 +776,8 @@ class rr {
|
|
|
776
776
|
return this.isTestMode() || this.hasClientId();
|
|
777
777
|
}
|
|
778
778
|
createMissingClientIdError() {
|
|
779
|
-
return new
|
|
780
|
-
|
|
779
|
+
return new N(
|
|
780
|
+
x.INVALID_PARAMETERS,
|
|
781
781
|
"clientId错误",
|
|
782
782
|
{ field: "clientId" }
|
|
783
783
|
);
|
|
@@ -807,7 +807,7 @@ class rr {
|
|
|
807
807
|
* @private
|
|
808
808
|
*/
|
|
809
809
|
fetchWeixinConfig() {
|
|
810
|
-
return
|
|
810
|
+
return h(this, null, function* () {
|
|
811
811
|
const e = this.getCurrentPageUrl();
|
|
812
812
|
if (this.isTestMode())
|
|
813
813
|
return w.info("使用测试模式,返回模拟配置"), this.getMockConfig();
|
|
@@ -831,8 +831,8 @@ class rr {
|
|
|
831
831
|
} catch (i) {
|
|
832
832
|
if (w.error("获取微信配置失败", i), this.shouldUseTestMode(i))
|
|
833
833
|
return w.warn("网络请求失败,降级到测试模式"), this.getMockConfig();
|
|
834
|
-
throw new
|
|
835
|
-
|
|
834
|
+
throw new N(
|
|
835
|
+
x.NETWORK_ERROR,
|
|
836
836
|
`获取微信配置失败: ${i.message}`,
|
|
837
837
|
{ url: n, originalError: i }
|
|
838
838
|
);
|
|
@@ -889,7 +889,7 @@ class rr {
|
|
|
889
889
|
}, 100);
|
|
890
890
|
return;
|
|
891
891
|
}
|
|
892
|
-
if (
|
|
892
|
+
if (!k())
|
|
893
893
|
throw new Error("微信JS-SDK未加载");
|
|
894
894
|
const r = {
|
|
895
895
|
debug: !1,
|
|
@@ -908,13 +908,13 @@ class rr {
|
|
|
908
908
|
* @private
|
|
909
909
|
*/
|
|
910
910
|
handleConfigSuccess() {
|
|
911
|
-
w.info("微信配置成功"), this.state =
|
|
911
|
+
w.info("微信配置成功"), this.state = S.CONFIGURED, this.lastError = null, this.configPromise = null;
|
|
912
912
|
const e = [...this.readyCallbacks];
|
|
913
913
|
this.readyCallbacks = [], this.errorCallbacks = [], e.forEach((r) => {
|
|
914
914
|
try {
|
|
915
915
|
r();
|
|
916
916
|
} catch (n) {
|
|
917
|
-
|
|
917
|
+
f.handleApiError(n, { context: "WeixinConfigManager.handleConfigSuccess" });
|
|
918
918
|
}
|
|
919
919
|
});
|
|
920
920
|
}
|
|
@@ -926,18 +926,18 @@ class rr {
|
|
|
926
926
|
handleConfigError(e) {
|
|
927
927
|
const r = `微信配置验证失败: ${JSON.stringify(e)}`;
|
|
928
928
|
w.error(r, e);
|
|
929
|
-
const n = new
|
|
930
|
-
|
|
929
|
+
const n = new N(
|
|
930
|
+
x.API_CALL_FAILED,
|
|
931
931
|
r,
|
|
932
932
|
{ weixinErrorResponse: e }
|
|
933
933
|
);
|
|
934
|
-
this.state =
|
|
934
|
+
this.state = S.ERROR, this.lastError = n, this.configPromise = null;
|
|
935
935
|
const i = [...this.errorCallbacks];
|
|
936
936
|
this.readyCallbacks = [], this.errorCallbacks = [], i.forEach((a) => {
|
|
937
937
|
try {
|
|
938
938
|
a(n);
|
|
939
939
|
} catch (o) {
|
|
940
|
-
|
|
940
|
+
f.handleApiError(o, { context: "WeixinConfigManager.handleConfigError" });
|
|
941
941
|
}
|
|
942
942
|
});
|
|
943
943
|
}
|
|
@@ -946,8 +946,8 @@ class rr {
|
|
|
946
946
|
* @returns {Promise<void>} 配置完成的Promise
|
|
947
947
|
*/
|
|
948
948
|
autoConfig() {
|
|
949
|
-
return
|
|
950
|
-
return this.hasRequiredConfig() ? this.state ===
|
|
949
|
+
return h(this, null, function* () {
|
|
950
|
+
return this.hasRequiredConfig() ? this.state === S.CONFIGURED ? Promise.resolve() : this.state === S.ERROR ? Promise.reject(this.lastError) : this.configPromise ? this.configPromise : (this.state = S.CONFIGURING, this.configPromise = this.performAutoConfig(), this.configPromise) : (w.warn("clientId为空,等待qsh.config({ clientId })"), Promise.resolve());
|
|
951
951
|
});
|
|
952
952
|
}
|
|
953
953
|
/**
|
|
@@ -956,33 +956,33 @@ class rr {
|
|
|
956
956
|
* @private
|
|
957
957
|
*/
|
|
958
958
|
performAutoConfig() {
|
|
959
|
-
return
|
|
959
|
+
return h(this, null, function* () {
|
|
960
960
|
try {
|
|
961
961
|
if (typeof window == "undefined")
|
|
962
962
|
throw new Error("非浏览器环境无法执行微信配置");
|
|
963
|
-
if (
|
|
963
|
+
if (!k())
|
|
964
964
|
throw new Error("微信JS-SDK未加载,无法执行配置");
|
|
965
965
|
const e = yield this.fetchWeixinConfig();
|
|
966
966
|
return this.executeWeixinConfig(e), yield new Promise((r, n) => {
|
|
967
|
-
if (this.state ===
|
|
967
|
+
if (this.state === S.CONFIGURED) {
|
|
968
968
|
r();
|
|
969
969
|
return;
|
|
970
970
|
}
|
|
971
|
-
if (this.state ===
|
|
971
|
+
if (this.state === S.ERROR) {
|
|
972
972
|
n(this.lastError);
|
|
973
973
|
return;
|
|
974
974
|
}
|
|
975
975
|
this.readyCallbacks.push(r), this.errorCallbacks.push(n);
|
|
976
976
|
});
|
|
977
977
|
} catch (e) {
|
|
978
|
-
const r = e instanceof
|
|
979
|
-
this.state =
|
|
978
|
+
const r = e instanceof N ? e : f.handleApiError(e, { context: "WeixinConfigManager.performAutoConfig" });
|
|
979
|
+
this.state = S.ERROR, this.lastError = r, this.configPromise = null;
|
|
980
980
|
const n = [...this.errorCallbacks];
|
|
981
981
|
throw this.readyCallbacks = [], this.errorCallbacks = [], n.forEach((i) => {
|
|
982
982
|
try {
|
|
983
983
|
i(r);
|
|
984
984
|
} catch (a) {
|
|
985
|
-
|
|
985
|
+
f.handleApiError(a, { context: "WeixinConfigManager.performAutoConfig.errorCallback" });
|
|
986
986
|
}
|
|
987
987
|
}), r;
|
|
988
988
|
}
|
|
@@ -993,7 +993,7 @@ class rr {
|
|
|
993
993
|
* @returns {Promise<void>} 配置完成的Promise
|
|
994
994
|
*/
|
|
995
995
|
waitForReady() {
|
|
996
|
-
return this.state ===
|
|
996
|
+
return this.state === S.CONFIGURED ? Promise.resolve() : this.state === S.ERROR ? Promise.reject(this.lastError) : this.hasRequiredConfig() ? this.state === S.UNINITIALIZED ? this.autoConfig() : new Promise((e, r) => {
|
|
997
997
|
this.readyCallbacks.push(e), this.errorCallbacks.push(r);
|
|
998
998
|
}) : Promise.reject(this.createMissingClientIdError());
|
|
999
999
|
}
|
|
@@ -1002,7 +1002,7 @@ class rr {
|
|
|
1002
1002
|
* @returns {boolean} 是否已配置
|
|
1003
1003
|
*/
|
|
1004
1004
|
isReady() {
|
|
1005
|
-
return this.state ===
|
|
1005
|
+
return this.state === S.CONFIGURED;
|
|
1006
1006
|
}
|
|
1007
1007
|
/**
|
|
1008
1008
|
* 获取当前状态
|
|
@@ -1022,7 +1022,7 @@ class rr {
|
|
|
1022
1022
|
* 重置配置管理器(用于重试或测试)
|
|
1023
1023
|
*/
|
|
1024
1024
|
reset() {
|
|
1025
|
-
this.state =
|
|
1025
|
+
this.state = S.UNINITIALIZED, this.configPromise = null, this.readyCallbacks = [], this.errorCallbacks = [], this.lastError = null, w.debug("微信配置管理器已重置");
|
|
1026
1026
|
}
|
|
1027
1027
|
/**
|
|
1028
1028
|
* 获取配置统计信息
|
|
@@ -1043,129 +1043,129 @@ class rr {
|
|
|
1043
1043
|
};
|
|
1044
1044
|
}
|
|
1045
1045
|
}
|
|
1046
|
-
const
|
|
1047
|
-
let
|
|
1048
|
-
function
|
|
1046
|
+
const b = new fr();
|
|
1047
|
+
let re = !1, ge = !1, U = null, _e = !1;
|
|
1048
|
+
function dr(t) {
|
|
1049
1049
|
return new Promise((e) => {
|
|
1050
1050
|
let r = !1, n = null;
|
|
1051
|
-
const i = (
|
|
1051
|
+
const i = (u) => h(null, null, function* () {
|
|
1052
1052
|
if (!r) {
|
|
1053
|
-
if (r = !0, n && clearTimeout(n),
|
|
1053
|
+
if (r = !0, n && clearTimeout(n), re = !1, ge = u, u)
|
|
1054
1054
|
try {
|
|
1055
|
-
yield
|
|
1056
|
-
} catch (
|
|
1057
|
-
w.error("微信配置失败,将使用消息桥作为后备",
|
|
1055
|
+
yield ct();
|
|
1056
|
+
} catch (d) {
|
|
1057
|
+
w.error("微信配置失败,将使用消息桥作为后备", d);
|
|
1058
1058
|
}
|
|
1059
1059
|
e();
|
|
1060
1060
|
}
|
|
1061
|
-
}), a = () => i(
|
|
1061
|
+
}), a = () => i(k()), o = () => {
|
|
1062
1062
|
w.warn("已存在的微信 JS-SDK 脚本加载失败,SDK 将使用消息桥作为后备"), i(!1);
|
|
1063
1063
|
};
|
|
1064
1064
|
t.addEventListener("load", a, { once: !0 }), t.addEventListener("error", o, { once: !0 }), setTimeout(() => {
|
|
1065
|
-
|
|
1065
|
+
k() && a();
|
|
1066
1066
|
}, 0), n = setTimeout(() => {
|
|
1067
|
-
i(
|
|
1067
|
+
i(k());
|
|
1068
1068
|
}, 3e3);
|
|
1069
1069
|
});
|
|
1070
1070
|
}
|
|
1071
|
-
function
|
|
1072
|
-
return
|
|
1071
|
+
function Be() {
|
|
1072
|
+
return h(this, arguments, function* (t = {}) {
|
|
1073
1073
|
const { force: e = !1, recoverFromError: r = !1 } = t;
|
|
1074
|
-
if (yield
|
|
1074
|
+
if (yield ut({ force: e }), !k())
|
|
1075
1075
|
throw new Error("微信 JS-SDK 未正确加载,无法执行配置");
|
|
1076
|
-
r &&
|
|
1076
|
+
r && pr();
|
|
1077
1077
|
});
|
|
1078
1078
|
}
|
|
1079
|
-
function
|
|
1079
|
+
function gr(t = !1) {
|
|
1080
1080
|
if (typeof window == "undefined") return !1;
|
|
1081
|
-
if (
|
|
1082
|
-
return
|
|
1083
|
-
if (
|
|
1081
|
+
if (k())
|
|
1082
|
+
return ge = !0, !1;
|
|
1083
|
+
if (ge || Q()) return !1;
|
|
1084
1084
|
if (t) return !0;
|
|
1085
1085
|
const e = navigator.userAgent || "", r = /micromessenger/i.test(e), n = /miniProgram/i.test(e), i = typeof window.__wxjs_environment != "undefined" && window.__wxjs_environment === "miniprogram", a = !!(window.wx && window.wx.miniProgram);
|
|
1086
1086
|
return r && (n || i || a);
|
|
1087
1087
|
}
|
|
1088
|
-
function
|
|
1089
|
-
|
|
1088
|
+
function pr() {
|
|
1089
|
+
b.getState() === "error" && (b.reset(), _e = !1);
|
|
1090
1090
|
}
|
|
1091
|
-
function
|
|
1092
|
-
return
|
|
1093
|
-
if (
|
|
1094
|
-
return
|
|
1095
|
-
|
|
1091
|
+
function ct() {
|
|
1092
|
+
return h(this, null, function* () {
|
|
1093
|
+
if (_e)
|
|
1094
|
+
return b.waitForReady();
|
|
1095
|
+
_e = !0, w.info("开始自动配置微信JS-SDK");
|
|
1096
1096
|
try {
|
|
1097
|
-
yield
|
|
1097
|
+
yield b.autoConfig(), w.info("微信JS-SDK自动配置完成");
|
|
1098
1098
|
} catch (t) {
|
|
1099
1099
|
w.error("微信JS-SDK自动配置失败", t);
|
|
1100
1100
|
}
|
|
1101
1101
|
});
|
|
1102
1102
|
}
|
|
1103
|
-
function
|
|
1103
|
+
function ut(t = {}) {
|
|
1104
1104
|
const { force: e = !1 } = t;
|
|
1105
1105
|
if (typeof window == "undefined")
|
|
1106
1106
|
return Promise.resolve();
|
|
1107
|
-
if (
|
|
1108
|
-
return
|
|
1107
|
+
if (k())
|
|
1108
|
+
return ge = !0, Promise.resolve();
|
|
1109
1109
|
const r = document.getElementById("weixin-jssdk");
|
|
1110
|
-
return r ?
|
|
1111
|
-
|
|
1112
|
-
}),
|
|
1113
|
-
|
|
1110
|
+
return r ? U || (re = !0, U = dr(r).finally(() => {
|
|
1111
|
+
U = null;
|
|
1112
|
+
}), U) : gr(e) ? U || (U = new Promise((n) => {
|
|
1113
|
+
re = !0;
|
|
1114
1114
|
try {
|
|
1115
1115
|
const i = document.createElement("script");
|
|
1116
1116
|
i.id = "weixin-jssdk", i.type = "text/javascript", i.async = !0, i.src = "https://res.wx.qq.com/open/js/jweixin-1.6.2.js", i.onload = function() {
|
|
1117
|
-
return
|
|
1118
|
-
|
|
1117
|
+
return h(this, null, function* () {
|
|
1118
|
+
ge = !0, re = !1, w.info("微信 JS-SDK 已自动加载");
|
|
1119
1119
|
try {
|
|
1120
|
-
yield
|
|
1120
|
+
yield ct();
|
|
1121
1121
|
} catch (o) {
|
|
1122
1122
|
w.error("微信配置失败,将使用消息桥作为后备", o);
|
|
1123
1123
|
}
|
|
1124
1124
|
n();
|
|
1125
1125
|
});
|
|
1126
1126
|
}, i.onerror = function() {
|
|
1127
|
-
|
|
1127
|
+
re = !1, w.warn("微信 JS-SDK 加载失败,SDK 将使用消息桥作为后备"), n();
|
|
1128
1128
|
}, (document.getElementsByTagName("head")[0] || document.documentElement).appendChild(i);
|
|
1129
1129
|
} catch (i) {
|
|
1130
|
-
|
|
1130
|
+
re = !1, w.error("注入微信 JS-SDK 失败", i), n();
|
|
1131
1131
|
}
|
|
1132
1132
|
}).finally(() => {
|
|
1133
|
-
|
|
1134
|
-
}),
|
|
1133
|
+
U = null;
|
|
1134
|
+
}), U) : Promise.resolve();
|
|
1135
1135
|
}
|
|
1136
|
-
function
|
|
1137
|
-
return
|
|
1136
|
+
function K() {
|
|
1137
|
+
return Be({ force: !0, recoverFromError: !0 }).then(() => b.waitForReady());
|
|
1138
1138
|
}
|
|
1139
|
-
function
|
|
1140
|
-
const e =
|
|
1141
|
-
return typeof window == "undefined" ||
|
|
1139
|
+
function Qe(t = {}) {
|
|
1140
|
+
const e = b.configure(t);
|
|
1141
|
+
return typeof window == "undefined" || Be({
|
|
1142
1142
|
force: !0,
|
|
1143
|
-
recoverFromError:
|
|
1143
|
+
recoverFromError: b.getState() === "error"
|
|
1144
1144
|
}).then(() => {
|
|
1145
|
-
if (!
|
|
1146
|
-
return
|
|
1145
|
+
if (!b.isReady())
|
|
1146
|
+
return b.waitForReady().catch((r) => {
|
|
1147
1147
|
w.error("Failed to auto-configure Weixin after qsh.config()", r);
|
|
1148
1148
|
});
|
|
1149
|
-
window.wx &&
|
|
1149
|
+
window.wx && !k() && w.warn("window.wx 已存在,但微信 JS-SDK 尚未就绪,跳过自动配置");
|
|
1150
1150
|
}).catch((r) => {
|
|
1151
1151
|
w.error("Failed to preload Weixin JS-SDK", r);
|
|
1152
1152
|
}), e;
|
|
1153
1153
|
}
|
|
1154
|
-
function
|
|
1155
|
-
return
|
|
1154
|
+
function j() {
|
|
1155
|
+
return b.isReady();
|
|
1156
1156
|
}
|
|
1157
|
-
function
|
|
1158
|
-
return
|
|
1157
|
+
function mr() {
|
|
1158
|
+
return b.getState();
|
|
1159
1159
|
}
|
|
1160
|
-
function
|
|
1161
|
-
return
|
|
1160
|
+
function xe() {
|
|
1161
|
+
return b;
|
|
1162
1162
|
}
|
|
1163
|
-
function
|
|
1164
|
-
return
|
|
1165
|
-
return w.info("手动重试微信配置"),
|
|
1163
|
+
function hr() {
|
|
1164
|
+
return h(this, null, function* () {
|
|
1165
|
+
return w.info("手动重试微信配置"), b.reset(), _e = !1, yield Be({ force: !0 }), b.waitForReady();
|
|
1166
1166
|
});
|
|
1167
1167
|
}
|
|
1168
|
-
class
|
|
1168
|
+
class wr {
|
|
1169
1169
|
constructor() {
|
|
1170
1170
|
this.plugins = /* @__PURE__ */ new Map(), this.installed = /* @__PURE__ */ new Set(), this.installOrder = [], s.debug("插件管理器已初始化");
|
|
1171
1171
|
}
|
|
@@ -1177,7 +1177,7 @@ class cr {
|
|
|
1177
1177
|
* pluginManager.register(imagePlugin)
|
|
1178
1178
|
*/
|
|
1179
1179
|
register(e) {
|
|
1180
|
-
return
|
|
1180
|
+
return f.safeExecute(() => {
|
|
1181
1181
|
this.validatePlugin(e);
|
|
1182
1182
|
const { name: r, version: n } = e;
|
|
1183
1183
|
if (this.plugins.has(r)) {
|
|
@@ -1217,8 +1217,8 @@ class cr {
|
|
|
1217
1217
|
* await pluginManager.install('image', qsh)
|
|
1218
1218
|
*/
|
|
1219
1219
|
install(e, r) {
|
|
1220
|
-
return
|
|
1221
|
-
return
|
|
1220
|
+
return h(this, null, function* () {
|
|
1221
|
+
return f.safeExecute(() => h(this, null, function* () {
|
|
1222
1222
|
if (!this.plugins.has(e))
|
|
1223
1223
|
throw new Error(`插件 ${e} 未注册`);
|
|
1224
1224
|
if (this.installed.has(e)) {
|
|
@@ -1247,8 +1247,8 @@ class cr {
|
|
|
1247
1247
|
* await pluginManager.uninstall('image', qsh)
|
|
1248
1248
|
*/
|
|
1249
1249
|
uninstall(e, r) {
|
|
1250
|
-
return
|
|
1251
|
-
return
|
|
1250
|
+
return h(this, null, function* () {
|
|
1251
|
+
return f.safeExecute(() => h(this, null, function* () {
|
|
1252
1252
|
if (!this.installed.has(e)) {
|
|
1253
1253
|
s.debug(`插件 ${e} 未安装,跳过卸载`);
|
|
1254
1254
|
return;
|
|
@@ -1269,7 +1269,7 @@ class cr {
|
|
|
1269
1269
|
* @returns {Promise<void>}
|
|
1270
1270
|
*/
|
|
1271
1271
|
uninstallAll(e) {
|
|
1272
|
-
return
|
|
1272
|
+
return h(this, null, function* () {
|
|
1273
1273
|
const r = [...this.installOrder].reverse();
|
|
1274
1274
|
for (const n of r)
|
|
1275
1275
|
yield this.uninstall(n, e);
|
|
@@ -1296,7 +1296,7 @@ class cr {
|
|
|
1296
1296
|
* await pluginManager.installAll(['image', 'location'], qsh)
|
|
1297
1297
|
*/
|
|
1298
1298
|
installAll(e, r) {
|
|
1299
|
-
return
|
|
1299
|
+
return h(this, null, function* () {
|
|
1300
1300
|
if (!Array.isArray(e))
|
|
1301
1301
|
throw new Error("names 必须是数组");
|
|
1302
1302
|
for (const n of e)
|
|
@@ -1358,8 +1358,8 @@ class cr {
|
|
|
1358
1358
|
this.plugins.clear(), this.installed.clear(), this.installOrder = [];
|
|
1359
1359
|
}
|
|
1360
1360
|
}
|
|
1361
|
-
const
|
|
1362
|
-
class
|
|
1361
|
+
const le = new wr();
|
|
1362
|
+
class Er {
|
|
1363
1363
|
constructor() {
|
|
1364
1364
|
this.requestInterceptors = [], this.responseInterceptors = [], s.debug("拦截器链已初始化");
|
|
1365
1365
|
}
|
|
@@ -1418,8 +1418,8 @@ class ur {
|
|
|
1418
1418
|
* @private
|
|
1419
1419
|
*/
|
|
1420
1420
|
runRequest(e) {
|
|
1421
|
-
return
|
|
1422
|
-
let r =
|
|
1421
|
+
return h(this, null, function* () {
|
|
1422
|
+
let r = g({}, e);
|
|
1423
1423
|
for (const { fn: n } of this.requestInterceptors) {
|
|
1424
1424
|
if (r.abort) {
|
|
1425
1425
|
s.debug("请求被中止", { apiName: r.apiName });
|
|
@@ -1444,7 +1444,7 @@ class ur {
|
|
|
1444
1444
|
* @private
|
|
1445
1445
|
*/
|
|
1446
1446
|
runResponse(e, r) {
|
|
1447
|
-
return
|
|
1447
|
+
return h(this, null, function* () {
|
|
1448
1448
|
let n = e;
|
|
1449
1449
|
for (const { fn: i } of this.responseInterceptors)
|
|
1450
1450
|
try {
|
|
@@ -1473,7 +1473,7 @@ class ur {
|
|
|
1473
1473
|
};
|
|
1474
1474
|
}
|
|
1475
1475
|
}
|
|
1476
|
-
const
|
|
1476
|
+
const Y = new Er(), yr = {
|
|
1477
1477
|
/**
|
|
1478
1478
|
* 请求日志
|
|
1479
1479
|
*/
|
|
@@ -1490,7 +1490,7 @@ const j = new ur(), lr = {
|
|
|
1490
1490
|
success: t == null ? void 0 : t.success
|
|
1491
1491
|
}), t;
|
|
1492
1492
|
}
|
|
1493
|
-
},
|
|
1493
|
+
}, G = {
|
|
1494
1494
|
// 性能数据存储
|
|
1495
1495
|
metrics: /* @__PURE__ */ new Map(),
|
|
1496
1496
|
/**
|
|
@@ -1502,14 +1502,14 @@ const j = new ur(), lr = {
|
|
|
1502
1502
|
*/
|
|
1503
1503
|
response: (t, e) => {
|
|
1504
1504
|
const r = performance.now() - e.perfStartTime;
|
|
1505
|
-
|
|
1505
|
+
G.metrics.has(e.apiName) || G.metrics.set(e.apiName, {
|
|
1506
1506
|
count: 0,
|
|
1507
1507
|
totalTime: 0,
|
|
1508
1508
|
minTime: 1 / 0,
|
|
1509
1509
|
maxTime: 0,
|
|
1510
1510
|
avgTime: 0
|
|
1511
1511
|
});
|
|
1512
|
-
const n =
|
|
1512
|
+
const n = G.metrics.get(e.apiName);
|
|
1513
1513
|
return n.count++, n.totalTime += r, n.minTime = Math.min(n.minTime, r), n.maxTime = Math.max(n.maxTime, r), n.avgTime = n.totalTime / n.count, t;
|
|
1514
1514
|
},
|
|
1515
1515
|
/**
|
|
@@ -1517,30 +1517,30 @@ const j = new ur(), lr = {
|
|
|
1517
1517
|
*/
|
|
1518
1518
|
getReport: () => {
|
|
1519
1519
|
const t = {};
|
|
1520
|
-
return
|
|
1521
|
-
t[r] =
|
|
1520
|
+
return G.metrics.forEach((e, r) => {
|
|
1521
|
+
t[r] = g({}, e);
|
|
1522
1522
|
}), t;
|
|
1523
1523
|
},
|
|
1524
1524
|
/**
|
|
1525
1525
|
* 清空性能数据
|
|
1526
1526
|
*/
|
|
1527
1527
|
clearMetrics: () => {
|
|
1528
|
-
|
|
1528
|
+
G.metrics.clear();
|
|
1529
1529
|
}
|
|
1530
1530
|
};
|
|
1531
|
-
function
|
|
1531
|
+
function Ir(t = {}) {
|
|
1532
1532
|
const {
|
|
1533
1533
|
maxRetries: e = 3,
|
|
1534
1534
|
retryDelay: r = 1e3,
|
|
1535
1535
|
shouldRetry: n = (i) => !i.success
|
|
1536
1536
|
} = t;
|
|
1537
1537
|
return {
|
|
1538
|
-
response: (i, a) =>
|
|
1538
|
+
response: (i, a) => h(null, null, function* () {
|
|
1539
1539
|
return a.retryCount || (a.retryCount = 0), n(i) && a.retryCount < e && (a.retryCount++, s.warn(`API 调用失败,第 ${a.retryCount} 次重试: ${a.apiName}`), yield new Promise((o) => setTimeout(o, r)), i.shouldRetry = !0, i.retryContext = a), i;
|
|
1540
1540
|
})
|
|
1541
1541
|
};
|
|
1542
1542
|
}
|
|
1543
|
-
function
|
|
1543
|
+
function Ar(t = {}) {
|
|
1544
1544
|
return {
|
|
1545
1545
|
request: (e) => {
|
|
1546
1546
|
const r = t[e.apiName];
|
|
@@ -1552,7 +1552,7 @@ function dr(t = {}) {
|
|
|
1552
1552
|
}
|
|
1553
1553
|
};
|
|
1554
1554
|
}
|
|
1555
|
-
class
|
|
1555
|
+
class Or {
|
|
1556
1556
|
constructor() {
|
|
1557
1557
|
this.state = {
|
|
1558
1558
|
// SDK 状态
|
|
@@ -1597,7 +1597,7 @@ class gr {
|
|
|
1597
1597
|
api: {
|
|
1598
1598
|
// 格式: { apiName: { loading: boolean, lastCall: timestamp, lastResult: any } }
|
|
1599
1599
|
}
|
|
1600
|
-
}, this.listeners = /* @__PURE__ */ new Map(), this.wildcardListeners = /* @__PURE__ */ new Set(), this.initNetworkListener(),
|
|
1600
|
+
}, this.listeners = /* @__PURE__ */ new Map(), this.wildcardListeners = /* @__PURE__ */ new Set(), this.initNetworkListener(), D.debug("状态仓库已初始化");
|
|
1601
1601
|
}
|
|
1602
1602
|
/**
|
|
1603
1603
|
* 获取状态值
|
|
@@ -1619,8 +1619,8 @@ class gr {
|
|
|
1619
1619
|
* store.set('network.online', false)
|
|
1620
1620
|
*/
|
|
1621
1621
|
set(e, r) {
|
|
1622
|
-
const n = e.split("."), i = n.pop(), a = n.reduce((
|
|
1623
|
-
o !== r && (a[i] = r,
|
|
1622
|
+
const n = e.split("."), i = n.pop(), a = n.reduce((u, d) => ((!u[d] || typeof u[d] != "object") && (u[d] = {}), u[d]), this.state), o = a[i];
|
|
1623
|
+
o !== r && (a[i] = r, D.debug(`状态已更新: ${e}`, { oldValue: o, newValue: r }), this.notify(e, r, o));
|
|
1624
1624
|
}
|
|
1625
1625
|
/**
|
|
1626
1626
|
* 批量更新状态
|
|
@@ -1651,11 +1651,11 @@ class gr {
|
|
|
1651
1651
|
subscribe(e, r) {
|
|
1652
1652
|
if (typeof r != "function")
|
|
1653
1653
|
throw new Error("listener 必须是函数");
|
|
1654
|
-
return e === "*" ? (this.wildcardListeners.add(r),
|
|
1655
|
-
this.wildcardListeners.delete(r),
|
|
1656
|
-
}) : (this.listeners.has(e) || this.listeners.set(e, /* @__PURE__ */ new Set()), this.listeners.get(e).add(r),
|
|
1654
|
+
return e === "*" ? (this.wildcardListeners.add(r), D.debug("添加通配符订阅者"), () => {
|
|
1655
|
+
this.wildcardListeners.delete(r), D.debug("移除通配符订阅者");
|
|
1656
|
+
}) : (this.listeners.has(e) || this.listeners.set(e, /* @__PURE__ */ new Set()), this.listeners.get(e).add(r), D.debug(`添加订阅者: ${e}`), () => {
|
|
1657
1657
|
const n = this.listeners.get(e);
|
|
1658
|
-
n && (n.delete(r), n.size === 0 && this.listeners.delete(e),
|
|
1658
|
+
n && (n.delete(r), n.size === 0 && this.listeners.delete(e), D.debug(`移除订阅者: ${e}`));
|
|
1659
1659
|
});
|
|
1660
1660
|
}
|
|
1661
1661
|
/**
|
|
@@ -1682,20 +1682,20 @@ class gr {
|
|
|
1682
1682
|
i && i.forEach((o) => {
|
|
1683
1683
|
try {
|
|
1684
1684
|
o(r, n, e);
|
|
1685
|
-
} catch (
|
|
1686
|
-
|
|
1685
|
+
} catch (u) {
|
|
1686
|
+
D.error("订阅者执行失败", u);
|
|
1687
1687
|
}
|
|
1688
1688
|
});
|
|
1689
1689
|
const a = e.split(".");
|
|
1690
1690
|
for (let o = 1; o < a.length; o++) {
|
|
1691
|
-
const
|
|
1692
|
-
if (
|
|
1693
|
-
const O = this.get(
|
|
1694
|
-
|
|
1691
|
+
const u = a.slice(0, o).join("."), d = this.listeners.get(u);
|
|
1692
|
+
if (d) {
|
|
1693
|
+
const O = this.get(u);
|
|
1694
|
+
d.forEach((R) => {
|
|
1695
1695
|
try {
|
|
1696
|
-
|
|
1697
|
-
} catch (
|
|
1698
|
-
|
|
1696
|
+
R(O, void 0, u);
|
|
1697
|
+
} catch (_) {
|
|
1698
|
+
D.error("父路径订阅者执行失败", _);
|
|
1699
1699
|
}
|
|
1700
1700
|
});
|
|
1701
1701
|
}
|
|
@@ -1703,8 +1703,8 @@ class gr {
|
|
|
1703
1703
|
this.wildcardListeners.forEach((o) => {
|
|
1704
1704
|
try {
|
|
1705
1705
|
o(r, n, e);
|
|
1706
|
-
} catch (
|
|
1707
|
-
|
|
1706
|
+
} catch (u) {
|
|
1707
|
+
D.error("通配符订阅者执行失败", u);
|
|
1708
1708
|
}
|
|
1709
1709
|
});
|
|
1710
1710
|
}
|
|
@@ -1730,7 +1730,7 @@ class gr {
|
|
|
1730
1730
|
*/
|
|
1731
1731
|
setApiLoading(e, r = !0) {
|
|
1732
1732
|
const n = `api.${e}`, i = this.get(n) || {};
|
|
1733
|
-
this.set(n,
|
|
1733
|
+
this.set(n, m(g({}, i), {
|
|
1734
1734
|
loading: r,
|
|
1735
1735
|
lastCall: r ? Date.now() : i.lastCall
|
|
1736
1736
|
}));
|
|
@@ -1742,7 +1742,7 @@ class gr {
|
|
|
1742
1742
|
*/
|
|
1743
1743
|
setApiResult(e, r) {
|
|
1744
1744
|
const n = `api.${e}`, i = this.get(n) || {};
|
|
1745
|
-
this.set(n,
|
|
1745
|
+
this.set(n, m(g({}, i), {
|
|
1746
1746
|
loading: !1,
|
|
1747
1747
|
lastResult: r,
|
|
1748
1748
|
lastCallEnd: Date.now()
|
|
@@ -1783,7 +1783,7 @@ class gr {
|
|
|
1783
1783
|
album: "prompt"
|
|
1784
1784
|
},
|
|
1785
1785
|
api: {}
|
|
1786
|
-
},
|
|
1786
|
+
}, D.debug("状态已重置");
|
|
1787
1787
|
}
|
|
1788
1788
|
/**
|
|
1789
1789
|
* 获取统计信息
|
|
@@ -1797,7 +1797,7 @@ class gr {
|
|
|
1797
1797
|
};
|
|
1798
1798
|
}
|
|
1799
1799
|
}
|
|
1800
|
-
const
|
|
1800
|
+
const $ = new Or(), c = {
|
|
1801
1801
|
// SDK 核心错误 (E_SDK_xxx)
|
|
1802
1802
|
SDK_NOT_READY: "E_SDK_001",
|
|
1803
1803
|
SDK_INIT_FAILED: "E_SDK_002",
|
|
@@ -1848,7 +1848,7 @@ const W = new gr(), c = {
|
|
|
1848
1848
|
API_TIMEOUT: "E_TIMEOUT_001",
|
|
1849
1849
|
// 通用错误
|
|
1850
1850
|
UNKNOWN_ERROR: "E_UNKNOWN_999"
|
|
1851
|
-
},
|
|
1851
|
+
}, ve = {
|
|
1852
1852
|
// SDK 核心
|
|
1853
1853
|
[c.SDK_NOT_READY]: "SDK 未就绪",
|
|
1854
1854
|
[c.SDK_INIT_FAILED]: "SDK 初始化失败",
|
|
@@ -1889,7 +1889,7 @@ const W = new gr(), c = {
|
|
|
1889
1889
|
[c.API_TIMEOUT]: "API 调用超时",
|
|
1890
1890
|
// 通用
|
|
1891
1891
|
[c.UNKNOWN_ERROR]: "未知错误"
|
|
1892
|
-
},
|
|
1892
|
+
}, W = {
|
|
1893
1893
|
USER_CANCEL: "user_cancel",
|
|
1894
1894
|
// 用户主动取消
|
|
1895
1895
|
PERMISSION: "permission",
|
|
@@ -1904,7 +1904,7 @@ const W = new gr(), c = {
|
|
|
1904
1904
|
// 配置问题
|
|
1905
1905
|
UNKNOWN: "unknown"
|
|
1906
1906
|
// 未知问题
|
|
1907
|
-
},
|
|
1907
|
+
}, _r = {
|
|
1908
1908
|
// 图片相关
|
|
1909
1909
|
"IMAGE/USER_CANCEL": c.IMAGE_CANCELLED,
|
|
1910
1910
|
"IMAGE/PERMISSION_DENIED": c.IMAGE_NO_PERMISSION,
|
|
@@ -1912,7 +1912,7 @@ const W = new gr(), c = {
|
|
|
1912
1912
|
"COMMON/UNKNOWN": c.UNKNOWN_ERROR,
|
|
1913
1913
|
"COMMON/CONFIG_NOT_READY": c.IMAGE_CONFIG_NOT_READY,
|
|
1914
1914
|
"COMMON/PLATFORM_NOT_SUPPORTED": c.PLATFORM_NOT_SUPPORTED
|
|
1915
|
-
},
|
|
1915
|
+
}, et = {
|
|
1916
1916
|
// 微信平台错误模式
|
|
1917
1917
|
weixin: {
|
|
1918
1918
|
patterns: [
|
|
@@ -1946,7 +1946,7 @@ const W = new gr(), c = {
|
|
|
1946
1946
|
],
|
|
1947
1947
|
default: c.UNKNOWN_ERROR
|
|
1948
1948
|
}
|
|
1949
|
-
},
|
|
1949
|
+
}, tt = {
|
|
1950
1950
|
chooseImage: {
|
|
1951
1951
|
"fail cancel": c.IMAGE_CANCELLED,
|
|
1952
1952
|
"fail auth deny": c.IMAGE_NO_PERMISSION,
|
|
@@ -1960,17 +1960,17 @@ const W = new gr(), c = {
|
|
|
1960
1960
|
NOT_IN_CONTAINER: c.PLATFORM_NOT_SUPPORTED
|
|
1961
1961
|
}
|
|
1962
1962
|
};
|
|
1963
|
-
function
|
|
1964
|
-
return t ? t.includes("CANCEL") ?
|
|
1963
|
+
function lt(t) {
|
|
1964
|
+
return t ? t.includes("CANCEL") ? W.USER_CANCEL : t.includes("PERM") || t.includes("PERMISSION") ? W.PERMISSION : t.includes("NET") || t.includes("NETWORK") ? W.NETWORK : t.includes("PARAM") ? W.PARAM : t.includes("CONFIG") ? W.CONFIG : t.includes("SDK") || t.includes("PLATFORM") ? W.SYSTEM : W.UNKNOWN : W.UNKNOWN;
|
|
1965
1965
|
}
|
|
1966
|
-
function
|
|
1966
|
+
function Cr(t) {
|
|
1967
1967
|
return t.includes("NET_") || t.includes("TIMEOUT") || t === c.NETWORK_ERROR || t === c.NETWORK_TIMEOUT || t === c.API_TIMEOUT;
|
|
1968
1968
|
}
|
|
1969
|
-
function
|
|
1970
|
-
return t.includes("CANCEL") ||
|
|
1969
|
+
function Pr(t) {
|
|
1970
|
+
return t.includes("CANCEL") || lt(t) === W.USER_CANCEL;
|
|
1971
1971
|
}
|
|
1972
|
-
function
|
|
1973
|
-
return
|
|
1972
|
+
function ne(t) {
|
|
1973
|
+
return ve[t] || ve[c.UNKNOWN_ERROR];
|
|
1974
1974
|
}
|
|
1975
1975
|
class F extends Error {
|
|
1976
1976
|
/**
|
|
@@ -1980,7 +1980,7 @@ class F extends Error {
|
|
|
1980
1980
|
* @param {Object} options - 选项
|
|
1981
1981
|
*/
|
|
1982
1982
|
constructor(e, r, n = {}) {
|
|
1983
|
-
super(r), this.name = "StandardError", this.code = e, this.message = r ||
|
|
1983
|
+
super(r), this.name = "StandardError", this.code = e, this.message = r || ne(e), this.platform = n.platform || l.type, this.apiName = n.apiName, this.category = n.category || lt(e), this.retriable = n.retriable !== void 0 ? n.retriable : Cr(e), this.originalError = n.originalError, this.details = n.details || {}, this.timestamp = Date.now();
|
|
1984
1984
|
}
|
|
1985
1985
|
/**
|
|
1986
1986
|
* 是否可重试
|
|
@@ -1994,14 +1994,14 @@ class F extends Error {
|
|
|
1994
1994
|
* @returns {boolean}
|
|
1995
1995
|
*/
|
|
1996
1996
|
isUserAction() {
|
|
1997
|
-
return
|
|
1997
|
+
return Pr(this.code);
|
|
1998
1998
|
}
|
|
1999
1999
|
/**
|
|
2000
2000
|
* 转为普通对象
|
|
2001
2001
|
* @returns {Object}
|
|
2002
2002
|
*/
|
|
2003
2003
|
toJSON() {
|
|
2004
|
-
return
|
|
2004
|
+
return g({
|
|
2005
2005
|
code: this.code,
|
|
2006
2006
|
message: this.message,
|
|
2007
2007
|
platform: this.platform,
|
|
@@ -2015,11 +2015,11 @@ class F extends Error {
|
|
|
2015
2015
|
} : {});
|
|
2016
2016
|
}
|
|
2017
2017
|
}
|
|
2018
|
-
function
|
|
2018
|
+
function ft(t, e = {}) {
|
|
2019
2019
|
if (t instanceof F)
|
|
2020
2020
|
return t;
|
|
2021
2021
|
const { apiName: r, platform: n = l.type } = e;
|
|
2022
|
-
return t && typeof t.code == "string" && t.code.includes("/") ?
|
|
2022
|
+
return t && typeof t.code == "string" && t.code.includes("/") ? Sr(t, { apiName: r, platform: n }) : t && (t.errMsg || t.message) ? Nr(t, { apiName: r, platform: n }) : typeof t == "string" ? new F(
|
|
2023
2023
|
c.UNKNOWN_ERROR,
|
|
2024
2024
|
t,
|
|
2025
2025
|
{ apiName: r, platform: n, originalError: t }
|
|
@@ -2034,41 +2034,41 @@ function et(t, e = {}) {
|
|
|
2034
2034
|
}
|
|
2035
2035
|
);
|
|
2036
2036
|
}
|
|
2037
|
-
function
|
|
2038
|
-
const { apiName: r, platform: n } = e, i = t.code, a =
|
|
2037
|
+
function Sr(t, e) {
|
|
2038
|
+
const { apiName: r, platform: n } = e, i = t.code, a = _r[i] || c.UNKNOWN_ERROR;
|
|
2039
2039
|
return s.debug("转换旧版错误码", {
|
|
2040
2040
|
legacy: i,
|
|
2041
2041
|
new: a
|
|
2042
2042
|
}), new F(
|
|
2043
2043
|
a,
|
|
2044
|
-
t.message ||
|
|
2044
|
+
t.message || ne(a),
|
|
2045
2045
|
{
|
|
2046
2046
|
apiName: r,
|
|
2047
2047
|
platform: t.platform || n,
|
|
2048
2048
|
originalError: t,
|
|
2049
|
-
details:
|
|
2049
|
+
details: g({
|
|
2050
2050
|
legacyCode: i,
|
|
2051
2051
|
legacyVersion: t.version
|
|
2052
2052
|
}, t.details)
|
|
2053
2053
|
}
|
|
2054
2054
|
);
|
|
2055
2055
|
}
|
|
2056
|
-
function
|
|
2056
|
+
function Nr(t, e) {
|
|
2057
2057
|
const { apiName: r, platform: n } = e, i = (t.errMsg || t.message || "").toLowerCase();
|
|
2058
|
-
if (r &&
|
|
2059
|
-
const
|
|
2060
|
-
for (const [
|
|
2061
|
-
if (i.includes(
|
|
2062
|
-
return new F(O,
|
|
2058
|
+
if (r && tt[r]) {
|
|
2059
|
+
const u = tt[r];
|
|
2060
|
+
for (const [d, O] of Object.entries(u))
|
|
2061
|
+
if (i.includes(d.toLowerCase()))
|
|
2062
|
+
return new F(O, ne(O), {
|
|
2063
2063
|
apiName: r,
|
|
2064
2064
|
platform: n,
|
|
2065
2065
|
originalError: t
|
|
2066
2066
|
});
|
|
2067
2067
|
}
|
|
2068
|
-
const a =
|
|
2069
|
-
for (const { pattern:
|
|
2070
|
-
if (
|
|
2071
|
-
return new F(
|
|
2068
|
+
const a = et[n] || et.uniapp;
|
|
2069
|
+
for (const { pattern: u, code: d } of a.patterns)
|
|
2070
|
+
if (u.test(i))
|
|
2071
|
+
return new F(d, ne(d), {
|
|
2072
2072
|
apiName: r,
|
|
2073
2073
|
platform: n,
|
|
2074
2074
|
originalError: t
|
|
@@ -2076,7 +2076,7 @@ function Er(t, e) {
|
|
|
2076
2076
|
const o = a.default || c.UNKNOWN_ERROR;
|
|
2077
2077
|
return new F(
|
|
2078
2078
|
o,
|
|
2079
|
-
t.errMsg || t.message ||
|
|
2079
|
+
t.errMsg || t.message || ne(o),
|
|
2080
2080
|
{
|
|
2081
2081
|
apiName: r,
|
|
2082
2082
|
platform: n,
|
|
@@ -2084,7 +2084,7 @@ function Er(t, e) {
|
|
|
2084
2084
|
}
|
|
2085
2085
|
);
|
|
2086
2086
|
}
|
|
2087
|
-
const
|
|
2087
|
+
const dt = {
|
|
2088
2088
|
/**
|
|
2089
2089
|
* 响应拦截器
|
|
2090
2090
|
* @param {Object} result - API 响应结果
|
|
@@ -2093,7 +2093,7 @@ const tt = {
|
|
|
2093
2093
|
*/
|
|
2094
2094
|
response: (t, e) => {
|
|
2095
2095
|
if (!t.success && t.error) {
|
|
2096
|
-
const r =
|
|
2096
|
+
const r = ft(t.error, {
|
|
2097
2097
|
apiName: e.apiName,
|
|
2098
2098
|
platform: l.type
|
|
2099
2099
|
});
|
|
@@ -2106,25 +2106,25 @@ const tt = {
|
|
|
2106
2106
|
return t;
|
|
2107
2107
|
}
|
|
2108
2108
|
};
|
|
2109
|
-
function
|
|
2110
|
-
return new F(t,
|
|
2109
|
+
function Rr(t, e = {}) {
|
|
2110
|
+
return new F(t, ne(t), e);
|
|
2111
2111
|
}
|
|
2112
|
-
function
|
|
2112
|
+
function br(t) {
|
|
2113
2113
|
return t instanceof F;
|
|
2114
2114
|
}
|
|
2115
|
-
function
|
|
2115
|
+
function Tr(t, e, r) {
|
|
2116
2116
|
return e ? Promise.race([
|
|
2117
2117
|
t(),
|
|
2118
2118
|
new Promise((n, i) => setTimeout(() => i(new Error(`Init task timeout: ${r}`)), e))
|
|
2119
2119
|
]) : t();
|
|
2120
2120
|
}
|
|
2121
|
-
function
|
|
2122
|
-
return
|
|
2121
|
+
function Mr() {
|
|
2122
|
+
return h(this, arguments, function* (t = [], e = {}) {
|
|
2123
2123
|
for (const r of t) {
|
|
2124
2124
|
const n = (r == null ? void 0 : r.name) || "anonymous-task", i = (r == null ? void 0 : r.run) || r;
|
|
2125
2125
|
if (typeof i == "function")
|
|
2126
2126
|
try {
|
|
2127
|
-
yield
|
|
2127
|
+
yield Tr(() => Promise.resolve().then(() => i()), r.timeoutMs, n), typeof r.onSuccess == "function" && r.onSuccess();
|
|
2128
2128
|
} catch (a) {
|
|
2129
2129
|
if (typeof r.onError == "function" && r.onError(a), typeof e.onError == "function")
|
|
2130
2130
|
e.onError(a, r);
|
|
@@ -2134,7 +2134,7 @@ function Or() {
|
|
|
2134
2134
|
}
|
|
2135
2135
|
});
|
|
2136
2136
|
}
|
|
2137
|
-
class
|
|
2137
|
+
class gt {
|
|
2138
2138
|
/**
|
|
2139
2139
|
* 构造函数
|
|
2140
2140
|
* @param {string} name - 平台名称
|
|
@@ -2149,7 +2149,7 @@ class rt {
|
|
|
2149
2149
|
*/
|
|
2150
2150
|
processNavigationOptions(e = {}) {
|
|
2151
2151
|
const { url: r, delta: n = 1 } = e, i = r && encodeURI(r), a = parseInt(n) || 1;
|
|
2152
|
-
return
|
|
2152
|
+
return m(g({}, e), {
|
|
2153
2153
|
url: i,
|
|
2154
2154
|
delta: a
|
|
2155
2155
|
});
|
|
@@ -2260,18 +2260,18 @@ class rt {
|
|
|
2260
2260
|
throw new Error(`${this.name} platform must implement performGetEnv method`);
|
|
2261
2261
|
}
|
|
2262
2262
|
}
|
|
2263
|
-
let
|
|
2264
|
-
function
|
|
2265
|
-
if (
|
|
2263
|
+
let de = [];
|
|
2264
|
+
function Lr() {
|
|
2265
|
+
if (de.length === 0 && window.plus) {
|
|
2266
2266
|
const t = plus.webview.currentWebview();
|
|
2267
2267
|
if (!t)
|
|
2268
2268
|
throw new Error("plus.webview.currentWebview() is undefined");
|
|
2269
2269
|
const e = t.parent(), r = e ? e.id : t.id;
|
|
2270
|
-
|
|
2270
|
+
de.push(r);
|
|
2271
2271
|
}
|
|
2272
|
-
return
|
|
2272
|
+
return de;
|
|
2273
2273
|
}
|
|
2274
|
-
function
|
|
2274
|
+
function xr(t, e) {
|
|
2275
2275
|
const r = {
|
|
2276
2276
|
options: {
|
|
2277
2277
|
timestamp: +/* @__PURE__ */ new Date()
|
|
@@ -2287,12 +2287,12 @@ function _r(t, e) {
|
|
|
2287
2287
|
type: "WEB_INVOKE_APPSERVICE",
|
|
2288
2288
|
args: {
|
|
2289
2289
|
data: r,
|
|
2290
|
-
webviewIds:
|
|
2290
|
+
webviewIds: de
|
|
2291
2291
|
}
|
|
2292
2292
|
};
|
|
2293
2293
|
window.__uniapp_x_postMessage ? window.__uniapp_x_postMessageToService(n) : window.__uniapp_x_.postMessageToService(JSON.stringify(n));
|
|
2294
2294
|
}
|
|
2295
|
-
function
|
|
2295
|
+
function vr(t, e) {
|
|
2296
2296
|
const r = {
|
|
2297
2297
|
options: {
|
|
2298
2298
|
timestamp: +/* @__PURE__ */ new Date()
|
|
@@ -2308,19 +2308,19 @@ function Pr(t, e) {
|
|
|
2308
2308
|
type: "WEB_INVOKE_APPSERVICE",
|
|
2309
2309
|
args: {
|
|
2310
2310
|
data: r,
|
|
2311
|
-
webviewIds:
|
|
2311
|
+
webviewIds: de
|
|
2312
2312
|
}
|
|
2313
2313
|
};
|
|
2314
2314
|
window.__dcloud_weex_postMessage ? window.__dcloud_weex_postMessageToService(n) : window.__dcloud_weex_.postMessageToService(JSON.stringify(n));
|
|
2315
2315
|
}
|
|
2316
|
-
function
|
|
2316
|
+
function Dr(t, e) {
|
|
2317
2317
|
const r = {
|
|
2318
2318
|
options: {
|
|
2319
2319
|
timestamp: +/* @__PURE__ */ new Date()
|
|
2320
2320
|
},
|
|
2321
2321
|
name: t,
|
|
2322
2322
|
arg: e
|
|
2323
|
-
}, n =
|
|
2323
|
+
}, n = Lr();
|
|
2324
2324
|
if (plus.webview.getWebviewById("__uniapp__service"))
|
|
2325
2325
|
plus.webview.postMessageToUniNView({
|
|
2326
2326
|
type: "WEB_INVOKE_APPSERVICE",
|
|
@@ -2336,7 +2336,7 @@ function Rr(t, e) {
|
|
|
2336
2336
|
);
|
|
2337
2337
|
}
|
|
2338
2338
|
}
|
|
2339
|
-
function
|
|
2339
|
+
function Ur(t, e) {
|
|
2340
2340
|
const r = {
|
|
2341
2341
|
options: {
|
|
2342
2342
|
timestamp: +/* @__PURE__ */ new Date()
|
|
@@ -2350,10 +2350,10 @@ function Sr(t, e) {
|
|
|
2350
2350
|
pageId: ""
|
|
2351
2351
|
}, "*");
|
|
2352
2352
|
}
|
|
2353
|
-
function
|
|
2353
|
+
function Wr(t) {
|
|
2354
2354
|
return !!(t && typeof t == "object" && t.type === "qsh_api_call" && typeof t.api == "string" && typeof t.callbackId == "string");
|
|
2355
2355
|
}
|
|
2356
|
-
function
|
|
2356
|
+
function Br(t, e) {
|
|
2357
2357
|
const r = {
|
|
2358
2358
|
options: {
|
|
2359
2359
|
timestamp: +/* @__PURE__ */ new Date()
|
|
@@ -2361,7 +2361,7 @@ function Tr(t, e) {
|
|
|
2361
2361
|
name: t,
|
|
2362
2362
|
arg: e
|
|
2363
2363
|
};
|
|
2364
|
-
if (t === "postMessage" &&
|
|
2364
|
+
if (t === "postMessage" && Wr(e))
|
|
2365
2365
|
return window.__offline_bridge_postMessage(e);
|
|
2366
2366
|
window.__offline_bridge_postMessage({
|
|
2367
2367
|
type: "WEB_INVOKE_APPSERVICE",
|
|
@@ -2369,10 +2369,10 @@ function Tr(t, e) {
|
|
|
2369
2369
|
pageId: ""
|
|
2370
2370
|
});
|
|
2371
2371
|
}
|
|
2372
|
-
function
|
|
2373
|
-
|
|
2372
|
+
function pe(t, e) {
|
|
2373
|
+
Re() ? xr(t, e) : Ne() ? vr(t, e) : Q() ? Br(t, e) : Se() ? Dr(t, e) : Ur(t, e);
|
|
2374
2374
|
}
|
|
2375
|
-
class
|
|
2375
|
+
class pt extends gt {
|
|
2376
2376
|
constructor() {
|
|
2377
2377
|
super("weixin");
|
|
2378
2378
|
}
|
|
@@ -2391,17 +2391,17 @@ class nt extends rt {
|
|
|
2391
2391
|
* @returns {void}
|
|
2392
2392
|
*/
|
|
2393
2393
|
performNavigation(e, r) {
|
|
2394
|
-
return
|
|
2394
|
+
return f.safeExecute(() => {
|
|
2395
2395
|
const { url: n, delta: i } = r;
|
|
2396
2396
|
if (w.debug(`微信平台执行导航操作: ${e}`, r), this.isWeixinApiAvailable()) {
|
|
2397
2397
|
const o = window.wx.miniProgram[e];
|
|
2398
2398
|
if (typeof o == "function") {
|
|
2399
2399
|
w.debug(`使用微信原生 API: wx.miniProgram.${e}`);
|
|
2400
|
-
const
|
|
2401
|
-
return o.call(window.wx.miniProgram,
|
|
2400
|
+
const u = e === "navigateBack" ? { delta: i } : { url: n };
|
|
2401
|
+
return o.call(window.wx.miniProgram, u);
|
|
2402
2402
|
}
|
|
2403
2403
|
}
|
|
2404
|
-
w.debug(`使用消息桥接执行: ${e}`),
|
|
2404
|
+
w.debug(`使用消息桥接执行: ${e}`), pe(e, e === "navigateBack" ? { delta: i } : { url: n });
|
|
2405
2405
|
}, {
|
|
2406
2406
|
platform: this.name,
|
|
2407
2407
|
method: "performNavigation",
|
|
@@ -2415,11 +2415,11 @@ class nt extends rt {
|
|
|
2415
2415
|
* @returns {void}
|
|
2416
2416
|
*/
|
|
2417
2417
|
performPostMessage(e) {
|
|
2418
|
-
return
|
|
2418
|
+
return f.safeExecute(() => {
|
|
2419
2419
|
const { data: r } = e;
|
|
2420
2420
|
if (this.isWeixinApiAvailable())
|
|
2421
2421
|
return window.wx.miniProgram.postMessage({ data: r });
|
|
2422
|
-
|
|
2422
|
+
pe("postMessage", r);
|
|
2423
2423
|
}, {
|
|
2424
2424
|
platform: this.name,
|
|
2425
2425
|
method: "performPostMessage",
|
|
@@ -2432,7 +2432,7 @@ class nt extends rt {
|
|
|
2432
2432
|
* @returns {void}
|
|
2433
2433
|
*/
|
|
2434
2434
|
performGetEnv(e) {
|
|
2435
|
-
return
|
|
2435
|
+
return f.safeExecute(() => {
|
|
2436
2436
|
if (!e || typeof e != "function")
|
|
2437
2437
|
throw new Error("Callback function is required for getEnv");
|
|
2438
2438
|
if (this.isWeixinApiAvailable() && window.wx.miniProgram.getEnv)
|
|
@@ -2447,19 +2447,19 @@ class nt extends rt {
|
|
|
2447
2447
|
});
|
|
2448
2448
|
}
|
|
2449
2449
|
}
|
|
2450
|
-
const
|
|
2451
|
-
var
|
|
2450
|
+
const ee = new pt(), $r = (t) => ee.navigateTo(t), kr = (t) => ee.navigateBack(t), Fr = (t) => ee.switchTab(t), Kr = (t) => ee.reLaunch(t), zr = (t) => ee.redirectTo(t), Gr = (t) => ee.postMessage(t), Vr = (t) => ee.getEnv(t);
|
|
2451
|
+
var mt = /* @__PURE__ */ Object.freeze({
|
|
2452
2452
|
__proto__: null,
|
|
2453
|
-
WeixinPlatform:
|
|
2454
|
-
getEnv:
|
|
2455
|
-
navigateBack:
|
|
2456
|
-
navigateTo:
|
|
2457
|
-
postMessage:
|
|
2458
|
-
reLaunch:
|
|
2459
|
-
redirectTo:
|
|
2460
|
-
switchTab:
|
|
2453
|
+
WeixinPlatform: pt,
|
|
2454
|
+
getEnv: Vr,
|
|
2455
|
+
navigateBack: kr,
|
|
2456
|
+
navigateTo: $r,
|
|
2457
|
+
postMessage: Gr,
|
|
2458
|
+
reLaunch: Kr,
|
|
2459
|
+
redirectTo: zr,
|
|
2460
|
+
switchTab: Fr
|
|
2461
2461
|
});
|
|
2462
|
-
class
|
|
2462
|
+
class ht extends gt {
|
|
2463
2463
|
constructor() {
|
|
2464
2464
|
super("app");
|
|
2465
2465
|
}
|
|
@@ -2470,9 +2470,9 @@ class st extends rt {
|
|
|
2470
2470
|
* @returns {void}
|
|
2471
2471
|
*/
|
|
2472
2472
|
performNavigation(e, r) {
|
|
2473
|
-
return
|
|
2473
|
+
return f.safeExecute(() => {
|
|
2474
2474
|
const { url: n, delta: i } = r;
|
|
2475
|
-
|
|
2475
|
+
pe(e, e === "navigateBack" ? { delta: i } : { url: n });
|
|
2476
2476
|
}, {
|
|
2477
2477
|
platform: this.name,
|
|
2478
2478
|
method: "performNavigation",
|
|
@@ -2486,9 +2486,9 @@ class st extends rt {
|
|
|
2486
2486
|
* @returns {void}
|
|
2487
2487
|
*/
|
|
2488
2488
|
performPostMessage(e) {
|
|
2489
|
-
return
|
|
2489
|
+
return f.safeExecute(() => {
|
|
2490
2490
|
const { data: r } = e;
|
|
2491
|
-
|
|
2491
|
+
pe("postMessage", r);
|
|
2492
2492
|
}, {
|
|
2493
2493
|
platform: this.name,
|
|
2494
2494
|
method: "performPostMessage",
|
|
@@ -2501,64 +2501,64 @@ class st extends rt {
|
|
|
2501
2501
|
* @returns {void}
|
|
2502
2502
|
*/
|
|
2503
2503
|
performGetEnv(e) {
|
|
2504
|
-
return
|
|
2504
|
+
return f.safeExecute(() => {
|
|
2505
2505
|
if (!e || typeof e != "function")
|
|
2506
2506
|
throw new Error("Callback function is required for getEnv");
|
|
2507
2507
|
const r = {};
|
|
2508
2508
|
let n = !1;
|
|
2509
|
-
|
|
2509
|
+
Re() ? (r.uvue = !0, n = !0) : Ne() ? (r.nvue = !0, n = !0) : Se() ? (r.plus = !0, n = !0) : Q() && (r.offline = !0, n = !0), n ? r.app = !0 : r.h5 = !0, e(r);
|
|
2510
2510
|
}, {
|
|
2511
2511
|
platform: this.name,
|
|
2512
2512
|
method: "performGetEnv"
|
|
2513
2513
|
});
|
|
2514
2514
|
}
|
|
2515
2515
|
}
|
|
2516
|
-
const
|
|
2517
|
-
var
|
|
2516
|
+
const te = new ht(), qr = (t) => te.navigateTo(t), jr = (t) => te.navigateBack(t), Jr = (t) => te.switchTab(t), Hr = (t) => te.reLaunch(t), Yr = (t) => te.redirectTo(t), Xr = (t) => te.postMessage(t), Zr = (t) => te.getEnv(t);
|
|
2517
|
+
var wt = /* @__PURE__ */ Object.freeze({
|
|
2518
2518
|
__proto__: null,
|
|
2519
|
-
AppPlatform:
|
|
2520
|
-
getEnv:
|
|
2521
|
-
navigateBack:
|
|
2522
|
-
navigateTo:
|
|
2523
|
-
postMessage:
|
|
2524
|
-
reLaunch:
|
|
2525
|
-
redirectTo:
|
|
2526
|
-
switchTab:
|
|
2519
|
+
AppPlatform: ht,
|
|
2520
|
+
getEnv: Zr,
|
|
2521
|
+
navigateBack: jr,
|
|
2522
|
+
navigateTo: qr,
|
|
2523
|
+
postMessage: Xr,
|
|
2524
|
+
reLaunch: Hr,
|
|
2525
|
+
redirectTo: Yr,
|
|
2526
|
+
switchTab: Jr
|
|
2527
2527
|
});
|
|
2528
|
-
function
|
|
2529
|
-
return
|
|
2528
|
+
function he() {
|
|
2529
|
+
return A() ? mt : wt;
|
|
2530
2530
|
}
|
|
2531
|
-
function
|
|
2532
|
-
return
|
|
2531
|
+
function Qr(t) {
|
|
2532
|
+
return he().navigateTo(t);
|
|
2533
2533
|
}
|
|
2534
|
-
function
|
|
2535
|
-
return
|
|
2534
|
+
function en(t) {
|
|
2535
|
+
return he().navigateBack(t);
|
|
2536
2536
|
}
|
|
2537
|
-
function
|
|
2538
|
-
return
|
|
2537
|
+
function tn(t) {
|
|
2538
|
+
return he().switchTab(t);
|
|
2539
2539
|
}
|
|
2540
|
-
function
|
|
2541
|
-
return
|
|
2540
|
+
function rn(t) {
|
|
2541
|
+
return he().reLaunch(t);
|
|
2542
2542
|
}
|
|
2543
|
-
function
|
|
2544
|
-
return
|
|
2543
|
+
function nn(t) {
|
|
2544
|
+
return he().redirectTo(t);
|
|
2545
2545
|
}
|
|
2546
|
-
function
|
|
2547
|
-
return
|
|
2546
|
+
function Et() {
|
|
2547
|
+
return A() ? mt : wt;
|
|
2548
2548
|
}
|
|
2549
|
-
function
|
|
2550
|
-
return
|
|
2549
|
+
function sn(t = {}) {
|
|
2550
|
+
return Et().postMessage(t);
|
|
2551
2551
|
}
|
|
2552
|
-
function
|
|
2553
|
-
return
|
|
2552
|
+
function an(t) {
|
|
2553
|
+
return Et().getEnv(t);
|
|
2554
2554
|
}
|
|
2555
|
-
function
|
|
2555
|
+
function on(t) {
|
|
2556
2556
|
return t && typeof t == "object" && t.__v_raw ? t.__v_raw : t;
|
|
2557
2557
|
}
|
|
2558
|
-
function
|
|
2558
|
+
function cn() {
|
|
2559
2559
|
return "qsh_callback_" + Date.now() + "_" + Math.random().toString(36).substring(2, 9);
|
|
2560
2560
|
}
|
|
2561
|
-
class
|
|
2561
|
+
class un {
|
|
2562
2562
|
constructor() {
|
|
2563
2563
|
this.callbacks = /* @__PURE__ */ new Map(), this.timeouts = /* @__PURE__ */ new Map(), this.persistentCallbacksByApi = /* @__PURE__ */ new Map(), this.defaultTimeout = 3e4, typeof window != "undefined" && (window.qshWebviewCallbacks || (window.qshWebviewCallbacks = {})), E.debug("WebView 桥接器已初始化");
|
|
2564
2564
|
}
|
|
@@ -2570,15 +2570,15 @@ class Qr {
|
|
|
2570
2570
|
* @returns {void}
|
|
2571
2571
|
*/
|
|
2572
2572
|
callApi(i) {
|
|
2573
|
-
return
|
|
2574
|
-
return
|
|
2573
|
+
return h(this, arguments, function* (e, r = {}, n = {}) {
|
|
2574
|
+
return f.safeExecute(() => h(this, null, function* () {
|
|
2575
2575
|
var O;
|
|
2576
|
-
if (typeof window != "undefined" && window === window.parent && !window.plus && !window.__uniapp_x_postMessage && !window.__uniapp_x_ && !window.__dcloud_weex_postMessage && !window.__dcloud_weex_ && !
|
|
2577
|
-
const
|
|
2578
|
-
|
|
2576
|
+
if (typeof window != "undefined" && window === window.parent && !window.plus && !window.__uniapp_x_postMessage && !window.__uniapp_x_ && !window.__dcloud_weex_postMessage && !window.__dcloud_weex_ && !Q()) {
|
|
2577
|
+
const R = new N(
|
|
2578
|
+
x.PLATFORM_NOT_SUPPORTED,
|
|
2579
2579
|
"当前不在宿主 WebView 容器中,无法发送消息"
|
|
2580
2580
|
);
|
|
2581
|
-
n && typeof n.fail == "function" && n.fail({ errMsg:
|
|
2581
|
+
n && typeof n.fail == "function" && n.fail({ errMsg: R.message, code: "NOT_IN_CONTAINER" }), n && typeof n.complete == "function" && n.complete({ success: !1, error: { errMsg: R.message } });
|
|
2582
2582
|
return;
|
|
2583
2583
|
}
|
|
2584
2584
|
const o = {
|
|
@@ -2589,50 +2589,50 @@ class Qr {
|
|
|
2589
2589
|
abort: !1,
|
|
2590
2590
|
metadata: {}
|
|
2591
2591
|
};
|
|
2592
|
-
|
|
2593
|
-
const
|
|
2594
|
-
if (
|
|
2595
|
-
E.warn("API 调用被拦截器中止", { api: e }),
|
|
2596
|
-
errMsg: ((O =
|
|
2592
|
+
$.setApiLoading(e, !0);
|
|
2593
|
+
const u = yield Y.runRequest(o);
|
|
2594
|
+
if (u.abort) {
|
|
2595
|
+
E.warn("API 调用被拦截器中止", { api: e }), $.setApiLoading(e, !1), n.fail && n.fail({
|
|
2596
|
+
errMsg: ((O = u.error) == null ? void 0 : O.message) || "API 调用被中止",
|
|
2597
2597
|
code: "INTERCEPTED"
|
|
2598
2598
|
}), n.complete && n.complete({ success: !1 });
|
|
2599
2599
|
return;
|
|
2600
2600
|
}
|
|
2601
|
-
const
|
|
2601
|
+
const d = cn();
|
|
2602
2602
|
if (n.success || n.fail || n.complete) {
|
|
2603
|
-
if (this.callbacks.set(
|
|
2604
|
-
context:
|
|
2603
|
+
if (this.callbacks.set(d, m(g({}, n), {
|
|
2604
|
+
context: u
|
|
2605
2605
|
// 保存上下文用于响应拦截
|
|
2606
|
-
})), window.qshWebviewCallbacks[
|
|
2607
|
-
this.handleCallback(
|
|
2608
|
-
}, r.isPersistent && (this.persistentCallbacksByApi.has(e) || this.persistentCallbacksByApi.set(e, /* @__PURE__ */ new Set()), this.persistentCallbacksByApi.get(e).add(
|
|
2606
|
+
})), window.qshWebviewCallbacks[d] = (v) => {
|
|
2607
|
+
this.handleCallback(d, v);
|
|
2608
|
+
}, r.isPersistent && (this.persistentCallbacksByApi.has(e) || this.persistentCallbacksByApi.set(e, /* @__PURE__ */ new Set()), this.persistentCallbacksByApi.get(e).add(d)), r.isPersistent || r.disableTimeout)
|
|
2609
2609
|
E.info(`API ${e} 禁用超时清理,将等待回调返回后清理`, {
|
|
2610
|
-
callbackId:
|
|
2610
|
+
callbackId: d,
|
|
2611
2611
|
isPersistent: r.isPersistent,
|
|
2612
2612
|
disableTimeout: r.disableTimeout
|
|
2613
2613
|
});
|
|
2614
2614
|
else {
|
|
2615
|
-
const
|
|
2616
|
-
E.warn("API 调用超时,自动清理回调", { api: e, callbackId:
|
|
2615
|
+
const v = setTimeout(() => {
|
|
2616
|
+
E.warn("API 调用超时,自动清理回调", { api: e, callbackId: d }), n.fail && n.fail({
|
|
2617
2617
|
errMsg: `API ${e} 调用超时`,
|
|
2618
2618
|
code: "TIMEOUT"
|
|
2619
|
-
}), this.cleanupCallback(
|
|
2619
|
+
}), this.cleanupCallback(d);
|
|
2620
2620
|
}, r.timeout || this.defaultTimeout);
|
|
2621
|
-
this.timeouts.set(
|
|
2621
|
+
this.timeouts.set(d, v);
|
|
2622
2622
|
}
|
|
2623
|
-
const
|
|
2623
|
+
const _ = {
|
|
2624
2624
|
type: "qsh_api_call",
|
|
2625
2625
|
api: e,
|
|
2626
|
-
params:
|
|
2627
|
-
callbackId:
|
|
2626
|
+
params: u.params,
|
|
2627
|
+
callbackId: d,
|
|
2628
2628
|
timestamp: Date.now()
|
|
2629
2629
|
};
|
|
2630
2630
|
E.info("发送 API 调用消息", {
|
|
2631
2631
|
api: e,
|
|
2632
|
-
callbackId:
|
|
2632
|
+
callbackId: d,
|
|
2633
2633
|
hasSuccess: !!n.success,
|
|
2634
2634
|
hasFail: !!n.fail
|
|
2635
|
-
}), console.log("message:", JSON.stringify(
|
|
2635
|
+
}), console.log("message:", JSON.stringify(on(_), null, 2)), pe("postMessage", _);
|
|
2636
2636
|
}
|
|
2637
2637
|
}), {
|
|
2638
2638
|
context: "WebViewBridge.callApi",
|
|
@@ -2647,18 +2647,18 @@ class Qr {
|
|
|
2647
2647
|
* @private
|
|
2648
2648
|
*/
|
|
2649
2649
|
handleCallback(e, r) {
|
|
2650
|
-
return
|
|
2651
|
-
return
|
|
2652
|
-
var
|
|
2650
|
+
return h(this, null, function* () {
|
|
2651
|
+
return f.safeExecute(() => h(this, null, function* () {
|
|
2652
|
+
var R, _;
|
|
2653
2653
|
const n = this.callbacks.get(e);
|
|
2654
2654
|
if (!n) {
|
|
2655
2655
|
E.warn("未找到回调函数", { callbackId: e });
|
|
2656
2656
|
return;
|
|
2657
2657
|
}
|
|
2658
|
-
const { success: i, fail: a, complete: o, context:
|
|
2658
|
+
const { success: i, fail: a, complete: o, context: u } = n;
|
|
2659
2659
|
E.debug("处理回调", { callbackId: e, result: r });
|
|
2660
|
-
const
|
|
2661
|
-
|
|
2660
|
+
const d = yield Y.runResponse(r, u);
|
|
2661
|
+
u && $.setApiResult(u.apiName, d), d.success && i ? i(d.data) : !d.success && a && a(d.error || { errMsg: "操作失败" }), o && o(d), ((_ = (R = n.context) == null ? void 0 : R.params) == null ? void 0 : _.isPersistent) ? E.debug("持久监听API:保留回调", { callbackId: e }) : (this.cleanupCallback(e), E.debug("回调执行完成,已清理", { callbackId: e }));
|
|
2662
2662
|
}), {
|
|
2663
2663
|
context: "WebViewBridge.handleCallback",
|
|
2664
2664
|
callbackId: e
|
|
@@ -2711,18 +2711,18 @@ class Qr {
|
|
|
2711
2711
|
};
|
|
2712
2712
|
}
|
|
2713
2713
|
}
|
|
2714
|
-
const
|
|
2715
|
-
function
|
|
2716
|
-
return
|
|
2714
|
+
const yt = new un(), P = (t, e, r) => yt.callApi(t, e, r), ie = (t) => yt.cleanupPersistentCallbacksByApi(t);
|
|
2715
|
+
function It() {
|
|
2716
|
+
return oe(!0);
|
|
2717
2717
|
}
|
|
2718
|
-
function
|
|
2718
|
+
function ln(t) {
|
|
2719
2719
|
return t === "offline";
|
|
2720
2720
|
}
|
|
2721
|
-
function
|
|
2722
|
-
return
|
|
2721
|
+
function fn(t = {}) {
|
|
2722
|
+
return f.safeExecute(() => {
|
|
2723
2723
|
s.debug("Call getCode through offline webview bridge", {
|
|
2724
2724
|
clientId: t.clientId
|
|
2725
|
-
}),
|
|
2725
|
+
}), P(
|
|
2726
2726
|
"getCode",
|
|
2727
2727
|
{
|
|
2728
2728
|
clientId: t.clientId
|
|
@@ -2741,13 +2741,13 @@ function tn(t = {}) {
|
|
|
2741
2741
|
);
|
|
2742
2742
|
}, {
|
|
2743
2743
|
context: "getCodeInHost",
|
|
2744
|
-
platform:
|
|
2744
|
+
platform: It().type
|
|
2745
2745
|
});
|
|
2746
2746
|
}
|
|
2747
|
-
function
|
|
2748
|
-
return
|
|
2747
|
+
function dn(t = {}) {
|
|
2748
|
+
return f.safeExecute(() => {
|
|
2749
2749
|
var n, i;
|
|
2750
|
-
const e =
|
|
2750
|
+
const e = It(), r = String((t == null ? void 0 : t.clientId) || "").trim();
|
|
2751
2751
|
if (!r) {
|
|
2752
2752
|
const a = {
|
|
2753
2753
|
errMsg: "clientId is required",
|
|
@@ -2756,7 +2756,7 @@ function rn(t = {}) {
|
|
|
2756
2756
|
s.error("Get code missing clientId"), (n = t.fail) == null || n.call(t, a);
|
|
2757
2757
|
return;
|
|
2758
2758
|
}
|
|
2759
|
-
if (!
|
|
2759
|
+
if (!ln(e.type)) {
|
|
2760
2760
|
const a = {
|
|
2761
2761
|
errMsg: `Current environment (${e.type}) does not support getCode`,
|
|
2762
2762
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
@@ -2766,7 +2766,7 @@ function rn(t = {}) {
|
|
|
2766
2766
|
}), (i = t.fail) == null || i.call(t, a);
|
|
2767
2767
|
return;
|
|
2768
2768
|
}
|
|
2769
|
-
|
|
2769
|
+
fn(m(g({}, t), {
|
|
2770
2770
|
clientId: r
|
|
2771
2771
|
}));
|
|
2772
2772
|
}, {
|
|
@@ -2774,30 +2774,30 @@ function rn(t = {}) {
|
|
|
2774
2774
|
options: t
|
|
2775
2775
|
});
|
|
2776
2776
|
}
|
|
2777
|
-
const
|
|
2777
|
+
const Ce = {
|
|
2778
2778
|
ALBUM: "album",
|
|
2779
2779
|
// 相册
|
|
2780
2780
|
CAMERA: "camera"
|
|
2781
2781
|
// 相机
|
|
2782
|
-
},
|
|
2782
|
+
}, Pe = {
|
|
2783
2783
|
ORIGINAL: "original",
|
|
2784
2784
|
// 原图
|
|
2785
2785
|
COMPRESSED: "compressed"
|
|
2786
2786
|
// 压缩图
|
|
2787
|
-
},
|
|
2787
|
+
}, gn = {
|
|
2788
2788
|
count: 9,
|
|
2789
|
-
sizeType: [
|
|
2790
|
-
sourceType: [
|
|
2789
|
+
sizeType: [Pe.ORIGINAL, Pe.COMPRESSED],
|
|
2790
|
+
sourceType: [Ce.ALBUM, Ce.CAMERA]
|
|
2791
2791
|
};
|
|
2792
|
-
function
|
|
2793
|
-
const e =
|
|
2794
|
-
return Array.isArray(e.sizeType) || (e.sizeType = [e.sizeType].filter(Boolean)), Array.isArray(e.sourceType) || (e.sourceType = [e.sourceType].filter(Boolean)), e.count = Math.max(1, Math.min(9, parseInt(e.count) || 1)), e.sizeType.length === 0 && (e.sizeType = [
|
|
2792
|
+
function pn(t = {}) {
|
|
2793
|
+
const e = g(g({}, gn), t);
|
|
2794
|
+
return Array.isArray(e.sizeType) || (e.sizeType = [e.sizeType].filter(Boolean)), Array.isArray(e.sourceType) || (e.sourceType = [e.sourceType].filter(Boolean)), e.count = Math.max(1, Math.min(9, parseInt(e.count) || 1)), e.sizeType.length === 0 && (e.sizeType = [Pe.COMPRESSED]), e.sourceType.length === 0 && (e.sourceType = [Ce.ALBUM]), e;
|
|
2795
2795
|
}
|
|
2796
|
-
function
|
|
2796
|
+
function At() {
|
|
2797
2797
|
return ["weixin", "webview", "UniApp", "plus", "nvue", "uvue", "offline"].includes(l.type);
|
|
2798
2798
|
}
|
|
2799
|
-
function
|
|
2800
|
-
return
|
|
2799
|
+
function Ot(t) {
|
|
2800
|
+
return f.safeExecute(() => {
|
|
2801
2801
|
var e;
|
|
2802
2802
|
if (!window.wx) {
|
|
2803
2803
|
const r = {
|
|
@@ -2807,8 +2807,8 @@ function ft(t) {
|
|
|
2807
2807
|
(e = t.fail) == null || e.call(t, r);
|
|
2808
2808
|
return;
|
|
2809
2809
|
}
|
|
2810
|
-
if (!
|
|
2811
|
-
s.info("等待微信配置完成"),
|
|
2810
|
+
if (!j()) {
|
|
2811
|
+
s.info("等待微信配置完成"), K().then(() => Ot(t)).catch((r) => {
|
|
2812
2812
|
var n;
|
|
2813
2813
|
s.error("微信配置失败", r), (n = t.fail) == null || n.call(t, { errMsg: `微信配置失败: ${r.message}` });
|
|
2814
2814
|
});
|
|
@@ -2833,9 +2833,9 @@ function ft(t) {
|
|
|
2833
2833
|
platform: "weixin"
|
|
2834
2834
|
});
|
|
2835
2835
|
}
|
|
2836
|
-
function
|
|
2837
|
-
return
|
|
2838
|
-
s.debug("通过 WebView 桥接调用图片选择", t),
|
|
2836
|
+
function mn(t) {
|
|
2837
|
+
return f.safeExecute(() => {
|
|
2838
|
+
s.debug("通过 WebView 桥接调用图片选择", t), P("chooseImage", m(g({}, t), { disableTimeout: !0 }), {
|
|
2839
2839
|
success: (e) => {
|
|
2840
2840
|
var r, n;
|
|
2841
2841
|
s.info("UniApp 图片选择成功", {
|
|
@@ -2853,10 +2853,10 @@ function an(t) {
|
|
|
2853
2853
|
platform: "uniapp"
|
|
2854
2854
|
});
|
|
2855
2855
|
}
|
|
2856
|
-
function
|
|
2857
|
-
return
|
|
2856
|
+
function hn(t = {}) {
|
|
2857
|
+
return f.safeExecute(() => {
|
|
2858
2858
|
var r;
|
|
2859
|
-
if (!
|
|
2859
|
+
if (!At()) {
|
|
2860
2860
|
const n = {
|
|
2861
2861
|
errMsg: `当前环境 (${l.type}) 不支持图片选择功能`,
|
|
2862
2862
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
@@ -2864,23 +2864,23 @@ function on(t = {}) {
|
|
|
2864
2864
|
s.error("平台不支持图片选择", { platform: l.type }), (r = t.fail) == null || r.call(t, n);
|
|
2865
2865
|
return;
|
|
2866
2866
|
}
|
|
2867
|
-
const e =
|
|
2867
|
+
const e = pn(t);
|
|
2868
2868
|
s.info("开始选择图片", {
|
|
2869
2869
|
platform: l.type,
|
|
2870
2870
|
count: e.count,
|
|
2871
2871
|
sizeType: e.sizeType,
|
|
2872
2872
|
sourceType: e.sourceType
|
|
2873
|
-
}),
|
|
2873
|
+
}), A() ? Ot(e) : mn(e);
|
|
2874
2874
|
}, {
|
|
2875
2875
|
context: "chooseImage",
|
|
2876
2876
|
options: t
|
|
2877
2877
|
});
|
|
2878
2878
|
}
|
|
2879
|
-
function
|
|
2879
|
+
function wn() {
|
|
2880
2880
|
return {
|
|
2881
|
-
supported:
|
|
2881
|
+
supported: At(),
|
|
2882
2882
|
environment: l.type,
|
|
2883
|
-
implementation:
|
|
2883
|
+
implementation: A() ? "weixin" : "webview",
|
|
2884
2884
|
features: {
|
|
2885
2885
|
multipleSelection: !0,
|
|
2886
2886
|
// 支持多选
|
|
@@ -2893,7 +2893,7 @@ function cn() {
|
|
|
2893
2893
|
}
|
|
2894
2894
|
};
|
|
2895
2895
|
}
|
|
2896
|
-
const
|
|
2896
|
+
const Z = {
|
|
2897
2897
|
QR_CODE: "qrCode",
|
|
2898
2898
|
// 二维码
|
|
2899
2899
|
BAR_CODE: "barCode",
|
|
@@ -2902,21 +2902,21 @@ const J = {
|
|
|
2902
2902
|
// Data Matrix 码
|
|
2903
2903
|
PDF417: "pdf417"
|
|
2904
2904
|
// PDF417 条码
|
|
2905
|
-
},
|
|
2905
|
+
}, En = {
|
|
2906
2906
|
onlyFromCamera: !0,
|
|
2907
2907
|
// 只从相机扫码
|
|
2908
|
-
scanType: [
|
|
2908
|
+
scanType: [Z.QR_CODE, Z.BAR_CODE]
|
|
2909
2909
|
// 支持二维码和一维码
|
|
2910
2910
|
};
|
|
2911
|
-
function
|
|
2912
|
-
const e =
|
|
2913
|
-
return Array.isArray(e.scanType) || (e.scanType = [e.scanType].filter(Boolean)), e.scanType.length === 0 && (e.scanType = [
|
|
2911
|
+
function yn(t = {}) {
|
|
2912
|
+
const e = g(g({}, En), t);
|
|
2913
|
+
return Array.isArray(e.scanType) || (e.scanType = [e.scanType].filter(Boolean)), e.scanType.length === 0 && (e.scanType = [Z.QR_CODE, Z.BAR_CODE]), e.onlyFromCamera = !!e.onlyFromCamera, e;
|
|
2914
2914
|
}
|
|
2915
|
-
function
|
|
2915
|
+
function _t() {
|
|
2916
2916
|
return ["weixin", "webview", "UniApp", "plus", "nvue", "uvue", "offline"].includes(l.type);
|
|
2917
2917
|
}
|
|
2918
|
-
function
|
|
2919
|
-
return
|
|
2918
|
+
function Ct(t) {
|
|
2919
|
+
return f.safeExecute(() => {
|
|
2920
2920
|
var e;
|
|
2921
2921
|
if (!window.wx) {
|
|
2922
2922
|
const r = {
|
|
@@ -2926,8 +2926,8 @@ function gt(t) {
|
|
|
2926
2926
|
(e = t.fail) == null || e.call(t, r);
|
|
2927
2927
|
return;
|
|
2928
2928
|
}
|
|
2929
|
-
if (!
|
|
2930
|
-
s.info("等待微信配置完成"),
|
|
2929
|
+
if (!j()) {
|
|
2930
|
+
s.info("等待微信配置完成"), K().then(() => Ct(t)).catch((r) => {
|
|
2931
2931
|
var n;
|
|
2932
2932
|
s.error("微信配置失败", r), (n = t.fail) == null || n.call(t, { errMsg: `微信配置失败: ${r.message}` });
|
|
2933
2933
|
});
|
|
@@ -2943,7 +2943,7 @@ function gt(t) {
|
|
|
2943
2943
|
const n = {
|
|
2944
2944
|
result: r.resultStr,
|
|
2945
2945
|
// 扫码内容
|
|
2946
|
-
scanType:
|
|
2946
|
+
scanType: In(r.resultStr),
|
|
2947
2947
|
// 推测扫码类型
|
|
2948
2948
|
charSet: "utf-8",
|
|
2949
2949
|
// 微信默认 UTF-8
|
|
@@ -2962,12 +2962,12 @@ function gt(t) {
|
|
|
2962
2962
|
platform: "weixin"
|
|
2963
2963
|
});
|
|
2964
2964
|
}
|
|
2965
|
-
function
|
|
2966
|
-
return t ? t.length > 50 || /[^\d]/.test(t) ?
|
|
2965
|
+
function In(t) {
|
|
2966
|
+
return t ? t.length > 50 || /[^\d]/.test(t) ? Z.QR_CODE : Z.BAR_CODE : "unknown";
|
|
2967
2967
|
}
|
|
2968
|
-
function
|
|
2969
|
-
return
|
|
2970
|
-
s.debug("通过 WebView 桥接调用扫码", t),
|
|
2968
|
+
function An(t) {
|
|
2969
|
+
return f.safeExecute(() => {
|
|
2970
|
+
s.debug("通过 WebView 桥接调用扫码", t), P("scanCode", m(g({}, t), { disableTimeout: !0 }), {
|
|
2971
2971
|
success: (e) => {
|
|
2972
2972
|
var r;
|
|
2973
2973
|
s.info("UniApp 扫码成功", {
|
|
@@ -2986,10 +2986,10 @@ function dn(t) {
|
|
|
2986
2986
|
platform: "uniapp"
|
|
2987
2987
|
});
|
|
2988
2988
|
}
|
|
2989
|
-
function
|
|
2990
|
-
return
|
|
2989
|
+
function On(t = {}) {
|
|
2990
|
+
return f.safeExecute(() => {
|
|
2991
2991
|
var r;
|
|
2992
|
-
if (!
|
|
2992
|
+
if (!_t()) {
|
|
2993
2993
|
const n = {
|
|
2994
2994
|
errMsg: `当前环境 (${l.type}) 不支持扫码功能`,
|
|
2995
2995
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
@@ -2997,22 +2997,22 @@ function gn(t = {}) {
|
|
|
2997
2997
|
s.error("平台不支持扫码", { platform: l.type }), (r = t.fail) == null || r.call(t, n);
|
|
2998
2998
|
return;
|
|
2999
2999
|
}
|
|
3000
|
-
const e =
|
|
3000
|
+
const e = yn(t);
|
|
3001
3001
|
s.info("开始扫码", {
|
|
3002
3002
|
platform: l.type,
|
|
3003
3003
|
onlyFromCamera: e.onlyFromCamera,
|
|
3004
3004
|
scanType: e.scanType
|
|
3005
|
-
}),
|
|
3005
|
+
}), A() ? Ct(e) : An(e);
|
|
3006
3006
|
}, {
|
|
3007
3007
|
context: "scanCode",
|
|
3008
3008
|
options: t
|
|
3009
3009
|
});
|
|
3010
3010
|
}
|
|
3011
|
-
function
|
|
3011
|
+
function _n() {
|
|
3012
3012
|
return {
|
|
3013
|
-
supported:
|
|
3013
|
+
supported: _t(),
|
|
3014
3014
|
environment: l.type,
|
|
3015
|
-
implementation:
|
|
3015
|
+
implementation: A() ? "weixin" : "webview",
|
|
3016
3016
|
features: {
|
|
3017
3017
|
onlyFromCamera: !0,
|
|
3018
3018
|
// 支持只从相机扫码
|
|
@@ -3025,30 +3025,30 @@ function hn() {
|
|
|
3025
3025
|
}
|
|
3026
3026
|
};
|
|
3027
3027
|
}
|
|
3028
|
-
const
|
|
3028
|
+
const se = {
|
|
3029
3029
|
WGS84: "wgs84",
|
|
3030
3030
|
// GPS 坐标
|
|
3031
3031
|
GCJ02: "gcj02",
|
|
3032
3032
|
// 国测局坐标(火星坐标)
|
|
3033
3033
|
BD09: "bd09"
|
|
3034
3034
|
// 百度坐标
|
|
3035
|
-
},
|
|
3036
|
-
type:
|
|
3035
|
+
}, Cn = {
|
|
3036
|
+
type: se.WGS84,
|
|
3037
3037
|
altitude: !1
|
|
3038
|
-
},
|
|
3038
|
+
}, Pn = {
|
|
3039
3039
|
scale: 18
|
|
3040
3040
|
// 地图缩放级别 1-28
|
|
3041
3041
|
};
|
|
3042
|
-
function
|
|
3043
|
-
const e =
|
|
3044
|
-
return Object.values(
|
|
3042
|
+
function Sn(t = {}) {
|
|
3043
|
+
const e = g(g({}, Cn), t);
|
|
3044
|
+
return Object.values(se).includes(e.type) || (e.type = se.WGS84), e.altitude = !!e.altitude, e;
|
|
3045
3045
|
}
|
|
3046
|
-
function
|
|
3047
|
-
const e =
|
|
3048
|
-
return Object.values(
|
|
3046
|
+
function Nn(t = {}) {
|
|
3047
|
+
const e = g({}, t);
|
|
3048
|
+
return Object.values(se).includes(e.type) || (e.type = se.WGS84), e.needFullAccuracy = !!e.needFullAccuracy, e;
|
|
3049
3049
|
}
|
|
3050
|
-
function
|
|
3051
|
-
const e =
|
|
3050
|
+
function Rn(t = {}) {
|
|
3051
|
+
const e = g(g({}, Pn), t);
|
|
3052
3052
|
if (e.latitude === void 0 || e.latitude === null)
|
|
3053
3053
|
throw {
|
|
3054
3054
|
errMsg: "缺少必需参数:latitude(纬度)",
|
|
@@ -3107,11 +3107,11 @@ function yn(t = {}) {
|
|
|
3107
3107
|
}
|
|
3108
3108
|
return e;
|
|
3109
3109
|
}
|
|
3110
|
-
function
|
|
3110
|
+
function $e() {
|
|
3111
3111
|
return ["weixin", "webview", "UniApp", "plus", "nvue", "uvue", "offline"].includes(l.type);
|
|
3112
3112
|
}
|
|
3113
|
-
function
|
|
3114
|
-
return
|
|
3113
|
+
function Pt(t) {
|
|
3114
|
+
return f.safeExecute(() => {
|
|
3115
3115
|
var e;
|
|
3116
3116
|
if (!window.wx) {
|
|
3117
3117
|
const r = {
|
|
@@ -3121,8 +3121,8 @@ function ht(t) {
|
|
|
3121
3121
|
(e = t.fail) == null || e.call(t, r);
|
|
3122
3122
|
return;
|
|
3123
3123
|
}
|
|
3124
|
-
if (!
|
|
3125
|
-
s.info("等待微信配置完成"),
|
|
3124
|
+
if (!j()) {
|
|
3125
|
+
s.info("等待微信配置完成"), K().then(() => Pt(t)).catch((r) => {
|
|
3126
3126
|
var n;
|
|
3127
3127
|
s.error("微信配置失败", r), (n = t.fail) == null || n.call(t, { errMsg: `微信配置失败: ${r.message}` });
|
|
3128
3128
|
});
|
|
@@ -3148,8 +3148,8 @@ function ht(t) {
|
|
|
3148
3148
|
platform: "weixin"
|
|
3149
3149
|
});
|
|
3150
3150
|
}
|
|
3151
|
-
function
|
|
3152
|
-
return
|
|
3151
|
+
function St(t) {
|
|
3152
|
+
return f.safeExecute(() => {
|
|
3153
3153
|
var e;
|
|
3154
3154
|
if (!window.wx) {
|
|
3155
3155
|
const r = {
|
|
@@ -3159,8 +3159,8 @@ function pt(t) {
|
|
|
3159
3159
|
(e = t.fail) == null || e.call(t, r);
|
|
3160
3160
|
return;
|
|
3161
3161
|
}
|
|
3162
|
-
if (!
|
|
3163
|
-
s.info("等待微信配置完成"),
|
|
3162
|
+
if (!j()) {
|
|
3163
|
+
s.info("等待微信配置完成"), K().then(() => St(t)).catch((r) => {
|
|
3164
3164
|
var n;
|
|
3165
3165
|
s.error("微信配置失败", r), (n = t.fail) == null || n.call(t, { errMsg: `微信配置失败: ${r.message}` });
|
|
3166
3166
|
});
|
|
@@ -3188,9 +3188,9 @@ function pt(t) {
|
|
|
3188
3188
|
platform: "weixin"
|
|
3189
3189
|
});
|
|
3190
3190
|
}
|
|
3191
|
-
function
|
|
3192
|
-
return
|
|
3193
|
-
s.debug("通过 WebView 桥接调用获取位置", t),
|
|
3191
|
+
function bn(t) {
|
|
3192
|
+
return f.safeExecute(() => {
|
|
3193
|
+
s.debug("通过 WebView 桥接调用获取位置", t), P("getLocation", t, {
|
|
3194
3194
|
success: (e) => {
|
|
3195
3195
|
var r;
|
|
3196
3196
|
s.info("UniApp 获取位置成功", {
|
|
@@ -3209,9 +3209,9 @@ function In(t) {
|
|
|
3209
3209
|
platform: "uniapp"
|
|
3210
3210
|
});
|
|
3211
3211
|
}
|
|
3212
|
-
function
|
|
3213
|
-
return
|
|
3214
|
-
s.debug("通过 WebView 桥接调用查看位置", t),
|
|
3212
|
+
function Tn(t) {
|
|
3213
|
+
return f.safeExecute(() => {
|
|
3214
|
+
s.debug("通过 WebView 桥接调用查看位置", t), P("openLocation", t, {
|
|
3215
3215
|
success: (e) => {
|
|
3216
3216
|
var r;
|
|
3217
3217
|
s.info("UniApp 查看位置成功"), (r = t.success) == null || r.call(t, e);
|
|
@@ -3227,10 +3227,10 @@ function An(t) {
|
|
|
3227
3227
|
platform: "uniapp"
|
|
3228
3228
|
});
|
|
3229
3229
|
}
|
|
3230
|
-
function
|
|
3231
|
-
return
|
|
3230
|
+
function Mn(t = {}) {
|
|
3231
|
+
return f.safeExecute(() => {
|
|
3232
3232
|
var r;
|
|
3233
|
-
if (
|
|
3233
|
+
if (!$e()) {
|
|
3234
3234
|
const n = {
|
|
3235
3235
|
errMsg: `当前环境 (${l.type}) 不支持定位功能`,
|
|
3236
3236
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
@@ -3238,21 +3238,21 @@ function On(t = {}) {
|
|
|
3238
3238
|
s.error("平台不支持定位", { platform: l.type }), (r = t.fail) == null || r.call(t, n);
|
|
3239
3239
|
return;
|
|
3240
3240
|
}
|
|
3241
|
-
const e =
|
|
3241
|
+
const e = Sn(t);
|
|
3242
3242
|
s.info("开始获取位置", {
|
|
3243
3243
|
platform: l.type,
|
|
3244
3244
|
type: e.type,
|
|
3245
3245
|
altitude: e.altitude
|
|
3246
|
-
}),
|
|
3246
|
+
}), A() ? Pt(e) : bn(e);
|
|
3247
3247
|
}, {
|
|
3248
3248
|
context: "getLocation",
|
|
3249
3249
|
options: t
|
|
3250
3250
|
});
|
|
3251
3251
|
}
|
|
3252
|
-
function
|
|
3253
|
-
return
|
|
3252
|
+
function Ln(t = {}) {
|
|
3253
|
+
return f.safeExecute(() => {
|
|
3254
3254
|
var r, n, i;
|
|
3255
|
-
if (
|
|
3255
|
+
if (!$e()) {
|
|
3256
3256
|
const a = {
|
|
3257
3257
|
errMsg: `当前环境 (${l.type}) 不支持查看位置功能`,
|
|
3258
3258
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
@@ -3262,7 +3262,7 @@ function Cn(t = {}) {
|
|
|
3262
3262
|
}
|
|
3263
3263
|
let e;
|
|
3264
3264
|
try {
|
|
3265
|
-
e =
|
|
3265
|
+
e = Rn(t);
|
|
3266
3266
|
} catch (a) {
|
|
3267
3267
|
s.error("参数验证失败", a), (n = t.fail) == null || n.call(t, a), (i = t.complete) == null || i.call(t);
|
|
3268
3268
|
return;
|
|
@@ -3272,16 +3272,16 @@ function Cn(t = {}) {
|
|
|
3272
3272
|
latitude: e.latitude,
|
|
3273
3273
|
longitude: e.longitude,
|
|
3274
3274
|
name: e.name
|
|
3275
|
-
}),
|
|
3275
|
+
}), A() ? St(e) : Tn(e);
|
|
3276
3276
|
}, {
|
|
3277
3277
|
context: "openLocation",
|
|
3278
3278
|
options: t
|
|
3279
3279
|
});
|
|
3280
3280
|
}
|
|
3281
|
-
function
|
|
3282
|
-
const t =
|
|
3281
|
+
function xn() {
|
|
3282
|
+
const t = A();
|
|
3283
3283
|
return {
|
|
3284
|
-
supported:
|
|
3284
|
+
supported: $e(),
|
|
3285
3285
|
environment: l.type,
|
|
3286
3286
|
implementation: t ? "weixin" : "webview",
|
|
3287
3287
|
features: {
|
|
@@ -3300,20 +3300,20 @@ function _n() {
|
|
|
3300
3300
|
}
|
|
3301
3301
|
};
|
|
3302
3302
|
}
|
|
3303
|
-
const
|
|
3304
|
-
function
|
|
3303
|
+
const V = /* @__PURE__ */ new Set(), q = /* @__PURE__ */ new Set();
|
|
3304
|
+
function Nt(t, e, r) {
|
|
3305
3305
|
t.forEach((n) => {
|
|
3306
3306
|
if (typeof n == "function") {
|
|
3307
|
-
|
|
3307
|
+
f.safeExecute(() => n(e), { context: r });
|
|
3308
3308
|
return;
|
|
3309
3309
|
}
|
|
3310
3310
|
s.warn("监听回调不是函数,已跳过", { type: typeof n });
|
|
3311
3311
|
});
|
|
3312
3312
|
}
|
|
3313
|
-
function
|
|
3314
|
-
return
|
|
3313
|
+
function vn(t = {}) {
|
|
3314
|
+
return f.safeExecute(() => {
|
|
3315
3315
|
var r, n;
|
|
3316
|
-
if (
|
|
3316
|
+
if (A()) {
|
|
3317
3317
|
const i = {
|
|
3318
3318
|
errMsg: `当前环境 (${l.type}) 不支持该接口`,
|
|
3319
3319
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
@@ -3321,8 +3321,8 @@ function Pn(t = {}) {
|
|
|
3321
3321
|
s.error("当前环境不支持此接口", { platform: l.type }), (r = t.fail) == null || r.call(t, i), (n = t.complete) == null || n.call(t, i);
|
|
3322
3322
|
return;
|
|
3323
3323
|
}
|
|
3324
|
-
const e =
|
|
3325
|
-
s.info("正在开启定位监听"),
|
|
3324
|
+
const e = Nn(t);
|
|
3325
|
+
s.info("正在开启定位监听"), P("startLocationUpdate", {
|
|
3326
3326
|
type: e.type,
|
|
3327
3327
|
needFullAccuracy: e.needFullAccuracy
|
|
3328
3328
|
}, {
|
|
@@ -3338,10 +3338,10 @@ function Pn(t = {}) {
|
|
|
3338
3338
|
});
|
|
3339
3339
|
}, { context: "startLocationUpdate" });
|
|
3340
3340
|
}
|
|
3341
|
-
function
|
|
3342
|
-
return
|
|
3341
|
+
function Dn(t = {}) {
|
|
3342
|
+
return f.safeExecute(() => {
|
|
3343
3343
|
var e, r;
|
|
3344
|
-
if (
|
|
3344
|
+
if (A()) {
|
|
3345
3345
|
const n = {
|
|
3346
3346
|
errMsg: `当前环境 (${l.type}) 不支持该接口`,
|
|
3347
3347
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
@@ -3349,7 +3349,7 @@ function Rn(t = {}) {
|
|
|
3349
3349
|
s.error("当前环境不支持此接口", { platform: l.type }), (e = t.fail) == null || e.call(t, n), (r = t.complete) == null || r.call(t, n);
|
|
3350
3350
|
return;
|
|
3351
3351
|
}
|
|
3352
|
-
s.info("正在停止定位监听"),
|
|
3352
|
+
s.info("正在停止定位监听"), P("stopLocationUpdate", t, {
|
|
3353
3353
|
success: (n) => {
|
|
3354
3354
|
var i;
|
|
3355
3355
|
s.info("定位监听已停止"), (i = t.success) == null || i.call(t, n);
|
|
@@ -3362,9 +3362,9 @@ function Rn(t = {}) {
|
|
|
3362
3362
|
});
|
|
3363
3363
|
}, { context: "stopLocationUpdate" });
|
|
3364
3364
|
}
|
|
3365
|
-
function
|
|
3366
|
-
return
|
|
3367
|
-
if (
|
|
3365
|
+
function Un(t) {
|
|
3366
|
+
return f.safeExecute(() => {
|
|
3367
|
+
if (A()) {
|
|
3368
3368
|
s.warn("当前环境不支持此接口", { platform: l.type });
|
|
3369
3369
|
return;
|
|
3370
3370
|
}
|
|
@@ -3373,20 +3373,20 @@ function Sn(t) {
|
|
|
3373
3373
|
errMsg: "onLocationChange 回调必须是函数",
|
|
3374
3374
|
code: "INVALID_CALLBACK"
|
|
3375
3375
|
};
|
|
3376
|
-
const e =
|
|
3377
|
-
|
|
3376
|
+
const e = V.size > 0;
|
|
3377
|
+
V.add(t), e || (s.debug("注册实时位置变化监听器"), P("onLocationChange", { isPersistent: !0 }, {
|
|
3378
3378
|
success: (r) => {
|
|
3379
|
-
s.debug("收到实时位置推送", r),
|
|
3379
|
+
s.debug("收到实时位置推送", r), Nt(V, r, "onLocationChange");
|
|
3380
3380
|
},
|
|
3381
3381
|
fail: (r) => {
|
|
3382
|
-
s.warn("位置变化监听出错,请通过 onLocationChangeError 监听错误", r),
|
|
3382
|
+
s.warn("位置变化监听出错,请通过 onLocationChangeError 监听错误", r), V.delete(t), V.size === 0 && ie("onLocationChange");
|
|
3383
3383
|
}
|
|
3384
3384
|
}));
|
|
3385
3385
|
}, { context: "onLocationChange" });
|
|
3386
3386
|
}
|
|
3387
|
-
function
|
|
3388
|
-
return
|
|
3389
|
-
if (
|
|
3387
|
+
function Wn(t) {
|
|
3388
|
+
return f.safeExecute(() => {
|
|
3389
|
+
if (A()) {
|
|
3390
3390
|
s.warn("当前环境不支持此接口", { platform: l.type });
|
|
3391
3391
|
return;
|
|
3392
3392
|
}
|
|
@@ -3395,19 +3395,19 @@ function Nn(t) {
|
|
|
3395
3395
|
errMsg: "offLocationChange 回调必须是函数",
|
|
3396
3396
|
code: "INVALID_CALLBACK"
|
|
3397
3397
|
};
|
|
3398
|
-
t ?
|
|
3398
|
+
t ? V.delete(t) : V.clear(), !(V.size > 0) && (s.info("移除位置变化监听器"), P("offLocationChange", {}, {
|
|
3399
3399
|
success: () => {
|
|
3400
|
-
s.info("位置变化监听已移除"),
|
|
3400
|
+
s.info("位置变化监听已移除"), ie("onLocationChange");
|
|
3401
3401
|
},
|
|
3402
3402
|
fail: (e) => {
|
|
3403
|
-
s.error("移除位置变化监听失败", e),
|
|
3403
|
+
s.error("移除位置变化监听失败", e), ie("onLocationChange");
|
|
3404
3404
|
}
|
|
3405
3405
|
}));
|
|
3406
3406
|
}, { context: "offLocationChange" });
|
|
3407
3407
|
}
|
|
3408
|
-
function
|
|
3409
|
-
return
|
|
3410
|
-
if (
|
|
3408
|
+
function Bn(t) {
|
|
3409
|
+
return f.safeExecute(() => {
|
|
3410
|
+
if (A()) {
|
|
3411
3411
|
s.warn("当前环境不支持此接口", { platform: l.type });
|
|
3412
3412
|
return;
|
|
3413
3413
|
}
|
|
@@ -3416,20 +3416,20 @@ function Tn(t) {
|
|
|
3416
3416
|
errMsg: "onLocationChangeError 回调必须是函数",
|
|
3417
3417
|
code: "INVALID_CALLBACK"
|
|
3418
3418
|
};
|
|
3419
|
-
const e =
|
|
3420
|
-
|
|
3419
|
+
const e = q.size > 0;
|
|
3420
|
+
q.add(t), e || (s.debug("注册位置更新错误监听器"), P("onLocationChangeError", { isPersistent: !0 }, {
|
|
3421
3421
|
success: (r) => {
|
|
3422
|
-
s.warn("持续定位发生异常", r),
|
|
3422
|
+
s.warn("持续定位发生异常", r), Nt(q, r, "onLocationChangeError");
|
|
3423
3423
|
},
|
|
3424
3424
|
fail: (r) => {
|
|
3425
|
-
s.warn("位置更新错误监听注册失败", r),
|
|
3425
|
+
s.warn("位置更新错误监听注册失败", r), q.delete(t), q.size === 0 && ie("onLocationChangeError");
|
|
3426
3426
|
}
|
|
3427
3427
|
}));
|
|
3428
3428
|
}, { context: "onLocationChangeError" });
|
|
3429
3429
|
}
|
|
3430
|
-
function
|
|
3431
|
-
return
|
|
3432
|
-
if (
|
|
3430
|
+
function $n(t) {
|
|
3431
|
+
return f.safeExecute(() => {
|
|
3432
|
+
if (A()) {
|
|
3433
3433
|
s.warn("当前环境不支持此接口", { platform: l.type });
|
|
3434
3434
|
return;
|
|
3435
3435
|
}
|
|
@@ -3438,24 +3438,24 @@ function Mn(t) {
|
|
|
3438
3438
|
errMsg: "offLocationChangeError 回调必须是函数",
|
|
3439
3439
|
code: "INVALID_CALLBACK"
|
|
3440
3440
|
};
|
|
3441
|
-
t ?
|
|
3441
|
+
t ? q.delete(t) : q.clear(), !(q.size > 0) && (s.info("移除定位错误监听器"), P("offLocationChangeError", {}, {
|
|
3442
3442
|
success: () => {
|
|
3443
|
-
s.info("定位错误监听已移除"),
|
|
3443
|
+
s.info("定位错误监听已移除"), ie("onLocationChangeError");
|
|
3444
3444
|
},
|
|
3445
3445
|
fail: (e) => {
|
|
3446
|
-
s.error("移除定位错误监听失败", e),
|
|
3446
|
+
s.error("移除定位错误监听失败", e), ie("onLocationChangeError");
|
|
3447
3447
|
}
|
|
3448
3448
|
}));
|
|
3449
3449
|
}, { context: "offLocationChangeError" });
|
|
3450
3450
|
}
|
|
3451
|
-
const
|
|
3451
|
+
const kn = {
|
|
3452
3452
|
latitude: null,
|
|
3453
3453
|
// 目标地纬度
|
|
3454
3454
|
longitude: null
|
|
3455
3455
|
// 目标地经度
|
|
3456
3456
|
};
|
|
3457
|
-
function
|
|
3458
|
-
const e =
|
|
3457
|
+
function Fn(t = {}) {
|
|
3458
|
+
const e = g(g({}, kn), t);
|
|
3459
3459
|
return e.latitude !== null && e.latitude !== void 0 && (typeof e.latitude != "number" ? (s.warn("latitude 参数类型错误,已忽略", {
|
|
3460
3460
|
latitude: e.latitude
|
|
3461
3461
|
}), e.latitude = null) : (e.latitude < -90 || e.latitude > 90) && (s.warn("latitude 超出范围,已忽略", {
|
|
@@ -3466,11 +3466,11 @@ function bn(t = {}) {
|
|
|
3466
3466
|
longitude: e.longitude
|
|
3467
3467
|
}), e.longitude = null)), e;
|
|
3468
3468
|
}
|
|
3469
|
-
function
|
|
3469
|
+
function Rt() {
|
|
3470
3470
|
return ["weixin", "webview", "UniApp", "plus", "nvue", "uvue", "offline"].includes(l.type);
|
|
3471
3471
|
}
|
|
3472
|
-
function
|
|
3473
|
-
return
|
|
3472
|
+
function bt(t) {
|
|
3473
|
+
return f.safeExecute(() => {
|
|
3474
3474
|
var n;
|
|
3475
3475
|
if (!window.wx) {
|
|
3476
3476
|
const i = {
|
|
@@ -3480,8 +3480,8 @@ function Et(t) {
|
|
|
3480
3480
|
(n = t.fail) == null || n.call(t, i);
|
|
3481
3481
|
return;
|
|
3482
3482
|
}
|
|
3483
|
-
if (!
|
|
3484
|
-
s.info("等待微信配置完成"),
|
|
3483
|
+
if (!j()) {
|
|
3484
|
+
s.info("等待微信配置完成"), K().then(() => bt(t)).catch((i) => {
|
|
3485
3485
|
var a;
|
|
3486
3486
|
s.error("微信配置失败", i), (a = t.fail) == null || a.call(t, { errMsg: `微信配置失败: ${i.message}` });
|
|
3487
3487
|
});
|
|
@@ -3516,7 +3516,7 @@ function Et(t) {
|
|
|
3516
3516
|
},
|
|
3517
3517
|
complete: t.complete
|
|
3518
3518
|
}, r = {};
|
|
3519
|
-
t.latitude !== null && t.latitude !== void 0 && (r.latitude = t.latitude), t.longitude !== null && t.longitude !== void 0 && (r.longitude = t.longitude), window.wx.chooseLocation(
|
|
3519
|
+
t.latitude !== null && t.latitude !== void 0 && (r.latitude = t.latitude), t.longitude !== null && t.longitude !== void 0 && (r.longitude = t.longitude), window.wx.chooseLocation(m(g({}, r), {
|
|
3520
3520
|
success: e.success,
|
|
3521
3521
|
fail: e.fail,
|
|
3522
3522
|
complete: e.complete
|
|
@@ -3526,8 +3526,8 @@ function Et(t) {
|
|
|
3526
3526
|
platform: "weixin"
|
|
3527
3527
|
});
|
|
3528
3528
|
}
|
|
3529
|
-
function
|
|
3530
|
-
return
|
|
3529
|
+
function Kn(t) {
|
|
3530
|
+
return f.safeExecute(() => {
|
|
3531
3531
|
s.debug("通过 WebView 桥接调用位置选择", t);
|
|
3532
3532
|
const e = {
|
|
3533
3533
|
// 禁用超时清理,等待用户操作完成后才清理
|
|
@@ -3547,7 +3547,7 @@ function xn(t) {
|
|
|
3547
3547
|
},
|
|
3548
3548
|
complete: t.complete
|
|
3549
3549
|
};
|
|
3550
|
-
t.latitude !== null && t.latitude !== void 0 && (e.latitude = t.latitude), t.longitude !== null && t.longitude !== void 0 && (e.longitude = t.longitude),
|
|
3550
|
+
t.latitude !== null && t.latitude !== void 0 && (e.latitude = t.latitude), t.longitude !== null && t.longitude !== void 0 && (e.longitude = t.longitude), P("chooseLocation", e, {
|
|
3551
3551
|
success: (r) => {
|
|
3552
3552
|
e.success(r);
|
|
3553
3553
|
},
|
|
@@ -3561,10 +3561,10 @@ function xn(t) {
|
|
|
3561
3561
|
platform: "uniapp"
|
|
3562
3562
|
});
|
|
3563
3563
|
}
|
|
3564
|
-
function
|
|
3565
|
-
return
|
|
3564
|
+
function zn(t = {}) {
|
|
3565
|
+
return f.safeExecute(() => {
|
|
3566
3566
|
var r;
|
|
3567
|
-
if (!
|
|
3567
|
+
if (!Rt()) {
|
|
3568
3568
|
const n = {
|
|
3569
3569
|
errMsg: `当前环境 (${l.type}) 不支持位置选择功能`,
|
|
3570
3570
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
@@ -3572,22 +3572,22 @@ function vn(t = {}) {
|
|
|
3572
3572
|
s.error("平台不支持位置选择", { platform: l.type }), (r = t.fail) == null || r.call(t, n);
|
|
3573
3573
|
return;
|
|
3574
3574
|
}
|
|
3575
|
-
const e =
|
|
3575
|
+
const e = Fn(t);
|
|
3576
3576
|
s.info("开始选择位置", {
|
|
3577
3577
|
platform: l.type,
|
|
3578
3578
|
latitude: e.latitude,
|
|
3579
3579
|
longitude: e.longitude
|
|
3580
|
-
}),
|
|
3580
|
+
}), A() ? bt(e) : Kn(e);
|
|
3581
3581
|
}, {
|
|
3582
3582
|
context: "chooseLocation",
|
|
3583
3583
|
options: t
|
|
3584
3584
|
});
|
|
3585
3585
|
}
|
|
3586
|
-
function
|
|
3586
|
+
function Gn() {
|
|
3587
3587
|
return {
|
|
3588
|
-
supported:
|
|
3588
|
+
supported: Rt(),
|
|
3589
3589
|
environment: l.type,
|
|
3590
|
-
implementation:
|
|
3590
|
+
implementation: A() ? "weixin" : "webview",
|
|
3591
3591
|
features: {
|
|
3592
3592
|
chooseLocation: !0,
|
|
3593
3593
|
// 支持位置选择
|
|
@@ -3598,62 +3598,191 @@ function Dn() {
|
|
|
3598
3598
|
}
|
|
3599
3599
|
};
|
|
3600
3600
|
}
|
|
3601
|
-
const
|
|
3602
|
-
function
|
|
3603
|
-
|
|
3601
|
+
const Tt = /* @__PURE__ */ new Map();
|
|
3602
|
+
function Vn(t, e = {}) {
|
|
3603
|
+
Tt.set(t, e);
|
|
3604
3604
|
}
|
|
3605
|
-
function
|
|
3606
|
-
const r =
|
|
3605
|
+
function qn(t, e) {
|
|
3606
|
+
const r = Tt.get(t);
|
|
3607
3607
|
if (r)
|
|
3608
3608
|
return r[e] || r.default;
|
|
3609
3609
|
}
|
|
3610
|
-
|
|
3610
|
+
function Mt(t) {
|
|
3611
|
+
return t === "timeline" || t === 1 ? 1 : 0;
|
|
3612
|
+
}
|
|
3613
|
+
function jn(t = {}) {
|
|
3614
|
+
var a;
|
|
3615
|
+
const { kind: e, scene: r = "chat", payload: n = {} } = t, i = Mt(r);
|
|
3616
|
+
if (e === "web") {
|
|
3617
|
+
const o = n.path || n.href;
|
|
3618
|
+
if (!o)
|
|
3619
|
+
throw new Error("toShare: payload.path 或 payload.href 必填(图文链接)");
|
|
3620
|
+
return {
|
|
3621
|
+
type: 0,
|
|
3622
|
+
scene: i,
|
|
3623
|
+
title: n.title,
|
|
3624
|
+
summary: n.summary,
|
|
3625
|
+
imageUrl: n.imageUrl,
|
|
3626
|
+
path: o
|
|
3627
|
+
};
|
|
3628
|
+
}
|
|
3629
|
+
if (e === "text") {
|
|
3630
|
+
const o = (a = n.summary) != null ? a : n.text;
|
|
3631
|
+
if (!o)
|
|
3632
|
+
throw new Error("toShare: payload.summary 或 payload.text 必填(纯文字)");
|
|
3633
|
+
return {
|
|
3634
|
+
type: 1,
|
|
3635
|
+
scene: i,
|
|
3636
|
+
summary: o
|
|
3637
|
+
};
|
|
3638
|
+
}
|
|
3639
|
+
if (e === "image") {
|
|
3640
|
+
if (!n.imageUrl)
|
|
3641
|
+
throw new Error("toShare: payload.imageUrl 必填(纯图片)");
|
|
3642
|
+
return {
|
|
3643
|
+
type: 2,
|
|
3644
|
+
scene: i,
|
|
3645
|
+
imageUrl: n.imageUrl
|
|
3646
|
+
};
|
|
3647
|
+
}
|
|
3648
|
+
if (e === "miniProgram") {
|
|
3649
|
+
if (!n.miniProgram || typeof n.miniProgram != "object")
|
|
3650
|
+
throw new Error("toShare: payload.miniProgram 必填(小程序对象)");
|
|
3651
|
+
return {
|
|
3652
|
+
type: 5,
|
|
3653
|
+
scene: i,
|
|
3654
|
+
title: n.title,
|
|
3655
|
+
summary: n.summary,
|
|
3656
|
+
imageUrl: n.imageUrl,
|
|
3657
|
+
miniProgram: n.miniProgram
|
|
3658
|
+
};
|
|
3659
|
+
}
|
|
3660
|
+
throw new Error(`toShare: 不支持的 kind: ${e}`);
|
|
3661
|
+
}
|
|
3662
|
+
function Jn(t = {}) {
|
|
3663
|
+
const { kind: e, scene: r = "chat" } = t, n = oe(!0), i = Mt(r), a = n.isWeixinMiniProgram === !0, o = i === 1, u = [];
|
|
3664
|
+
return u.push(`当前环境: ${n.type}${a ? "(微信小程序 web-view)" : ""}`), a && u.push(
|
|
3665
|
+
"微信小程序内分享需用户点击右上角「···」菜单;本方法仅负责设置 wx.updateAppMessageShareData / updateTimelineShareData 所需内容。"
|
|
3666
|
+
), e === "miniProgram" && (o ? u.push(
|
|
3667
|
+
"朋友圈不支持小程序卡片:底层 toShare 会按 SDK 将 type=5 自动降级为图文(使用 miniProgram.webUrl 作为链接)。"
|
|
3668
|
+
) : u.push(
|
|
3669
|
+
"聊天框:需 App 与小程序绑定同一微信开放平台且 miniProgram.id 为 gh_ 原始 ID;否则可能失败。"
|
|
3670
|
+
), a && u.push(
|
|
3671
|
+
"在小程序 web-view 内无法直接分享「其他小程序」卡片;如需跨小程序卡片请使用宿主 App 的 OpenSDK 能力。"
|
|
3672
|
+
)), !a && n.type === "h5" && !n.isUniAppWebView && !n.isAppPlus && u.push(
|
|
3673
|
+
"当前为普通 H5:若未嵌入 App WebView,无桥接时 uni.share 可能不可用;请改用微信 JS-SDK 或系统分享。"
|
|
3674
|
+
), {
|
|
3675
|
+
hint: u.join(" "),
|
|
3676
|
+
environment: {
|
|
3677
|
+
type: n.type,
|
|
3678
|
+
isWeixinMiniProgram: a
|
|
3679
|
+
}
|
|
3680
|
+
};
|
|
3681
|
+
}
|
|
3682
|
+
const Hn = {
|
|
3611
3683
|
0: "WXSceneSession",
|
|
3612
3684
|
// 聊天界面
|
|
3613
3685
|
1: "WXSceneTimeline"
|
|
3614
3686
|
// 朋友圈
|
|
3615
|
-
}, $n = {
|
|
3616
|
-
0: "图文/网页",
|
|
3617
|
-
1: "纯文字",
|
|
3618
|
-
2: "纯图片",
|
|
3619
|
-
3: "音乐",
|
|
3620
|
-
4: "视频",
|
|
3621
|
-
5: "小程序"
|
|
3622
3687
|
};
|
|
3623
|
-
function
|
|
3624
|
-
return
|
|
3688
|
+
function z(t) {
|
|
3689
|
+
return typeof t == "string" && t.trim().length > 0;
|
|
3690
|
+
}
|
|
3691
|
+
function fe(t) {
|
|
3692
|
+
return z(t) ? /^https?:\/\/[\S]+$/i.test(t.trim()) : !1;
|
|
3693
|
+
}
|
|
3694
|
+
function Yn(t = {}) {
|
|
3695
|
+
const e = g({}, t);
|
|
3696
|
+
if (Object.prototype.hasOwnProperty.call(e, "scene")) {
|
|
3697
|
+
const n = Number(e.scene);
|
|
3698
|
+
if (![0, 1].includes(n))
|
|
3699
|
+
return { success: !1, message: "参数字段scene值有误!仅支持 0(会话) / 1(朋友圈)" };
|
|
3700
|
+
}
|
|
3701
|
+
if (!Object.prototype.hasOwnProperty.call(e, "type"))
|
|
3702
|
+
return { success: !1, message: "参数字段type缺少!" };
|
|
3703
|
+
const r = Number(e.type);
|
|
3704
|
+
if (![0, 1, 2, 5].includes(r))
|
|
3705
|
+
return { success: !1, message: "参数字段type值有误!仅支持 0(图文) / 1(文字) / 2(图片) / 5(小程序)" };
|
|
3706
|
+
if (r === 0) {
|
|
3707
|
+
if (!z(e.title))
|
|
3708
|
+
return { success: !1, message: "type=0 时,参数字段title值缺少或为空!" };
|
|
3709
|
+
if (!z(e.summary))
|
|
3710
|
+
return { success: !1, message: "type=0 时,参数字段summary值缺少或为空!" };
|
|
3711
|
+
if (!fe(e.imageUrl))
|
|
3712
|
+
return { success: !1, message: "type=0 时,参数字段imageUrl必须为http/https链接!" };
|
|
3713
|
+
if (!fe(e.path))
|
|
3714
|
+
return { success: !1, message: "type=0 时,参数字段path(会映射为href)必须为http/https链接!" };
|
|
3715
|
+
}
|
|
3716
|
+
if (r === 1 && !z(e.summary))
|
|
3717
|
+
return { success: !1, message: "type=1 时,参数字段summary值缺少或为空!" };
|
|
3718
|
+
if (r === 2 && !fe(e.imageUrl))
|
|
3719
|
+
return { success: !1, message: "type=2 时,参数字段imageUrl必须为http/https链接!" };
|
|
3720
|
+
if (r === 5) {
|
|
3721
|
+
if (!z(e.title))
|
|
3722
|
+
return { success: !1, message: "type=5 时,参数字段title值缺少或为空!" };
|
|
3723
|
+
if (!z(e.summary))
|
|
3724
|
+
return { success: !1, message: "type=5 时,参数字段summary值缺少或为空!" };
|
|
3725
|
+
if (!fe(e.imageUrl))
|
|
3726
|
+
return { success: !1, message: "type=5 时,参数字段imageUrl必须为http/https链接!" };
|
|
3727
|
+
if (!e.miniProgram || typeof e.miniProgram != "object")
|
|
3728
|
+
return { success: !1, message: "type=5 时,参数字段miniProgram值缺少或有误!" };
|
|
3729
|
+
const n = e.miniProgram;
|
|
3730
|
+
if (!z(n.id))
|
|
3731
|
+
return { success: !1, message: "type=5 时,miniProgram.id缺少或为空!" };
|
|
3732
|
+
const i = String(n.id).trim();
|
|
3733
|
+
if (/^wx[a-z0-9]+$/i.test(i))
|
|
3734
|
+
return {
|
|
3735
|
+
success: !1,
|
|
3736
|
+
message: "type=5 时,miniProgram.id 需要填写小程序原始ID(gh_开头),当前看起来像 AppId(wx_开头),请在微信公众平台-基本信息中复制“原始ID”"
|
|
3737
|
+
};
|
|
3738
|
+
if (!z(n.path))
|
|
3739
|
+
return { success: !1, message: "type=5 时,miniProgram.path缺少或为空!" };
|
|
3740
|
+
if (!fe(n.webUrl))
|
|
3741
|
+
return { success: !1, message: "type=5 时,miniProgram.webUrl必须为http/https链接!" };
|
|
3742
|
+
if (Object.prototype.hasOwnProperty.call(n, "type")) {
|
|
3743
|
+
const a = Number(n.type);
|
|
3744
|
+
if (![0, 1, 2].includes(a))
|
|
3745
|
+
return { success: !1, message: "type=5 时,miniProgram.type仅支持 0/1/2" };
|
|
3746
|
+
}
|
|
3747
|
+
}
|
|
3748
|
+
return { success: !0 };
|
|
3749
|
+
}
|
|
3750
|
+
function Lt(t = {}) {
|
|
3751
|
+
return f.safeExecute(
|
|
3625
3752
|
() => {
|
|
3626
3753
|
var r;
|
|
3627
3754
|
if (typeof window == "undefined" || !window.wx) {
|
|
3628
3755
|
const n = { errMsg: "微信JS-SDK未加载", code: "WEIXIN_SDK_NOT_LOADED" };
|
|
3629
3756
|
return (r = t.fail) == null || r.call(t, n), Promise.reject(n);
|
|
3630
3757
|
}
|
|
3631
|
-
if (!
|
|
3632
|
-
return s.info("等待微信配置完成"),
|
|
3633
|
-
|
|
3634
|
-
|
|
3635
|
-
|
|
3636
|
-
|
|
3637
|
-
|
|
3638
|
-
|
|
3639
|
-
|
|
3640
|
-
|
|
3641
|
-
|
|
3642
|
-
|
|
3643
|
-
|
|
3644
|
-
|
|
3758
|
+
if (!j())
|
|
3759
|
+
return s.info("等待微信配置完成"), K().then(() => Lt(t));
|
|
3760
|
+
if (t != null && t.isCallBack)
|
|
3761
|
+
return s.debug("微信环境通过 WebView 桥接分享(toShareData)", t), new Promise((n, i) => {
|
|
3762
|
+
P("toShareData", t, {
|
|
3763
|
+
success: (a) => {
|
|
3764
|
+
var o;
|
|
3765
|
+
(o = t.success) == null || o.call(t, a), n(a);
|
|
3766
|
+
},
|
|
3767
|
+
fail: (a) => {
|
|
3768
|
+
var o;
|
|
3769
|
+
s.error("WebView 桥接微信分享失败", a), (o = t.fail) == null || o.call(t, a), i(a);
|
|
3770
|
+
},
|
|
3771
|
+
complete: t.complete
|
|
3772
|
+
});
|
|
3645
3773
|
});
|
|
3646
|
-
|
|
3647
|
-
|
|
3774
|
+
const e = g({}, t);
|
|
3775
|
+
return s.debug("调用微信分享", e), new Promise((n, i) => {
|
|
3776
|
+
window.wx[e.scene](m(g({}, e), {
|
|
3648
3777
|
success: () => {
|
|
3649
3778
|
var o;
|
|
3650
3779
|
const a = { errMsg: "weixinShare:ok" };
|
|
3651
3780
|
(o = t.success) == null || o.call(t, a), n(a);
|
|
3652
3781
|
},
|
|
3653
3782
|
fail: (a) => {
|
|
3654
|
-
var
|
|
3783
|
+
var u;
|
|
3655
3784
|
const o = { errMsg: (a == null ? void 0 : a.errMsg) || "weixinShare:fail", details: a };
|
|
3656
|
-
s.error("微信分享失败", o), (
|
|
3785
|
+
s.error("微信分享失败", o), (u = t.fail) == null || u.call(t, o), i(o);
|
|
3657
3786
|
},
|
|
3658
3787
|
complete: t.complete
|
|
3659
3788
|
}));
|
|
@@ -3665,16 +3794,16 @@ function At(t = {}) {
|
|
|
3665
3794
|
}
|
|
3666
3795
|
);
|
|
3667
3796
|
}
|
|
3668
|
-
function
|
|
3669
|
-
const r =
|
|
3797
|
+
function Xn(t = {}, e) {
|
|
3798
|
+
const r = g({}, t), n = {
|
|
3670
3799
|
scene: r.scene === 1 ? "updateTimelineShareData" : "updateAppMessageShareData"
|
|
3671
3800
|
};
|
|
3672
3801
|
return s.info("格式化微信参数", r), Object.prototype.hasOwnProperty.call(r, "title") ? Object.prototype.hasOwnProperty.call(r, "imageUrl") ? Object.prototype.hasOwnProperty.call(r, "path") ? Object.prototype.hasOwnProperty.call(r, "summary") ? (n.title = r.title, n.imgUrl = r.imageUrl, n.link = r.path, n.desc = r.summary, { params: n, success: !0 }) : { message: "参数字段summary值缺少!", success: !1 } : { message: "参数字段path值缺少!", success: !1 } : { message: "参数字段imageUrl值缺少!9999", success: !1 } : { message: "参数字段title值缺少!", success: !1 };
|
|
3673
3802
|
}
|
|
3674
|
-
function
|
|
3675
|
-
return
|
|
3676
|
-
() => (s.debug("通过 WebView 桥接调用微信分享", t), console.log("桥接调用微信分享桥接调用微信分享:", JSON.stringify(
|
|
3677
|
-
|
|
3803
|
+
function H(t = {}) {
|
|
3804
|
+
return f.safeExecute(
|
|
3805
|
+
() => (s.debug("通过 WebView 桥接调用微信分享", t), console.log("桥接调用微信分享桥接调用微信分享:", JSON.stringify(Qn(t), null, 2)), new Promise((e, r) => {
|
|
3806
|
+
P("toShareData", t, {
|
|
3678
3807
|
success: (n) => {
|
|
3679
3808
|
var i;
|
|
3680
3809
|
(i = t.success) == null || i.call(t, n), e(n);
|
|
@@ -3692,70 +3821,100 @@ function V(t = {}) {
|
|
|
3692
3821
|
}
|
|
3693
3822
|
);
|
|
3694
3823
|
}
|
|
3695
|
-
function
|
|
3696
|
-
const e =
|
|
3824
|
+
function Zn(t = {}) {
|
|
3825
|
+
const e = g({}, t), r = {
|
|
3697
3826
|
provider: "weixin",
|
|
3698
3827
|
scene: "WXSceneSession"
|
|
3699
3828
|
};
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
|
|
3705
|
-
|
|
3706
|
-
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
|
|
3710
|
-
|
|
3711
|
-
|
|
3712
|
-
|
|
3713
|
-
|
|
3714
|
-
|
|
3715
|
-
|
|
3716
|
-
|
|
3717
|
-
|
|
3718
|
-
|
|
3719
|
-
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
|
|
3723
|
-
|
|
3724
|
-
|
|
3725
|
-
|
|
3726
|
-
|
|
3727
|
-
weixin: At,
|
|
3728
|
-
webview: V,
|
|
3729
|
-
plus: V,
|
|
3730
|
-
nvue: V,
|
|
3731
|
-
uvue: V,
|
|
3732
|
-
UniApp: V,
|
|
3733
|
-
offline: V,
|
|
3734
|
-
h5: V,
|
|
3829
|
+
s.info("格式化 UniApp 参数", e);
|
|
3830
|
+
const n = Yn(e);
|
|
3831
|
+
if (!n.success)
|
|
3832
|
+
return n;
|
|
3833
|
+
[0, 1].some((d) => parseInt(d) === parseInt(e.scene)) ? r.scene = Hn[e.scene] : r.scene = "WXSceneSession";
|
|
3834
|
+
const i = Number(e.type), a = r.scene === "WXSceneTimeline", o = i === 5 && a, u = o ? 0 : i;
|
|
3835
|
+
return o && s.info("小程序分享到朋友圈,自动降级为图文分享", {
|
|
3836
|
+
fromType: i,
|
|
3837
|
+
toType: u,
|
|
3838
|
+
scene: r.scene
|
|
3839
|
+
}), r.type = u, [0].includes(u) && (r.href = i === 5 ? e.miniProgram.webUrl : e.path), [0, 1].includes(u) && (r.summary = e.summary), [0, 2, 5].includes(u) && (r.imageUrl = e.imageUrl), [5].includes(u) && (r.miniProgram = {
|
|
3840
|
+
id: e.miniProgram.id,
|
|
3841
|
+
path: e.miniProgram.path,
|
|
3842
|
+
webUrl: e.miniProgram.webUrl,
|
|
3843
|
+
type: Object.prototype.hasOwnProperty.call(e.miniProgram, "type") ? Number(e.miniProgram.type) : 0
|
|
3844
|
+
}), Object.prototype.hasOwnProperty.call(e, "title") && (r.title = e.title), Object.prototype.hasOwnProperty.call(e, "success") && (r.success = e.success), Object.prototype.hasOwnProperty.call(e, "fail") && (r.fail = e.fail), Object.prototype.hasOwnProperty.call(e, "complete") && (r.complete = e.complete), { params: r, success: !0 };
|
|
3845
|
+
}
|
|
3846
|
+
const xt = "share.toShare";
|
|
3847
|
+
Vn(xt, {
|
|
3848
|
+
weixin: Lt,
|
|
3849
|
+
webview: H,
|
|
3850
|
+
plus: H,
|
|
3851
|
+
nvue: H,
|
|
3852
|
+
uvue: H,
|
|
3853
|
+
UniApp: H,
|
|
3854
|
+
offline: H,
|
|
3855
|
+
h5: H,
|
|
3735
3856
|
default: void 0
|
|
3736
3857
|
});
|
|
3737
|
-
function
|
|
3858
|
+
function Qn(t) {
|
|
3738
3859
|
return t && typeof t == "object" && t.__v_raw ? t.__v_raw : t;
|
|
3739
3860
|
}
|
|
3740
|
-
function
|
|
3741
|
-
return
|
|
3861
|
+
function vt(t = {}) {
|
|
3862
|
+
return f.safeExecute(
|
|
3742
3863
|
() => {
|
|
3743
|
-
var
|
|
3744
|
-
|
|
3745
|
-
|
|
3746
|
-
|
|
3747
|
-
|
|
3864
|
+
var Je, He, Ye, Xe;
|
|
3865
|
+
if (!t || typeof t.kind != "string" || !t.kind.trim()) {
|
|
3866
|
+
const T = {
|
|
3867
|
+
errMsg: 'toShare: 请传入 kind("web"|"text"|"image"|"miniProgram")与 payload;可调用 qsh.getToShareParamHelp() 或 qsh.printToShareParamHelp() 查看说明',
|
|
3868
|
+
code: "INVALID_PARAMS"
|
|
3869
|
+
};
|
|
3870
|
+
return (Je = t == null ? void 0 : t.fail) == null || Je.call(t, T), Promise.reject(T);
|
|
3871
|
+
}
|
|
3872
|
+
const {
|
|
3873
|
+
kind: e,
|
|
3874
|
+
scene: r = "chat",
|
|
3875
|
+
payload: n = {},
|
|
3876
|
+
silent: i = !1,
|
|
3877
|
+
viaWebViewBridge: a,
|
|
3878
|
+
isCallBack: o,
|
|
3879
|
+
success: u,
|
|
3880
|
+
fail: d,
|
|
3881
|
+
complete: O
|
|
3882
|
+
} = t, R = a === !0 || o === !0;
|
|
3883
|
+
let _;
|
|
3884
|
+
try {
|
|
3885
|
+
const T = jn({ kind: e, scene: r, payload: n }), J = Jn({ kind: e, scene: r, payload: n }) || {};
|
|
3886
|
+
!i && J.hint && s.info("[toShare]", J.hint), _ = m(g({}, T), {
|
|
3887
|
+
success: (Me) => {
|
|
3888
|
+
u == null || u(m(g({}, J), { raw: Me }));
|
|
3889
|
+
},
|
|
3890
|
+
fail: (Me) => {
|
|
3891
|
+
d == null || d(m(g({}, J), { error: Me }));
|
|
3892
|
+
},
|
|
3893
|
+
complete: O
|
|
3894
|
+
});
|
|
3895
|
+
} catch (T) {
|
|
3896
|
+
const J = { errMsg: T.message || String(T), code: "INVALID_PARAMS" };
|
|
3897
|
+
return (He = t.fail) == null || He.call(t, J), Promise.reject(J);
|
|
3898
|
+
}
|
|
3899
|
+
const v = oe(), je = qn(xt, v.type);
|
|
3900
|
+
if (typeof je != "function") {
|
|
3901
|
+
const T = {
|
|
3902
|
+
errMsg: `当前环境 (${v.type}) 不支持微信分享功能`,
|
|
3748
3903
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
3749
3904
|
};
|
|
3750
|
-
return s.error("平台不支持微信分享", { platform:
|
|
3905
|
+
return s.error("平台不支持微信分享", { platform: v.type }), (Ye = _.fail) == null || Ye.call(_, T), Promise.reject(T);
|
|
3751
3906
|
}
|
|
3752
|
-
const
|
|
3753
|
-
if (!
|
|
3754
|
-
const
|
|
3755
|
-
return (
|
|
3907
|
+
const Ee = A() ? Xn(_) : Zn(_);
|
|
3908
|
+
if (!Ee.success) {
|
|
3909
|
+
const T = { errMsg: Ee.message || "参数校验失败", code: "INVALID_PARAMS" };
|
|
3910
|
+
return (Xe = _.fail) == null || Xe.call(_, T), Promise.reject(T);
|
|
3756
3911
|
}
|
|
3757
|
-
|
|
3758
|
-
return
|
|
3912
|
+
let ce = Ee.params;
|
|
3913
|
+
return R && v.type === "weixin" && (ce = m(g({}, Ee.params), { isCallBack: !0 })), s.info("开始微信分享", {
|
|
3914
|
+
platform: v.type,
|
|
3915
|
+
type: ce == null ? void 0 : ce.type,
|
|
3916
|
+
viaWebViewBridge: R && v.type === "weixin"
|
|
3917
|
+
}), je(ce);
|
|
3759
3918
|
},
|
|
3760
3919
|
{
|
|
3761
3920
|
context: "toShare",
|
|
@@ -3763,49 +3922,159 @@ function _t(t = {}) {
|
|
|
3763
3922
|
}
|
|
3764
3923
|
);
|
|
3765
3924
|
}
|
|
3766
|
-
function
|
|
3925
|
+
function ei(t = {}) {
|
|
3767
3926
|
return new Promise((e, r) => {
|
|
3768
|
-
|
|
3927
|
+
vt(m(g({}, t), {
|
|
3769
3928
|
success: e,
|
|
3770
3929
|
fail: r
|
|
3771
3930
|
}));
|
|
3772
3931
|
});
|
|
3773
3932
|
}
|
|
3774
|
-
|
|
3775
|
-
|
|
3776
|
-
|
|
3777
|
-
|
|
3778
|
-
|
|
3779
|
-
|
|
3780
|
-
|
|
3781
|
-
|
|
3782
|
-
|
|
3783
|
-
|
|
3784
|
-
|
|
3933
|
+
const ke = Object.freeze({
|
|
3934
|
+
version: 1,
|
|
3935
|
+
api: "toShare",
|
|
3936
|
+
description: "qsh.toShare 仅支持高阶入参:必须传 kind 与 payload;scene 可选(会话/朋友圈)。可选 viaWebViewBridge(或已废弃别名 isCallBack):在微信 JS-SDK 环境改走宿主 WebView 桥 toShareData,等同原 toShareCallBack。",
|
|
3937
|
+
topLevel: {
|
|
3938
|
+
kind: {
|
|
3939
|
+
type: "string",
|
|
3940
|
+
required: !0,
|
|
3941
|
+
enum: ["web", "text", "image", "miniProgram"],
|
|
3942
|
+
description: "分享内容类型"
|
|
3943
|
+
},
|
|
3944
|
+
payload: {
|
|
3945
|
+
type: "object",
|
|
3946
|
+
required: !0,
|
|
3947
|
+
description: "各 kind 所需字段见下方 payloadByKind"
|
|
3948
|
+
},
|
|
3949
|
+
scene: {
|
|
3950
|
+
type: "string | number",
|
|
3951
|
+
required: !1,
|
|
3952
|
+
default: "chat",
|
|
3953
|
+
enum: ["chat", "timeline", 0, 1],
|
|
3954
|
+
description: "chat 或 0:微信会话;timeline 或 1:朋友圈(小程序卡片到朋友圈会按 SDK 降级为图文)"
|
|
3955
|
+
},
|
|
3956
|
+
silent: {
|
|
3957
|
+
type: "boolean",
|
|
3958
|
+
required: !1,
|
|
3959
|
+
default: !1,
|
|
3960
|
+
description: "为 true 时不将环境 hint 打到日志"
|
|
3961
|
+
},
|
|
3962
|
+
viaWebViewBridge: {
|
|
3963
|
+
type: "boolean",
|
|
3964
|
+
required: !1,
|
|
3965
|
+
default: !1,
|
|
3966
|
+
description: "为 true 且运行在微信 JS-SDK 环境(env.type=weixin)时,不调用 wx.update*ShareData,改走宿主 WebView 桥 toShareData(等同已移除的 toShareCallBack)"
|
|
3967
|
+
},
|
|
3968
|
+
isCallBack: {
|
|
3969
|
+
type: "boolean",
|
|
3970
|
+
required: !1,
|
|
3971
|
+
description: "已废弃,等同于 viaWebViewBridge: true,请改用 viaWebViewBridge"
|
|
3972
|
+
},
|
|
3973
|
+
success: { type: "function", required: !1 },
|
|
3974
|
+
fail: { type: "function", required: !1 },
|
|
3975
|
+
complete: { type: "function", required: !1 }
|
|
3976
|
+
},
|
|
3977
|
+
payloadByKind: {
|
|
3978
|
+
web: {
|
|
3979
|
+
fields: {
|
|
3980
|
+
title: { required: !0, type: "string", description: "标题" },
|
|
3981
|
+
summary: { required: !0, type: "string", description: "摘要" },
|
|
3982
|
+
imageUrl: { required: !0, type: "string", description: "缩略图,http/https" },
|
|
3983
|
+
path: { required: "与 href 二选一", type: "string", description: "网页链接 http/https" },
|
|
3984
|
+
href: { required: "与 path 二选一", type: "string", description: "同 path" }
|
|
3785
3985
|
}
|
|
3786
|
-
|
|
3787
|
-
|
|
3788
|
-
|
|
3789
|
-
|
|
3986
|
+
},
|
|
3987
|
+
text: {
|
|
3988
|
+
fields: {
|
|
3989
|
+
summary: { required: "与 text 二选一", type: "string", description: "文字内容" },
|
|
3990
|
+
text: { required: "与 summary 二选一", type: "string", description: "同 summary" }
|
|
3991
|
+
}
|
|
3992
|
+
},
|
|
3993
|
+
image: {
|
|
3994
|
+
fields: {
|
|
3995
|
+
imageUrl: { required: !0, type: "string", description: "图片地址 http/https" }
|
|
3790
3996
|
}
|
|
3791
|
-
const i = n.params;
|
|
3792
|
-
return s.info("开始微信分享", { platform: e.type, type: i == null ? void 0 : i.type }), r(p(d({}, i), { isCallBack: !0 }));
|
|
3793
3997
|
},
|
|
3998
|
+
miniProgram: {
|
|
3999
|
+
fields: {
|
|
4000
|
+
title: { required: !0, type: "string", description: "卡片标题" },
|
|
4001
|
+
summary: { required: !0, type: "string", description: "描述" },
|
|
4002
|
+
imageUrl: { required: !0, type: "string", description: "缩略图 http/https" },
|
|
4003
|
+
miniProgram: {
|
|
4004
|
+
required: !0,
|
|
4005
|
+
type: "object",
|
|
4006
|
+
description: "小程序信息",
|
|
4007
|
+
nested: {
|
|
4008
|
+
id: { required: !0, type: "string", description: "原始 ID,一般为 gh_ 开头(非 wx AppId)" },
|
|
4009
|
+
path: { required: !0, type: "string", description: "小程序页面路径" },
|
|
4010
|
+
webUrl: { required: !0, type: "string", description: "低版本兜底网页 http/https" },
|
|
4011
|
+
type: { required: !1, type: "0|1|2", description: "0 正式 1 开发 2 体验" }
|
|
4012
|
+
}
|
|
4013
|
+
}
|
|
4014
|
+
}
|
|
4015
|
+
}
|
|
4016
|
+
},
|
|
4017
|
+
examples: [
|
|
3794
4018
|
{
|
|
3795
|
-
|
|
3796
|
-
|
|
4019
|
+
name: "图文 → 会话",
|
|
4020
|
+
code: `qsh.toShare({
|
|
4021
|
+
kind: 'web',
|
|
4022
|
+
scene: 'chat',
|
|
4023
|
+
payload: {
|
|
4024
|
+
title: '标题',
|
|
4025
|
+
summary: '摘要',
|
|
4026
|
+
imageUrl: 'https://example.com/cover.jpg',
|
|
4027
|
+
path: 'https://example.com/page'
|
|
4028
|
+
}
|
|
4029
|
+
})`
|
|
4030
|
+
},
|
|
4031
|
+
{
|
|
4032
|
+
name: "小程序卡片 → 会话",
|
|
4033
|
+
code: `qsh.toShare({
|
|
4034
|
+
kind: 'miniProgram',
|
|
4035
|
+
scene: 0,
|
|
4036
|
+
payload: {
|
|
4037
|
+
title: '标题',
|
|
4038
|
+
summary: '描述',
|
|
4039
|
+
imageUrl: 'https://example.com/cover.jpg',
|
|
4040
|
+
miniProgram: {
|
|
4041
|
+
id: 'gh_xxxx',
|
|
4042
|
+
path: '/pages/home/index',
|
|
4043
|
+
webUrl: 'https://example.com/h5',
|
|
4044
|
+
type: 0
|
|
3797
4045
|
}
|
|
3798
|
-
|
|
4046
|
+
}
|
|
4047
|
+
})`
|
|
4048
|
+
},
|
|
4049
|
+
{
|
|
4050
|
+
name: "微信 H5 内走 WebView 桥(原 toShareCallBack)",
|
|
4051
|
+
code: `qsh.toShare({
|
|
4052
|
+
kind: 'web',
|
|
4053
|
+
scene: 'chat',
|
|
4054
|
+
viaWebViewBridge: true,
|
|
4055
|
+
payload: {
|
|
4056
|
+
title: '标题',
|
|
4057
|
+
summary: '摘要',
|
|
4058
|
+
imageUrl: 'https://example.com/cover.jpg',
|
|
4059
|
+
path: 'https://example.com/page'
|
|
4060
|
+
}
|
|
4061
|
+
})`
|
|
4062
|
+
}
|
|
4063
|
+
]
|
|
4064
|
+
});
|
|
4065
|
+
function ti() {
|
|
4066
|
+
return ke;
|
|
3799
4067
|
}
|
|
3800
|
-
function
|
|
3801
|
-
|
|
3802
|
-
|
|
3803
|
-
|
|
3804
|
-
fail: r
|
|
3805
|
-
}));
|
|
4068
|
+
function ri() {
|
|
4069
|
+
const t = ke, e = [];
|
|
4070
|
+
e.push(`[${t.api}] ${t.description}`), e.push(""), e.push("顶层字段:", JSON.stringify(t.topLevel, null, 2)), e.push(""), e.push("各 kind 的 payload:", JSON.stringify(t.payloadByKind, null, 2)), e.push(""), e.push("示例:"), t.examples.forEach((n) => {
|
|
4071
|
+
e.push(`--- ${n.name} ---`), e.push(n.code);
|
|
3806
4072
|
});
|
|
4073
|
+
const r = e.join(`
|
|
4074
|
+
`);
|
|
4075
|
+
return typeof console != "undefined" && console.log && console.log(r), r;
|
|
3807
4076
|
}
|
|
3808
|
-
const
|
|
4077
|
+
const ni = {
|
|
3809
4078
|
OFF: "off",
|
|
3810
4079
|
// 蓝牙关闭
|
|
3811
4080
|
ON: "on",
|
|
@@ -3814,29 +4083,29 @@ const kn = {
|
|
|
3814
4083
|
// 不支持蓝牙
|
|
3815
4084
|
UNAUTHORIZED: "unauthorized"
|
|
3816
4085
|
// 未授权
|
|
3817
|
-
},
|
|
4086
|
+
}, ii = {
|
|
3818
4087
|
allowDuplicatesKey: !1,
|
|
3819
4088
|
// 是否允许重复上报同一设备
|
|
3820
4089
|
services: []
|
|
3821
4090
|
// 指定服务 UUID 列表
|
|
3822
4091
|
};
|
|
3823
|
-
function
|
|
3824
|
-
return
|
|
4092
|
+
function Te(t = {}) {
|
|
4093
|
+
return g(g({}, ii), t);
|
|
3825
4094
|
}
|
|
3826
|
-
function
|
|
4095
|
+
function we() {
|
|
3827
4096
|
return ["weixin", "webview", "UniApp", "plus", "nvue", "uvue", "offline"].includes(l.type);
|
|
3828
4097
|
}
|
|
3829
|
-
function
|
|
3830
|
-
return
|
|
4098
|
+
function si(t) {
|
|
4099
|
+
return f.safeExecute(() => h(null, null, function* () {
|
|
3831
4100
|
var e;
|
|
3832
4101
|
if (!window.wx) {
|
|
3833
4102
|
const r = { errMsg: "微信JS-SDK未加载", code: "WEIXIN_SDK_NOT_LOADED" };
|
|
3834
4103
|
(e = t.fail) == null || e.call(t, r);
|
|
3835
4104
|
return;
|
|
3836
4105
|
}
|
|
3837
|
-
|
|
4106
|
+
j() || (s.info("等待微信配置完成"), yield K()), wx.openBluetoothAdapter({
|
|
3838
4107
|
success: () => {
|
|
3839
|
-
s.info("微信蓝牙适配器已打开"),
|
|
4108
|
+
s.info("微信蓝牙适配器已打开"), Dt(t);
|
|
3840
4109
|
},
|
|
3841
4110
|
fail: (r) => {
|
|
3842
4111
|
var n;
|
|
@@ -3845,9 +4114,9 @@ function Kn(t) {
|
|
|
3845
4114
|
});
|
|
3846
4115
|
}), { context: "openBluetoothAdapterInWeixin" });
|
|
3847
4116
|
}
|
|
3848
|
-
function
|
|
3849
|
-
return
|
|
3850
|
-
s.debug("通过 WebView 桥接调用蓝牙功能", t),
|
|
4117
|
+
function ai(t) {
|
|
4118
|
+
return f.safeExecute(() => {
|
|
4119
|
+
s.debug("通过 WebView 桥接调用蓝牙功能", t), P("bluetooth", t, {
|
|
3851
4120
|
success: (e) => {
|
|
3852
4121
|
var r;
|
|
3853
4122
|
s.info("UniApp 蓝牙调用成功", e), (r = t.success) == null || r.call(t, e);
|
|
@@ -3860,10 +4129,10 @@ function Gn(t) {
|
|
|
3860
4129
|
});
|
|
3861
4130
|
}, { context: "bluetoothInUniApp" });
|
|
3862
4131
|
}
|
|
3863
|
-
function
|
|
3864
|
-
return
|
|
4132
|
+
function oi(t) {
|
|
4133
|
+
return f.safeExecute(() => {
|
|
3865
4134
|
var e;
|
|
3866
|
-
s.debug("通过 WebView 桥接调用蓝牙设备搜索功能", t),
|
|
4135
|
+
s.debug("通过 WebView 桥接调用蓝牙设备搜索功能", t), P("bluetoothDevicesDiscovery", {
|
|
3867
4136
|
action: "startBluetoothDevicesDiscovery",
|
|
3868
4137
|
params: {
|
|
3869
4138
|
services: t.services || [],
|
|
@@ -3882,11 +4151,11 @@ function Vn(t) {
|
|
|
3882
4151
|
});
|
|
3883
4152
|
}, { context: "startBluetoothDevicesDiscoveryInUniApp" });
|
|
3884
4153
|
}
|
|
3885
|
-
const
|
|
3886
|
-
function
|
|
3887
|
-
return
|
|
4154
|
+
const Ie = /* @__PURE__ */ new Set();
|
|
4155
|
+
function ci(t, e = {}) {
|
|
4156
|
+
return f.safeExecute(() => {
|
|
3888
4157
|
var r;
|
|
3889
|
-
return
|
|
4158
|
+
return Ie.add(t), Ie.size === 1 && P("onBluetoothDeviceFound", {
|
|
3890
4159
|
action: "onBluetoothDeviceFound",
|
|
3891
4160
|
isPersistent: !0,
|
|
3892
4161
|
params: {
|
|
@@ -3895,8 +4164,8 @@ function jn(t, e = {}) {
|
|
|
3895
4164
|
}
|
|
3896
4165
|
}, {
|
|
3897
4166
|
success: (n) => {
|
|
3898
|
-
|
|
3899
|
-
typeof i == "function" ?
|
|
4167
|
+
Ie.forEach((i) => {
|
|
4168
|
+
typeof i == "function" ? f.safeExecute(() => i(n), { context: "BluetoothDeviceCallback" }) : console.warn("[BluetoothDeviceCallback] 不是函数:", i);
|
|
3900
4169
|
});
|
|
3901
4170
|
},
|
|
3902
4171
|
fail: (n) => {
|
|
@@ -3904,13 +4173,13 @@ function jn(t, e = {}) {
|
|
|
3904
4173
|
console.error("[Bluetooth] 搜索失败:", n), (i = e.fail) == null || i.call(e, n);
|
|
3905
4174
|
},
|
|
3906
4175
|
complete: e.complete
|
|
3907
|
-
}), () =>
|
|
4176
|
+
}), () => Ie.delete(t);
|
|
3908
4177
|
}, { context: "qsh_onBluetoothDeviceFound" });
|
|
3909
4178
|
}
|
|
3910
|
-
function
|
|
3911
|
-
return
|
|
4179
|
+
function ui(t) {
|
|
4180
|
+
return f.safeExecute(() => {
|
|
3912
4181
|
var e;
|
|
3913
|
-
s.debug("通过 WebView 桥接调用蓝牙连接功能", t),
|
|
4182
|
+
s.debug("通过 WebView 桥接调用蓝牙连接功能", t), P("bluetoothConnection", {
|
|
3914
4183
|
action: "createBLEConnection",
|
|
3915
4184
|
params: {
|
|
3916
4185
|
deviceId: t.deviceId,
|
|
@@ -3930,10 +4199,10 @@ function qn(t) {
|
|
|
3930
4199
|
});
|
|
3931
4200
|
}, { context: "createBLEConnectionInUniApp" });
|
|
3932
4201
|
}
|
|
3933
|
-
function
|
|
3934
|
-
return
|
|
4202
|
+
function li(t = {}) {
|
|
4203
|
+
return f.safeExecute(() => {
|
|
3935
4204
|
var r;
|
|
3936
|
-
if (!
|
|
4205
|
+
if (!we()) {
|
|
3937
4206
|
const n = {
|
|
3938
4207
|
errMsg: `当前环境 (${l.type}) 不支持蓝牙功能`,
|
|
3939
4208
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
@@ -3941,18 +4210,18 @@ function Jn(t = {}) {
|
|
|
3941
4210
|
s.error("平台不支持蓝牙", { platform: l.type }), (r = t.fail) == null || r.call(t, n);
|
|
3942
4211
|
return;
|
|
3943
4212
|
}
|
|
3944
|
-
const e =
|
|
4213
|
+
const e = Te(t);
|
|
3945
4214
|
s.info("开始蓝牙操作", {
|
|
3946
4215
|
platform: l.type,
|
|
3947
4216
|
services: e.services,
|
|
3948
4217
|
allowDuplicatesKey: e.allowDuplicatesKey
|
|
3949
|
-
}),
|
|
4218
|
+
}), A() ? si(e) : ai(e);
|
|
3950
4219
|
}, { context: "openBluetoothAdapter", options: t });
|
|
3951
4220
|
}
|
|
3952
|
-
function
|
|
3953
|
-
return
|
|
4221
|
+
function fi(t = {}) {
|
|
4222
|
+
return f.safeExecute(() => {
|
|
3954
4223
|
var r, n;
|
|
3955
|
-
if (!
|
|
4224
|
+
if (!we()) {
|
|
3956
4225
|
const i = {
|
|
3957
4226
|
errMsg: `当前环境 (${l.type}) 不支持蓝牙功能`,
|
|
3958
4227
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
@@ -3960,18 +4229,18 @@ function Hn(t = {}) {
|
|
|
3960
4229
|
s.error("平台不支持蓝牙", { platform: l.type }), (r = t.fail) == null || r.call(t, i), (n = t.complete) == null || n.call(t, i);
|
|
3961
4230
|
return;
|
|
3962
4231
|
}
|
|
3963
|
-
const e =
|
|
4232
|
+
const e = Te(t);
|
|
3964
4233
|
s.info("开始搜索蓝牙设备", {
|
|
3965
4234
|
platform: l.type,
|
|
3966
4235
|
services: e.services,
|
|
3967
4236
|
allowDuplicatesKey: e.allowDuplicatesKey
|
|
3968
|
-
}),
|
|
4237
|
+
}), A() ? startBluetoothDevicesDiscoveryInWeixin(e) : oi(e);
|
|
3969
4238
|
}, { context: "startBluetoothDevicesDiscovery", options: t });
|
|
3970
4239
|
}
|
|
3971
|
-
function
|
|
3972
|
-
return
|
|
4240
|
+
function Dt(t, e = {}) {
|
|
4241
|
+
return f.safeExecute(() => {
|
|
3973
4242
|
var n, i;
|
|
3974
|
-
if (!
|
|
4243
|
+
if (!we()) {
|
|
3975
4244
|
const a = {
|
|
3976
4245
|
errMsg: `当前环境 (${l.type}) 不支持蓝牙功能`,
|
|
3977
4246
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
@@ -3979,14 +4248,14 @@ function Rt(t, e = {}) {
|
|
|
3979
4248
|
s.error("平台不支持蓝牙", { platform: l.type }), (n = e.fail) == null || n.call(e, a), (i = e.complete) == null || i.call(e, a);
|
|
3980
4249
|
return;
|
|
3981
4250
|
}
|
|
3982
|
-
const r =
|
|
3983
|
-
s.info("注册蓝牙设备发现监听", { platform: l.type }),
|
|
4251
|
+
const r = Te(e);
|
|
4252
|
+
s.info("注册蓝牙设备发现监听", { platform: l.type }), A() ? onBluetoothDeviceFoundInWeixin(r) : ci(t, r);
|
|
3984
4253
|
}, { context: "onBluetoothDeviceFound", options: e });
|
|
3985
4254
|
}
|
|
3986
|
-
function
|
|
3987
|
-
return
|
|
3988
|
-
var a, o,
|
|
3989
|
-
if (!
|
|
4255
|
+
function di(t = {}) {
|
|
4256
|
+
return f.safeExecute(() => {
|
|
4257
|
+
var a, o, u, d;
|
|
4258
|
+
if (!we()) {
|
|
3990
4259
|
const O = {
|
|
3991
4260
|
errMsg: `当前环境 (${l.type}) 不支持蓝牙功能`,
|
|
3992
4261
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
@@ -3994,26 +4263,26 @@ function Yn(t = {}) {
|
|
|
3994
4263
|
s.error("平台不支持蓝牙连接", { platform: l.type }), (a = t.fail) == null || a.call(t, O), (o = t.complete) == null || o.call(t, O);
|
|
3995
4264
|
return;
|
|
3996
4265
|
}
|
|
3997
|
-
const e =
|
|
4266
|
+
const e = Te(t), { name: r, deviceId: n, autoConnect: i = !1 } = e;
|
|
3998
4267
|
if (!n) {
|
|
3999
4268
|
const O = { errMsg: "缺少 deviceId 参数", code: "INVALID_PARAMS" };
|
|
4000
|
-
(
|
|
4269
|
+
(u = t.fail) == null || u.call(t, O), (d = t.complete) == null || d.call(t, O);
|
|
4001
4270
|
return;
|
|
4002
4271
|
}
|
|
4003
|
-
s.info("创建蓝牙连接", { deviceId: n, autoConnect: i, platform: l.type }),
|
|
4272
|
+
s.info("创建蓝牙连接", { deviceId: n, autoConnect: i, platform: l.type }), A() ? uni.createBLEConnection({
|
|
4004
4273
|
deviceId: n,
|
|
4005
4274
|
autoConnect: i,
|
|
4006
4275
|
success: t.success,
|
|
4007
4276
|
fail: t.fail,
|
|
4008
4277
|
complete: t.complete
|
|
4009
|
-
}) :
|
|
4278
|
+
}) : ui(e);
|
|
4010
4279
|
}, { context: "createBLEConnection", options: t });
|
|
4011
4280
|
}
|
|
4012
|
-
function
|
|
4281
|
+
function gi() {
|
|
4013
4282
|
return {
|
|
4014
|
-
supported:
|
|
4283
|
+
supported: we(),
|
|
4015
4284
|
environment: l.type,
|
|
4016
|
-
implementation:
|
|
4285
|
+
implementation: A() ? "weixin" : "webview",
|
|
4017
4286
|
features: {
|
|
4018
4287
|
discovery: !0,
|
|
4019
4288
|
connect: !0,
|
|
@@ -4023,18 +4292,18 @@ function Xn() {
|
|
|
4023
4292
|
}
|
|
4024
4293
|
};
|
|
4025
4294
|
}
|
|
4026
|
-
const
|
|
4295
|
+
const pi = {
|
|
4027
4296
|
// TODO: 添加更多默认配置
|
|
4028
4297
|
};
|
|
4029
|
-
function
|
|
4030
|
-
return
|
|
4298
|
+
function mi(t = {}) {
|
|
4299
|
+
return g(g({}, pi), t);
|
|
4031
4300
|
}
|
|
4032
|
-
function
|
|
4301
|
+
function Ut() {
|
|
4033
4302
|
return ["webview", "UniApp", "plus", "nvue", "uvue", "offline"].includes(l.type);
|
|
4034
4303
|
}
|
|
4035
|
-
function
|
|
4036
|
-
return
|
|
4037
|
-
s.debug("通过 WebView 桥接调用打印PDF", t),
|
|
4304
|
+
function hi(t) {
|
|
4305
|
+
return f.safeExecute(() => {
|
|
4306
|
+
s.debug("通过 WebView 桥接调用打印PDF", t), P("printPdf", m(g({}, t), {
|
|
4038
4307
|
isPersistent: !0
|
|
4039
4308
|
// 强制禁用超时自动清理
|
|
4040
4309
|
}), {
|
|
@@ -4053,10 +4322,10 @@ function ei(t) {
|
|
|
4053
4322
|
platform: "uniapp"
|
|
4054
4323
|
});
|
|
4055
4324
|
}
|
|
4056
|
-
function
|
|
4057
|
-
return
|
|
4325
|
+
function wi(t = {}) {
|
|
4326
|
+
return f.safeExecute(() => {
|
|
4058
4327
|
var r;
|
|
4059
|
-
if (!
|
|
4328
|
+
if (!Ut()) {
|
|
4060
4329
|
const n = {
|
|
4061
4330
|
errMsg: `当前环境 (${l.type}) 不支持打印PDF功能`,
|
|
4062
4331
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
@@ -4064,16 +4333,16 @@ function ti(t = {}) {
|
|
|
4064
4333
|
s.error("平台不支持打印PDF", { platform: l.type }), (r = t.fail) == null || r.call(t, n);
|
|
4065
4334
|
return;
|
|
4066
4335
|
}
|
|
4067
|
-
const e =
|
|
4068
|
-
s.info("开始打印PDF", { platform: l.type }),
|
|
4336
|
+
const e = mi(t);
|
|
4337
|
+
s.info("开始打印PDF", { platform: l.type }), hi(e);
|
|
4069
4338
|
}, {
|
|
4070
4339
|
context: "printPdf",
|
|
4071
4340
|
options: t
|
|
4072
4341
|
});
|
|
4073
4342
|
}
|
|
4074
|
-
function
|
|
4343
|
+
function Ei() {
|
|
4075
4344
|
return {
|
|
4076
|
-
supported:
|
|
4345
|
+
supported: Ut(),
|
|
4077
4346
|
environment: l.type,
|
|
4078
4347
|
implementation: "uniapp",
|
|
4079
4348
|
features: {
|
|
@@ -4081,9 +4350,9 @@ function ri() {
|
|
|
4081
4350
|
}
|
|
4082
4351
|
};
|
|
4083
4352
|
}
|
|
4084
|
-
const
|
|
4085
|
-
function
|
|
4086
|
-
const e =
|
|
4353
|
+
const De = "/pages/face/index";
|
|
4354
|
+
function yi(t = {}) {
|
|
4355
|
+
const e = g({}, t);
|
|
4087
4356
|
if (!e.name || typeof e.name != "string" || !e.name.trim())
|
|
4088
4357
|
throw {
|
|
4089
4358
|
errMsg: "缺少必需参数:name(姓名)",
|
|
@@ -4096,26 +4365,26 @@ function ni(t = {}) {
|
|
|
4096
4365
|
};
|
|
4097
4366
|
return e.idCardNumber = e.idCardNumber.trim(), e;
|
|
4098
4367
|
}
|
|
4099
|
-
function
|
|
4100
|
-
return
|
|
4368
|
+
function Wt() {
|
|
4369
|
+
return A();
|
|
4101
4370
|
}
|
|
4102
|
-
function
|
|
4371
|
+
function Ii() {
|
|
4103
4372
|
return typeof window != "undefined" && window.wx && window.wx.miniProgram && typeof window.wx.miniProgram.navigateTo == "function";
|
|
4104
4373
|
}
|
|
4105
|
-
function
|
|
4106
|
-
const e =
|
|
4374
|
+
function Ai(t) {
|
|
4375
|
+
const e = m(g({}, t), {
|
|
4107
4376
|
title: document.title || "",
|
|
4108
4377
|
url: window.location.href || ""
|
|
4109
4378
|
}), r = Object.entries(e).filter(([, n]) => n != null && n !== "").map(([n, i]) => `${encodeURIComponent(n)}=${encodeURIComponent(String(i))}`).join("&");
|
|
4110
|
-
return r ? `${
|
|
4379
|
+
return r ? `${De}?${r}` : De;
|
|
4111
4380
|
}
|
|
4112
|
-
function
|
|
4113
|
-
return
|
|
4114
|
-
if (!
|
|
4381
|
+
function Oi(t) {
|
|
4382
|
+
return f.safeExecute(() => {
|
|
4383
|
+
if (!Ii()) {
|
|
4115
4384
|
s.error("微信小程序导航API不可用");
|
|
4116
4385
|
return;
|
|
4117
4386
|
}
|
|
4118
|
-
const e =
|
|
4387
|
+
const e = Ai(t);
|
|
4119
4388
|
s.debug("跳转宿主人脸识别页面", {
|
|
4120
4389
|
name: t.name,
|
|
4121
4390
|
targetUrl: e
|
|
@@ -4133,15 +4402,15 @@ function ai(t) {
|
|
|
4133
4402
|
platform: "weixin"
|
|
4134
4403
|
});
|
|
4135
4404
|
}
|
|
4136
|
-
function
|
|
4137
|
-
return
|
|
4138
|
-
if (!
|
|
4405
|
+
function _i(t = {}) {
|
|
4406
|
+
return f.safeExecute(() => {
|
|
4407
|
+
if (!Wt()) {
|
|
4139
4408
|
s.error("平台不支持人脸识别", { platform: l.type });
|
|
4140
4409
|
return;
|
|
4141
4410
|
}
|
|
4142
4411
|
let e;
|
|
4143
4412
|
try {
|
|
4144
|
-
e =
|
|
4413
|
+
e = yi(t);
|
|
4145
4414
|
} catch (r) {
|
|
4146
4415
|
s.error("人脸识别参数校验失败", r);
|
|
4147
4416
|
return;
|
|
@@ -4149,16 +4418,16 @@ function oi(t = {}) {
|
|
|
4149
4418
|
s.info("开始人脸识别", {
|
|
4150
4419
|
platform: l.type,
|
|
4151
4420
|
name: e.name,
|
|
4152
|
-
pagePath:
|
|
4153
|
-
}),
|
|
4421
|
+
pagePath: De
|
|
4422
|
+
}), Oi(e);
|
|
4154
4423
|
}, {
|
|
4155
4424
|
context: "faceVerify",
|
|
4156
4425
|
options: t
|
|
4157
4426
|
});
|
|
4158
4427
|
}
|
|
4159
|
-
function
|
|
4428
|
+
function Ci() {
|
|
4160
4429
|
return {
|
|
4161
|
-
supported:
|
|
4430
|
+
supported: Wt(),
|
|
4162
4431
|
environment: l.type,
|
|
4163
4432
|
implementation: "weixin",
|
|
4164
4433
|
features: {
|
|
@@ -4167,192 +4436,192 @@ function ci() {
|
|
|
4167
4436
|
}
|
|
4168
4437
|
};
|
|
4169
4438
|
}
|
|
4170
|
-
const
|
|
4171
|
-
function
|
|
4172
|
-
if (typeof window == "undefined" || !
|
|
4439
|
+
const Bt = oe();
|
|
4440
|
+
function Pi() {
|
|
4441
|
+
if (typeof window == "undefined" || !oe(!0).isWeixinMiniProgram)
|
|
4173
4442
|
return !1;
|
|
4174
|
-
const e =
|
|
4443
|
+
const e = xe().getRuntimeConfig();
|
|
4175
4444
|
return typeof e.clientId == "string" && e.clientId.length > 0;
|
|
4176
4445
|
}
|
|
4177
|
-
function
|
|
4178
|
-
return
|
|
4179
|
-
yield
|
|
4446
|
+
function Si() {
|
|
4447
|
+
return h(this, null, function* () {
|
|
4448
|
+
yield lr(), Pi() && (yield K());
|
|
4180
4449
|
});
|
|
4181
4450
|
}
|
|
4182
|
-
|
|
4183
|
-
let
|
|
4184
|
-
function
|
|
4185
|
-
if (
|
|
4186
|
-
|
|
4187
|
-
{ name: "load-weixin-sdk", run:
|
|
4188
|
-
{ name: "init-bridge", run:
|
|
4451
|
+
Y.useResponse(dt.response, { priority: 1e3 });
|
|
4452
|
+
let rt = !1;
|
|
4453
|
+
function nt() {
|
|
4454
|
+
if (rt) return;
|
|
4455
|
+
rt = !0, Mr([
|
|
4456
|
+
{ name: "load-weixin-sdk", run: ut, timeoutMs: 8e3 },
|
|
4457
|
+
{ name: "init-bridge", run: ot, timeoutMs: 8e3 }
|
|
4189
4458
|
], {
|
|
4190
4459
|
onError: (e, r) => {
|
|
4191
4460
|
console.error(`[QSH-SDK] 初始化失败(${(r == null ? void 0 : r.name) || "unknown"}):`, e);
|
|
4192
4461
|
}
|
|
4193
4462
|
});
|
|
4194
4463
|
}
|
|
4195
|
-
typeof window != "undefined" && (document.readyState === "complete" || document.readyState === "interactive" ? setTimeout(
|
|
4196
|
-
function
|
|
4464
|
+
typeof window != "undefined" && (document.readyState === "complete" || document.readyState === "interactive" ? setTimeout(nt, 0) : document.addEventListener("DOMContentLoaded", nt));
|
|
4465
|
+
function I(t, { apiName: e } = {}) {
|
|
4197
4466
|
return function(r = {}, ...n) {
|
|
4198
|
-
const i = r && typeof r == "object" && (typeof r.success == "function" || typeof r.fail == "function" || typeof r.complete == "function"), a = r && typeof r == "object" ? r : {}, o = () => i ? t(a, ...n) : new Promise((
|
|
4199
|
-
const
|
|
4200
|
-
success: (
|
|
4201
|
-
typeof a.success == "function" && a.success(
|
|
4467
|
+
const i = r && typeof r == "object" && (typeof r.success == "function" || typeof r.fail == "function" || typeof r.complete == "function"), a = r && typeof r == "object" ? r : {}, o = () => i ? t(a, ...n) : new Promise((d, O) => {
|
|
4468
|
+
const R = m(g({}, a), {
|
|
4469
|
+
success: (_) => {
|
|
4470
|
+
typeof a.success == "function" && a.success(_), d(_);
|
|
4202
4471
|
},
|
|
4203
|
-
fail: (
|
|
4204
|
-
typeof a.fail == "function" && a.fail(
|
|
4472
|
+
fail: (_) => {
|
|
4473
|
+
typeof a.fail == "function" && a.fail(_), O(_);
|
|
4205
4474
|
},
|
|
4206
4475
|
complete: a.complete
|
|
4207
4476
|
});
|
|
4208
|
-
t(
|
|
4477
|
+
t(R, ...n);
|
|
4209
4478
|
});
|
|
4210
|
-
return (typeof window == "undefined" ? Promise.resolve() :
|
|
4211
|
-
throw console.error(`[QSH-SDK] ${e || "API"} call failed:`,
|
|
4479
|
+
return (typeof window == "undefined" ? Promise.resolve() : at()).then(() => o()).catch((d) => {
|
|
4480
|
+
throw console.error(`[QSH-SDK] ${e || "API"} call failed:`, d), d;
|
|
4212
4481
|
});
|
|
4213
4482
|
};
|
|
4214
4483
|
}
|
|
4215
|
-
function
|
|
4484
|
+
function Ae(t) {
|
|
4216
4485
|
return typeof t == "function" ? { success: t } : t && typeof t == "object" ? t : {};
|
|
4217
4486
|
}
|
|
4218
|
-
const
|
|
4219
|
-
function
|
|
4220
|
-
const e = () =>
|
|
4221
|
-
return (typeof window == "undefined" ? Promise.resolve() :
|
|
4487
|
+
const $t = I(Qr), kt = I(en), Ft = I(tn), Kt = I(rn), zt = I(nn), Gt = I(sn);
|
|
4488
|
+
function Vt(t) {
|
|
4489
|
+
const e = () => an(t);
|
|
4490
|
+
return (typeof window == "undefined" ? Promise.resolve() : at()).then(() => e());
|
|
4222
4491
|
}
|
|
4223
|
-
const
|
|
4224
|
-
function
|
|
4492
|
+
const Fe = I(dn, { apiName: "getCode" });
|
|
4493
|
+
function Ni(t = {}) {
|
|
4225
4494
|
return new Promise((e, r) => {
|
|
4226
|
-
|
|
4495
|
+
Fe(m(g({}, t), {
|
|
4227
4496
|
success: e,
|
|
4228
4497
|
fail: r
|
|
4229
4498
|
}));
|
|
4230
4499
|
});
|
|
4231
4500
|
}
|
|
4232
|
-
const
|
|
4233
|
-
function
|
|
4501
|
+
const Ke = I(hn);
|
|
4502
|
+
function Ri(t = {}) {
|
|
4234
4503
|
return new Promise((e, r) => {
|
|
4235
|
-
|
|
4504
|
+
Ke(m(g({}, t), {
|
|
4236
4505
|
success: e,
|
|
4237
4506
|
fail: r
|
|
4238
4507
|
}));
|
|
4239
4508
|
});
|
|
4240
4509
|
}
|
|
4241
|
-
const
|
|
4242
|
-
function
|
|
4510
|
+
const qt = I(wi);
|
|
4511
|
+
function bi(t = {}) {
|
|
4243
4512
|
return new Promise((e, r) => {
|
|
4244
|
-
|
|
4513
|
+
qt(m(g({}, t), {
|
|
4245
4514
|
success: e,
|
|
4246
4515
|
fail: r
|
|
4247
4516
|
}));
|
|
4248
4517
|
});
|
|
4249
4518
|
}
|
|
4250
|
-
const
|
|
4251
|
-
function
|
|
4519
|
+
const ze = I(On), Ti = I(_i);
|
|
4520
|
+
function Mi(t = {}) {
|
|
4252
4521
|
return new Promise((e, r) => {
|
|
4253
|
-
|
|
4522
|
+
ze(m(g({}, t), {
|
|
4254
4523
|
success: e,
|
|
4255
4524
|
fail: r
|
|
4256
4525
|
}));
|
|
4257
4526
|
});
|
|
4258
4527
|
}
|
|
4259
|
-
const
|
|
4260
|
-
function
|
|
4528
|
+
const Li = I(vt), xi = I(ei), Ge = I(Mn);
|
|
4529
|
+
function vi(t = {}) {
|
|
4261
4530
|
return new Promise((e, r) => {
|
|
4262
|
-
|
|
4531
|
+
Ge(m(g({}, t), {
|
|
4263
4532
|
success: e,
|
|
4264
4533
|
fail: r
|
|
4265
4534
|
}));
|
|
4266
4535
|
});
|
|
4267
4536
|
}
|
|
4268
|
-
const
|
|
4269
|
-
function
|
|
4537
|
+
const Ve = I(Ln);
|
|
4538
|
+
function Di(t = {}) {
|
|
4270
4539
|
return new Promise((e, r) => {
|
|
4271
|
-
|
|
4540
|
+
Ve(m(g({}, t), {
|
|
4272
4541
|
success: e,
|
|
4273
4542
|
fail: r
|
|
4274
4543
|
}));
|
|
4275
4544
|
});
|
|
4276
4545
|
}
|
|
4277
|
-
const
|
|
4278
|
-
function
|
|
4546
|
+
const qe = I(zn);
|
|
4547
|
+
function Ui(t = {}) {
|
|
4279
4548
|
return new Promise((e, r) => {
|
|
4280
|
-
|
|
4549
|
+
qe(m(g({}, t), {
|
|
4281
4550
|
success: e,
|
|
4282
4551
|
fail: r
|
|
4283
4552
|
}));
|
|
4284
4553
|
});
|
|
4285
4554
|
}
|
|
4286
|
-
const
|
|
4287
|
-
function
|
|
4555
|
+
const jt = I(li);
|
|
4556
|
+
function Wi(t = {}) {
|
|
4288
4557
|
return new Promise((e, r) => {
|
|
4289
|
-
|
|
4558
|
+
jt(m(g({}, t), {
|
|
4290
4559
|
success: e,
|
|
4291
4560
|
fail: r
|
|
4292
4561
|
}));
|
|
4293
4562
|
});
|
|
4294
4563
|
}
|
|
4295
|
-
const
|
|
4296
|
-
function
|
|
4564
|
+
const Jt = I(fi);
|
|
4565
|
+
function Bi(t = {}) {
|
|
4297
4566
|
return new Promise((e, r) => {
|
|
4298
|
-
|
|
4567
|
+
Jt(m(g({}, t), {
|
|
4299
4568
|
success: e,
|
|
4300
4569
|
fail: r
|
|
4301
4570
|
}));
|
|
4302
4571
|
});
|
|
4303
4572
|
}
|
|
4304
|
-
const
|
|
4305
|
-
function
|
|
4573
|
+
const Ht = I(Dt);
|
|
4574
|
+
function $i(t = {}) {
|
|
4306
4575
|
return new Promise((e, r) => {
|
|
4307
|
-
|
|
4576
|
+
Ht(m(g({}, t), {
|
|
4308
4577
|
success: e,
|
|
4309
4578
|
fail: r
|
|
4310
4579
|
}));
|
|
4311
4580
|
});
|
|
4312
4581
|
}
|
|
4313
|
-
const
|
|
4314
|
-
function
|
|
4582
|
+
const Yt = I(di);
|
|
4583
|
+
function ki(t = {}) {
|
|
4315
4584
|
return new Promise((e, r) => {
|
|
4316
|
-
|
|
4585
|
+
Yt(m(g({}, t), {
|
|
4317
4586
|
success: e,
|
|
4318
4587
|
fail: r
|
|
4319
4588
|
}));
|
|
4320
4589
|
});
|
|
4321
4590
|
}
|
|
4322
|
-
const
|
|
4591
|
+
const ae = {
|
|
4323
4592
|
// 导航 API
|
|
4324
|
-
navigateTo:
|
|
4325
|
-
navigateBack:
|
|
4326
|
-
switchTab:
|
|
4327
|
-
reLaunch:
|
|
4328
|
-
redirectTo:
|
|
4593
|
+
navigateTo: $t,
|
|
4594
|
+
navigateBack: kt,
|
|
4595
|
+
switchTab: Ft,
|
|
4596
|
+
reLaunch: Kt,
|
|
4597
|
+
redirectTo: zt,
|
|
4329
4598
|
// 消息 API
|
|
4330
|
-
postMessage:
|
|
4331
|
-
getEnv:
|
|
4332
|
-
getCode:
|
|
4333
|
-
getCodeAsync:
|
|
4599
|
+
postMessage: Gt,
|
|
4600
|
+
getEnv: Vt,
|
|
4601
|
+
getCode: Fe,
|
|
4602
|
+
getCodeAsync: Ni,
|
|
4334
4603
|
// 图片 API
|
|
4335
|
-
chooseImage:
|
|
4336
|
-
chooseImageAsync:
|
|
4604
|
+
chooseImage: Ke,
|
|
4605
|
+
chooseImageAsync: Ri,
|
|
4337
4606
|
// 扫码 API
|
|
4338
|
-
scanCode:
|
|
4339
|
-
scanCodeAsync:
|
|
4607
|
+
scanCode: ze,
|
|
4608
|
+
scanCodeAsync: Mi,
|
|
4340
4609
|
// 位置 API
|
|
4341
|
-
getLocation:
|
|
4342
|
-
getLocationAsync:
|
|
4343
|
-
openLocation:
|
|
4344
|
-
openLocationAsync:
|
|
4345
|
-
chooseLocation:
|
|
4346
|
-
chooseLocationAsync:
|
|
4610
|
+
getLocation: Ge,
|
|
4611
|
+
getLocationAsync: vi,
|
|
4612
|
+
openLocation: Ve,
|
|
4613
|
+
openLocationAsync: Di,
|
|
4614
|
+
chooseLocation: qe,
|
|
4615
|
+
chooseLocationAsync: Ui,
|
|
4347
4616
|
// 位置监听 API(保留回调签名)
|
|
4348
|
-
onLocationChange: (t) =>
|
|
4349
|
-
offLocationChange: (t) =>
|
|
4350
|
-
onLocationChangeError: (t) =>
|
|
4351
|
-
offLocationChangeError: (t) =>
|
|
4352
|
-
startLocationUpdate:
|
|
4353
|
-
stopLocationUpdate:
|
|
4617
|
+
onLocationChange: (t) => I((e = {}) => Un(e.success), { apiName: "onLocationChange" })(Ae(t)),
|
|
4618
|
+
offLocationChange: (t) => I((e = {}) => Wn(e.success), { apiName: "offLocationChange" })(Ae(t)),
|
|
4619
|
+
onLocationChangeError: (t) => I((e = {}) => Bn(e.success), { apiName: "onLocationChangeError" })(Ae(t)),
|
|
4620
|
+
offLocationChangeError: (t) => I((e = {}) => $n(e.success), { apiName: "offLocationChangeError" })(Ae(t)),
|
|
4621
|
+
startLocationUpdate: I(vn, { apiName: "startLocationUpdate" }),
|
|
4622
|
+
stopLocationUpdate: I(Dn, { apiName: "stopLocationUpdate" }),
|
|
4354
4623
|
// 环境信息
|
|
4355
|
-
environment:
|
|
4624
|
+
environment: Bt,
|
|
4356
4625
|
/**
|
|
4357
4626
|
* Wait for SDK readiness.
|
|
4358
4627
|
* In Weixin mini-program web-view, if qsh.config({ clientId }) was called,
|
|
@@ -4362,7 +4631,7 @@ const re = {
|
|
|
4362
4631
|
* await qsh.ready()
|
|
4363
4632
|
* @since 2.0.0
|
|
4364
4633
|
*/
|
|
4365
|
-
ready:
|
|
4634
|
+
ready: Si,
|
|
4366
4635
|
/**
|
|
4367
4636
|
* 手动初始化 JSBridge
|
|
4368
4637
|
* 默认会在 DOM 就绪时自动初始化;如需更早或手动控制,可调用本方法。
|
|
@@ -4371,7 +4640,7 @@ const re = {
|
|
|
4371
4640
|
* await qsh.init()
|
|
4372
4641
|
* @since 2.0.0
|
|
4373
4642
|
*/
|
|
4374
|
-
init:
|
|
4643
|
+
init: ot,
|
|
4375
4644
|
/**
|
|
4376
4645
|
* 检查 JSBridge 是否就绪
|
|
4377
4646
|
* @returns {boolean}
|
|
@@ -4379,7 +4648,7 @@ const re = {
|
|
|
4379
4648
|
* if (qsh.isReady()) { console.log('ready') }
|
|
4380
4649
|
* @since 2.0.0
|
|
4381
4650
|
*/
|
|
4382
|
-
isReady:
|
|
4651
|
+
isReady: ir,
|
|
4383
4652
|
/**
|
|
4384
4653
|
* 获取当前 SDK 状态
|
|
4385
4654
|
* @returns {string}
|
|
@@ -4387,8 +4656,8 @@ const re = {
|
|
|
4387
4656
|
* console.log(qsh.getState()) // 'ready'
|
|
4388
4657
|
* @since 2.0.0
|
|
4389
4658
|
*/
|
|
4390
|
-
getState:
|
|
4391
|
-
config:
|
|
4659
|
+
getState: sr,
|
|
4660
|
+
config: Qe,
|
|
4392
4661
|
// 微信配置 API
|
|
4393
4662
|
weixin: {
|
|
4394
4663
|
/**
|
|
@@ -4398,8 +4667,8 @@ const re = {
|
|
|
4398
4667
|
* await qsh.weixin.waitForConfig()
|
|
4399
4668
|
* @since 2.0.0
|
|
4400
4669
|
*/
|
|
4401
|
-
config:
|
|
4402
|
-
waitForConfig:
|
|
4670
|
+
config: Qe,
|
|
4671
|
+
waitForConfig: K,
|
|
4403
4672
|
/**
|
|
4404
4673
|
* 检查微信配置是否完成
|
|
4405
4674
|
* @returns {boolean}
|
|
@@ -4407,7 +4676,7 @@ const re = {
|
|
|
4407
4676
|
* if (qsh.weixin.isConfigReady()) { wx.chooseImage({}) }
|
|
4408
4677
|
* @since 2.0.0
|
|
4409
4678
|
*/
|
|
4410
|
-
isConfigReady:
|
|
4679
|
+
isConfigReady: j,
|
|
4411
4680
|
/**
|
|
4412
4681
|
* 获取微信配置状态
|
|
4413
4682
|
* @returns {string}
|
|
@@ -4415,7 +4684,7 @@ const re = {
|
|
|
4415
4684
|
* console.log(qsh.weixin.getConfigState()) // 'configured'
|
|
4416
4685
|
* @since 2.0.0
|
|
4417
4686
|
*/
|
|
4418
|
-
getConfigState:
|
|
4687
|
+
getConfigState: mr,
|
|
4419
4688
|
/**
|
|
4420
4689
|
* 手动重试微信配置
|
|
4421
4690
|
* @returns {Promise<void>}
|
|
@@ -4423,13 +4692,13 @@ const re = {
|
|
|
4423
4692
|
* await qsh.weixin.retryConfig()
|
|
4424
4693
|
* @since 2.0.0
|
|
4425
4694
|
*/
|
|
4426
|
-
retryConfig:
|
|
4695
|
+
retryConfig: hr
|
|
4427
4696
|
},
|
|
4428
4697
|
// WebView 对象(兼容旧版本)
|
|
4429
4698
|
webView: null,
|
|
4430
4699
|
// 图片相关常量
|
|
4431
|
-
ImageSourceTypes:
|
|
4432
|
-
ImageSizeTypes:
|
|
4700
|
+
ImageSourceTypes: Ce,
|
|
4701
|
+
ImageSizeTypes: Pe,
|
|
4433
4702
|
/**
|
|
4434
4703
|
* 获取图片功能能力信息
|
|
4435
4704
|
* @returns {Object} 能力信息对象
|
|
@@ -4438,9 +4707,9 @@ const re = {
|
|
|
4438
4707
|
* console.log('是否支持:', capabilities.supported)
|
|
4439
4708
|
* @since 2.0.0
|
|
4440
4709
|
*/
|
|
4441
|
-
getImageCapabilities:
|
|
4710
|
+
getImageCapabilities: wn,
|
|
4442
4711
|
// 扫码相关常量
|
|
4443
|
-
ScanTypes:
|
|
4712
|
+
ScanTypes: Z,
|
|
4444
4713
|
/**
|
|
4445
4714
|
* 获取扫码功能能力信息
|
|
4446
4715
|
* @returns {Object} 能力信息对象
|
|
@@ -4449,9 +4718,9 @@ const re = {
|
|
|
4449
4718
|
* console.log('是否支持:', capabilities.supported)
|
|
4450
4719
|
* @since 2.1.0
|
|
4451
4720
|
*/
|
|
4452
|
-
getScanCapabilities:
|
|
4721
|
+
getScanCapabilities: _n,
|
|
4453
4722
|
// 位置相关常量
|
|
4454
|
-
CoordinateTypes:
|
|
4723
|
+
CoordinateTypes: se,
|
|
4455
4724
|
/**
|
|
4456
4725
|
* 获取位置功能能力信息
|
|
4457
4726
|
* @returns {Object} 能力信息对象
|
|
@@ -4460,7 +4729,7 @@ const re = {
|
|
|
4460
4729
|
* console.log('是否支持:', capabilities.supported)
|
|
4461
4730
|
* @since 2.1.0
|
|
4462
4731
|
*/
|
|
4463
|
-
getLocationCapabilities:
|
|
4732
|
+
getLocationCapabilities: xn,
|
|
4464
4733
|
/**
|
|
4465
4734
|
* 获取位置选择功能能力信息
|
|
4466
4735
|
* @returns {Object} 能力信息对象
|
|
@@ -4469,23 +4738,27 @@ const re = {
|
|
|
4469
4738
|
* console.log('是否支持:', capabilities.supported)
|
|
4470
4739
|
* @since 2.1.0
|
|
4471
4740
|
*/
|
|
4472
|
-
getChooseLocationCapabilities:
|
|
4741
|
+
getChooseLocationCapabilities: Gn,
|
|
4473
4742
|
// 蓝牙 API
|
|
4474
|
-
openBluetoothAdapter:
|
|
4475
|
-
openBluetoothAdapterAsync:
|
|
4476
|
-
startBluetoothDevicesDiscovery:
|
|
4477
|
-
startBluetoothDevicesDiscoveryAsync:
|
|
4478
|
-
onBluetoothDeviceFound:
|
|
4479
|
-
onBluetoothDeviceFoundAsync:
|
|
4480
|
-
createBLEConnection:
|
|
4481
|
-
createBLEConnectionAsync:
|
|
4743
|
+
openBluetoothAdapter: jt,
|
|
4744
|
+
openBluetoothAdapterAsync: Wi,
|
|
4745
|
+
startBluetoothDevicesDiscovery: Jt,
|
|
4746
|
+
startBluetoothDevicesDiscoveryAsync: Bi,
|
|
4747
|
+
onBluetoothDeviceFound: Ht,
|
|
4748
|
+
onBluetoothDeviceFoundAsync: $i,
|
|
4749
|
+
createBLEConnection: Yt,
|
|
4750
|
+
createBLEConnectionAsync: ki,
|
|
4482
4751
|
// 蓝牙相关常量
|
|
4483
|
-
BluetoothStates:
|
|
4752
|
+
BluetoothStates: ni,
|
|
4484
4753
|
//微信分享
|
|
4485
|
-
toShare:
|
|
4486
|
-
toShareAsync:
|
|
4487
|
-
|
|
4488
|
-
|
|
4754
|
+
toShare: Li,
|
|
4755
|
+
toShareAsync: xi,
|
|
4756
|
+
/** toShare 参数说明常量(只读结构,可 JSON 序列化) */
|
|
4757
|
+
TO_SHARE_PARAM_HELP: ke,
|
|
4758
|
+
/** 返回 toShare 参数说明对象 */
|
|
4759
|
+
getToShareParamHelp: ti,
|
|
4760
|
+
/** 在控制台打印 toShare 参数说明 */
|
|
4761
|
+
printToShareParamHelp: ri,
|
|
4489
4762
|
/**
|
|
4490
4763
|
* 获取蓝牙功能能力信息
|
|
4491
4764
|
* @returns {Object} 能力信息对象
|
|
@@ -4493,10 +4766,10 @@ const re = {
|
|
|
4493
4766
|
* const capabilities = qsh.getBluetoothCapabilities()
|
|
4494
4767
|
* console.log('是否支持:', capabilities.supported)
|
|
4495
4768
|
*/
|
|
4496
|
-
getBluetoothCapabilities:
|
|
4769
|
+
getBluetoothCapabilities: gi,
|
|
4497
4770
|
// 打印PDF API
|
|
4498
|
-
printPdf:
|
|
4499
|
-
printPdfAsync:
|
|
4771
|
+
printPdf: qt,
|
|
4772
|
+
printPdfAsync: bi,
|
|
4500
4773
|
/**
|
|
4501
4774
|
* 获取打印PDF功能能力信息
|
|
4502
4775
|
* @returns {Object} 能力信息对象
|
|
@@ -4504,16 +4777,16 @@ const re = {
|
|
|
4504
4777
|
* const capabilities = qsh.getPrintCapabilities()
|
|
4505
4778
|
* console.log('是否支持:', capabilities.supported)
|
|
4506
4779
|
*/
|
|
4507
|
-
getPrintCapabilities:
|
|
4780
|
+
getPrintCapabilities: Ei,
|
|
4508
4781
|
// 人脸识别 API(仅支持微信小程序环境)
|
|
4509
|
-
faceVerify:
|
|
4510
|
-
getFaceCapabilities:
|
|
4782
|
+
faceVerify: Ti,
|
|
4783
|
+
getFaceCapabilities: Ci,
|
|
4511
4784
|
// 插件系统
|
|
4512
4785
|
plugins: {
|
|
4513
4786
|
/**
|
|
4514
4787
|
* 插件管理器
|
|
4515
4788
|
*/
|
|
4516
|
-
manager:
|
|
4789
|
+
manager: le,
|
|
4517
4790
|
/**
|
|
4518
4791
|
* 注册插件
|
|
4519
4792
|
* @param {Object} plugin - 插件对象
|
|
@@ -4521,7 +4794,7 @@ const re = {
|
|
|
4521
4794
|
* @example
|
|
4522
4795
|
* qsh.plugins.register(myPlugin)
|
|
4523
4796
|
*/
|
|
4524
|
-
register: (t) =>
|
|
4797
|
+
register: (t) => le.register(t),
|
|
4525
4798
|
/**
|
|
4526
4799
|
* 安装插件
|
|
4527
4800
|
* @param {string} name - 插件名称
|
|
@@ -4529,21 +4802,21 @@ const re = {
|
|
|
4529
4802
|
* @example
|
|
4530
4803
|
* await qsh.plugins.install('image')
|
|
4531
4804
|
*/
|
|
4532
|
-
install: (t) =>
|
|
4805
|
+
install: (t) => le.install(t, ae),
|
|
4533
4806
|
/**
|
|
4534
4807
|
* 获取插件列表
|
|
4535
4808
|
* @returns {Array} 插件列表
|
|
4536
4809
|
* @example
|
|
4537
4810
|
* console.log(qsh.plugins.list())
|
|
4538
4811
|
*/
|
|
4539
|
-
list: () =>
|
|
4812
|
+
list: () => le.getPluginList()
|
|
4540
4813
|
},
|
|
4541
4814
|
// 拦截器系统
|
|
4542
4815
|
interceptors: {
|
|
4543
4816
|
/**
|
|
4544
4817
|
* 拦截器链
|
|
4545
4818
|
*/
|
|
4546
|
-
chain:
|
|
4819
|
+
chain: Y,
|
|
4547
4820
|
/**
|
|
4548
4821
|
* 注册请求拦截器
|
|
4549
4822
|
* @param {Function} interceptor - 拦截器函数
|
|
@@ -4555,7 +4828,7 @@ const re = {
|
|
|
4555
4828
|
* return ctx
|
|
4556
4829
|
* })
|
|
4557
4830
|
*/
|
|
4558
|
-
useRequest: (t, e) =>
|
|
4831
|
+
useRequest: (t, e) => Y.useRequest(t, e),
|
|
4559
4832
|
/**
|
|
4560
4833
|
* 注册响应拦截器
|
|
4561
4834
|
* @param {Function} interceptor - 拦截器函数
|
|
@@ -4567,16 +4840,16 @@ const re = {
|
|
|
4567
4840
|
* return result
|
|
4568
4841
|
* })
|
|
4569
4842
|
*/
|
|
4570
|
-
useResponse: (t, e) =>
|
|
4843
|
+
useResponse: (t, e) => Y.useResponse(t, e),
|
|
4571
4844
|
/**
|
|
4572
4845
|
* 内置拦截器
|
|
4573
4846
|
*/
|
|
4574
4847
|
builtin: {
|
|
4575
|
-
logging:
|
|
4576
|
-
performance:
|
|
4577
|
-
createRetry:
|
|
4578
|
-
createValidation:
|
|
4579
|
-
errorNormalizer:
|
|
4848
|
+
logging: yr,
|
|
4849
|
+
performance: G,
|
|
4850
|
+
createRetry: Ir,
|
|
4851
|
+
createValidation: Ar,
|
|
4852
|
+
errorNormalizer: dt
|
|
4580
4853
|
}
|
|
4581
4854
|
},
|
|
4582
4855
|
// 观测指标
|
|
@@ -4584,11 +4857,11 @@ const re = {
|
|
|
4584
4857
|
/**
|
|
4585
4858
|
* 获取性能指标报告
|
|
4586
4859
|
*/
|
|
4587
|
-
getPerformanceReport: () =>
|
|
4860
|
+
getPerformanceReport: () => G.getReport(),
|
|
4588
4861
|
/**
|
|
4589
4862
|
* 清空性能指标
|
|
4590
4863
|
*/
|
|
4591
|
-
clearPerformanceMetrics: () =>
|
|
4864
|
+
clearPerformanceMetrics: () => G.clearMetrics()
|
|
4592
4865
|
},
|
|
4593
4866
|
// 错误处理工具
|
|
4594
4867
|
errors: {
|
|
@@ -4599,11 +4872,11 @@ const re = {
|
|
|
4599
4872
|
/**
|
|
4600
4873
|
* 错误消息
|
|
4601
4874
|
*/
|
|
4602
|
-
messages:
|
|
4875
|
+
messages: ve,
|
|
4603
4876
|
/**
|
|
4604
4877
|
* 错误分类
|
|
4605
4878
|
*/
|
|
4606
|
-
categories:
|
|
4879
|
+
categories: W,
|
|
4607
4880
|
/**
|
|
4608
4881
|
* 标准化错误
|
|
4609
4882
|
* @param {any} error - 原始错误
|
|
@@ -4612,7 +4885,7 @@ const re = {
|
|
|
4612
4885
|
* @example
|
|
4613
4886
|
* const standardError = qsh.errors.normalize(error, { apiName: 'chooseImage' })
|
|
4614
4887
|
*/
|
|
4615
|
-
normalize:
|
|
4888
|
+
normalize: ft,
|
|
4616
4889
|
/**
|
|
4617
4890
|
* 创建标准错误
|
|
4618
4891
|
* @param {string} code - 错误码
|
|
@@ -4621,7 +4894,7 @@ const re = {
|
|
|
4621
4894
|
* @example
|
|
4622
4895
|
* const error = qsh.errors.create('E_IMG_001', { apiName: 'chooseImage' })
|
|
4623
4896
|
*/
|
|
4624
|
-
create:
|
|
4897
|
+
create: Rr,
|
|
4625
4898
|
/**
|
|
4626
4899
|
* 判断是否为标准错误
|
|
4627
4900
|
* @param {any} error - 错误对象
|
|
@@ -4629,14 +4902,14 @@ const re = {
|
|
|
4629
4902
|
* @example
|
|
4630
4903
|
* if (qsh.errors.isStandard(error)) { ... }
|
|
4631
4904
|
*/
|
|
4632
|
-
isStandard:
|
|
4905
|
+
isStandard: br
|
|
4633
4906
|
},
|
|
4634
4907
|
// 状态管理
|
|
4635
4908
|
store: {
|
|
4636
4909
|
/**
|
|
4637
4910
|
* 状态仓库实例
|
|
4638
4911
|
*/
|
|
4639
|
-
instance:
|
|
4912
|
+
instance: $,
|
|
4640
4913
|
/**
|
|
4641
4914
|
* 获取状态
|
|
4642
4915
|
* @param {string} path - 状态路径
|
|
@@ -4644,7 +4917,7 @@ const re = {
|
|
|
4644
4917
|
* @example
|
|
4645
4918
|
* const status = qsh.store.get('sdk.status')
|
|
4646
4919
|
*/
|
|
4647
|
-
get: (t) =>
|
|
4920
|
+
get: (t) => $.get(t),
|
|
4648
4921
|
/**
|
|
4649
4922
|
* 设置状态
|
|
4650
4923
|
* @param {string} path - 状态路径
|
|
@@ -4652,7 +4925,7 @@ const re = {
|
|
|
4652
4925
|
* @example
|
|
4653
4926
|
* qsh.store.set('sdk.status', 'ready')
|
|
4654
4927
|
*/
|
|
4655
|
-
set: (t, e) =>
|
|
4928
|
+
set: (t, e) => $.set(t, e),
|
|
4656
4929
|
/**
|
|
4657
4930
|
* 订阅状态变化
|
|
4658
4931
|
* @param {string} path - 状态路径
|
|
@@ -4663,39 +4936,39 @@ const re = {
|
|
|
4663
4936
|
* console.log('网络状态:', online)
|
|
4664
4937
|
* })
|
|
4665
4938
|
*/
|
|
4666
|
-
subscribe: (t, e) =>
|
|
4939
|
+
subscribe: (t, e) => $.subscribe(t, e),
|
|
4667
4940
|
/**
|
|
4668
4941
|
* 获取状态快照
|
|
4669
4942
|
* @returns {Object} 状态快照
|
|
4670
4943
|
* @example
|
|
4671
4944
|
* console.log(qsh.store.getSnapshot())
|
|
4672
4945
|
*/
|
|
4673
|
-
getSnapshot: () =>
|
|
4946
|
+
getSnapshot: () => $.getSnapshot()
|
|
4674
4947
|
},
|
|
4675
4948
|
// 调试工具(生产环境可能被优化掉)
|
|
4676
4949
|
debug: {
|
|
4677
4950
|
/**
|
|
4678
4951
|
* 日志记录器
|
|
4679
4952
|
*/
|
|
4680
|
-
logger:
|
|
4953
|
+
logger: M,
|
|
4681
4954
|
/**
|
|
4682
4955
|
* 设置外部日志 reporter,便于对接埋点/观测
|
|
4683
4956
|
*/
|
|
4684
|
-
setLogReporter: (t) =>
|
|
4957
|
+
setLogReporter: (t) => M.setReporter(t),
|
|
4685
4958
|
/**
|
|
4686
4959
|
* 错误处理器
|
|
4687
4960
|
*/
|
|
4688
|
-
errorHandler:
|
|
4961
|
+
errorHandler: f,
|
|
4689
4962
|
/**
|
|
4690
4963
|
* 状态管理器
|
|
4691
4964
|
*/
|
|
4692
|
-
stateManager:
|
|
4965
|
+
stateManager: X,
|
|
4693
4966
|
/**
|
|
4694
4967
|
* 启用调试模式
|
|
4695
4968
|
* @example
|
|
4696
4969
|
* qsh.debug.enableDevMode()
|
|
4697
4970
|
*/
|
|
4698
|
-
enableDevMode: () =>
|
|
4971
|
+
enableDevMode: () => M.enableDevMode(),
|
|
4699
4972
|
/**
|
|
4700
4973
|
* 获取日志历史
|
|
4701
4974
|
* @param {number} [count] - 获取条数
|
|
@@ -4703,7 +4976,7 @@ const re = {
|
|
|
4703
4976
|
* @example
|
|
4704
4977
|
* console.log(qsh.debug.getLogs(10))
|
|
4705
4978
|
*/
|
|
4706
|
-
getLogs: (t) =>
|
|
4979
|
+
getLogs: (t) => M.getHistory(t),
|
|
4707
4980
|
/**
|
|
4708
4981
|
* 获取 SDK 统计信息
|
|
4709
4982
|
* @returns {Object} 统计信息
|
|
@@ -4711,12 +4984,12 @@ const re = {
|
|
|
4711
4984
|
* console.log(qsh.debug.getStats())
|
|
4712
4985
|
*/
|
|
4713
4986
|
getStats: () => ({
|
|
4714
|
-
logger:
|
|
4715
|
-
state:
|
|
4716
|
-
weixinConfig:
|
|
4717
|
-
plugins:
|
|
4718
|
-
interceptors:
|
|
4719
|
-
store:
|
|
4987
|
+
logger: M.getStats(),
|
|
4988
|
+
state: X.getStats(),
|
|
4989
|
+
weixinConfig: xe().getStats(),
|
|
4990
|
+
plugins: le.getStats(),
|
|
4991
|
+
interceptors: Y.getStats(),
|
|
4992
|
+
store: $.getStats()
|
|
4720
4993
|
}),
|
|
4721
4994
|
/**
|
|
4722
4995
|
* 获取微信配置管理器
|
|
@@ -4724,37 +4997,37 @@ const re = {
|
|
|
4724
4997
|
* @example
|
|
4725
4998
|
* console.log(qsh.debug.getWeixinConfigManager().getStats())
|
|
4726
4999
|
*/
|
|
4727
|
-
getWeixinConfigManager:
|
|
5000
|
+
getWeixinConfigManager: xe,
|
|
4728
5001
|
/**
|
|
4729
5002
|
* 导出调试信息
|
|
4730
5003
|
* @returns {string} JSON 格式的调试信息
|
|
4731
5004
|
* @example
|
|
4732
5005
|
* console.log(qsh.debug.exportDebugInfo())
|
|
4733
5006
|
*/
|
|
4734
|
-
exportDebugInfo: () =>
|
|
5007
|
+
exportDebugInfo: () => M.exportToJSON()
|
|
4735
5008
|
}
|
|
4736
5009
|
};
|
|
4737
|
-
|
|
4738
|
-
navigateTo:
|
|
4739
|
-
navigateBack:
|
|
4740
|
-
switchTab:
|
|
4741
|
-
reLaunch:
|
|
4742
|
-
redirectTo:
|
|
4743
|
-
postMessage:
|
|
4744
|
-
getEnv:
|
|
4745
|
-
getCode:
|
|
4746
|
-
chooseImage:
|
|
4747
|
-
scanCode:
|
|
4748
|
-
getLocation:
|
|
4749
|
-
openLocation:
|
|
4750
|
-
chooseLocation:
|
|
5010
|
+
Bt.isWeixinMiniProgram ? ae.webView = window.wx && window.wx.miniProgram : ae.webView = {
|
|
5011
|
+
navigateTo: $t,
|
|
5012
|
+
navigateBack: kt,
|
|
5013
|
+
switchTab: Ft,
|
|
5014
|
+
reLaunch: Kt,
|
|
5015
|
+
redirectTo: zt,
|
|
5016
|
+
postMessage: Gt,
|
|
5017
|
+
getEnv: Vt,
|
|
5018
|
+
getCode: Fe,
|
|
5019
|
+
chooseImage: Ke,
|
|
5020
|
+
scanCode: ze,
|
|
5021
|
+
getLocation: Ge,
|
|
5022
|
+
openLocation: Ve,
|
|
5023
|
+
chooseLocation: qe
|
|
4751
5024
|
};
|
|
4752
|
-
const
|
|
4753
|
-
Object.keys(
|
|
4754
|
-
|
|
5025
|
+
const it = typeof window.uni != "undefined" ? window.uni : {};
|
|
5026
|
+
Object.keys(it).forEach((t) => {
|
|
5027
|
+
ae.hasOwnProperty(t) || (ae[t] = it[t]);
|
|
4755
5028
|
});
|
|
4756
|
-
typeof window != "undefined" && (window.qsh =
|
|
5029
|
+
typeof window != "undefined" && (window.qsh = ae);
|
|
4757
5030
|
export {
|
|
4758
|
-
|
|
5031
|
+
ae as default
|
|
4759
5032
|
};
|
|
4760
5033
|
//# sourceMappingURL=qsh-webview-sdk.es.js.map
|