qsh-webview-sdk 2.2.2 → 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/README.md +18 -49
- package/dist/index.d.ts +79 -11
- package/dist/qsh-webview-sdk.es.js +1444 -1032
- 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,93 +1,105 @@
|
|
|
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
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
|
|
36
|
+
function A() {
|
|
37
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
|
|
44
|
+
function Se() {
|
|
45
45
|
const t = me();
|
|
46
46
|
return !!(t && t.plus);
|
|
47
47
|
}
|
|
48
|
-
function
|
|
48
|
+
function Ne() {
|
|
49
49
|
const t = me();
|
|
50
50
|
return !!(t && (t.__dcloud_weex_postMessage || t.__dcloud_weex_));
|
|
51
51
|
}
|
|
52
|
-
function
|
|
52
|
+
function Re() {
|
|
53
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
|
-
|
|
67
|
+
function Q() {
|
|
68
|
+
const t = me();
|
|
69
|
+
if (!t) return !1;
|
|
70
|
+
if (t.__offline_bridge_postMessage) return !0;
|
|
71
|
+
try {
|
|
72
|
+
const e = t.location && t.location.hostname;
|
|
73
|
+
if (e && /\.?offline\.?/i.test(e)) return !0;
|
|
74
|
+
} catch (e) {
|
|
75
|
+
}
|
|
76
|
+
return !1;
|
|
69
77
|
}
|
|
70
|
-
|
|
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;
|
|
71
82
|
function oe(t = !1) {
|
|
72
|
-
return
|
|
73
|
-
isWeixinMiniProgram:
|
|
74
|
-
isAppPlus:
|
|
75
|
-
isNvue:
|
|
76
|
-
isUvue:
|
|
77
|
-
isUniApp:
|
|
78
|
-
isHtml5Plus:
|
|
79
|
-
isUniAppWebView:
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
83
|
-
|
|
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 = {
|
|
84
96
|
PLATFORM_NOT_SUPPORTED: "PLATFORM_NOT_SUPPORTED",
|
|
85
97
|
API_CALL_FAILED: "API_CALL_FAILED",
|
|
86
98
|
BRIDGE_NOT_READY: "BRIDGE_NOT_READY",
|
|
87
99
|
INVALID_PARAMETERS: "INVALID_PARAMETERS",
|
|
88
100
|
NETWORK_ERROR: "NETWORK_ERROR"
|
|
89
101
|
};
|
|
90
|
-
class
|
|
102
|
+
class N extends Error {
|
|
91
103
|
/**
|
|
92
104
|
* 构造函数
|
|
93
105
|
* @param {string} type - 错误类型
|
|
@@ -96,7 +108,7 @@ class R extends Error {
|
|
|
96
108
|
* @param {Error} [originalError] - 原始错误对象
|
|
97
109
|
*/
|
|
98
110
|
constructor(e, r, n = {}, i = null) {
|
|
99
|
-
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);
|
|
100
112
|
}
|
|
101
113
|
/**
|
|
102
114
|
* 转换为 JSON 格式
|
|
@@ -144,13 +156,13 @@ const C = class C {
|
|
|
144
156
|
*/
|
|
145
157
|
static handleApiError(e, r = {}) {
|
|
146
158
|
let n;
|
|
147
|
-
return e instanceof
|
|
148
|
-
|
|
159
|
+
return e instanceof N ? n = e : e instanceof Error ? n = new N(
|
|
160
|
+
x.API_CALL_FAILED,
|
|
149
161
|
e.message,
|
|
150
162
|
r,
|
|
151
163
|
e
|
|
152
|
-
) : n = new
|
|
153
|
-
|
|
164
|
+
) : n = new N(
|
|
165
|
+
x.API_CALL_FAILED,
|
|
154
166
|
String(e),
|
|
155
167
|
r
|
|
156
168
|
), C.logError(n), C.notifyCallbacks(n), n;
|
|
@@ -162,8 +174,8 @@ const C = class C {
|
|
|
162
174
|
* @returns {QshError} 错误对象
|
|
163
175
|
*/
|
|
164
176
|
static handlePlatformNotSupported(e, r) {
|
|
165
|
-
const n = new
|
|
166
|
-
|
|
177
|
+
const n = new N(
|
|
178
|
+
x.PLATFORM_NOT_SUPPORTED,
|
|
167
179
|
`API "${r}" is not supported on platform "${e}"`,
|
|
168
180
|
{ platformType: e, apiName: r }
|
|
169
181
|
);
|
|
@@ -175,8 +187,8 @@ const C = class C {
|
|
|
175
187
|
* @returns {QshError} 错误对象
|
|
176
188
|
*/
|
|
177
189
|
static handleBridgeNotReady(e) {
|
|
178
|
-
const r = new
|
|
179
|
-
|
|
190
|
+
const r = new N(
|
|
191
|
+
x.BRIDGE_NOT_READY,
|
|
180
192
|
`Bridge is not ready when calling "${e}"`,
|
|
181
193
|
{ apiName: e }
|
|
182
194
|
);
|
|
@@ -191,8 +203,8 @@ const C = class C {
|
|
|
191
203
|
* @returns {QshError} 错误对象
|
|
192
204
|
*/
|
|
193
205
|
static handleInvalidParameters(e, r, n, i) {
|
|
194
|
-
const a = new
|
|
195
|
-
|
|
206
|
+
const a = new N(
|
|
207
|
+
x.INVALID_PARAMETERS,
|
|
196
208
|
`Invalid parameter "${r}" in "${e}": expected ${n}, got ${typeof i}`,
|
|
197
209
|
{ apiName: e, paramName: r, expectedType: n, actualValue: i }
|
|
198
210
|
);
|
|
@@ -218,7 +230,7 @@ const C = class C {
|
|
|
218
230
|
* @returns {Promise} Promise 对象
|
|
219
231
|
*/
|
|
220
232
|
static safeExecuteAsync(n) {
|
|
221
|
-
return
|
|
233
|
+
return h(this, arguments, function* (e, r = {}) {
|
|
222
234
|
try {
|
|
223
235
|
return yield e();
|
|
224
236
|
} catch (i) {
|
|
@@ -265,22 +277,22 @@ const C = class C {
|
|
|
265
277
|
return function(r, n, i) {
|
|
266
278
|
const a = i.value;
|
|
267
279
|
return i.value = function(...o) {
|
|
268
|
-
return C.safeExecute(() => a.apply(this, o),
|
|
280
|
+
return C.safeExecute(() => a.apply(this, o), m(g({}, e), { method: n, target: r.constructor.name }));
|
|
269
281
|
}, i;
|
|
270
282
|
};
|
|
271
283
|
}
|
|
272
284
|
};
|
|
273
|
-
|
|
274
|
-
let
|
|
275
|
-
const
|
|
285
|
+
B(C, "isDebugMode", !1), B(C, "errorCallbacks", []);
|
|
286
|
+
let f = C;
|
|
287
|
+
const L = {
|
|
276
288
|
UNINITIALIZED: "uninitialized",
|
|
277
289
|
INITIALIZING: "initializing",
|
|
278
290
|
READY: "ready",
|
|
279
291
|
ERROR: "error"
|
|
280
292
|
};
|
|
281
|
-
class
|
|
293
|
+
class nr {
|
|
282
294
|
constructor() {
|
|
283
|
-
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);
|
|
284
296
|
}
|
|
285
297
|
/**
|
|
286
298
|
* 获取当前状态
|
|
@@ -294,21 +306,21 @@ class Vt {
|
|
|
294
306
|
* @returns {boolean} 是否就绪
|
|
295
307
|
*/
|
|
296
308
|
isReady() {
|
|
297
|
-
return this.state ===
|
|
309
|
+
return this.state === L.READY;
|
|
298
310
|
}
|
|
299
311
|
/**
|
|
300
312
|
* 检查是否正在初始化
|
|
301
313
|
* @returns {boolean} 是否正在初始化
|
|
302
314
|
*/
|
|
303
315
|
isInitializing() {
|
|
304
|
-
return this.state ===
|
|
316
|
+
return this.state === L.INITIALIZING;
|
|
305
317
|
}
|
|
306
318
|
/**
|
|
307
319
|
* 检查是否出错
|
|
308
320
|
* @returns {boolean} 是否出错
|
|
309
321
|
*/
|
|
310
322
|
hasError() {
|
|
311
|
-
return this.state ===
|
|
323
|
+
return this.state === L.ERROR;
|
|
312
324
|
}
|
|
313
325
|
/**
|
|
314
326
|
* 获取初始化错误
|
|
@@ -332,10 +344,10 @@ class Vt {
|
|
|
332
344
|
* @returns {Promise<void>} 初始化 Promise
|
|
333
345
|
*/
|
|
334
346
|
startInitialization(e) {
|
|
335
|
-
return
|
|
336
|
-
if (this.state !==
|
|
347
|
+
return h(this, null, function* () {
|
|
348
|
+
if (this.state !== L.UNINITIALIZED)
|
|
337
349
|
return this.waitForReady();
|
|
338
|
-
this.state =
|
|
350
|
+
this.state = L.INITIALIZING;
|
|
339
351
|
try {
|
|
340
352
|
yield e(), this.handleBridgeReady();
|
|
341
353
|
} catch (r) {
|
|
@@ -349,11 +361,11 @@ class Vt {
|
|
|
349
361
|
* @private
|
|
350
362
|
*/
|
|
351
363
|
handleBridgeReady() {
|
|
352
|
-
this.state ===
|
|
364
|
+
this.state === L.INITIALIZING && (this.state = L.READY, this.readyCallbacks.forEach((e) => {
|
|
353
365
|
try {
|
|
354
366
|
e();
|
|
355
367
|
} catch (r) {
|
|
356
|
-
|
|
368
|
+
f.handleApiError(r, { context: "StateManager.handleBridgeReady" });
|
|
357
369
|
}
|
|
358
370
|
}), this.readyCallbacks = [], this.errorCallbacks = []);
|
|
359
371
|
}
|
|
@@ -363,11 +375,11 @@ class Vt {
|
|
|
363
375
|
* @private
|
|
364
376
|
*/
|
|
365
377
|
handleInitializationError(e) {
|
|
366
|
-
this.state =
|
|
378
|
+
this.state = L.ERROR, this.initializationError = e, this.errorCallbacks.forEach((r) => {
|
|
367
379
|
try {
|
|
368
380
|
r(e);
|
|
369
381
|
} catch (n) {
|
|
370
|
-
|
|
382
|
+
f.handleApiError(n, { context: "StateManager.handleInitializationError" });
|
|
371
383
|
}
|
|
372
384
|
}), this.readyCallbacks = [], this.errorCallbacks = [];
|
|
373
385
|
}
|
|
@@ -375,7 +387,7 @@ class Vt {
|
|
|
375
387
|
* 重置状态管理器(用于测试或重新初始化)
|
|
376
388
|
*/
|
|
377
389
|
reset() {
|
|
378
|
-
this.state =
|
|
390
|
+
this.state = L.UNINITIALIZED, this.readyPromise = null, this.readyCallbacks = [], this.errorCallbacks = [], this.initializationError = null;
|
|
379
391
|
}
|
|
380
392
|
/**
|
|
381
393
|
* 添加状态变化监听器
|
|
@@ -390,7 +402,7 @@ class Vt {
|
|
|
390
402
|
const n = () => {
|
|
391
403
|
this.state === e && r(this.state);
|
|
392
404
|
};
|
|
393
|
-
return e ===
|
|
405
|
+
return e === L.READY ? this.readyCallbacks.push(n) : e === L.ERROR && this.errorCallbacks.push(n), () => {
|
|
394
406
|
const i = this.readyCallbacks.indexOf(n);
|
|
395
407
|
i > -1 && this.readyCallbacks.splice(i, 1);
|
|
396
408
|
const a = this.errorCallbacks.indexOf(n);
|
|
@@ -411,52 +423,52 @@ class Vt {
|
|
|
411
423
|
};
|
|
412
424
|
}
|
|
413
425
|
}
|
|
414
|
-
const
|
|
426
|
+
const X = new nr(), at = () => X.waitForReady(), ir = () => X.isReady(), sr = () => X.getState(), y = {
|
|
415
427
|
ERROR: 0,
|
|
416
428
|
WARN: 1,
|
|
417
429
|
INFO: 2,
|
|
418
430
|
DEBUG: 3,
|
|
419
431
|
TRACE: 4
|
|
420
|
-
},
|
|
421
|
-
[
|
|
422
|
-
[
|
|
423
|
-
[
|
|
424
|
-
[
|
|
425
|
-
[
|
|
426
|
-
},
|
|
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 {
|
|
427
439
|
// 可注入的外部 reporter
|
|
428
440
|
/**
|
|
429
441
|
* 设置日志级别
|
|
430
442
|
* @param {number} level - 日志级别
|
|
431
443
|
*/
|
|
432
444
|
static setLevel(e) {
|
|
433
|
-
e >=
|
|
445
|
+
e >= y.ERROR && e <= y.TRACE && (p.currentLevel = e, p.log(y.INFO, "Logger", `日志级别设置为: ${ue[e]}`));
|
|
434
446
|
}
|
|
435
447
|
/**
|
|
436
448
|
* 启用开发模式(显示所有日志)
|
|
437
449
|
*/
|
|
438
450
|
static enableDevMode() {
|
|
439
|
-
|
|
451
|
+
p.setLevel(y.DEBUG), p.log(y.INFO, "Logger", "开发模式已启用");
|
|
440
452
|
}
|
|
441
453
|
/**
|
|
442
454
|
* 启用生产模式(只显示错误和警告)
|
|
443
455
|
*/
|
|
444
456
|
static enableProdMode() {
|
|
445
|
-
|
|
457
|
+
p.setLevel(y.WARN), p.log(y.INFO, "Logger", "生产模式已启用");
|
|
446
458
|
}
|
|
447
459
|
/**
|
|
448
460
|
* 启用特定模块的日志
|
|
449
461
|
* @param {string} module - 模块名称
|
|
450
462
|
*/
|
|
451
463
|
static enableModule(e) {
|
|
452
|
-
|
|
464
|
+
p.enabledModules.add(e), p.log(y.INFO, "Logger", `模块日志已启用: ${e}`);
|
|
453
465
|
}
|
|
454
466
|
/**
|
|
455
467
|
* 禁用特定模块的日志
|
|
456
468
|
* @param {string} module - 模块名称
|
|
457
469
|
*/
|
|
458
470
|
static disableModule(e) {
|
|
459
|
-
|
|
471
|
+
p.enabledModules.delete(e), p.log(y.INFO, "Logger", `模块日志已禁用: ${e}`);
|
|
460
472
|
}
|
|
461
473
|
/**
|
|
462
474
|
* 检查是否应该记录日志
|
|
@@ -466,7 +478,7 @@ const j = new Vt(), qe = () => j.waitForReady(), jt = () => j.isReady(), qt = ()
|
|
|
466
478
|
* @private
|
|
467
479
|
*/
|
|
468
480
|
static shouldLog(e, r) {
|
|
469
|
-
return e >
|
|
481
|
+
return e > p.currentLevel ? !1 : r && p.enabledModules.size > 0 ? p.enabledModules.has(r) : !0;
|
|
470
482
|
}
|
|
471
483
|
/**
|
|
472
484
|
* 核心日志记录方法
|
|
@@ -477,9 +489,9 @@ const j = new Vt(), qe = () => j.waitForReady(), jt = () => j.isReady(), qt = ()
|
|
|
477
489
|
* @private
|
|
478
490
|
*/
|
|
479
491
|
static log(e, r, n, ...i) {
|
|
480
|
-
if (!
|
|
492
|
+
if (!p.shouldLog(e, r))
|
|
481
493
|
return;
|
|
482
|
-
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 = {
|
|
483
495
|
timestamp: a,
|
|
484
496
|
level: e,
|
|
485
497
|
levelName: o,
|
|
@@ -487,12 +499,12 @@ const j = new Vt(), qe = () => j.waitForReady(), jt = () => j.isReady(), qt = ()
|
|
|
487
499
|
message: n,
|
|
488
500
|
args: i
|
|
489
501
|
};
|
|
490
|
-
if (
|
|
502
|
+
if (p.addToHistory(O), typeof p.reporter == "function")
|
|
491
503
|
try {
|
|
492
|
-
|
|
493
|
-
} catch (
|
|
504
|
+
p.reporter(O);
|
|
505
|
+
} catch (R) {
|
|
494
506
|
}
|
|
495
|
-
|
|
507
|
+
p.outputToConsole(e, d, ...i);
|
|
496
508
|
}
|
|
497
509
|
/**
|
|
498
510
|
* 添加日志到历史记录
|
|
@@ -500,7 +512,7 @@ const j = new Vt(), qe = () => j.waitForReady(), jt = () => j.isReady(), qt = ()
|
|
|
500
512
|
* @private
|
|
501
513
|
*/
|
|
502
514
|
static addToHistory(e) {
|
|
503
|
-
|
|
515
|
+
p.logHistory.push(e), p.logHistory.length > p.maxHistorySize && p.logHistory.shift();
|
|
504
516
|
}
|
|
505
517
|
/**
|
|
506
518
|
* 输出到控制台
|
|
@@ -514,17 +526,17 @@ const j = new Vt(), qe = () => j.waitForReady(), jt = () => j.isReady(), qt = ()
|
|
|
514
526
|
return;
|
|
515
527
|
const i = n && n.length > 0;
|
|
516
528
|
switch (e) {
|
|
517
|
-
case
|
|
529
|
+
case y.ERROR:
|
|
518
530
|
i ? console.error(r, ...n) : console.error(r);
|
|
519
531
|
break;
|
|
520
|
-
case
|
|
532
|
+
case y.WARN:
|
|
521
533
|
i ? console.warn(r, ...n) : console.warn(r);
|
|
522
534
|
break;
|
|
523
|
-
case
|
|
535
|
+
case y.INFO:
|
|
524
536
|
i ? console.info(r, ...n) : console.info(r);
|
|
525
537
|
break;
|
|
526
|
-
case
|
|
527
|
-
case
|
|
538
|
+
case y.DEBUG:
|
|
539
|
+
case y.TRACE:
|
|
528
540
|
i ? console.log(r, ...n) : console.log(r);
|
|
529
541
|
break;
|
|
530
542
|
}
|
|
@@ -536,7 +548,7 @@ const j = new Vt(), qe = () => j.waitForReady(), jt = () => j.isReady(), qt = ()
|
|
|
536
548
|
* @param {any[]} args - 额外参数
|
|
537
549
|
*/
|
|
538
550
|
static error(e, r, ...n) {
|
|
539
|
-
|
|
551
|
+
p.log(y.ERROR, e, r, ...n);
|
|
540
552
|
}
|
|
541
553
|
/**
|
|
542
554
|
* 警告级别日志
|
|
@@ -545,7 +557,7 @@ const j = new Vt(), qe = () => j.waitForReady(), jt = () => j.isReady(), qt = ()
|
|
|
545
557
|
* @param {any[]} args - 额外参数
|
|
546
558
|
*/
|
|
547
559
|
static warn(e, r, ...n) {
|
|
548
|
-
|
|
560
|
+
p.log(y.WARN, e, r, ...n);
|
|
549
561
|
}
|
|
550
562
|
/**
|
|
551
563
|
* 信息级别日志
|
|
@@ -554,7 +566,7 @@ const j = new Vt(), qe = () => j.waitForReady(), jt = () => j.isReady(), qt = ()
|
|
|
554
566
|
* @param {any[]} args - 额外参数
|
|
555
567
|
*/
|
|
556
568
|
static info(e, r, ...n) {
|
|
557
|
-
|
|
569
|
+
p.log(y.INFO, e, r, ...n);
|
|
558
570
|
}
|
|
559
571
|
/**
|
|
560
572
|
* 调试级别日志
|
|
@@ -563,7 +575,7 @@ const j = new Vt(), qe = () => j.waitForReady(), jt = () => j.isReady(), qt = ()
|
|
|
563
575
|
* @param {any[]} args - 额外参数
|
|
564
576
|
*/
|
|
565
577
|
static debug(e, r, ...n) {
|
|
566
|
-
|
|
578
|
+
p.log(y.DEBUG, e, r, ...n);
|
|
567
579
|
}
|
|
568
580
|
/**
|
|
569
581
|
* 跟踪级别日志
|
|
@@ -572,7 +584,7 @@ const j = new Vt(), qe = () => j.waitForReady(), jt = () => j.isReady(), qt = ()
|
|
|
572
584
|
* @param {any[]} args - 额外参数
|
|
573
585
|
*/
|
|
574
586
|
static trace(e, r, ...n) {
|
|
575
|
-
|
|
587
|
+
p.log(y.TRACE, e, r, ...n);
|
|
576
588
|
}
|
|
577
589
|
/**
|
|
578
590
|
* 获取日志历史
|
|
@@ -580,13 +592,13 @@ const j = new Vt(), qe = () => j.waitForReady(), jt = () => j.isReady(), qt = ()
|
|
|
580
592
|
* @returns {Array} 日志条目数组
|
|
581
593
|
*/
|
|
582
594
|
static getHistory(e) {
|
|
583
|
-
return e && e > 0 ?
|
|
595
|
+
return e && e > 0 ? p.logHistory.slice(-e) : [...p.logHistory];
|
|
584
596
|
}
|
|
585
597
|
/**
|
|
586
598
|
* 清空日志历史
|
|
587
599
|
*/
|
|
588
600
|
static clearHistory() {
|
|
589
|
-
|
|
601
|
+
p.logHistory = [], p.log(y.INFO, "Logger", "日志历史已清空");
|
|
590
602
|
}
|
|
591
603
|
/**
|
|
592
604
|
* 获取日志统计信息
|
|
@@ -594,15 +606,15 @@ const j = new Vt(), qe = () => j.waitForReady(), jt = () => j.isReady(), qt = ()
|
|
|
594
606
|
*/
|
|
595
607
|
static getStats() {
|
|
596
608
|
const e = {
|
|
597
|
-
currentLevel:
|
|
598
|
-
currentLevelName:
|
|
599
|
-
enabledModules: Array.from(
|
|
600
|
-
historySize:
|
|
601
|
-
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
|
|
602
614
|
}, r = {};
|
|
603
|
-
for (const n of Object.keys(
|
|
604
|
-
r[
|
|
605
|
-
return
|
|
615
|
+
for (const n of Object.keys(ue))
|
|
616
|
+
r[ue[n]] = 0;
|
|
617
|
+
return p.logHistory.forEach((n) => {
|
|
606
618
|
r[n.levelName]++;
|
|
607
619
|
}), e.levelCounts = r, e;
|
|
608
620
|
}
|
|
@@ -612,7 +624,7 @@ const j = new Vt(), qe = () => j.waitForReady(), jt = () => j.isReady(), qt = ()
|
|
|
612
624
|
* @returns {string} JSON 字符串
|
|
613
625
|
*/
|
|
614
626
|
static exportToJSON(e) {
|
|
615
|
-
const r =
|
|
627
|
+
const r = p.getHistory(e), n = p.getStats();
|
|
616
628
|
return JSON.stringify({
|
|
617
629
|
exportTime: (/* @__PURE__ */ new Date()).toISOString(),
|
|
618
630
|
stats: n,
|
|
@@ -626,11 +638,11 @@ const j = new Vt(), qe = () => j.waitForReady(), jt = () => j.isReady(), qt = ()
|
|
|
626
638
|
*/
|
|
627
639
|
static createModuleLogger(e) {
|
|
628
640
|
return {
|
|
629
|
-
error: (r, ...n) =>
|
|
630
|
-
warn: (r, ...n) =>
|
|
631
|
-
info: (r, ...n) =>
|
|
632
|
-
debug: (r, ...n) =>
|
|
633
|
-
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)
|
|
634
646
|
};
|
|
635
647
|
}
|
|
636
648
|
/**
|
|
@@ -638,14 +650,14 @@ const j = new Vt(), qe = () => j.waitForReady(), jt = () => j.isReady(), qt = ()
|
|
|
638
650
|
* @param {(entry: any) => void|null} reporter
|
|
639
651
|
*/
|
|
640
652
|
static setReporter(e) {
|
|
641
|
-
|
|
653
|
+
p.reporter = typeof e == "function" ? e : null;
|
|
642
654
|
}
|
|
643
655
|
};
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
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;
|
|
649
661
|
if (typeof window != "undefined") {
|
|
650
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"));
|
|
651
663
|
let r = !1;
|
|
@@ -653,34 +665,52 @@ if (typeof window != "undefined") {
|
|
|
653
665
|
r = localStorage && localStorage.getItem("qsh_debug") === "true";
|
|
654
666
|
} catch (n) {
|
|
655
667
|
}
|
|
656
|
-
(t || e || r) &&
|
|
668
|
+
(t || e || r) && M.enableDevMode();
|
|
657
669
|
}
|
|
658
|
-
const
|
|
659
|
-
function
|
|
660
|
-
|
|
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
|
+
E.debug("检测到离线包环境,开始初始化");
|
|
674
|
+
const e = () => {
|
|
675
|
+
t();
|
|
676
|
+
};
|
|
677
|
+
if (Oe.test(document.readyState))
|
|
678
|
+
E.debug("离线包环境 DOM 已就绪,立即初始化"), setTimeout(e, 0);
|
|
679
|
+
else {
|
|
680
|
+
E.debug("离线包环境,等待 DOMContentLoaded");
|
|
681
|
+
let r = !1;
|
|
682
|
+
const n = () => {
|
|
683
|
+
r || (r = !0, e());
|
|
684
|
+
};
|
|
685
|
+
document.addEventListener("DOMContentLoaded", n), setTimeout(n, 500);
|
|
686
|
+
}
|
|
687
|
+
return !0;
|
|
688
|
+
}
|
|
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;
|
|
661
691
|
}
|
|
662
|
-
function
|
|
663
|
-
return window.wx && window.wx.miniProgram ? (
|
|
692
|
+
function cr(t) {
|
|
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;
|
|
664
694
|
}
|
|
665
|
-
function
|
|
666
|
-
return
|
|
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);
|
|
667
697
|
}
|
|
668
|
-
function
|
|
669
|
-
return
|
|
698
|
+
function lr() {
|
|
699
|
+
return X.waitForReady();
|
|
670
700
|
}
|
|
671
|
-
function
|
|
672
|
-
return
|
|
701
|
+
function ot() {
|
|
702
|
+
return X.startInitialization(() => h(null, null, function* () {
|
|
673
703
|
return new Promise((t, e) => {
|
|
674
704
|
const r = () => {
|
|
675
705
|
t();
|
|
676
706
|
}, n = (i) => {
|
|
677
|
-
const a =
|
|
707
|
+
const a = f.handleApiError(i, {
|
|
678
708
|
context: "bridge initialization"
|
|
679
709
|
});
|
|
680
710
|
e(a);
|
|
681
711
|
};
|
|
682
712
|
try {
|
|
683
|
-
|
|
713
|
+
ur(() => {
|
|
684
714
|
r();
|
|
685
715
|
});
|
|
686
716
|
} catch (i) {
|
|
@@ -689,48 +719,48 @@ function Je() {
|
|
|
689
719
|
});
|
|
690
720
|
}));
|
|
691
721
|
}
|
|
692
|
-
const
|
|
722
|
+
const S = {
|
|
693
723
|
UNINITIALIZED: "uninitialized",
|
|
694
724
|
CONFIGURING: "configuring",
|
|
695
725
|
CONFIGURED: "configured",
|
|
696
726
|
ERROR: "error"
|
|
697
727
|
};
|
|
698
|
-
function
|
|
728
|
+
function k() {
|
|
699
729
|
return typeof window == "undefined" || !window.wx ? !1 : typeof window.wx.config == "function" && typeof window.wx.ready == "function" && typeof window.wx.error == "function";
|
|
700
730
|
}
|
|
701
|
-
class
|
|
731
|
+
class fr {
|
|
702
732
|
constructor() {
|
|
703
|
-
this.state =
|
|
733
|
+
this.state = S.UNINITIALIZED, this.configPromise = null, this.readyCallbacks = [], this.errorCallbacks = [], this.lastError = null, this.runtimeConfig = {
|
|
704
734
|
clientId: null,
|
|
705
735
|
isProd: !1
|
|
706
|
-
}, 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.handleConfigSuccess = this.handleConfigSuccess.bind(this), this.handleConfigError = this.handleConfigError.bind(this);
|
|
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);
|
|
707
737
|
}
|
|
708
738
|
configure(e = {}) {
|
|
709
739
|
if (!e || typeof e != "object" || Array.isArray(e))
|
|
710
|
-
throw new
|
|
711
|
-
|
|
740
|
+
throw new N(
|
|
741
|
+
x.INVALID_PARAMETERS,
|
|
712
742
|
"config参数异常",
|
|
713
743
|
{ config: e }
|
|
714
744
|
);
|
|
715
745
|
if (!Object.prototype.hasOwnProperty.call(e, "clientId"))
|
|
716
746
|
throw this.createMissingClientIdError();
|
|
717
747
|
if (typeof e.clientId != "string" || !e.clientId.trim())
|
|
718
|
-
throw new
|
|
719
|
-
|
|
748
|
+
throw new N(
|
|
749
|
+
x.INVALID_PARAMETERS,
|
|
720
750
|
"clientId参数异常",
|
|
721
751
|
{ clientId: e.clientId }
|
|
722
752
|
);
|
|
723
753
|
if (Object.prototype.hasOwnProperty.call(e, "isProd") && typeof e.isProd != "boolean")
|
|
724
|
-
throw new
|
|
725
|
-
|
|
754
|
+
throw new N(
|
|
755
|
+
x.INVALID_PARAMETERS,
|
|
726
756
|
"isProd参数异常",
|
|
727
757
|
{ isProd: e.isProd }
|
|
728
758
|
);
|
|
729
759
|
const r = e.clientId.trim(), n = e.isProd === !0, i = r !== this.runtimeConfig.clientId || n !== this.runtimeConfig.isProd;
|
|
730
|
-
return this.runtimeConfig =
|
|
760
|
+
return this.runtimeConfig = m(g({}, this.runtimeConfig), {
|
|
731
761
|
clientId: r,
|
|
732
762
|
isProd: n
|
|
733
|
-
}), 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", {
|
|
734
764
|
clientId: this.runtimeConfig.clientId,
|
|
735
765
|
isProd: this.runtimeConfig.isProd,
|
|
736
766
|
configApiUrl: this.CONFIG_API_URL
|
|
@@ -746,8 +776,8 @@ class Zt {
|
|
|
746
776
|
return this.isTestMode() || this.hasClientId();
|
|
747
777
|
}
|
|
748
778
|
createMissingClientIdError() {
|
|
749
|
-
return new
|
|
750
|
-
|
|
779
|
+
return new N(
|
|
780
|
+
x.INVALID_PARAMETERS,
|
|
751
781
|
"clientId错误",
|
|
752
782
|
{ field: "clientId" }
|
|
753
783
|
);
|
|
@@ -777,32 +807,32 @@ class Zt {
|
|
|
777
807
|
* @private
|
|
778
808
|
*/
|
|
779
809
|
fetchWeixinConfig() {
|
|
780
|
-
return
|
|
810
|
+
return h(this, null, function* () {
|
|
781
811
|
const e = this.getCurrentPageUrl();
|
|
782
812
|
if (this.isTestMode())
|
|
783
|
-
return
|
|
813
|
+
return w.info("使用测试模式,返回模拟配置"), this.getMockConfig();
|
|
784
814
|
if (!this.hasClientId())
|
|
785
815
|
throw this.createMissingClientIdError();
|
|
786
816
|
const r = this.getConfigApiUrl(this.runtimeConfig.isProd);
|
|
787
817
|
this.CONFIG_API_URL = r;
|
|
788
818
|
const n = `${r}?clientId=${this.runtimeConfig.clientId}&url=${encodeURIComponent(e)}`;
|
|
789
|
-
|
|
819
|
+
w.debug("请求微信配置", { url: n });
|
|
790
820
|
try {
|
|
791
821
|
const i = yield fetch(n);
|
|
792
822
|
if (!i.ok)
|
|
793
823
|
throw new Error(`HTTP ${i.status}: ${i.statusText}`);
|
|
794
824
|
const a = yield i.json();
|
|
795
|
-
if (
|
|
825
|
+
if (w.debug("微信配置响应", a), !a.success || a.code !== 200)
|
|
796
826
|
throw new Error(`配置获取失败: ${a.message || "未知错误"}`);
|
|
797
827
|
const { data: o } = a;
|
|
798
828
|
if (!o || !o.appId || !o.timestamp || !o.nonceStr || !o.signature)
|
|
799
829
|
throw new Error("配置数据格式不正确,缺少必需字段");
|
|
800
830
|
return o;
|
|
801
831
|
} catch (i) {
|
|
802
|
-
if (
|
|
803
|
-
return
|
|
804
|
-
throw new
|
|
805
|
-
|
|
832
|
+
if (w.error("获取微信配置失败", i), this.shouldUseTestMode(i))
|
|
833
|
+
return w.warn("网络请求失败,降级到测试模式"), this.getMockConfig();
|
|
834
|
+
throw new N(
|
|
835
|
+
x.NETWORK_ERROR,
|
|
806
836
|
`获取微信配置失败: ${i.message}`,
|
|
807
837
|
{ url: n, originalError: i }
|
|
808
838
|
);
|
|
@@ -854,12 +884,12 @@ class Zt {
|
|
|
854
884
|
*/
|
|
855
885
|
executeWeixinConfig(e) {
|
|
856
886
|
if (this.isTestMode() || e.appId === "wx_test_app_id") {
|
|
857
|
-
|
|
887
|
+
w.info("测试模式:模拟微信配置成功"), setTimeout(() => {
|
|
858
888
|
this.handleConfigSuccess();
|
|
859
889
|
}, 100);
|
|
860
890
|
return;
|
|
861
891
|
}
|
|
862
|
-
if (
|
|
892
|
+
if (!k())
|
|
863
893
|
throw new Error("微信JS-SDK未加载");
|
|
864
894
|
const r = {
|
|
865
895
|
debug: !1,
|
|
@@ -868,22 +898,23 @@ class Zt {
|
|
|
868
898
|
timestamp: parseInt(e.timestamp),
|
|
869
899
|
nonceStr: e.nonceStr,
|
|
870
900
|
signature: e.signature,
|
|
871
|
-
jsApiList: this.DEFAULT_JS_API_LIST
|
|
901
|
+
jsApiList: this.DEFAULT_JS_API_LIST,
|
|
902
|
+
openTagList: this.DEFAULT_OPEN_TAG_LIST
|
|
872
903
|
};
|
|
873
|
-
|
|
904
|
+
w.info("执行微信配置", r), window.wx.ready(this.handleConfigSuccess), window.wx.error(this.handleConfigError), window.wx.config(r);
|
|
874
905
|
}
|
|
875
906
|
/**
|
|
876
907
|
* 处理配置成功
|
|
877
908
|
* @private
|
|
878
909
|
*/
|
|
879
910
|
handleConfigSuccess() {
|
|
880
|
-
|
|
911
|
+
w.info("微信配置成功"), this.state = S.CONFIGURED, this.lastError = null, this.configPromise = null;
|
|
881
912
|
const e = [...this.readyCallbacks];
|
|
882
913
|
this.readyCallbacks = [], this.errorCallbacks = [], e.forEach((r) => {
|
|
883
914
|
try {
|
|
884
915
|
r();
|
|
885
916
|
} catch (n) {
|
|
886
|
-
|
|
917
|
+
f.handleApiError(n, { context: "WeixinConfigManager.handleConfigSuccess" });
|
|
887
918
|
}
|
|
888
919
|
});
|
|
889
920
|
}
|
|
@@ -894,19 +925,19 @@ class Zt {
|
|
|
894
925
|
*/
|
|
895
926
|
handleConfigError(e) {
|
|
896
927
|
const r = `微信配置验证失败: ${JSON.stringify(e)}`;
|
|
897
|
-
|
|
898
|
-
const n = new
|
|
899
|
-
|
|
928
|
+
w.error(r, e);
|
|
929
|
+
const n = new N(
|
|
930
|
+
x.API_CALL_FAILED,
|
|
900
931
|
r,
|
|
901
932
|
{ weixinErrorResponse: e }
|
|
902
933
|
);
|
|
903
|
-
this.state =
|
|
934
|
+
this.state = S.ERROR, this.lastError = n, this.configPromise = null;
|
|
904
935
|
const i = [...this.errorCallbacks];
|
|
905
936
|
this.readyCallbacks = [], this.errorCallbacks = [], i.forEach((a) => {
|
|
906
937
|
try {
|
|
907
938
|
a(n);
|
|
908
939
|
} catch (o) {
|
|
909
|
-
|
|
940
|
+
f.handleApiError(o, { context: "WeixinConfigManager.handleConfigError" });
|
|
910
941
|
}
|
|
911
942
|
});
|
|
912
943
|
}
|
|
@@ -915,8 +946,8 @@ class Zt {
|
|
|
915
946
|
* @returns {Promise<void>} 配置完成的Promise
|
|
916
947
|
*/
|
|
917
948
|
autoConfig() {
|
|
918
|
-
return
|
|
919
|
-
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());
|
|
920
951
|
});
|
|
921
952
|
}
|
|
922
953
|
/**
|
|
@@ -925,33 +956,33 @@ class Zt {
|
|
|
925
956
|
* @private
|
|
926
957
|
*/
|
|
927
958
|
performAutoConfig() {
|
|
928
|
-
return
|
|
959
|
+
return h(this, null, function* () {
|
|
929
960
|
try {
|
|
930
961
|
if (typeof window == "undefined")
|
|
931
962
|
throw new Error("非浏览器环境无法执行微信配置");
|
|
932
|
-
if (
|
|
963
|
+
if (!k())
|
|
933
964
|
throw new Error("微信JS-SDK未加载,无法执行配置");
|
|
934
965
|
const e = yield this.fetchWeixinConfig();
|
|
935
966
|
return this.executeWeixinConfig(e), yield new Promise((r, n) => {
|
|
936
|
-
if (this.state ===
|
|
967
|
+
if (this.state === S.CONFIGURED) {
|
|
937
968
|
r();
|
|
938
969
|
return;
|
|
939
970
|
}
|
|
940
|
-
if (this.state ===
|
|
971
|
+
if (this.state === S.ERROR) {
|
|
941
972
|
n(this.lastError);
|
|
942
973
|
return;
|
|
943
974
|
}
|
|
944
975
|
this.readyCallbacks.push(r), this.errorCallbacks.push(n);
|
|
945
976
|
});
|
|
946
977
|
} catch (e) {
|
|
947
|
-
const r = e instanceof
|
|
948
|
-
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;
|
|
949
980
|
const n = [...this.errorCallbacks];
|
|
950
981
|
throw this.readyCallbacks = [], this.errorCallbacks = [], n.forEach((i) => {
|
|
951
982
|
try {
|
|
952
983
|
i(r);
|
|
953
984
|
} catch (a) {
|
|
954
|
-
|
|
985
|
+
f.handleApiError(a, { context: "WeixinConfigManager.performAutoConfig.errorCallback" });
|
|
955
986
|
}
|
|
956
987
|
}), r;
|
|
957
988
|
}
|
|
@@ -962,7 +993,7 @@ class Zt {
|
|
|
962
993
|
* @returns {Promise<void>} 配置完成的Promise
|
|
963
994
|
*/
|
|
964
995
|
waitForReady() {
|
|
965
|
-
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) => {
|
|
966
997
|
this.readyCallbacks.push(e), this.errorCallbacks.push(r);
|
|
967
998
|
}) : Promise.reject(this.createMissingClientIdError());
|
|
968
999
|
}
|
|
@@ -971,7 +1002,7 @@ class Zt {
|
|
|
971
1002
|
* @returns {boolean} 是否已配置
|
|
972
1003
|
*/
|
|
973
1004
|
isReady() {
|
|
974
|
-
return this.state ===
|
|
1005
|
+
return this.state === S.CONFIGURED;
|
|
975
1006
|
}
|
|
976
1007
|
/**
|
|
977
1008
|
* 获取当前状态
|
|
@@ -991,7 +1022,7 @@ class Zt {
|
|
|
991
1022
|
* 重置配置管理器(用于重试或测试)
|
|
992
1023
|
*/
|
|
993
1024
|
reset() {
|
|
994
|
-
this.state =
|
|
1025
|
+
this.state = S.UNINITIALIZED, this.configPromise = null, this.readyCallbacks = [], this.errorCallbacks = [], this.lastError = null, w.debug("微信配置管理器已重置");
|
|
995
1026
|
}
|
|
996
1027
|
/**
|
|
997
1028
|
* 获取配置统计信息
|
|
@@ -1007,133 +1038,134 @@ class Zt {
|
|
|
1007
1038
|
configApiUrl: this.CONFIG_API_URL,
|
|
1008
1039
|
clientId: this.runtimeConfig.clientId,
|
|
1009
1040
|
isProd: this.runtimeConfig.isProd,
|
|
1010
|
-
jsApiList: this.DEFAULT_JS_API_LIST
|
|
1041
|
+
jsApiList: this.DEFAULT_JS_API_LIST,
|
|
1042
|
+
openTagList: this.DEFAULT_OPEN_TAG_LIST
|
|
1011
1043
|
};
|
|
1012
1044
|
}
|
|
1013
1045
|
}
|
|
1014
|
-
const
|
|
1015
|
-
let
|
|
1016
|
-
function
|
|
1046
|
+
const b = new fr();
|
|
1047
|
+
let re = !1, ge = !1, U = null, _e = !1;
|
|
1048
|
+
function dr(t) {
|
|
1017
1049
|
return new Promise((e) => {
|
|
1018
1050
|
let r = !1, n = null;
|
|
1019
|
-
const i = (
|
|
1051
|
+
const i = (u) => h(null, null, function* () {
|
|
1020
1052
|
if (!r) {
|
|
1021
|
-
if (r = !0, n && clearTimeout(n),
|
|
1053
|
+
if (r = !0, n && clearTimeout(n), re = !1, ge = u, u)
|
|
1022
1054
|
try {
|
|
1023
|
-
yield
|
|
1024
|
-
} catch (
|
|
1025
|
-
|
|
1055
|
+
yield ct();
|
|
1056
|
+
} catch (d) {
|
|
1057
|
+
w.error("微信配置失败,将使用消息桥作为后备", d);
|
|
1026
1058
|
}
|
|
1027
1059
|
e();
|
|
1028
1060
|
}
|
|
1029
|
-
}), a = () => i(
|
|
1030
|
-
|
|
1061
|
+
}), a = () => i(k()), o = () => {
|
|
1062
|
+
w.warn("已存在的微信 JS-SDK 脚本加载失败,SDK 将使用消息桥作为后备"), i(!1);
|
|
1031
1063
|
};
|
|
1032
1064
|
t.addEventListener("load", a, { once: !0 }), t.addEventListener("error", o, { once: !0 }), setTimeout(() => {
|
|
1033
|
-
|
|
1065
|
+
k() && a();
|
|
1034
1066
|
}, 0), n = setTimeout(() => {
|
|
1035
|
-
i(
|
|
1067
|
+
i(k());
|
|
1036
1068
|
}, 3e3);
|
|
1037
1069
|
});
|
|
1038
1070
|
}
|
|
1039
|
-
function
|
|
1040
|
-
return
|
|
1071
|
+
function Be() {
|
|
1072
|
+
return h(this, arguments, function* (t = {}) {
|
|
1041
1073
|
const { force: e = !1, recoverFromError: r = !1 } = t;
|
|
1042
|
-
if (yield
|
|
1074
|
+
if (yield ut({ force: e }), !k())
|
|
1043
1075
|
throw new Error("微信 JS-SDK 未正确加载,无法执行配置");
|
|
1044
|
-
r &&
|
|
1076
|
+
r && pr();
|
|
1045
1077
|
});
|
|
1046
1078
|
}
|
|
1047
|
-
function
|
|
1079
|
+
function gr(t = !1) {
|
|
1048
1080
|
if (typeof window == "undefined") return !1;
|
|
1049
|
-
if (
|
|
1050
|
-
return
|
|
1051
|
-
if (
|
|
1081
|
+
if (k())
|
|
1082
|
+
return ge = !0, !1;
|
|
1083
|
+
if (ge || Q()) return !1;
|
|
1052
1084
|
if (t) return !0;
|
|
1053
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);
|
|
1054
1086
|
return r && (n || i || a);
|
|
1055
1087
|
}
|
|
1056
|
-
function
|
|
1057
|
-
|
|
1088
|
+
function pr() {
|
|
1089
|
+
b.getState() === "error" && (b.reset(), _e = !1);
|
|
1058
1090
|
}
|
|
1059
|
-
function
|
|
1060
|
-
return
|
|
1061
|
-
if (
|
|
1062
|
-
return
|
|
1063
|
-
|
|
1091
|
+
function ct() {
|
|
1092
|
+
return h(this, null, function* () {
|
|
1093
|
+
if (_e)
|
|
1094
|
+
return b.waitForReady();
|
|
1095
|
+
_e = !0, w.info("开始自动配置微信JS-SDK");
|
|
1064
1096
|
try {
|
|
1065
|
-
yield
|
|
1097
|
+
yield b.autoConfig(), w.info("微信JS-SDK自动配置完成");
|
|
1066
1098
|
} catch (t) {
|
|
1067
|
-
|
|
1099
|
+
w.error("微信JS-SDK自动配置失败", t);
|
|
1068
1100
|
}
|
|
1069
1101
|
});
|
|
1070
1102
|
}
|
|
1071
|
-
function
|
|
1103
|
+
function ut(t = {}) {
|
|
1072
1104
|
const { force: e = !1 } = t;
|
|
1073
1105
|
if (typeof window == "undefined")
|
|
1074
1106
|
return Promise.resolve();
|
|
1075
|
-
if (
|
|
1076
|
-
return
|
|
1107
|
+
if (k())
|
|
1108
|
+
return ge = !0, Promise.resolve();
|
|
1077
1109
|
const r = document.getElementById("weixin-jssdk");
|
|
1078
|
-
return r ?
|
|
1079
|
-
|
|
1080
|
-
}),
|
|
1081
|
-
|
|
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;
|
|
1082
1114
|
try {
|
|
1083
1115
|
const i = document.createElement("script");
|
|
1084
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() {
|
|
1085
|
-
return
|
|
1086
|
-
|
|
1117
|
+
return h(this, null, function* () {
|
|
1118
|
+
ge = !0, re = !1, w.info("微信 JS-SDK 已自动加载");
|
|
1087
1119
|
try {
|
|
1088
|
-
yield
|
|
1120
|
+
yield ct();
|
|
1089
1121
|
} catch (o) {
|
|
1090
|
-
|
|
1122
|
+
w.error("微信配置失败,将使用消息桥作为后备", o);
|
|
1091
1123
|
}
|
|
1092
1124
|
n();
|
|
1093
1125
|
});
|
|
1094
1126
|
}, i.onerror = function() {
|
|
1095
|
-
|
|
1127
|
+
re = !1, w.warn("微信 JS-SDK 加载失败,SDK 将使用消息桥作为后备"), n();
|
|
1096
1128
|
}, (document.getElementsByTagName("head")[0] || document.documentElement).appendChild(i);
|
|
1097
1129
|
} catch (i) {
|
|
1098
|
-
|
|
1130
|
+
re = !1, w.error("注入微信 JS-SDK 失败", i), n();
|
|
1099
1131
|
}
|
|
1100
1132
|
}).finally(() => {
|
|
1101
|
-
|
|
1102
|
-
}),
|
|
1133
|
+
U = null;
|
|
1134
|
+
}), U) : Promise.resolve();
|
|
1103
1135
|
}
|
|
1104
|
-
function
|
|
1105
|
-
return
|
|
1136
|
+
function K() {
|
|
1137
|
+
return Be({ force: !0, recoverFromError: !0 }).then(() => b.waitForReady());
|
|
1106
1138
|
}
|
|
1107
|
-
function
|
|
1108
|
-
const e =
|
|
1109
|
-
return typeof window == "undefined" ||
|
|
1139
|
+
function Qe(t = {}) {
|
|
1140
|
+
const e = b.configure(t);
|
|
1141
|
+
return typeof window == "undefined" || Be({
|
|
1110
1142
|
force: !0,
|
|
1111
|
-
recoverFromError:
|
|
1143
|
+
recoverFromError: b.getState() === "error"
|
|
1112
1144
|
}).then(() => {
|
|
1113
|
-
if (!
|
|
1114
|
-
return
|
|
1115
|
-
|
|
1145
|
+
if (!b.isReady())
|
|
1146
|
+
return b.waitForReady().catch((r) => {
|
|
1147
|
+
w.error("Failed to auto-configure Weixin after qsh.config()", r);
|
|
1116
1148
|
});
|
|
1117
|
-
window.wx &&
|
|
1149
|
+
window.wx && !k() && w.warn("window.wx 已存在,但微信 JS-SDK 尚未就绪,跳过自动配置");
|
|
1118
1150
|
}).catch((r) => {
|
|
1119
|
-
|
|
1151
|
+
w.error("Failed to preload Weixin JS-SDK", r);
|
|
1120
1152
|
}), e;
|
|
1121
1153
|
}
|
|
1122
|
-
function
|
|
1123
|
-
return
|
|
1154
|
+
function j() {
|
|
1155
|
+
return b.isReady();
|
|
1124
1156
|
}
|
|
1125
|
-
function
|
|
1126
|
-
return
|
|
1157
|
+
function mr() {
|
|
1158
|
+
return b.getState();
|
|
1127
1159
|
}
|
|
1128
|
-
function
|
|
1129
|
-
return
|
|
1160
|
+
function xe() {
|
|
1161
|
+
return b;
|
|
1130
1162
|
}
|
|
1131
|
-
function
|
|
1132
|
-
return
|
|
1133
|
-
return
|
|
1163
|
+
function hr() {
|
|
1164
|
+
return h(this, null, function* () {
|
|
1165
|
+
return w.info("手动重试微信配置"), b.reset(), _e = !1, yield Be({ force: !0 }), b.waitForReady();
|
|
1134
1166
|
});
|
|
1135
1167
|
}
|
|
1136
|
-
class
|
|
1168
|
+
class wr {
|
|
1137
1169
|
constructor() {
|
|
1138
1170
|
this.plugins = /* @__PURE__ */ new Map(), this.installed = /* @__PURE__ */ new Set(), this.installOrder = [], s.debug("插件管理器已初始化");
|
|
1139
1171
|
}
|
|
@@ -1145,7 +1177,7 @@ class ir {
|
|
|
1145
1177
|
* pluginManager.register(imagePlugin)
|
|
1146
1178
|
*/
|
|
1147
1179
|
register(e) {
|
|
1148
|
-
return
|
|
1180
|
+
return f.safeExecute(() => {
|
|
1149
1181
|
this.validatePlugin(e);
|
|
1150
1182
|
const { name: r, version: n } = e;
|
|
1151
1183
|
if (this.plugins.has(r)) {
|
|
@@ -1185,8 +1217,8 @@ class ir {
|
|
|
1185
1217
|
* await pluginManager.install('image', qsh)
|
|
1186
1218
|
*/
|
|
1187
1219
|
install(e, r) {
|
|
1188
|
-
return
|
|
1189
|
-
return
|
|
1220
|
+
return h(this, null, function* () {
|
|
1221
|
+
return f.safeExecute(() => h(this, null, function* () {
|
|
1190
1222
|
if (!this.plugins.has(e))
|
|
1191
1223
|
throw new Error(`插件 ${e} 未注册`);
|
|
1192
1224
|
if (this.installed.has(e)) {
|
|
@@ -1215,8 +1247,8 @@ class ir {
|
|
|
1215
1247
|
* await pluginManager.uninstall('image', qsh)
|
|
1216
1248
|
*/
|
|
1217
1249
|
uninstall(e, r) {
|
|
1218
|
-
return
|
|
1219
|
-
return
|
|
1250
|
+
return h(this, null, function* () {
|
|
1251
|
+
return f.safeExecute(() => h(this, null, function* () {
|
|
1220
1252
|
if (!this.installed.has(e)) {
|
|
1221
1253
|
s.debug(`插件 ${e} 未安装,跳过卸载`);
|
|
1222
1254
|
return;
|
|
@@ -1237,7 +1269,7 @@ class ir {
|
|
|
1237
1269
|
* @returns {Promise<void>}
|
|
1238
1270
|
*/
|
|
1239
1271
|
uninstallAll(e) {
|
|
1240
|
-
return
|
|
1272
|
+
return h(this, null, function* () {
|
|
1241
1273
|
const r = [...this.installOrder].reverse();
|
|
1242
1274
|
for (const n of r)
|
|
1243
1275
|
yield this.uninstall(n, e);
|
|
@@ -1264,7 +1296,7 @@ class ir {
|
|
|
1264
1296
|
* await pluginManager.installAll(['image', 'location'], qsh)
|
|
1265
1297
|
*/
|
|
1266
1298
|
installAll(e, r) {
|
|
1267
|
-
return
|
|
1299
|
+
return h(this, null, function* () {
|
|
1268
1300
|
if (!Array.isArray(e))
|
|
1269
1301
|
throw new Error("names 必须是数组");
|
|
1270
1302
|
for (const n of e)
|
|
@@ -1326,8 +1358,8 @@ class ir {
|
|
|
1326
1358
|
this.plugins.clear(), this.installed.clear(), this.installOrder = [];
|
|
1327
1359
|
}
|
|
1328
1360
|
}
|
|
1329
|
-
const
|
|
1330
|
-
class
|
|
1361
|
+
const le = new wr();
|
|
1362
|
+
class Er {
|
|
1331
1363
|
constructor() {
|
|
1332
1364
|
this.requestInterceptors = [], this.responseInterceptors = [], s.debug("拦截器链已初始化");
|
|
1333
1365
|
}
|
|
@@ -1386,7 +1418,7 @@ class sr {
|
|
|
1386
1418
|
* @private
|
|
1387
1419
|
*/
|
|
1388
1420
|
runRequest(e) {
|
|
1389
|
-
return
|
|
1421
|
+
return h(this, null, function* () {
|
|
1390
1422
|
let r = g({}, e);
|
|
1391
1423
|
for (const { fn: n } of this.requestInterceptors) {
|
|
1392
1424
|
if (r.abort) {
|
|
@@ -1412,7 +1444,7 @@ class sr {
|
|
|
1412
1444
|
* @private
|
|
1413
1445
|
*/
|
|
1414
1446
|
runResponse(e, r) {
|
|
1415
|
-
return
|
|
1447
|
+
return h(this, null, function* () {
|
|
1416
1448
|
let n = e;
|
|
1417
1449
|
for (const { fn: i } of this.responseInterceptors)
|
|
1418
1450
|
try {
|
|
@@ -1441,7 +1473,7 @@ class sr {
|
|
|
1441
1473
|
};
|
|
1442
1474
|
}
|
|
1443
1475
|
}
|
|
1444
|
-
const
|
|
1476
|
+
const Y = new Er(), yr = {
|
|
1445
1477
|
/**
|
|
1446
1478
|
* 请求日志
|
|
1447
1479
|
*/
|
|
@@ -1458,7 +1490,7 @@ const V = new sr(), ar = {
|
|
|
1458
1490
|
success: t == null ? void 0 : t.success
|
|
1459
1491
|
}), t;
|
|
1460
1492
|
}
|
|
1461
|
-
},
|
|
1493
|
+
}, G = {
|
|
1462
1494
|
// 性能数据存储
|
|
1463
1495
|
metrics: /* @__PURE__ */ new Map(),
|
|
1464
1496
|
/**
|
|
@@ -1470,14 +1502,14 @@ const V = new sr(), ar = {
|
|
|
1470
1502
|
*/
|
|
1471
1503
|
response: (t, e) => {
|
|
1472
1504
|
const r = performance.now() - e.perfStartTime;
|
|
1473
|
-
|
|
1505
|
+
G.metrics.has(e.apiName) || G.metrics.set(e.apiName, {
|
|
1474
1506
|
count: 0,
|
|
1475
1507
|
totalTime: 0,
|
|
1476
1508
|
minTime: 1 / 0,
|
|
1477
1509
|
maxTime: 0,
|
|
1478
1510
|
avgTime: 0
|
|
1479
1511
|
});
|
|
1480
|
-
const n =
|
|
1512
|
+
const n = G.metrics.get(e.apiName);
|
|
1481
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;
|
|
1482
1514
|
},
|
|
1483
1515
|
/**
|
|
@@ -1485,7 +1517,7 @@ const V = new sr(), ar = {
|
|
|
1485
1517
|
*/
|
|
1486
1518
|
getReport: () => {
|
|
1487
1519
|
const t = {};
|
|
1488
|
-
return
|
|
1520
|
+
return G.metrics.forEach((e, r) => {
|
|
1489
1521
|
t[r] = g({}, e);
|
|
1490
1522
|
}), t;
|
|
1491
1523
|
},
|
|
@@ -1493,22 +1525,22 @@ const V = new sr(), ar = {
|
|
|
1493
1525
|
* 清空性能数据
|
|
1494
1526
|
*/
|
|
1495
1527
|
clearMetrics: () => {
|
|
1496
|
-
|
|
1528
|
+
G.metrics.clear();
|
|
1497
1529
|
}
|
|
1498
1530
|
};
|
|
1499
|
-
function
|
|
1531
|
+
function Ir(t = {}) {
|
|
1500
1532
|
const {
|
|
1501
1533
|
maxRetries: e = 3,
|
|
1502
1534
|
retryDelay: r = 1e3,
|
|
1503
1535
|
shouldRetry: n = (i) => !i.success
|
|
1504
1536
|
} = t;
|
|
1505
1537
|
return {
|
|
1506
|
-
response: (i, a) =>
|
|
1538
|
+
response: (i, a) => h(null, null, function* () {
|
|
1507
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;
|
|
1508
1540
|
})
|
|
1509
1541
|
};
|
|
1510
1542
|
}
|
|
1511
|
-
function
|
|
1543
|
+
function Ar(t = {}) {
|
|
1512
1544
|
return {
|
|
1513
1545
|
request: (e) => {
|
|
1514
1546
|
const r = t[e.apiName];
|
|
@@ -1520,7 +1552,7 @@ function cr(t = {}) {
|
|
|
1520
1552
|
}
|
|
1521
1553
|
};
|
|
1522
1554
|
}
|
|
1523
|
-
class
|
|
1555
|
+
class Or {
|
|
1524
1556
|
constructor() {
|
|
1525
1557
|
this.state = {
|
|
1526
1558
|
// SDK 状态
|
|
@@ -1532,11 +1564,12 @@ class ur {
|
|
|
1532
1564
|
},
|
|
1533
1565
|
// 平台信息
|
|
1534
1566
|
platform: {
|
|
1535
|
-
type:
|
|
1536
|
-
isWeixinMiniProgram:
|
|
1537
|
-
isAppPlus:
|
|
1538
|
-
isNvue:
|
|
1539
|
-
isUvue:
|
|
1567
|
+
type: l.type,
|
|
1568
|
+
isWeixinMiniProgram: l.isWeixinMiniProgram,
|
|
1569
|
+
isAppPlus: l.isAppPlus,
|
|
1570
|
+
isNvue: l.isNvue,
|
|
1571
|
+
isUvue: l.isUvue,
|
|
1572
|
+
isOfflineWebview: l.isOfflineWebview,
|
|
1540
1573
|
features: {}
|
|
1541
1574
|
// 平台支持的特性
|
|
1542
1575
|
},
|
|
@@ -1564,7 +1597,7 @@ class ur {
|
|
|
1564
1597
|
api: {
|
|
1565
1598
|
// 格式: { apiName: { loading: boolean, lastCall: timestamp, lastResult: any } }
|
|
1566
1599
|
}
|
|
1567
|
-
}, 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("状态仓库已初始化");
|
|
1568
1601
|
}
|
|
1569
1602
|
/**
|
|
1570
1603
|
* 获取状态值
|
|
@@ -1586,8 +1619,8 @@ class ur {
|
|
|
1586
1619
|
* store.set('network.online', false)
|
|
1587
1620
|
*/
|
|
1588
1621
|
set(e, r) {
|
|
1589
|
-
const n = e.split("."), i = n.pop(), a = n.reduce((
|
|
1590
|
-
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));
|
|
1591
1624
|
}
|
|
1592
1625
|
/**
|
|
1593
1626
|
* 批量更新状态
|
|
@@ -1618,11 +1651,11 @@ class ur {
|
|
|
1618
1651
|
subscribe(e, r) {
|
|
1619
1652
|
if (typeof r != "function")
|
|
1620
1653
|
throw new Error("listener 必须是函数");
|
|
1621
|
-
return e === "*" ? (this.wildcardListeners.add(r),
|
|
1622
|
-
this.wildcardListeners.delete(r),
|
|
1623
|
-
}) : (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}`), () => {
|
|
1624
1657
|
const n = this.listeners.get(e);
|
|
1625
|
-
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}`));
|
|
1626
1659
|
});
|
|
1627
1660
|
}
|
|
1628
1661
|
/**
|
|
@@ -1649,20 +1682,20 @@ class ur {
|
|
|
1649
1682
|
i && i.forEach((o) => {
|
|
1650
1683
|
try {
|
|
1651
1684
|
o(r, n, e);
|
|
1652
|
-
} catch (
|
|
1653
|
-
|
|
1685
|
+
} catch (u) {
|
|
1686
|
+
D.error("订阅者执行失败", u);
|
|
1654
1687
|
}
|
|
1655
1688
|
});
|
|
1656
1689
|
const a = e.split(".");
|
|
1657
1690
|
for (let o = 1; o < a.length; o++) {
|
|
1658
|
-
const
|
|
1659
|
-
if (
|
|
1660
|
-
const O = this.get(
|
|
1661
|
-
|
|
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) => {
|
|
1662
1695
|
try {
|
|
1663
|
-
|
|
1664
|
-
} catch (
|
|
1665
|
-
|
|
1696
|
+
R(O, void 0, u);
|
|
1697
|
+
} catch (_) {
|
|
1698
|
+
D.error("父路径订阅者执行失败", _);
|
|
1666
1699
|
}
|
|
1667
1700
|
});
|
|
1668
1701
|
}
|
|
@@ -1670,8 +1703,8 @@ class ur {
|
|
|
1670
1703
|
this.wildcardListeners.forEach((o) => {
|
|
1671
1704
|
try {
|
|
1672
1705
|
o(r, n, e);
|
|
1673
|
-
} catch (
|
|
1674
|
-
|
|
1706
|
+
} catch (u) {
|
|
1707
|
+
D.error("通配符订阅者执行失败", u);
|
|
1675
1708
|
}
|
|
1676
1709
|
});
|
|
1677
1710
|
}
|
|
@@ -1697,7 +1730,7 @@ class ur {
|
|
|
1697
1730
|
*/
|
|
1698
1731
|
setApiLoading(e, r = !0) {
|
|
1699
1732
|
const n = `api.${e}`, i = this.get(n) || {};
|
|
1700
|
-
this.set(n,
|
|
1733
|
+
this.set(n, m(g({}, i), {
|
|
1701
1734
|
loading: r,
|
|
1702
1735
|
lastCall: r ? Date.now() : i.lastCall
|
|
1703
1736
|
}));
|
|
@@ -1709,7 +1742,7 @@ class ur {
|
|
|
1709
1742
|
*/
|
|
1710
1743
|
setApiResult(e, r) {
|
|
1711
1744
|
const n = `api.${e}`, i = this.get(n) || {};
|
|
1712
|
-
this.set(n,
|
|
1745
|
+
this.set(n, m(g({}, i), {
|
|
1713
1746
|
loading: !1,
|
|
1714
1747
|
lastResult: r,
|
|
1715
1748
|
lastCallEnd: Date.now()
|
|
@@ -1750,7 +1783,7 @@ class ur {
|
|
|
1750
1783
|
album: "prompt"
|
|
1751
1784
|
},
|
|
1752
1785
|
api: {}
|
|
1753
|
-
},
|
|
1786
|
+
}, D.debug("状态已重置");
|
|
1754
1787
|
}
|
|
1755
1788
|
/**
|
|
1756
1789
|
* 获取统计信息
|
|
@@ -1764,7 +1797,7 @@ class ur {
|
|
|
1764
1797
|
};
|
|
1765
1798
|
}
|
|
1766
1799
|
}
|
|
1767
|
-
const
|
|
1800
|
+
const $ = new Or(), c = {
|
|
1768
1801
|
// SDK 核心错误 (E_SDK_xxx)
|
|
1769
1802
|
SDK_NOT_READY: "E_SDK_001",
|
|
1770
1803
|
SDK_INIT_FAILED: "E_SDK_002",
|
|
@@ -1815,7 +1848,7 @@ const W = new ur(), c = {
|
|
|
1815
1848
|
API_TIMEOUT: "E_TIMEOUT_001",
|
|
1816
1849
|
// 通用错误
|
|
1817
1850
|
UNKNOWN_ERROR: "E_UNKNOWN_999"
|
|
1818
|
-
},
|
|
1851
|
+
}, ve = {
|
|
1819
1852
|
// SDK 核心
|
|
1820
1853
|
[c.SDK_NOT_READY]: "SDK 未就绪",
|
|
1821
1854
|
[c.SDK_INIT_FAILED]: "SDK 初始化失败",
|
|
@@ -1856,7 +1889,7 @@ const W = new ur(), c = {
|
|
|
1856
1889
|
[c.API_TIMEOUT]: "API 调用超时",
|
|
1857
1890
|
// 通用
|
|
1858
1891
|
[c.UNKNOWN_ERROR]: "未知错误"
|
|
1859
|
-
},
|
|
1892
|
+
}, W = {
|
|
1860
1893
|
USER_CANCEL: "user_cancel",
|
|
1861
1894
|
// 用户主动取消
|
|
1862
1895
|
PERMISSION: "permission",
|
|
@@ -1871,7 +1904,7 @@ const W = new ur(), c = {
|
|
|
1871
1904
|
// 配置问题
|
|
1872
1905
|
UNKNOWN: "unknown"
|
|
1873
1906
|
// 未知问题
|
|
1874
|
-
},
|
|
1907
|
+
}, _r = {
|
|
1875
1908
|
// 图片相关
|
|
1876
1909
|
"IMAGE/USER_CANCEL": c.IMAGE_CANCELLED,
|
|
1877
1910
|
"IMAGE/PERMISSION_DENIED": c.IMAGE_NO_PERMISSION,
|
|
@@ -1879,7 +1912,7 @@ const W = new ur(), c = {
|
|
|
1879
1912
|
"COMMON/UNKNOWN": c.UNKNOWN_ERROR,
|
|
1880
1913
|
"COMMON/CONFIG_NOT_READY": c.IMAGE_CONFIG_NOT_READY,
|
|
1881
1914
|
"COMMON/PLATFORM_NOT_SUPPORTED": c.PLATFORM_NOT_SUPPORTED
|
|
1882
|
-
},
|
|
1915
|
+
}, et = {
|
|
1883
1916
|
// 微信平台错误模式
|
|
1884
1917
|
weixin: {
|
|
1885
1918
|
patterns: [
|
|
@@ -1901,8 +1934,19 @@ const W = new ur(), c = {
|
|
|
1901
1934
|
{ pattern: /not_in_container/i, code: c.PLATFORM_NOT_SUPPORTED }
|
|
1902
1935
|
],
|
|
1903
1936
|
default: c.UNKNOWN_ERROR
|
|
1937
|
+
},
|
|
1938
|
+
// 离线包环境错误模式(与 uniapp 一致,走消息桥)
|
|
1939
|
+
offline: {
|
|
1940
|
+
patterns: [
|
|
1941
|
+
{ pattern: /cancel/i, code: c.IMAGE_CANCELLED },
|
|
1942
|
+
{ pattern: /permission|denied/i, code: c.IMAGE_NO_PERMISSION },
|
|
1943
|
+
{ pattern: /timeout/i, code: c.API_TIMEOUT },
|
|
1944
|
+
{ pattern: /network/i, code: c.NETWORK_ERROR },
|
|
1945
|
+
{ pattern: /not_in_container/i, code: c.PLATFORM_NOT_SUPPORTED }
|
|
1946
|
+
],
|
|
1947
|
+
default: c.UNKNOWN_ERROR
|
|
1904
1948
|
}
|
|
1905
|
-
},
|
|
1949
|
+
}, tt = {
|
|
1906
1950
|
chooseImage: {
|
|
1907
1951
|
"fail cancel": c.IMAGE_CANCELLED,
|
|
1908
1952
|
"fail auth deny": c.IMAGE_NO_PERMISSION,
|
|
@@ -1916,17 +1960,17 @@ const W = new ur(), c = {
|
|
|
1916
1960
|
NOT_IN_CONTAINER: c.PLATFORM_NOT_SUPPORTED
|
|
1917
1961
|
}
|
|
1918
1962
|
};
|
|
1919
|
-
function
|
|
1920
|
-
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;
|
|
1921
1965
|
}
|
|
1922
|
-
function
|
|
1966
|
+
function Cr(t) {
|
|
1923
1967
|
return t.includes("NET_") || t.includes("TIMEOUT") || t === c.NETWORK_ERROR || t === c.NETWORK_TIMEOUT || t === c.API_TIMEOUT;
|
|
1924
1968
|
}
|
|
1925
|
-
function
|
|
1926
|
-
return t.includes("CANCEL") ||
|
|
1969
|
+
function Pr(t) {
|
|
1970
|
+
return t.includes("CANCEL") || lt(t) === W.USER_CANCEL;
|
|
1927
1971
|
}
|
|
1928
|
-
function
|
|
1929
|
-
return
|
|
1972
|
+
function ne(t) {
|
|
1973
|
+
return ve[t] || ve[c.UNKNOWN_ERROR];
|
|
1930
1974
|
}
|
|
1931
1975
|
class F extends Error {
|
|
1932
1976
|
/**
|
|
@@ -1936,7 +1980,7 @@ class F extends Error {
|
|
|
1936
1980
|
* @param {Object} options - 选项
|
|
1937
1981
|
*/
|
|
1938
1982
|
constructor(e, r, n = {}) {
|
|
1939
|
-
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();
|
|
1940
1984
|
}
|
|
1941
1985
|
/**
|
|
1942
1986
|
* 是否可重试
|
|
@@ -1950,7 +1994,7 @@ class F extends Error {
|
|
|
1950
1994
|
* @returns {boolean}
|
|
1951
1995
|
*/
|
|
1952
1996
|
isUserAction() {
|
|
1953
|
-
return
|
|
1997
|
+
return Pr(this.code);
|
|
1954
1998
|
}
|
|
1955
1999
|
/**
|
|
1956
2000
|
* 转为普通对象
|
|
@@ -1971,11 +2015,11 @@ class F extends Error {
|
|
|
1971
2015
|
} : {});
|
|
1972
2016
|
}
|
|
1973
2017
|
}
|
|
1974
|
-
function
|
|
2018
|
+
function ft(t, e = {}) {
|
|
1975
2019
|
if (t instanceof F)
|
|
1976
2020
|
return t;
|
|
1977
|
-
const { apiName: r, platform: n =
|
|
1978
|
-
return t && typeof t.code == "string" && t.code.includes("/") ?
|
|
2021
|
+
const { apiName: r, platform: n = l.type } = e;
|
|
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(
|
|
1979
2023
|
c.UNKNOWN_ERROR,
|
|
1980
2024
|
t,
|
|
1981
2025
|
{ apiName: r, platform: n, originalError: t }
|
|
@@ -1990,14 +2034,14 @@ function Ze(t, e = {}) {
|
|
|
1990
2034
|
}
|
|
1991
2035
|
);
|
|
1992
2036
|
}
|
|
1993
|
-
function
|
|
1994
|
-
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;
|
|
1995
2039
|
return s.debug("转换旧版错误码", {
|
|
1996
2040
|
legacy: i,
|
|
1997
2041
|
new: a
|
|
1998
2042
|
}), new F(
|
|
1999
2043
|
a,
|
|
2000
|
-
t.message ||
|
|
2044
|
+
t.message || ne(a),
|
|
2001
2045
|
{
|
|
2002
2046
|
apiName: r,
|
|
2003
2047
|
platform: t.platform || n,
|
|
@@ -2009,22 +2053,22 @@ function gr(t, e) {
|
|
|
2009
2053
|
}
|
|
2010
2054
|
);
|
|
2011
2055
|
}
|
|
2012
|
-
function
|
|
2056
|
+
function Nr(t, e) {
|
|
2013
2057
|
const { apiName: r, platform: n } = e, i = (t.errMsg || t.message || "").toLowerCase();
|
|
2014
|
-
if (r &&
|
|
2015
|
-
const
|
|
2016
|
-
for (const [
|
|
2017
|
-
if (i.includes(
|
|
2018
|
-
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), {
|
|
2019
2063
|
apiName: r,
|
|
2020
2064
|
platform: n,
|
|
2021
2065
|
originalError: t
|
|
2022
2066
|
});
|
|
2023
2067
|
}
|
|
2024
|
-
const a =
|
|
2025
|
-
for (const { pattern:
|
|
2026
|
-
if (
|
|
2027
|
-
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), {
|
|
2028
2072
|
apiName: r,
|
|
2029
2073
|
platform: n,
|
|
2030
2074
|
originalError: t
|
|
@@ -2032,7 +2076,7 @@ function hr(t, e) {
|
|
|
2032
2076
|
const o = a.default || c.UNKNOWN_ERROR;
|
|
2033
2077
|
return new F(
|
|
2034
2078
|
o,
|
|
2035
|
-
t.errMsg || t.message ||
|
|
2079
|
+
t.errMsg || t.message || ne(o),
|
|
2036
2080
|
{
|
|
2037
2081
|
apiName: r,
|
|
2038
2082
|
platform: n,
|
|
@@ -2040,7 +2084,7 @@ function hr(t, e) {
|
|
|
2040
2084
|
}
|
|
2041
2085
|
);
|
|
2042
2086
|
}
|
|
2043
|
-
const
|
|
2087
|
+
const dt = {
|
|
2044
2088
|
/**
|
|
2045
2089
|
* 响应拦截器
|
|
2046
2090
|
* @param {Object} result - API 响应结果
|
|
@@ -2049,9 +2093,9 @@ const Qe = {
|
|
|
2049
2093
|
*/
|
|
2050
2094
|
response: (t, e) => {
|
|
2051
2095
|
if (!t.success && t.error) {
|
|
2052
|
-
const r =
|
|
2096
|
+
const r = ft(t.error, {
|
|
2053
2097
|
apiName: e.apiName,
|
|
2054
|
-
platform:
|
|
2098
|
+
platform: l.type
|
|
2055
2099
|
});
|
|
2056
2100
|
t.error = r.toJSON(), t.errorCode = r.code, t.errorCategory = r.category, t.retriable = r.isRetriable(), s.debug("错误已标准化", {
|
|
2057
2101
|
api: e.apiName,
|
|
@@ -2062,25 +2106,25 @@ const Qe = {
|
|
|
2062
2106
|
return t;
|
|
2063
2107
|
}
|
|
2064
2108
|
};
|
|
2065
|
-
function
|
|
2066
|
-
return new F(t,
|
|
2109
|
+
function Rr(t, e = {}) {
|
|
2110
|
+
return new F(t, ne(t), e);
|
|
2067
2111
|
}
|
|
2068
|
-
function
|
|
2112
|
+
function br(t) {
|
|
2069
2113
|
return t instanceof F;
|
|
2070
2114
|
}
|
|
2071
|
-
function
|
|
2115
|
+
function Tr(t, e, r) {
|
|
2072
2116
|
return e ? Promise.race([
|
|
2073
2117
|
t(),
|
|
2074
2118
|
new Promise((n, i) => setTimeout(() => i(new Error(`Init task timeout: ${r}`)), e))
|
|
2075
2119
|
]) : t();
|
|
2076
2120
|
}
|
|
2077
|
-
function
|
|
2078
|
-
return
|
|
2121
|
+
function Mr() {
|
|
2122
|
+
return h(this, arguments, function* (t = [], e = {}) {
|
|
2079
2123
|
for (const r of t) {
|
|
2080
2124
|
const n = (r == null ? void 0 : r.name) || "anonymous-task", i = (r == null ? void 0 : r.run) || r;
|
|
2081
2125
|
if (typeof i == "function")
|
|
2082
2126
|
try {
|
|
2083
|
-
yield
|
|
2127
|
+
yield Tr(() => Promise.resolve().then(() => i()), r.timeoutMs, n), typeof r.onSuccess == "function" && r.onSuccess();
|
|
2084
2128
|
} catch (a) {
|
|
2085
2129
|
if (typeof r.onError == "function" && r.onError(a), typeof e.onError == "function")
|
|
2086
2130
|
e.onError(a, r);
|
|
@@ -2090,7 +2134,7 @@ function Er() {
|
|
|
2090
2134
|
}
|
|
2091
2135
|
});
|
|
2092
2136
|
}
|
|
2093
|
-
class
|
|
2137
|
+
class gt {
|
|
2094
2138
|
/**
|
|
2095
2139
|
* 构造函数
|
|
2096
2140
|
* @param {string} name - 平台名称
|
|
@@ -2105,7 +2149,7 @@ class et {
|
|
|
2105
2149
|
*/
|
|
2106
2150
|
processNavigationOptions(e = {}) {
|
|
2107
2151
|
const { url: r, delta: n = 1 } = e, i = r && encodeURI(r), a = parseInt(n) || 1;
|
|
2108
|
-
return
|
|
2152
|
+
return m(g({}, e), {
|
|
2109
2153
|
url: i,
|
|
2110
2154
|
delta: a
|
|
2111
2155
|
});
|
|
@@ -2216,18 +2260,18 @@ class et {
|
|
|
2216
2260
|
throw new Error(`${this.name} platform must implement performGetEnv method`);
|
|
2217
2261
|
}
|
|
2218
2262
|
}
|
|
2219
|
-
let
|
|
2220
|
-
function
|
|
2221
|
-
if (
|
|
2263
|
+
let de = [];
|
|
2264
|
+
function Lr() {
|
|
2265
|
+
if (de.length === 0 && window.plus) {
|
|
2222
2266
|
const t = plus.webview.currentWebview();
|
|
2223
2267
|
if (!t)
|
|
2224
2268
|
throw new Error("plus.webview.currentWebview() is undefined");
|
|
2225
2269
|
const e = t.parent(), r = e ? e.id : t.id;
|
|
2226
|
-
|
|
2270
|
+
de.push(r);
|
|
2227
2271
|
}
|
|
2228
|
-
return
|
|
2272
|
+
return de;
|
|
2229
2273
|
}
|
|
2230
|
-
function
|
|
2274
|
+
function xr(t, e) {
|
|
2231
2275
|
const r = {
|
|
2232
2276
|
options: {
|
|
2233
2277
|
timestamp: +/* @__PURE__ */ new Date()
|
|
@@ -2243,12 +2287,12 @@ function Ir(t, e) {
|
|
|
2243
2287
|
type: "WEB_INVOKE_APPSERVICE",
|
|
2244
2288
|
args: {
|
|
2245
2289
|
data: r,
|
|
2246
|
-
webviewIds:
|
|
2290
|
+
webviewIds: de
|
|
2247
2291
|
}
|
|
2248
2292
|
};
|
|
2249
2293
|
window.__uniapp_x_postMessage ? window.__uniapp_x_postMessageToService(n) : window.__uniapp_x_.postMessageToService(JSON.stringify(n));
|
|
2250
2294
|
}
|
|
2251
|
-
function
|
|
2295
|
+
function vr(t, e) {
|
|
2252
2296
|
const r = {
|
|
2253
2297
|
options: {
|
|
2254
2298
|
timestamp: +/* @__PURE__ */ new Date()
|
|
@@ -2264,19 +2308,19 @@ function Ar(t, e) {
|
|
|
2264
2308
|
type: "WEB_INVOKE_APPSERVICE",
|
|
2265
2309
|
args: {
|
|
2266
2310
|
data: r,
|
|
2267
|
-
webviewIds:
|
|
2311
|
+
webviewIds: de
|
|
2268
2312
|
}
|
|
2269
2313
|
};
|
|
2270
2314
|
window.__dcloud_weex_postMessage ? window.__dcloud_weex_postMessageToService(n) : window.__dcloud_weex_.postMessageToService(JSON.stringify(n));
|
|
2271
2315
|
}
|
|
2272
|
-
function
|
|
2316
|
+
function Dr(t, e) {
|
|
2273
2317
|
const r = {
|
|
2274
2318
|
options: {
|
|
2275
2319
|
timestamp: +/* @__PURE__ */ new Date()
|
|
2276
2320
|
},
|
|
2277
2321
|
name: t,
|
|
2278
2322
|
arg: e
|
|
2279
|
-
}, n =
|
|
2323
|
+
}, n = Lr();
|
|
2280
2324
|
if (plus.webview.getWebviewById("__uniapp__service"))
|
|
2281
2325
|
plus.webview.postMessageToUniNView({
|
|
2282
2326
|
type: "WEB_INVOKE_APPSERVICE",
|
|
@@ -2292,7 +2336,7 @@ function Or(t, e) {
|
|
|
2292
2336
|
);
|
|
2293
2337
|
}
|
|
2294
2338
|
}
|
|
2295
|
-
function
|
|
2339
|
+
function Ur(t, e) {
|
|
2296
2340
|
const r = {
|
|
2297
2341
|
options: {
|
|
2298
2342
|
timestamp: +/* @__PURE__ */ new Date()
|
|
@@ -2306,10 +2350,29 @@ function Cr(t, e) {
|
|
|
2306
2350
|
pageId: ""
|
|
2307
2351
|
}, "*");
|
|
2308
2352
|
}
|
|
2309
|
-
function
|
|
2310
|
-
|
|
2353
|
+
function Wr(t) {
|
|
2354
|
+
return !!(t && typeof t == "object" && t.type === "qsh_api_call" && typeof t.api == "string" && typeof t.callbackId == "string");
|
|
2355
|
+
}
|
|
2356
|
+
function Br(t, e) {
|
|
2357
|
+
const r = {
|
|
2358
|
+
options: {
|
|
2359
|
+
timestamp: +/* @__PURE__ */ new Date()
|
|
2360
|
+
},
|
|
2361
|
+
name: t,
|
|
2362
|
+
arg: e
|
|
2363
|
+
};
|
|
2364
|
+
if (t === "postMessage" && Wr(e))
|
|
2365
|
+
return window.__offline_bridge_postMessage(e);
|
|
2366
|
+
window.__offline_bridge_postMessage({
|
|
2367
|
+
type: "WEB_INVOKE_APPSERVICE",
|
|
2368
|
+
data: r,
|
|
2369
|
+
pageId: ""
|
|
2370
|
+
});
|
|
2371
|
+
}
|
|
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);
|
|
2311
2374
|
}
|
|
2312
|
-
class
|
|
2375
|
+
class pt extends gt {
|
|
2313
2376
|
constructor() {
|
|
2314
2377
|
super("weixin");
|
|
2315
2378
|
}
|
|
@@ -2328,17 +2391,17 @@ class tt extends et {
|
|
|
2328
2391
|
* @returns {void}
|
|
2329
2392
|
*/
|
|
2330
2393
|
performNavigation(e, r) {
|
|
2331
|
-
return
|
|
2394
|
+
return f.safeExecute(() => {
|
|
2332
2395
|
const { url: n, delta: i } = r;
|
|
2333
|
-
if (
|
|
2396
|
+
if (w.debug(`微信平台执行导航操作: ${e}`, r), this.isWeixinApiAvailable()) {
|
|
2334
2397
|
const o = window.wx.miniProgram[e];
|
|
2335
2398
|
if (typeof o == "function") {
|
|
2336
|
-
|
|
2337
|
-
const
|
|
2338
|
-
return o.call(window.wx.miniProgram,
|
|
2399
|
+
w.debug(`使用微信原生 API: wx.miniProgram.${e}`);
|
|
2400
|
+
const u = e === "navigateBack" ? { delta: i } : { url: n };
|
|
2401
|
+
return o.call(window.wx.miniProgram, u);
|
|
2339
2402
|
}
|
|
2340
2403
|
}
|
|
2341
|
-
|
|
2404
|
+
w.debug(`使用消息桥接执行: ${e}`), pe(e, e === "navigateBack" ? { delta: i } : { url: n });
|
|
2342
2405
|
}, {
|
|
2343
2406
|
platform: this.name,
|
|
2344
2407
|
method: "performNavigation",
|
|
@@ -2352,11 +2415,11 @@ class tt extends et {
|
|
|
2352
2415
|
* @returns {void}
|
|
2353
2416
|
*/
|
|
2354
2417
|
performPostMessage(e) {
|
|
2355
|
-
return
|
|
2418
|
+
return f.safeExecute(() => {
|
|
2356
2419
|
const { data: r } = e;
|
|
2357
2420
|
if (this.isWeixinApiAvailable())
|
|
2358
2421
|
return window.wx.miniProgram.postMessage({ data: r });
|
|
2359
|
-
|
|
2422
|
+
pe("postMessage", r);
|
|
2360
2423
|
}, {
|
|
2361
2424
|
platform: this.name,
|
|
2362
2425
|
method: "performPostMessage",
|
|
@@ -2369,7 +2432,7 @@ class tt extends et {
|
|
|
2369
2432
|
* @returns {void}
|
|
2370
2433
|
*/
|
|
2371
2434
|
performGetEnv(e) {
|
|
2372
|
-
return
|
|
2435
|
+
return f.safeExecute(() => {
|
|
2373
2436
|
if (!e || typeof e != "function")
|
|
2374
2437
|
throw new Error("Callback function is required for getEnv");
|
|
2375
2438
|
if (this.isWeixinApiAvailable() && window.wx.miniProgram.getEnv)
|
|
@@ -2384,19 +2447,19 @@ class tt extends et {
|
|
|
2384
2447
|
});
|
|
2385
2448
|
}
|
|
2386
2449
|
}
|
|
2387
|
-
const
|
|
2388
|
-
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({
|
|
2389
2452
|
__proto__: null,
|
|
2390
|
-
WeixinPlatform:
|
|
2391
|
-
getEnv:
|
|
2392
|
-
navigateBack:
|
|
2393
|
-
navigateTo:
|
|
2394
|
-
postMessage:
|
|
2395
|
-
reLaunch:
|
|
2396
|
-
redirectTo:
|
|
2397
|
-
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
|
|
2398
2461
|
});
|
|
2399
|
-
class
|
|
2462
|
+
class ht extends gt {
|
|
2400
2463
|
constructor() {
|
|
2401
2464
|
super("app");
|
|
2402
2465
|
}
|
|
@@ -2407,9 +2470,9 @@ class nt extends et {
|
|
|
2407
2470
|
* @returns {void}
|
|
2408
2471
|
*/
|
|
2409
2472
|
performNavigation(e, r) {
|
|
2410
|
-
return
|
|
2473
|
+
return f.safeExecute(() => {
|
|
2411
2474
|
const { url: n, delta: i } = r;
|
|
2412
|
-
|
|
2475
|
+
pe(e, e === "navigateBack" ? { delta: i } : { url: n });
|
|
2413
2476
|
}, {
|
|
2414
2477
|
platform: this.name,
|
|
2415
2478
|
method: "performNavigation",
|
|
@@ -2423,9 +2486,9 @@ class nt extends et {
|
|
|
2423
2486
|
* @returns {void}
|
|
2424
2487
|
*/
|
|
2425
2488
|
performPostMessage(e) {
|
|
2426
|
-
return
|
|
2489
|
+
return f.safeExecute(() => {
|
|
2427
2490
|
const { data: r } = e;
|
|
2428
|
-
|
|
2491
|
+
pe("postMessage", r);
|
|
2429
2492
|
}, {
|
|
2430
2493
|
platform: this.name,
|
|
2431
2494
|
method: "performPostMessage",
|
|
@@ -2438,66 +2501,66 @@ class nt extends et {
|
|
|
2438
2501
|
* @returns {void}
|
|
2439
2502
|
*/
|
|
2440
2503
|
performGetEnv(e) {
|
|
2441
|
-
return
|
|
2504
|
+
return f.safeExecute(() => {
|
|
2442
2505
|
if (!e || typeof e != "function")
|
|
2443
2506
|
throw new Error("Callback function is required for getEnv");
|
|
2444
2507
|
const r = {};
|
|
2445
2508
|
let n = !1;
|
|
2446
|
-
|
|
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);
|
|
2447
2510
|
}, {
|
|
2448
2511
|
platform: this.name,
|
|
2449
2512
|
method: "performGetEnv"
|
|
2450
2513
|
});
|
|
2451
2514
|
}
|
|
2452
2515
|
}
|
|
2453
|
-
const
|
|
2454
|
-
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({
|
|
2455
2518
|
__proto__: null,
|
|
2456
|
-
AppPlatform:
|
|
2457
|
-
getEnv:
|
|
2458
|
-
navigateBack:
|
|
2459
|
-
navigateTo:
|
|
2460
|
-
postMessage:
|
|
2461
|
-
reLaunch:
|
|
2462
|
-
redirectTo:
|
|
2463
|
-
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
|
|
2464
2527
|
});
|
|
2465
|
-
function
|
|
2466
|
-
return
|
|
2528
|
+
function he() {
|
|
2529
|
+
return A() ? mt : wt;
|
|
2467
2530
|
}
|
|
2468
|
-
function
|
|
2469
|
-
return
|
|
2531
|
+
function Qr(t) {
|
|
2532
|
+
return he().navigateTo(t);
|
|
2470
2533
|
}
|
|
2471
|
-
function
|
|
2472
|
-
return
|
|
2534
|
+
function en(t) {
|
|
2535
|
+
return he().navigateBack(t);
|
|
2473
2536
|
}
|
|
2474
|
-
function
|
|
2475
|
-
return
|
|
2537
|
+
function tn(t) {
|
|
2538
|
+
return he().switchTab(t);
|
|
2476
2539
|
}
|
|
2477
|
-
function
|
|
2478
|
-
return
|
|
2540
|
+
function rn(t) {
|
|
2541
|
+
return he().reLaunch(t);
|
|
2479
2542
|
}
|
|
2480
|
-
function
|
|
2481
|
-
return
|
|
2543
|
+
function nn(t) {
|
|
2544
|
+
return he().redirectTo(t);
|
|
2482
2545
|
}
|
|
2483
|
-
function
|
|
2484
|
-
return
|
|
2546
|
+
function Et() {
|
|
2547
|
+
return A() ? mt : wt;
|
|
2485
2548
|
}
|
|
2486
|
-
function
|
|
2487
|
-
return
|
|
2549
|
+
function sn(t = {}) {
|
|
2550
|
+
return Et().postMessage(t);
|
|
2488
2551
|
}
|
|
2489
|
-
function
|
|
2490
|
-
return
|
|
2552
|
+
function an(t) {
|
|
2553
|
+
return Et().getEnv(t);
|
|
2491
2554
|
}
|
|
2492
|
-
function
|
|
2555
|
+
function on(t) {
|
|
2493
2556
|
return t && typeof t == "object" && t.__v_raw ? t.__v_raw : t;
|
|
2494
2557
|
}
|
|
2495
|
-
function
|
|
2558
|
+
function cn() {
|
|
2496
2559
|
return "qsh_callback_" + Date.now() + "_" + Math.random().toString(36).substring(2, 9);
|
|
2497
2560
|
}
|
|
2498
|
-
class
|
|
2561
|
+
class un {
|
|
2499
2562
|
constructor() {
|
|
2500
|
-
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 = {})),
|
|
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 桥接器已初始化");
|
|
2501
2564
|
}
|
|
2502
2565
|
/**
|
|
2503
2566
|
* 向主应用发送 API 调用消息
|
|
@@ -2507,15 +2570,15 @@ class qr {
|
|
|
2507
2570
|
* @returns {void}
|
|
2508
2571
|
*/
|
|
2509
2572
|
callApi(i) {
|
|
2510
|
-
return
|
|
2511
|
-
return
|
|
2573
|
+
return h(this, arguments, function* (e, r = {}, n = {}) {
|
|
2574
|
+
return f.safeExecute(() => h(this, null, function* () {
|
|
2512
2575
|
var O;
|
|
2513
|
-
if (typeof window != "undefined" && window === window.parent && !window.plus && !window.__uniapp_x_postMessage && !window.__uniapp_x_ && !window.__dcloud_weex_postMessage && !window.__dcloud_weex_) {
|
|
2514
|
-
const
|
|
2515
|
-
|
|
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,
|
|
2516
2579
|
"当前不在宿主 WebView 容器中,无法发送消息"
|
|
2517
2580
|
);
|
|
2518
|
-
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 } });
|
|
2519
2582
|
return;
|
|
2520
2583
|
}
|
|
2521
2584
|
const o = {
|
|
@@ -2526,50 +2589,50 @@ class qr {
|
|
|
2526
2589
|
abort: !1,
|
|
2527
2590
|
metadata: {}
|
|
2528
2591
|
};
|
|
2529
|
-
|
|
2530
|
-
const
|
|
2531
|
-
if (
|
|
2532
|
-
|
|
2533
|
-
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 调用被中止",
|
|
2534
2597
|
code: "INTERCEPTED"
|
|
2535
2598
|
}), n.complete && n.complete({ success: !1 });
|
|
2536
2599
|
return;
|
|
2537
2600
|
}
|
|
2538
|
-
const
|
|
2601
|
+
const d = cn();
|
|
2539
2602
|
if (n.success || n.fail || n.complete) {
|
|
2540
|
-
if (this.callbacks.set(
|
|
2541
|
-
context:
|
|
2603
|
+
if (this.callbacks.set(d, m(g({}, n), {
|
|
2604
|
+
context: u
|
|
2542
2605
|
// 保存上下文用于响应拦截
|
|
2543
|
-
})), window.qshWebviewCallbacks[
|
|
2544
|
-
this.handleCallback(
|
|
2545
|
-
}, r.isPersistent && (this.persistentCallbacksByApi.has(e) || this.persistentCallbacksByApi.set(e, /* @__PURE__ */ new Set()), this.persistentCallbacksByApi.get(e).add(
|
|
2546
|
-
|
|
2547
|
-
callbackId:
|
|
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
|
+
E.info(`API ${e} 禁用超时清理,将等待回调返回后清理`, {
|
|
2610
|
+
callbackId: d,
|
|
2548
2611
|
isPersistent: r.isPersistent,
|
|
2549
2612
|
disableTimeout: r.disableTimeout
|
|
2550
2613
|
});
|
|
2551
2614
|
else {
|
|
2552
|
-
const
|
|
2553
|
-
|
|
2615
|
+
const v = setTimeout(() => {
|
|
2616
|
+
E.warn("API 调用超时,自动清理回调", { api: e, callbackId: d }), n.fail && n.fail({
|
|
2554
2617
|
errMsg: `API ${e} 调用超时`,
|
|
2555
2618
|
code: "TIMEOUT"
|
|
2556
|
-
}), this.cleanupCallback(
|
|
2619
|
+
}), this.cleanupCallback(d);
|
|
2557
2620
|
}, r.timeout || this.defaultTimeout);
|
|
2558
|
-
this.timeouts.set(
|
|
2621
|
+
this.timeouts.set(d, v);
|
|
2559
2622
|
}
|
|
2560
|
-
const
|
|
2623
|
+
const _ = {
|
|
2561
2624
|
type: "qsh_api_call",
|
|
2562
2625
|
api: e,
|
|
2563
|
-
params:
|
|
2564
|
-
callbackId:
|
|
2626
|
+
params: u.params,
|
|
2627
|
+
callbackId: d,
|
|
2565
2628
|
timestamp: Date.now()
|
|
2566
2629
|
};
|
|
2567
|
-
|
|
2630
|
+
E.info("发送 API 调用消息", {
|
|
2568
2631
|
api: e,
|
|
2569
|
-
callbackId:
|
|
2632
|
+
callbackId: d,
|
|
2570
2633
|
hasSuccess: !!n.success,
|
|
2571
2634
|
hasFail: !!n.fail
|
|
2572
|
-
}), console.log("message:", JSON.stringify(
|
|
2635
|
+
}), console.log("message:", JSON.stringify(on(_), null, 2)), pe("postMessage", _);
|
|
2573
2636
|
}
|
|
2574
2637
|
}), {
|
|
2575
2638
|
context: "WebViewBridge.callApi",
|
|
@@ -2584,18 +2647,18 @@ class qr {
|
|
|
2584
2647
|
* @private
|
|
2585
2648
|
*/
|
|
2586
2649
|
handleCallback(e, r) {
|
|
2587
|
-
return
|
|
2588
|
-
return
|
|
2589
|
-
var
|
|
2650
|
+
return h(this, null, function* () {
|
|
2651
|
+
return f.safeExecute(() => h(this, null, function* () {
|
|
2652
|
+
var R, _;
|
|
2590
2653
|
const n = this.callbacks.get(e);
|
|
2591
2654
|
if (!n) {
|
|
2592
|
-
|
|
2655
|
+
E.warn("未找到回调函数", { callbackId: e });
|
|
2593
2656
|
return;
|
|
2594
2657
|
}
|
|
2595
|
-
const { success: i, fail: a, complete: o, context:
|
|
2596
|
-
|
|
2597
|
-
const
|
|
2598
|
-
|
|
2658
|
+
const { success: i, fail: a, complete: o, context: u } = n;
|
|
2659
|
+
E.debug("处理回调", { callbackId: e, result: r });
|
|
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 }));
|
|
2599
2662
|
}), {
|
|
2600
2663
|
context: "WebViewBridge.handleCallback",
|
|
2601
2664
|
callbackId: e
|
|
@@ -2620,7 +2683,7 @@ class qr {
|
|
|
2620
2683
|
* 清理所有待处理的回调
|
|
2621
2684
|
*/
|
|
2622
2685
|
clearCallbacks() {
|
|
2623
|
-
|
|
2686
|
+
E.debug("清理所有回调", { count: this.callbacks.size }), this.timeouts.forEach((e) => clearTimeout(e)), this.timeouts.clear(), this.callbacks.clear(), this.persistentCallbacksByApi && this.persistentCallbacksByApi.clear(), typeof window != "undefined" && window.qshWebviewCallbacks && Object.keys(window.qshWebviewCallbacks).forEach((e) => {
|
|
2624
2687
|
e.startsWith("qsh_callback_") && delete window.qshWebviewCallbacks[e];
|
|
2625
2688
|
});
|
|
2626
2689
|
}
|
|
@@ -2634,7 +2697,7 @@ class qr {
|
|
|
2634
2697
|
if (!r || r.size === 0)
|
|
2635
2698
|
return 0;
|
|
2636
2699
|
const n = Array.from(r);
|
|
2637
|
-
return n.forEach((i) => this.cleanupCallback(i)), this.persistentCallbacksByApi.delete(e),
|
|
2700
|
+
return n.forEach((i) => this.cleanupCallback(i)), this.persistentCallbacksByApi.delete(e), E.info("已清理持久回调", { api: e, count: n.length }), n.length;
|
|
2638
2701
|
}
|
|
2639
2702
|
/**
|
|
2640
2703
|
* 获取桥接器状态信息
|
|
@@ -2648,30 +2711,93 @@ class qr {
|
|
|
2648
2711
|
};
|
|
2649
2712
|
}
|
|
2650
2713
|
}
|
|
2651
|
-
const
|
|
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
|
+
}
|
|
2718
|
+
function ln(t) {
|
|
2719
|
+
return t === "offline";
|
|
2720
|
+
}
|
|
2721
|
+
function fn(t = {}) {
|
|
2722
|
+
return f.safeExecute(() => {
|
|
2723
|
+
s.debug("Call getCode through offline webview bridge", {
|
|
2724
|
+
clientId: t.clientId
|
|
2725
|
+
}), P(
|
|
2726
|
+
"getCode",
|
|
2727
|
+
{
|
|
2728
|
+
clientId: t.clientId
|
|
2729
|
+
},
|
|
2730
|
+
{
|
|
2731
|
+
success: (e) => {
|
|
2732
|
+
var r;
|
|
2733
|
+
s.info("Get code success"), (r = t.success) == null || r.call(t, e);
|
|
2734
|
+
},
|
|
2735
|
+
fail: (e) => {
|
|
2736
|
+
var r;
|
|
2737
|
+
s.error("Get code failed", e), (r = t.fail) == null || r.call(t, e);
|
|
2738
|
+
},
|
|
2739
|
+
complete: t.complete
|
|
2740
|
+
}
|
|
2741
|
+
);
|
|
2742
|
+
}, {
|
|
2743
|
+
context: "getCodeInHost",
|
|
2744
|
+
platform: It().type
|
|
2745
|
+
});
|
|
2746
|
+
}
|
|
2747
|
+
function dn(t = {}) {
|
|
2748
|
+
return f.safeExecute(() => {
|
|
2749
|
+
var n, i;
|
|
2750
|
+
const e = It(), r = String((t == null ? void 0 : t.clientId) || "").trim();
|
|
2751
|
+
if (!r) {
|
|
2752
|
+
const a = {
|
|
2753
|
+
errMsg: "clientId is required",
|
|
2754
|
+
code: "APP_KEY_MISSING"
|
|
2755
|
+
};
|
|
2756
|
+
s.error("Get code missing clientId"), (n = t.fail) == null || n.call(t, a);
|
|
2757
|
+
return;
|
|
2758
|
+
}
|
|
2759
|
+
if (!ln(e.type)) {
|
|
2760
|
+
const a = {
|
|
2761
|
+
errMsg: `Current environment (${e.type}) does not support getCode`,
|
|
2762
|
+
code: "PLATFORM_NOT_SUPPORTED"
|
|
2763
|
+
};
|
|
2764
|
+
s.error("Platform does not support getCode", {
|
|
2765
|
+
platform: e.type
|
|
2766
|
+
}), (i = t.fail) == null || i.call(t, a);
|
|
2767
|
+
return;
|
|
2768
|
+
}
|
|
2769
|
+
fn(m(g({}, t), {
|
|
2770
|
+
clientId: r
|
|
2771
|
+
}));
|
|
2772
|
+
}, {
|
|
2773
|
+
context: "getCode",
|
|
2774
|
+
options: t
|
|
2775
|
+
});
|
|
2776
|
+
}
|
|
2777
|
+
const Ce = {
|
|
2652
2778
|
ALBUM: "album",
|
|
2653
2779
|
// 相册
|
|
2654
2780
|
CAMERA: "camera"
|
|
2655
2781
|
// 相机
|
|
2656
|
-
},
|
|
2782
|
+
}, Pe = {
|
|
2657
2783
|
ORIGINAL: "original",
|
|
2658
2784
|
// 原图
|
|
2659
2785
|
COMPRESSED: "compressed"
|
|
2660
2786
|
// 压缩图
|
|
2661
|
-
},
|
|
2787
|
+
}, gn = {
|
|
2662
2788
|
count: 9,
|
|
2663
|
-
sizeType: [
|
|
2664
|
-
sourceType: [
|
|
2789
|
+
sizeType: [Pe.ORIGINAL, Pe.COMPRESSED],
|
|
2790
|
+
sourceType: [Ce.ALBUM, Ce.CAMERA]
|
|
2665
2791
|
};
|
|
2666
|
-
function
|
|
2667
|
-
const e = g(g({},
|
|
2668
|
-
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;
|
|
2669
2795
|
}
|
|
2670
|
-
function
|
|
2671
|
-
return ["weixin", "webview", "UniApp", "plus", "nvue", "uvue"].includes(
|
|
2796
|
+
function At() {
|
|
2797
|
+
return ["weixin", "webview", "UniApp", "plus", "nvue", "uvue", "offline"].includes(l.type);
|
|
2672
2798
|
}
|
|
2673
|
-
function
|
|
2674
|
-
return
|
|
2799
|
+
function Ot(t) {
|
|
2800
|
+
return f.safeExecute(() => {
|
|
2675
2801
|
var e;
|
|
2676
2802
|
if (!window.wx) {
|
|
2677
2803
|
const r = {
|
|
@@ -2681,8 +2807,8 @@ function ct(t) {
|
|
|
2681
2807
|
(e = t.fail) == null || e.call(t, r);
|
|
2682
2808
|
return;
|
|
2683
2809
|
}
|
|
2684
|
-
if (!
|
|
2685
|
-
s.info("等待微信配置完成"),
|
|
2810
|
+
if (!j()) {
|
|
2811
|
+
s.info("等待微信配置完成"), K().then(() => Ot(t)).catch((r) => {
|
|
2686
2812
|
var n;
|
|
2687
2813
|
s.error("微信配置失败", r), (n = t.fail) == null || n.call(t, { errMsg: `微信配置失败: ${r.message}` });
|
|
2688
2814
|
});
|
|
@@ -2707,9 +2833,9 @@ function ct(t) {
|
|
|
2707
2833
|
platform: "weixin"
|
|
2708
2834
|
});
|
|
2709
2835
|
}
|
|
2710
|
-
function
|
|
2711
|
-
return
|
|
2712
|
-
s.debug("通过 WebView 桥接调用图片选择", t),
|
|
2836
|
+
function mn(t) {
|
|
2837
|
+
return f.safeExecute(() => {
|
|
2838
|
+
s.debug("通过 WebView 桥接调用图片选择", t), P("chooseImage", m(g({}, t), { disableTimeout: !0 }), {
|
|
2713
2839
|
success: (e) => {
|
|
2714
2840
|
var r, n;
|
|
2715
2841
|
s.info("UniApp 图片选择成功", {
|
|
@@ -2727,34 +2853,34 @@ function Yr(t) {
|
|
|
2727
2853
|
platform: "uniapp"
|
|
2728
2854
|
});
|
|
2729
2855
|
}
|
|
2730
|
-
function
|
|
2731
|
-
return
|
|
2856
|
+
function hn(t = {}) {
|
|
2857
|
+
return f.safeExecute(() => {
|
|
2732
2858
|
var r;
|
|
2733
|
-
if (!
|
|
2859
|
+
if (!At()) {
|
|
2734
2860
|
const n = {
|
|
2735
|
-
errMsg: `当前环境 (${
|
|
2861
|
+
errMsg: `当前环境 (${l.type}) 不支持图片选择功能`,
|
|
2736
2862
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
2737
2863
|
};
|
|
2738
|
-
s.error("平台不支持图片选择", { platform:
|
|
2864
|
+
s.error("平台不支持图片选择", { platform: l.type }), (r = t.fail) == null || r.call(t, n);
|
|
2739
2865
|
return;
|
|
2740
2866
|
}
|
|
2741
|
-
const e =
|
|
2867
|
+
const e = pn(t);
|
|
2742
2868
|
s.info("开始选择图片", {
|
|
2743
|
-
platform:
|
|
2869
|
+
platform: l.type,
|
|
2744
2870
|
count: e.count,
|
|
2745
2871
|
sizeType: e.sizeType,
|
|
2746
2872
|
sourceType: e.sourceType
|
|
2747
|
-
}),
|
|
2873
|
+
}), A() ? Ot(e) : mn(e);
|
|
2748
2874
|
}, {
|
|
2749
2875
|
context: "chooseImage",
|
|
2750
2876
|
options: t
|
|
2751
2877
|
});
|
|
2752
2878
|
}
|
|
2753
|
-
function
|
|
2879
|
+
function wn() {
|
|
2754
2880
|
return {
|
|
2755
|
-
supported:
|
|
2756
|
-
environment:
|
|
2757
|
-
implementation:
|
|
2881
|
+
supported: At(),
|
|
2882
|
+
environment: l.type,
|
|
2883
|
+
implementation: A() ? "weixin" : "webview",
|
|
2758
2884
|
features: {
|
|
2759
2885
|
multipleSelection: !0,
|
|
2760
2886
|
// 支持多选
|
|
@@ -2767,7 +2893,7 @@ function Zr() {
|
|
|
2767
2893
|
}
|
|
2768
2894
|
};
|
|
2769
2895
|
}
|
|
2770
|
-
const
|
|
2896
|
+
const Z = {
|
|
2771
2897
|
QR_CODE: "qrCode",
|
|
2772
2898
|
// 二维码
|
|
2773
2899
|
BAR_CODE: "barCode",
|
|
@@ -2776,21 +2902,21 @@ const q = {
|
|
|
2776
2902
|
// Data Matrix 码
|
|
2777
2903
|
PDF417: "pdf417"
|
|
2778
2904
|
// PDF417 条码
|
|
2779
|
-
},
|
|
2905
|
+
}, En = {
|
|
2780
2906
|
onlyFromCamera: !0,
|
|
2781
2907
|
// 只从相机扫码
|
|
2782
|
-
scanType: [
|
|
2908
|
+
scanType: [Z.QR_CODE, Z.BAR_CODE]
|
|
2783
2909
|
// 支持二维码和一维码
|
|
2784
2910
|
};
|
|
2785
|
-
function
|
|
2786
|
-
const e = g(g({},
|
|
2787
|
-
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;
|
|
2788
2914
|
}
|
|
2789
|
-
function
|
|
2790
|
-
return ["weixin", "webview", "UniApp", "plus", "nvue", "uvue"].includes(
|
|
2915
|
+
function _t() {
|
|
2916
|
+
return ["weixin", "webview", "UniApp", "plus", "nvue", "uvue", "offline"].includes(l.type);
|
|
2791
2917
|
}
|
|
2792
|
-
function
|
|
2793
|
-
return
|
|
2918
|
+
function Ct(t) {
|
|
2919
|
+
return f.safeExecute(() => {
|
|
2794
2920
|
var e;
|
|
2795
2921
|
if (!window.wx) {
|
|
2796
2922
|
const r = {
|
|
@@ -2800,8 +2926,8 @@ function lt(t) {
|
|
|
2800
2926
|
(e = t.fail) == null || e.call(t, r);
|
|
2801
2927
|
return;
|
|
2802
2928
|
}
|
|
2803
|
-
if (!
|
|
2804
|
-
s.info("等待微信配置完成"),
|
|
2929
|
+
if (!j()) {
|
|
2930
|
+
s.info("等待微信配置完成"), K().then(() => Ct(t)).catch((r) => {
|
|
2805
2931
|
var n;
|
|
2806
2932
|
s.error("微信配置失败", r), (n = t.fail) == null || n.call(t, { errMsg: `微信配置失败: ${r.message}` });
|
|
2807
2933
|
});
|
|
@@ -2817,7 +2943,7 @@ function lt(t) {
|
|
|
2817
2943
|
const n = {
|
|
2818
2944
|
result: r.resultStr,
|
|
2819
2945
|
// 扫码内容
|
|
2820
|
-
scanType:
|
|
2946
|
+
scanType: In(r.resultStr),
|
|
2821
2947
|
// 推测扫码类型
|
|
2822
2948
|
charSet: "utf-8",
|
|
2823
2949
|
// 微信默认 UTF-8
|
|
@@ -2836,12 +2962,12 @@ function lt(t) {
|
|
|
2836
2962
|
platform: "weixin"
|
|
2837
2963
|
});
|
|
2838
2964
|
}
|
|
2839
|
-
function
|
|
2840
|
-
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";
|
|
2841
2967
|
}
|
|
2842
|
-
function
|
|
2843
|
-
return
|
|
2844
|
-
s.debug("通过 WebView 桥接调用扫码", t),
|
|
2968
|
+
function An(t) {
|
|
2969
|
+
return f.safeExecute(() => {
|
|
2970
|
+
s.debug("通过 WebView 桥接调用扫码", t), P("scanCode", m(g({}, t), { disableTimeout: !0 }), {
|
|
2845
2971
|
success: (e) => {
|
|
2846
2972
|
var r;
|
|
2847
2973
|
s.info("UniApp 扫码成功", {
|
|
@@ -2860,33 +2986,33 @@ function rn(t) {
|
|
|
2860
2986
|
platform: "uniapp"
|
|
2861
2987
|
});
|
|
2862
2988
|
}
|
|
2863
|
-
function
|
|
2864
|
-
return
|
|
2989
|
+
function On(t = {}) {
|
|
2990
|
+
return f.safeExecute(() => {
|
|
2865
2991
|
var r;
|
|
2866
|
-
if (!
|
|
2992
|
+
if (!_t()) {
|
|
2867
2993
|
const n = {
|
|
2868
|
-
errMsg: `当前环境 (${
|
|
2994
|
+
errMsg: `当前环境 (${l.type}) 不支持扫码功能`,
|
|
2869
2995
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
2870
2996
|
};
|
|
2871
|
-
s.error("平台不支持扫码", { platform:
|
|
2997
|
+
s.error("平台不支持扫码", { platform: l.type }), (r = t.fail) == null || r.call(t, n);
|
|
2872
2998
|
return;
|
|
2873
2999
|
}
|
|
2874
|
-
const e =
|
|
3000
|
+
const e = yn(t);
|
|
2875
3001
|
s.info("开始扫码", {
|
|
2876
|
-
platform:
|
|
3002
|
+
platform: l.type,
|
|
2877
3003
|
onlyFromCamera: e.onlyFromCamera,
|
|
2878
3004
|
scanType: e.scanType
|
|
2879
|
-
}),
|
|
3005
|
+
}), A() ? Ct(e) : An(e);
|
|
2880
3006
|
}, {
|
|
2881
3007
|
context: "scanCode",
|
|
2882
3008
|
options: t
|
|
2883
3009
|
});
|
|
2884
3010
|
}
|
|
2885
|
-
function
|
|
3011
|
+
function _n() {
|
|
2886
3012
|
return {
|
|
2887
|
-
supported:
|
|
2888
|
-
environment:
|
|
2889
|
-
implementation:
|
|
3013
|
+
supported: _t(),
|
|
3014
|
+
environment: l.type,
|
|
3015
|
+
implementation: A() ? "weixin" : "webview",
|
|
2890
3016
|
features: {
|
|
2891
3017
|
onlyFromCamera: !0,
|
|
2892
3018
|
// 支持只从相机扫码
|
|
@@ -2899,30 +3025,30 @@ function sn() {
|
|
|
2899
3025
|
}
|
|
2900
3026
|
};
|
|
2901
3027
|
}
|
|
2902
|
-
const
|
|
3028
|
+
const se = {
|
|
2903
3029
|
WGS84: "wgs84",
|
|
2904
3030
|
// GPS 坐标
|
|
2905
3031
|
GCJ02: "gcj02",
|
|
2906
3032
|
// 国测局坐标(火星坐标)
|
|
2907
3033
|
BD09: "bd09"
|
|
2908
3034
|
// 百度坐标
|
|
2909
|
-
},
|
|
2910
|
-
type:
|
|
3035
|
+
}, Cn = {
|
|
3036
|
+
type: se.WGS84,
|
|
2911
3037
|
altitude: !1
|
|
2912
|
-
},
|
|
3038
|
+
}, Pn = {
|
|
2913
3039
|
scale: 18
|
|
2914
3040
|
// 地图缩放级别 1-28
|
|
2915
3041
|
};
|
|
2916
|
-
function
|
|
2917
|
-
const e = g(g({},
|
|
2918
|
-
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;
|
|
2919
3045
|
}
|
|
2920
|
-
function
|
|
3046
|
+
function Nn(t = {}) {
|
|
2921
3047
|
const e = g({}, t);
|
|
2922
|
-
return Object.values(
|
|
3048
|
+
return Object.values(se).includes(e.type) || (e.type = se.WGS84), e.needFullAccuracy = !!e.needFullAccuracy, e;
|
|
2923
3049
|
}
|
|
2924
|
-
function
|
|
2925
|
-
const e = g(g({},
|
|
3050
|
+
function Rn(t = {}) {
|
|
3051
|
+
const e = g(g({}, Pn), t);
|
|
2926
3052
|
if (e.latitude === void 0 || e.latitude === null)
|
|
2927
3053
|
throw {
|
|
2928
3054
|
errMsg: "缺少必需参数:latitude(纬度)",
|
|
@@ -2981,11 +3107,11 @@ function ln(t = {}) {
|
|
|
2981
3107
|
}
|
|
2982
3108
|
return e;
|
|
2983
3109
|
}
|
|
2984
|
-
function
|
|
2985
|
-
return ["weixin", "webview", "UniApp", "plus", "nvue", "uvue"].includes(
|
|
3110
|
+
function $e() {
|
|
3111
|
+
return ["weixin", "webview", "UniApp", "plus", "nvue", "uvue", "offline"].includes(l.type);
|
|
2986
3112
|
}
|
|
2987
|
-
function
|
|
2988
|
-
return
|
|
3113
|
+
function Pt(t) {
|
|
3114
|
+
return f.safeExecute(() => {
|
|
2989
3115
|
var e;
|
|
2990
3116
|
if (!window.wx) {
|
|
2991
3117
|
const r = {
|
|
@@ -2995,8 +3121,8 @@ function ft(t) {
|
|
|
2995
3121
|
(e = t.fail) == null || e.call(t, r);
|
|
2996
3122
|
return;
|
|
2997
3123
|
}
|
|
2998
|
-
if (!
|
|
2999
|
-
s.info("等待微信配置完成"),
|
|
3124
|
+
if (!j()) {
|
|
3125
|
+
s.info("等待微信配置完成"), K().then(() => Pt(t)).catch((r) => {
|
|
3000
3126
|
var n;
|
|
3001
3127
|
s.error("微信配置失败", r), (n = t.fail) == null || n.call(t, { errMsg: `微信配置失败: ${r.message}` });
|
|
3002
3128
|
});
|
|
@@ -3022,8 +3148,8 @@ function ft(t) {
|
|
|
3022
3148
|
platform: "weixin"
|
|
3023
3149
|
});
|
|
3024
3150
|
}
|
|
3025
|
-
function
|
|
3026
|
-
return
|
|
3151
|
+
function St(t) {
|
|
3152
|
+
return f.safeExecute(() => {
|
|
3027
3153
|
var e;
|
|
3028
3154
|
if (!window.wx) {
|
|
3029
3155
|
const r = {
|
|
@@ -3033,8 +3159,8 @@ function dt(t) {
|
|
|
3033
3159
|
(e = t.fail) == null || e.call(t, r);
|
|
3034
3160
|
return;
|
|
3035
3161
|
}
|
|
3036
|
-
if (!
|
|
3037
|
-
s.info("等待微信配置完成"),
|
|
3162
|
+
if (!j()) {
|
|
3163
|
+
s.info("等待微信配置完成"), K().then(() => St(t)).catch((r) => {
|
|
3038
3164
|
var n;
|
|
3039
3165
|
s.error("微信配置失败", r), (n = t.fail) == null || n.call(t, { errMsg: `微信配置失败: ${r.message}` });
|
|
3040
3166
|
});
|
|
@@ -3062,9 +3188,9 @@ function dt(t) {
|
|
|
3062
3188
|
platform: "weixin"
|
|
3063
3189
|
});
|
|
3064
3190
|
}
|
|
3065
|
-
function
|
|
3066
|
-
return
|
|
3067
|
-
s.debug("通过 WebView 桥接调用获取位置", t),
|
|
3191
|
+
function bn(t) {
|
|
3192
|
+
return f.safeExecute(() => {
|
|
3193
|
+
s.debug("通过 WebView 桥接调用获取位置", t), P("getLocation", t, {
|
|
3068
3194
|
success: (e) => {
|
|
3069
3195
|
var r;
|
|
3070
3196
|
s.info("UniApp 获取位置成功", {
|
|
@@ -3083,9 +3209,9 @@ function fn(t) {
|
|
|
3083
3209
|
platform: "uniapp"
|
|
3084
3210
|
});
|
|
3085
3211
|
}
|
|
3086
|
-
function
|
|
3087
|
-
return
|
|
3088
|
-
s.debug("通过 WebView 桥接调用查看位置", t),
|
|
3212
|
+
function Tn(t) {
|
|
3213
|
+
return f.safeExecute(() => {
|
|
3214
|
+
s.debug("通过 WebView 桥接调用查看位置", t), P("openLocation", t, {
|
|
3089
3215
|
success: (e) => {
|
|
3090
3216
|
var r;
|
|
3091
3217
|
s.info("UniApp 查看位置成功"), (r = t.success) == null || r.call(t, e);
|
|
@@ -3101,62 +3227,62 @@ function dn(t) {
|
|
|
3101
3227
|
platform: "uniapp"
|
|
3102
3228
|
});
|
|
3103
3229
|
}
|
|
3104
|
-
function
|
|
3105
|
-
return
|
|
3230
|
+
function Mn(t = {}) {
|
|
3231
|
+
return f.safeExecute(() => {
|
|
3106
3232
|
var r;
|
|
3107
|
-
if (
|
|
3233
|
+
if (!$e()) {
|
|
3108
3234
|
const n = {
|
|
3109
|
-
errMsg: `当前环境 (${
|
|
3235
|
+
errMsg: `当前环境 (${l.type}) 不支持定位功能`,
|
|
3110
3236
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
3111
3237
|
};
|
|
3112
|
-
s.error("平台不支持定位", { platform:
|
|
3238
|
+
s.error("平台不支持定位", { platform: l.type }), (r = t.fail) == null || r.call(t, n);
|
|
3113
3239
|
return;
|
|
3114
3240
|
}
|
|
3115
|
-
const e =
|
|
3241
|
+
const e = Sn(t);
|
|
3116
3242
|
s.info("开始获取位置", {
|
|
3117
|
-
platform:
|
|
3243
|
+
platform: l.type,
|
|
3118
3244
|
type: e.type,
|
|
3119
3245
|
altitude: e.altitude
|
|
3120
|
-
}),
|
|
3246
|
+
}), A() ? Pt(e) : bn(e);
|
|
3121
3247
|
}, {
|
|
3122
3248
|
context: "getLocation",
|
|
3123
3249
|
options: t
|
|
3124
3250
|
});
|
|
3125
3251
|
}
|
|
3126
|
-
function
|
|
3127
|
-
return
|
|
3252
|
+
function Ln(t = {}) {
|
|
3253
|
+
return f.safeExecute(() => {
|
|
3128
3254
|
var r, n, i;
|
|
3129
|
-
if (
|
|
3255
|
+
if (!$e()) {
|
|
3130
3256
|
const a = {
|
|
3131
|
-
errMsg: `当前环境 (${
|
|
3257
|
+
errMsg: `当前环境 (${l.type}) 不支持查看位置功能`,
|
|
3132
3258
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
3133
3259
|
};
|
|
3134
|
-
s.error("平台不支持查看位置", { platform:
|
|
3260
|
+
s.error("平台不支持查看位置", { platform: l.type }), (r = t.fail) == null || r.call(t, a);
|
|
3135
3261
|
return;
|
|
3136
3262
|
}
|
|
3137
3263
|
let e;
|
|
3138
3264
|
try {
|
|
3139
|
-
e =
|
|
3265
|
+
e = Rn(t);
|
|
3140
3266
|
} catch (a) {
|
|
3141
3267
|
s.error("参数验证失败", a), (n = t.fail) == null || n.call(t, a), (i = t.complete) == null || i.call(t);
|
|
3142
3268
|
return;
|
|
3143
3269
|
}
|
|
3144
3270
|
s.info("开始查看位置", {
|
|
3145
|
-
platform:
|
|
3271
|
+
platform: l.type,
|
|
3146
3272
|
latitude: e.latitude,
|
|
3147
3273
|
longitude: e.longitude,
|
|
3148
3274
|
name: e.name
|
|
3149
|
-
}),
|
|
3275
|
+
}), A() ? St(e) : Tn(e);
|
|
3150
3276
|
}, {
|
|
3151
3277
|
context: "openLocation",
|
|
3152
3278
|
options: t
|
|
3153
3279
|
});
|
|
3154
3280
|
}
|
|
3155
|
-
function
|
|
3156
|
-
const t =
|
|
3281
|
+
function xn() {
|
|
3282
|
+
const t = A();
|
|
3157
3283
|
return {
|
|
3158
|
-
supported:
|
|
3159
|
-
environment:
|
|
3284
|
+
supported: $e(),
|
|
3285
|
+
environment: l.type,
|
|
3160
3286
|
implementation: t ? "weixin" : "webview",
|
|
3161
3287
|
features: {
|
|
3162
3288
|
getLocation: !0,
|
|
@@ -3174,29 +3300,29 @@ function pn() {
|
|
|
3174
3300
|
}
|
|
3175
3301
|
};
|
|
3176
3302
|
}
|
|
3177
|
-
const
|
|
3178
|
-
function
|
|
3303
|
+
const V = /* @__PURE__ */ new Set(), q = /* @__PURE__ */ new Set();
|
|
3304
|
+
function Nt(t, e, r) {
|
|
3179
3305
|
t.forEach((n) => {
|
|
3180
3306
|
if (typeof n == "function") {
|
|
3181
|
-
|
|
3307
|
+
f.safeExecute(() => n(e), { context: r });
|
|
3182
3308
|
return;
|
|
3183
3309
|
}
|
|
3184
3310
|
s.warn("监听回调不是函数,已跳过", { type: typeof n });
|
|
3185
3311
|
});
|
|
3186
3312
|
}
|
|
3187
|
-
function
|
|
3188
|
-
return
|
|
3313
|
+
function vn(t = {}) {
|
|
3314
|
+
return f.safeExecute(() => {
|
|
3189
3315
|
var r, n;
|
|
3190
|
-
if (
|
|
3316
|
+
if (A()) {
|
|
3191
3317
|
const i = {
|
|
3192
|
-
errMsg: `当前环境 (${
|
|
3318
|
+
errMsg: `当前环境 (${l.type}) 不支持该接口`,
|
|
3193
3319
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
3194
3320
|
};
|
|
3195
|
-
s.error("当前环境不支持此接口", { platform:
|
|
3321
|
+
s.error("当前环境不支持此接口", { platform: l.type }), (r = t.fail) == null || r.call(t, i), (n = t.complete) == null || n.call(t, i);
|
|
3196
3322
|
return;
|
|
3197
3323
|
}
|
|
3198
|
-
const e =
|
|
3199
|
-
s.info("正在开启定位监听"),
|
|
3324
|
+
const e = Nn(t);
|
|
3325
|
+
s.info("正在开启定位监听"), P("startLocationUpdate", {
|
|
3200
3326
|
type: e.type,
|
|
3201
3327
|
needFullAccuracy: e.needFullAccuracy
|
|
3202
3328
|
}, {
|
|
@@ -3212,18 +3338,18 @@ function mn(t = {}) {
|
|
|
3212
3338
|
});
|
|
3213
3339
|
}, { context: "startLocationUpdate" });
|
|
3214
3340
|
}
|
|
3215
|
-
function
|
|
3216
|
-
return
|
|
3341
|
+
function Dn(t = {}) {
|
|
3342
|
+
return f.safeExecute(() => {
|
|
3217
3343
|
var e, r;
|
|
3218
|
-
if (
|
|
3344
|
+
if (A()) {
|
|
3219
3345
|
const n = {
|
|
3220
|
-
errMsg: `当前环境 (${
|
|
3346
|
+
errMsg: `当前环境 (${l.type}) 不支持该接口`,
|
|
3221
3347
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
3222
3348
|
};
|
|
3223
|
-
s.error("当前环境不支持此接口", { platform:
|
|
3349
|
+
s.error("当前环境不支持此接口", { platform: l.type }), (e = t.fail) == null || e.call(t, n), (r = t.complete) == null || r.call(t, n);
|
|
3224
3350
|
return;
|
|
3225
3351
|
}
|
|
3226
|
-
s.info("正在停止定位监听"),
|
|
3352
|
+
s.info("正在停止定位监听"), P("stopLocationUpdate", t, {
|
|
3227
3353
|
success: (n) => {
|
|
3228
3354
|
var i;
|
|
3229
3355
|
s.info("定位监听已停止"), (i = t.success) == null || i.call(t, n);
|
|
@@ -3236,10 +3362,10 @@ function wn(t = {}) {
|
|
|
3236
3362
|
});
|
|
3237
3363
|
}, { context: "stopLocationUpdate" });
|
|
3238
3364
|
}
|
|
3239
|
-
function
|
|
3240
|
-
return
|
|
3241
|
-
if (
|
|
3242
|
-
s.warn("当前环境不支持此接口", { platform:
|
|
3365
|
+
function Un(t) {
|
|
3366
|
+
return f.safeExecute(() => {
|
|
3367
|
+
if (A()) {
|
|
3368
|
+
s.warn("当前环境不支持此接口", { platform: l.type });
|
|
3243
3369
|
return;
|
|
3244
3370
|
}
|
|
3245
3371
|
if (typeof t != "function")
|
|
@@ -3247,21 +3373,21 @@ function En(t) {
|
|
|
3247
3373
|
errMsg: "onLocationChange 回调必须是函数",
|
|
3248
3374
|
code: "INVALID_CALLBACK"
|
|
3249
3375
|
};
|
|
3250
|
-
const e =
|
|
3251
|
-
|
|
3376
|
+
const e = V.size > 0;
|
|
3377
|
+
V.add(t), e || (s.debug("注册实时位置变化监听器"), P("onLocationChange", { isPersistent: !0 }, {
|
|
3252
3378
|
success: (r) => {
|
|
3253
|
-
s.debug("收到实时位置推送", r),
|
|
3379
|
+
s.debug("收到实时位置推送", r), Nt(V, r, "onLocationChange");
|
|
3254
3380
|
},
|
|
3255
3381
|
fail: (r) => {
|
|
3256
|
-
s.warn("位置变化监听出错,请通过 onLocationChangeError 监听错误", r),
|
|
3382
|
+
s.warn("位置变化监听出错,请通过 onLocationChangeError 监听错误", r), V.delete(t), V.size === 0 && ie("onLocationChange");
|
|
3257
3383
|
}
|
|
3258
3384
|
}));
|
|
3259
3385
|
}, { context: "onLocationChange" });
|
|
3260
3386
|
}
|
|
3261
|
-
function
|
|
3262
|
-
return
|
|
3263
|
-
if (
|
|
3264
|
-
s.warn("当前环境不支持此接口", { platform:
|
|
3387
|
+
function Wn(t) {
|
|
3388
|
+
return f.safeExecute(() => {
|
|
3389
|
+
if (A()) {
|
|
3390
|
+
s.warn("当前环境不支持此接口", { platform: l.type });
|
|
3265
3391
|
return;
|
|
3266
3392
|
}
|
|
3267
3393
|
if (t && typeof t != "function")
|
|
@@ -3269,20 +3395,20 @@ function yn(t) {
|
|
|
3269
3395
|
errMsg: "offLocationChange 回调必须是函数",
|
|
3270
3396
|
code: "INVALID_CALLBACK"
|
|
3271
3397
|
};
|
|
3272
|
-
t ?
|
|
3398
|
+
t ? V.delete(t) : V.clear(), !(V.size > 0) && (s.info("移除位置变化监听器"), P("offLocationChange", {}, {
|
|
3273
3399
|
success: () => {
|
|
3274
|
-
s.info("位置变化监听已移除"),
|
|
3400
|
+
s.info("位置变化监听已移除"), ie("onLocationChange");
|
|
3275
3401
|
},
|
|
3276
3402
|
fail: (e) => {
|
|
3277
|
-
s.error("移除位置变化监听失败", e),
|
|
3403
|
+
s.error("移除位置变化监听失败", e), ie("onLocationChange");
|
|
3278
3404
|
}
|
|
3279
3405
|
}));
|
|
3280
3406
|
}, { context: "offLocationChange" });
|
|
3281
3407
|
}
|
|
3282
|
-
function
|
|
3283
|
-
return
|
|
3284
|
-
if (
|
|
3285
|
-
s.warn("当前环境不支持此接口", { platform:
|
|
3408
|
+
function Bn(t) {
|
|
3409
|
+
return f.safeExecute(() => {
|
|
3410
|
+
if (A()) {
|
|
3411
|
+
s.warn("当前环境不支持此接口", { platform: l.type });
|
|
3286
3412
|
return;
|
|
3287
3413
|
}
|
|
3288
3414
|
if (typeof t != "function")
|
|
@@ -3290,21 +3416,21 @@ function In(t) {
|
|
|
3290
3416
|
errMsg: "onLocationChangeError 回调必须是函数",
|
|
3291
3417
|
code: "INVALID_CALLBACK"
|
|
3292
3418
|
};
|
|
3293
|
-
const e =
|
|
3294
|
-
|
|
3419
|
+
const e = q.size > 0;
|
|
3420
|
+
q.add(t), e || (s.debug("注册位置更新错误监听器"), P("onLocationChangeError", { isPersistent: !0 }, {
|
|
3295
3421
|
success: (r) => {
|
|
3296
|
-
s.warn("持续定位发生异常", r),
|
|
3422
|
+
s.warn("持续定位发生异常", r), Nt(q, r, "onLocationChangeError");
|
|
3297
3423
|
},
|
|
3298
3424
|
fail: (r) => {
|
|
3299
|
-
s.warn("位置更新错误监听注册失败", r),
|
|
3425
|
+
s.warn("位置更新错误监听注册失败", r), q.delete(t), q.size === 0 && ie("onLocationChangeError");
|
|
3300
3426
|
}
|
|
3301
3427
|
}));
|
|
3302
3428
|
}, { context: "onLocationChangeError" });
|
|
3303
3429
|
}
|
|
3304
|
-
function
|
|
3305
|
-
return
|
|
3306
|
-
if (
|
|
3307
|
-
s.warn("当前环境不支持此接口", { platform:
|
|
3430
|
+
function $n(t) {
|
|
3431
|
+
return f.safeExecute(() => {
|
|
3432
|
+
if (A()) {
|
|
3433
|
+
s.warn("当前环境不支持此接口", { platform: l.type });
|
|
3308
3434
|
return;
|
|
3309
3435
|
}
|
|
3310
3436
|
if (t && typeof t != "function")
|
|
@@ -3312,24 +3438,24 @@ function An(t) {
|
|
|
3312
3438
|
errMsg: "offLocationChangeError 回调必须是函数",
|
|
3313
3439
|
code: "INVALID_CALLBACK"
|
|
3314
3440
|
};
|
|
3315
|
-
t ?
|
|
3441
|
+
t ? q.delete(t) : q.clear(), !(q.size > 0) && (s.info("移除定位错误监听器"), P("offLocationChangeError", {}, {
|
|
3316
3442
|
success: () => {
|
|
3317
|
-
s.info("定位错误监听已移除"),
|
|
3443
|
+
s.info("定位错误监听已移除"), ie("onLocationChangeError");
|
|
3318
3444
|
},
|
|
3319
3445
|
fail: (e) => {
|
|
3320
|
-
s.error("移除定位错误监听失败", e),
|
|
3446
|
+
s.error("移除定位错误监听失败", e), ie("onLocationChangeError");
|
|
3321
3447
|
}
|
|
3322
3448
|
}));
|
|
3323
3449
|
}, { context: "offLocationChangeError" });
|
|
3324
3450
|
}
|
|
3325
|
-
const
|
|
3451
|
+
const kn = {
|
|
3326
3452
|
latitude: null,
|
|
3327
3453
|
// 目标地纬度
|
|
3328
3454
|
longitude: null
|
|
3329
3455
|
// 目标地经度
|
|
3330
3456
|
};
|
|
3331
|
-
function
|
|
3332
|
-
const e = g(g({},
|
|
3457
|
+
function Fn(t = {}) {
|
|
3458
|
+
const e = g(g({}, kn), t);
|
|
3333
3459
|
return e.latitude !== null && e.latitude !== void 0 && (typeof e.latitude != "number" ? (s.warn("latitude 参数类型错误,已忽略", {
|
|
3334
3460
|
latitude: e.latitude
|
|
3335
3461
|
}), e.latitude = null) : (e.latitude < -90 || e.latitude > 90) && (s.warn("latitude 超出范围,已忽略", {
|
|
@@ -3340,11 +3466,11 @@ function Cn(t = {}) {
|
|
|
3340
3466
|
longitude: e.longitude
|
|
3341
3467
|
}), e.longitude = null)), e;
|
|
3342
3468
|
}
|
|
3343
|
-
function
|
|
3344
|
-
return ["weixin", "webview", "UniApp", "plus", "nvue", "uvue"].includes(
|
|
3469
|
+
function Rt() {
|
|
3470
|
+
return ["weixin", "webview", "UniApp", "plus", "nvue", "uvue", "offline"].includes(l.type);
|
|
3345
3471
|
}
|
|
3346
|
-
function
|
|
3347
|
-
return
|
|
3472
|
+
function bt(t) {
|
|
3473
|
+
return f.safeExecute(() => {
|
|
3348
3474
|
var n;
|
|
3349
3475
|
if (!window.wx) {
|
|
3350
3476
|
const i = {
|
|
@@ -3354,8 +3480,8 @@ function pt(t) {
|
|
|
3354
3480
|
(n = t.fail) == null || n.call(t, i);
|
|
3355
3481
|
return;
|
|
3356
3482
|
}
|
|
3357
|
-
if (!
|
|
3358
|
-
s.info("等待微信配置完成"),
|
|
3483
|
+
if (!j()) {
|
|
3484
|
+
s.info("等待微信配置完成"), K().then(() => bt(t)).catch((i) => {
|
|
3359
3485
|
var a;
|
|
3360
3486
|
s.error("微信配置失败", i), (a = t.fail) == null || a.call(t, { errMsg: `微信配置失败: ${i.message}` });
|
|
3361
3487
|
});
|
|
@@ -3390,7 +3516,7 @@ function pt(t) {
|
|
|
3390
3516
|
},
|
|
3391
3517
|
complete: t.complete
|
|
3392
3518
|
}, r = {};
|
|
3393
|
-
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), {
|
|
3394
3520
|
success: e.success,
|
|
3395
3521
|
fail: e.fail,
|
|
3396
3522
|
complete: e.complete
|
|
@@ -3400,8 +3526,8 @@ function pt(t) {
|
|
|
3400
3526
|
platform: "weixin"
|
|
3401
3527
|
});
|
|
3402
3528
|
}
|
|
3403
|
-
function
|
|
3404
|
-
return
|
|
3529
|
+
function Kn(t) {
|
|
3530
|
+
return f.safeExecute(() => {
|
|
3405
3531
|
s.debug("通过 WebView 桥接调用位置选择", t);
|
|
3406
3532
|
const e = {
|
|
3407
3533
|
// 禁用超时清理,等待用户操作完成后才清理
|
|
@@ -3421,7 +3547,7 @@ function _n(t) {
|
|
|
3421
3547
|
},
|
|
3422
3548
|
complete: t.complete
|
|
3423
3549
|
};
|
|
3424
|
-
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, {
|
|
3425
3551
|
success: (r) => {
|
|
3426
3552
|
e.success(r);
|
|
3427
3553
|
},
|
|
@@ -3435,33 +3561,33 @@ function _n(t) {
|
|
|
3435
3561
|
platform: "uniapp"
|
|
3436
3562
|
});
|
|
3437
3563
|
}
|
|
3438
|
-
function
|
|
3439
|
-
return
|
|
3564
|
+
function zn(t = {}) {
|
|
3565
|
+
return f.safeExecute(() => {
|
|
3440
3566
|
var r;
|
|
3441
|
-
if (!
|
|
3567
|
+
if (!Rt()) {
|
|
3442
3568
|
const n = {
|
|
3443
|
-
errMsg: `当前环境 (${
|
|
3569
|
+
errMsg: `当前环境 (${l.type}) 不支持位置选择功能`,
|
|
3444
3570
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
3445
3571
|
};
|
|
3446
|
-
s.error("平台不支持位置选择", { platform:
|
|
3572
|
+
s.error("平台不支持位置选择", { platform: l.type }), (r = t.fail) == null || r.call(t, n);
|
|
3447
3573
|
return;
|
|
3448
3574
|
}
|
|
3449
|
-
const e =
|
|
3575
|
+
const e = Fn(t);
|
|
3450
3576
|
s.info("开始选择位置", {
|
|
3451
|
-
platform:
|
|
3577
|
+
platform: l.type,
|
|
3452
3578
|
latitude: e.latitude,
|
|
3453
3579
|
longitude: e.longitude
|
|
3454
|
-
}),
|
|
3580
|
+
}), A() ? bt(e) : Kn(e);
|
|
3455
3581
|
}, {
|
|
3456
3582
|
context: "chooseLocation",
|
|
3457
3583
|
options: t
|
|
3458
3584
|
});
|
|
3459
3585
|
}
|
|
3460
|
-
function
|
|
3586
|
+
function Gn() {
|
|
3461
3587
|
return {
|
|
3462
|
-
supported:
|
|
3463
|
-
environment:
|
|
3464
|
-
implementation:
|
|
3588
|
+
supported: Rt(),
|
|
3589
|
+
environment: l.type,
|
|
3590
|
+
implementation: A() ? "weixin" : "webview",
|
|
3465
3591
|
features: {
|
|
3466
3592
|
chooseLocation: !0,
|
|
3467
3593
|
// 支持位置选择
|
|
@@ -3472,62 +3598,191 @@ function Rn() {
|
|
|
3472
3598
|
}
|
|
3473
3599
|
};
|
|
3474
3600
|
}
|
|
3475
|
-
const
|
|
3476
|
-
function
|
|
3477
|
-
|
|
3601
|
+
const Tt = /* @__PURE__ */ new Map();
|
|
3602
|
+
function Vn(t, e = {}) {
|
|
3603
|
+
Tt.set(t, e);
|
|
3478
3604
|
}
|
|
3479
|
-
function
|
|
3480
|
-
const r =
|
|
3605
|
+
function qn(t, e) {
|
|
3606
|
+
const r = Tt.get(t);
|
|
3481
3607
|
if (r)
|
|
3482
3608
|
return r[e] || r.default;
|
|
3483
3609
|
}
|
|
3484
|
-
|
|
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 = {
|
|
3485
3683
|
0: "WXSceneSession",
|
|
3486
3684
|
// 聊天界面
|
|
3487
3685
|
1: "WXSceneTimeline"
|
|
3488
3686
|
// 朋友圈
|
|
3489
|
-
}, Tn = {
|
|
3490
|
-
0: "图文/网页",
|
|
3491
|
-
1: "纯文字",
|
|
3492
|
-
2: "纯图片",
|
|
3493
|
-
3: "音乐",
|
|
3494
|
-
4: "视频",
|
|
3495
|
-
5: "小程序"
|
|
3496
3687
|
};
|
|
3497
|
-
function
|
|
3498
|
-
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(
|
|
3499
3752
|
() => {
|
|
3500
3753
|
var r;
|
|
3501
3754
|
if (typeof window == "undefined" || !window.wx) {
|
|
3502
3755
|
const n = { errMsg: "微信JS-SDK未加载", code: "WEIXIN_SDK_NOT_LOADED" };
|
|
3503
3756
|
return (r = t.fail) == null || r.call(t, n), Promise.reject(n);
|
|
3504
3757
|
}
|
|
3505
|
-
if (!
|
|
3506
|
-
return s.info("等待微信配置完成"),
|
|
3507
|
-
|
|
3508
|
-
|
|
3509
|
-
|
|
3510
|
-
|
|
3511
|
-
|
|
3512
|
-
|
|
3513
|
-
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
|
|
3518
|
-
|
|
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
|
+
});
|
|
3519
3773
|
});
|
|
3520
|
-
|
|
3521
|
-
|
|
3774
|
+
const e = g({}, t);
|
|
3775
|
+
return s.debug("调用微信分享", e), new Promise((n, i) => {
|
|
3776
|
+
window.wx[e.scene](m(g({}, e), {
|
|
3522
3777
|
success: () => {
|
|
3523
3778
|
var o;
|
|
3524
3779
|
const a = { errMsg: "weixinShare:ok" };
|
|
3525
3780
|
(o = t.success) == null || o.call(t, a), n(a);
|
|
3526
3781
|
},
|
|
3527
3782
|
fail: (a) => {
|
|
3528
|
-
var
|
|
3783
|
+
var u;
|
|
3529
3784
|
const o = { errMsg: (a == null ? void 0 : a.errMsg) || "weixinShare:fail", details: a };
|
|
3530
|
-
s.error("微信分享失败", o), (
|
|
3785
|
+
s.error("微信分享失败", o), (u = t.fail) == null || u.call(t, o), i(o);
|
|
3531
3786
|
},
|
|
3532
3787
|
complete: t.complete
|
|
3533
3788
|
}));
|
|
@@ -3539,16 +3794,16 @@ function Et(t = {}) {
|
|
|
3539
3794
|
}
|
|
3540
3795
|
);
|
|
3541
3796
|
}
|
|
3542
|
-
function
|
|
3797
|
+
function Xn(t = {}, e) {
|
|
3543
3798
|
const r = g({}, t), n = {
|
|
3544
3799
|
scene: r.scene === 1 ? "updateTimelineShareData" : "updateAppMessageShareData"
|
|
3545
3800
|
};
|
|
3546
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 };
|
|
3547
3802
|
}
|
|
3548
|
-
function
|
|
3549
|
-
return
|
|
3550
|
-
() => (s.debug("通过 WebView 桥接调用微信分享", t), console.log("桥接调用微信分享桥接调用微信分享:", JSON.stringify(
|
|
3551
|
-
|
|
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, {
|
|
3552
3807
|
success: (n) => {
|
|
3553
3808
|
var i;
|
|
3554
3809
|
(i = t.success) == null || i.call(t, n), e(n);
|
|
@@ -3566,69 +3821,100 @@ function Y(t = {}) {
|
|
|
3566
3821
|
}
|
|
3567
3822
|
);
|
|
3568
3823
|
}
|
|
3569
|
-
function
|
|
3824
|
+
function Zn(t = {}) {
|
|
3570
3825
|
const e = g({}, t), r = {
|
|
3571
3826
|
provider: "weixin",
|
|
3572
3827
|
scene: "WXSceneSession"
|
|
3573
3828
|
};
|
|
3574
|
-
|
|
3575
|
-
|
|
3576
|
-
|
|
3577
|
-
|
|
3578
|
-
|
|
3579
|
-
|
|
3580
|
-
|
|
3581
|
-
|
|
3582
|
-
|
|
3583
|
-
|
|
3584
|
-
|
|
3585
|
-
|
|
3586
|
-
|
|
3587
|
-
|
|
3588
|
-
|
|
3589
|
-
|
|
3590
|
-
|
|
3591
|
-
|
|
3592
|
-
|
|
3593
|
-
|
|
3594
|
-
|
|
3595
|
-
|
|
3596
|
-
|
|
3597
|
-
|
|
3598
|
-
|
|
3599
|
-
|
|
3600
|
-
|
|
3601
|
-
weixin: Et,
|
|
3602
|
-
webview: Y,
|
|
3603
|
-
plus: Y,
|
|
3604
|
-
nvue: Y,
|
|
3605
|
-
uvue: Y,
|
|
3606
|
-
UniApp: Y,
|
|
3607
|
-
h5: Y,
|
|
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,
|
|
3608
3856
|
default: void 0
|
|
3609
3857
|
});
|
|
3610
|
-
function
|
|
3858
|
+
function Qn(t) {
|
|
3611
3859
|
return t && typeof t == "object" && t.__v_raw ? t.__v_raw : t;
|
|
3612
3860
|
}
|
|
3613
|
-
function
|
|
3614
|
-
return
|
|
3861
|
+
function vt(t = {}) {
|
|
3862
|
+
return f.safeExecute(
|
|
3615
3863
|
() => {
|
|
3616
|
-
var
|
|
3617
|
-
|
|
3618
|
-
|
|
3619
|
-
|
|
3620
|
-
|
|
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}) 不支持微信分享功能`,
|
|
3621
3903
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
3622
3904
|
};
|
|
3623
|
-
return s.error("平台不支持微信分享", { platform:
|
|
3905
|
+
return s.error("平台不支持微信分享", { platform: v.type }), (Ye = _.fail) == null || Ye.call(_, T), Promise.reject(T);
|
|
3624
3906
|
}
|
|
3625
|
-
const
|
|
3626
|
-
if (!
|
|
3627
|
-
const
|
|
3628
|
-
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);
|
|
3629
3911
|
}
|
|
3630
|
-
|
|
3631
|
-
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);
|
|
3632
3918
|
},
|
|
3633
3919
|
{
|
|
3634
3920
|
context: "toShare",
|
|
@@ -3636,49 +3922,159 @@ function At(t = {}) {
|
|
|
3636
3922
|
}
|
|
3637
3923
|
);
|
|
3638
3924
|
}
|
|
3639
|
-
function
|
|
3925
|
+
function ei(t = {}) {
|
|
3640
3926
|
return new Promise((e, r) => {
|
|
3641
|
-
|
|
3927
|
+
vt(m(g({}, t), {
|
|
3642
3928
|
success: e,
|
|
3643
3929
|
fail: r
|
|
3644
3930
|
}));
|
|
3645
3931
|
});
|
|
3646
3932
|
}
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
|
-
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
|
|
3653
|
-
|
|
3654
|
-
|
|
3655
|
-
|
|
3656
|
-
|
|
3657
|
-
|
|
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" }
|
|
3658
3985
|
}
|
|
3659
|
-
|
|
3660
|
-
|
|
3661
|
-
|
|
3662
|
-
|
|
3986
|
+
},
|
|
3987
|
+
text: {
|
|
3988
|
+
fields: {
|
|
3989
|
+
summary: { required: "与 text 二选一", type: "string", description: "文字内容" },
|
|
3990
|
+
text: { required: "与 summary 二选一", type: "string", description: "同 summary" }
|
|
3663
3991
|
}
|
|
3664
|
-
const i = n.params;
|
|
3665
|
-
return s.info("开始微信分享", { platform: e.type, type: i == null ? void 0 : i.type }), r(w(g({}, i), { isCallBack: !0 }));
|
|
3666
3992
|
},
|
|
3993
|
+
image: {
|
|
3994
|
+
fields: {
|
|
3995
|
+
imageUrl: { required: !0, type: "string", description: "图片地址 http/https" }
|
|
3996
|
+
}
|
|
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: [
|
|
3667
4018
|
{
|
|
3668
|
-
|
|
3669
|
-
|
|
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
|
|
3670
4045
|
}
|
|
3671
|
-
|
|
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;
|
|
3672
4067
|
}
|
|
3673
|
-
function
|
|
3674
|
-
|
|
3675
|
-
|
|
3676
|
-
|
|
3677
|
-
fail: r
|
|
3678
|
-
}));
|
|
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);
|
|
3679
4072
|
});
|
|
4073
|
+
const r = e.join(`
|
|
4074
|
+
`);
|
|
4075
|
+
return typeof console != "undefined" && console.log && console.log(r), r;
|
|
3680
4076
|
}
|
|
3681
|
-
const
|
|
4077
|
+
const ni = {
|
|
3682
4078
|
OFF: "off",
|
|
3683
4079
|
// 蓝牙关闭
|
|
3684
4080
|
ON: "on",
|
|
@@ -3687,29 +4083,29 @@ const bn = {
|
|
|
3687
4083
|
// 不支持蓝牙
|
|
3688
4084
|
UNAUTHORIZED: "unauthorized"
|
|
3689
4085
|
// 未授权
|
|
3690
|
-
},
|
|
4086
|
+
}, ii = {
|
|
3691
4087
|
allowDuplicatesKey: !1,
|
|
3692
4088
|
// 是否允许重复上报同一设备
|
|
3693
4089
|
services: []
|
|
3694
4090
|
// 指定服务 UUID 列表
|
|
3695
4091
|
};
|
|
3696
|
-
function
|
|
3697
|
-
return g(g({},
|
|
4092
|
+
function Te(t = {}) {
|
|
4093
|
+
return g(g({}, ii), t);
|
|
3698
4094
|
}
|
|
3699
|
-
function
|
|
3700
|
-
return ["weixin", "webview", "UniApp", "plus", "nvue", "uvue"].includes(
|
|
4095
|
+
function we() {
|
|
4096
|
+
return ["weixin", "webview", "UniApp", "plus", "nvue", "uvue", "offline"].includes(l.type);
|
|
3701
4097
|
}
|
|
3702
|
-
function
|
|
3703
|
-
return
|
|
4098
|
+
function si(t) {
|
|
4099
|
+
return f.safeExecute(() => h(null, null, function* () {
|
|
3704
4100
|
var e;
|
|
3705
4101
|
if (!window.wx) {
|
|
3706
4102
|
const r = { errMsg: "微信JS-SDK未加载", code: "WEIXIN_SDK_NOT_LOADED" };
|
|
3707
4103
|
(e = t.fail) == null || e.call(t, r);
|
|
3708
4104
|
return;
|
|
3709
4105
|
}
|
|
3710
|
-
|
|
4106
|
+
j() || (s.info("等待微信配置完成"), yield K()), wx.openBluetoothAdapter({
|
|
3711
4107
|
success: () => {
|
|
3712
|
-
s.info("微信蓝牙适配器已打开"),
|
|
4108
|
+
s.info("微信蓝牙适配器已打开"), Dt(t);
|
|
3713
4109
|
},
|
|
3714
4110
|
fail: (r) => {
|
|
3715
4111
|
var n;
|
|
@@ -3718,9 +4114,9 @@ function vn(t) {
|
|
|
3718
4114
|
});
|
|
3719
4115
|
}), { context: "openBluetoothAdapterInWeixin" });
|
|
3720
4116
|
}
|
|
3721
|
-
function
|
|
3722
|
-
return
|
|
3723
|
-
s.debug("通过 WebView 桥接调用蓝牙功能", t),
|
|
4117
|
+
function ai(t) {
|
|
4118
|
+
return f.safeExecute(() => {
|
|
4119
|
+
s.debug("通过 WebView 桥接调用蓝牙功能", t), P("bluetooth", t, {
|
|
3724
4120
|
success: (e) => {
|
|
3725
4121
|
var r;
|
|
3726
4122
|
s.info("UniApp 蓝牙调用成功", e), (r = t.success) == null || r.call(t, e);
|
|
@@ -3733,10 +4129,10 @@ function Dn(t) {
|
|
|
3733
4129
|
});
|
|
3734
4130
|
}, { context: "bluetoothInUniApp" });
|
|
3735
4131
|
}
|
|
3736
|
-
function
|
|
3737
|
-
return
|
|
4132
|
+
function oi(t) {
|
|
4133
|
+
return f.safeExecute(() => {
|
|
3738
4134
|
var e;
|
|
3739
|
-
s.debug("通过 WebView 桥接调用蓝牙设备搜索功能", t),
|
|
4135
|
+
s.debug("通过 WebView 桥接调用蓝牙设备搜索功能", t), P("bluetoothDevicesDiscovery", {
|
|
3740
4136
|
action: "startBluetoothDevicesDiscovery",
|
|
3741
4137
|
params: {
|
|
3742
4138
|
services: t.services || [],
|
|
@@ -3755,11 +4151,11 @@ function Un(t) {
|
|
|
3755
4151
|
});
|
|
3756
4152
|
}, { context: "startBluetoothDevicesDiscoveryInUniApp" });
|
|
3757
4153
|
}
|
|
3758
|
-
const
|
|
3759
|
-
function
|
|
3760
|
-
return
|
|
4154
|
+
const Ie = /* @__PURE__ */ new Set();
|
|
4155
|
+
function ci(t, e = {}) {
|
|
4156
|
+
return f.safeExecute(() => {
|
|
3761
4157
|
var r;
|
|
3762
|
-
return
|
|
4158
|
+
return Ie.add(t), Ie.size === 1 && P("onBluetoothDeviceFound", {
|
|
3763
4159
|
action: "onBluetoothDeviceFound",
|
|
3764
4160
|
isPersistent: !0,
|
|
3765
4161
|
params: {
|
|
@@ -3768,8 +4164,8 @@ function Wn(t, e = {}) {
|
|
|
3768
4164
|
}
|
|
3769
4165
|
}, {
|
|
3770
4166
|
success: (n) => {
|
|
3771
|
-
|
|
3772
|
-
typeof i == "function" ?
|
|
4167
|
+
Ie.forEach((i) => {
|
|
4168
|
+
typeof i == "function" ? f.safeExecute(() => i(n), { context: "BluetoothDeviceCallback" }) : console.warn("[BluetoothDeviceCallback] 不是函数:", i);
|
|
3773
4169
|
});
|
|
3774
4170
|
},
|
|
3775
4171
|
fail: (n) => {
|
|
@@ -3777,13 +4173,13 @@ function Wn(t, e = {}) {
|
|
|
3777
4173
|
console.error("[Bluetooth] 搜索失败:", n), (i = e.fail) == null || i.call(e, n);
|
|
3778
4174
|
},
|
|
3779
4175
|
complete: e.complete
|
|
3780
|
-
}), () =>
|
|
4176
|
+
}), () => Ie.delete(t);
|
|
3781
4177
|
}, { context: "qsh_onBluetoothDeviceFound" });
|
|
3782
4178
|
}
|
|
3783
|
-
function
|
|
3784
|
-
return
|
|
4179
|
+
function ui(t) {
|
|
4180
|
+
return f.safeExecute(() => {
|
|
3785
4181
|
var e;
|
|
3786
|
-
s.debug("通过 WebView 桥接调用蓝牙连接功能", t),
|
|
4182
|
+
s.debug("通过 WebView 桥接调用蓝牙连接功能", t), P("bluetoothConnection", {
|
|
3787
4183
|
action: "createBLEConnection",
|
|
3788
4184
|
params: {
|
|
3789
4185
|
deviceId: t.deviceId,
|
|
@@ -3803,90 +4199,90 @@ function $n(t) {
|
|
|
3803
4199
|
});
|
|
3804
4200
|
}, { context: "createBLEConnectionInUniApp" });
|
|
3805
4201
|
}
|
|
3806
|
-
function
|
|
3807
|
-
return
|
|
4202
|
+
function li(t = {}) {
|
|
4203
|
+
return f.safeExecute(() => {
|
|
3808
4204
|
var r;
|
|
3809
|
-
if (!
|
|
4205
|
+
if (!we()) {
|
|
3810
4206
|
const n = {
|
|
3811
|
-
errMsg: `当前环境 (${
|
|
4207
|
+
errMsg: `当前环境 (${l.type}) 不支持蓝牙功能`,
|
|
3812
4208
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
3813
4209
|
};
|
|
3814
|
-
s.error("平台不支持蓝牙", { platform:
|
|
4210
|
+
s.error("平台不支持蓝牙", { platform: l.type }), (r = t.fail) == null || r.call(t, n);
|
|
3815
4211
|
return;
|
|
3816
4212
|
}
|
|
3817
|
-
const e =
|
|
4213
|
+
const e = Te(t);
|
|
3818
4214
|
s.info("开始蓝牙操作", {
|
|
3819
|
-
platform:
|
|
4215
|
+
platform: l.type,
|
|
3820
4216
|
services: e.services,
|
|
3821
4217
|
allowDuplicatesKey: e.allowDuplicatesKey
|
|
3822
|
-
}),
|
|
4218
|
+
}), A() ? si(e) : ai(e);
|
|
3823
4219
|
}, { context: "openBluetoothAdapter", options: t });
|
|
3824
4220
|
}
|
|
3825
|
-
function
|
|
3826
|
-
return
|
|
4221
|
+
function fi(t = {}) {
|
|
4222
|
+
return f.safeExecute(() => {
|
|
3827
4223
|
var r, n;
|
|
3828
|
-
if (!
|
|
4224
|
+
if (!we()) {
|
|
3829
4225
|
const i = {
|
|
3830
|
-
errMsg: `当前环境 (${
|
|
4226
|
+
errMsg: `当前环境 (${l.type}) 不支持蓝牙功能`,
|
|
3831
4227
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
3832
4228
|
};
|
|
3833
|
-
s.error("平台不支持蓝牙", { platform:
|
|
4229
|
+
s.error("平台不支持蓝牙", { platform: l.type }), (r = t.fail) == null || r.call(t, i), (n = t.complete) == null || n.call(t, i);
|
|
3834
4230
|
return;
|
|
3835
4231
|
}
|
|
3836
|
-
const e =
|
|
4232
|
+
const e = Te(t);
|
|
3837
4233
|
s.info("开始搜索蓝牙设备", {
|
|
3838
|
-
platform:
|
|
4234
|
+
platform: l.type,
|
|
3839
4235
|
services: e.services,
|
|
3840
4236
|
allowDuplicatesKey: e.allowDuplicatesKey
|
|
3841
|
-
}),
|
|
4237
|
+
}), A() ? startBluetoothDevicesDiscoveryInWeixin(e) : oi(e);
|
|
3842
4238
|
}, { context: "startBluetoothDevicesDiscovery", options: t });
|
|
3843
4239
|
}
|
|
3844
|
-
function
|
|
3845
|
-
return
|
|
4240
|
+
function Dt(t, e = {}) {
|
|
4241
|
+
return f.safeExecute(() => {
|
|
3846
4242
|
var n, i;
|
|
3847
|
-
if (!
|
|
4243
|
+
if (!we()) {
|
|
3848
4244
|
const a = {
|
|
3849
|
-
errMsg: `当前环境 (${
|
|
4245
|
+
errMsg: `当前环境 (${l.type}) 不支持蓝牙功能`,
|
|
3850
4246
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
3851
4247
|
};
|
|
3852
|
-
s.error("平台不支持蓝牙", { platform:
|
|
4248
|
+
s.error("平台不支持蓝牙", { platform: l.type }), (n = e.fail) == null || n.call(e, a), (i = e.complete) == null || i.call(e, a);
|
|
3853
4249
|
return;
|
|
3854
4250
|
}
|
|
3855
|
-
const r =
|
|
3856
|
-
s.info("注册蓝牙设备发现监听", { platform:
|
|
4251
|
+
const r = Te(e);
|
|
4252
|
+
s.info("注册蓝牙设备发现监听", { platform: l.type }), A() ? onBluetoothDeviceFoundInWeixin(r) : ci(t, r);
|
|
3857
4253
|
}, { context: "onBluetoothDeviceFound", options: e });
|
|
3858
4254
|
}
|
|
3859
|
-
function
|
|
3860
|
-
return
|
|
3861
|
-
var a, o,
|
|
3862
|
-
if (!
|
|
4255
|
+
function di(t = {}) {
|
|
4256
|
+
return f.safeExecute(() => {
|
|
4257
|
+
var a, o, u, d;
|
|
4258
|
+
if (!we()) {
|
|
3863
4259
|
const O = {
|
|
3864
|
-
errMsg: `当前环境 (${
|
|
4260
|
+
errMsg: `当前环境 (${l.type}) 不支持蓝牙功能`,
|
|
3865
4261
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
3866
4262
|
};
|
|
3867
|
-
s.error("平台不支持蓝牙连接", { platform:
|
|
4263
|
+
s.error("平台不支持蓝牙连接", { platform: l.type }), (a = t.fail) == null || a.call(t, O), (o = t.complete) == null || o.call(t, O);
|
|
3868
4264
|
return;
|
|
3869
4265
|
}
|
|
3870
|
-
const e =
|
|
4266
|
+
const e = Te(t), { name: r, deviceId: n, autoConnect: i = !1 } = e;
|
|
3871
4267
|
if (!n) {
|
|
3872
4268
|
const O = { errMsg: "缺少 deviceId 参数", code: "INVALID_PARAMS" };
|
|
3873
|
-
(
|
|
4269
|
+
(u = t.fail) == null || u.call(t, O), (d = t.complete) == null || d.call(t, O);
|
|
3874
4270
|
return;
|
|
3875
4271
|
}
|
|
3876
|
-
s.info("创建蓝牙连接", { deviceId: n, autoConnect: i, platform:
|
|
4272
|
+
s.info("创建蓝牙连接", { deviceId: n, autoConnect: i, platform: l.type }), A() ? uni.createBLEConnection({
|
|
3877
4273
|
deviceId: n,
|
|
3878
4274
|
autoConnect: i,
|
|
3879
4275
|
success: t.success,
|
|
3880
4276
|
fail: t.fail,
|
|
3881
4277
|
complete: t.complete
|
|
3882
|
-
}) :
|
|
4278
|
+
}) : ui(e);
|
|
3883
4279
|
}, { context: "createBLEConnection", options: t });
|
|
3884
4280
|
}
|
|
3885
|
-
function
|
|
4281
|
+
function gi() {
|
|
3886
4282
|
return {
|
|
3887
|
-
supported:
|
|
3888
|
-
environment:
|
|
3889
|
-
implementation:
|
|
4283
|
+
supported: we(),
|
|
4284
|
+
environment: l.type,
|
|
4285
|
+
implementation: A() ? "weixin" : "webview",
|
|
3890
4286
|
features: {
|
|
3891
4287
|
discovery: !0,
|
|
3892
4288
|
connect: !0,
|
|
@@ -3896,18 +4292,18 @@ function zn() {
|
|
|
3896
4292
|
}
|
|
3897
4293
|
};
|
|
3898
4294
|
}
|
|
3899
|
-
const
|
|
4295
|
+
const pi = {
|
|
3900
4296
|
// TODO: 添加更多默认配置
|
|
3901
4297
|
};
|
|
3902
|
-
function
|
|
3903
|
-
return g(g({},
|
|
4298
|
+
function mi(t = {}) {
|
|
4299
|
+
return g(g({}, pi), t);
|
|
3904
4300
|
}
|
|
3905
|
-
function
|
|
3906
|
-
return ["webview", "UniApp", "plus", "nvue", "uvue"].includes(
|
|
4301
|
+
function Ut() {
|
|
4302
|
+
return ["webview", "UniApp", "plus", "nvue", "uvue", "offline"].includes(l.type);
|
|
3907
4303
|
}
|
|
3908
|
-
function
|
|
3909
|
-
return
|
|
3910
|
-
s.debug("通过 WebView 桥接调用打印PDF", t),
|
|
4304
|
+
function hi(t) {
|
|
4305
|
+
return f.safeExecute(() => {
|
|
4306
|
+
s.debug("通过 WebView 桥接调用打印PDF", t), P("printPdf", m(g({}, t), {
|
|
3911
4307
|
isPersistent: !0
|
|
3912
4308
|
// 强制禁用超时自动清理
|
|
3913
4309
|
}), {
|
|
@@ -3926,36 +4322,36 @@ function Vn(t) {
|
|
|
3926
4322
|
platform: "uniapp"
|
|
3927
4323
|
});
|
|
3928
4324
|
}
|
|
3929
|
-
function
|
|
3930
|
-
return
|
|
4325
|
+
function wi(t = {}) {
|
|
4326
|
+
return f.safeExecute(() => {
|
|
3931
4327
|
var r;
|
|
3932
|
-
if (!
|
|
4328
|
+
if (!Ut()) {
|
|
3933
4329
|
const n = {
|
|
3934
|
-
errMsg: `当前环境 (${
|
|
4330
|
+
errMsg: `当前环境 (${l.type}) 不支持打印PDF功能`,
|
|
3935
4331
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
3936
4332
|
};
|
|
3937
|
-
s.error("平台不支持打印PDF", { platform:
|
|
4333
|
+
s.error("平台不支持打印PDF", { platform: l.type }), (r = t.fail) == null || r.call(t, n);
|
|
3938
4334
|
return;
|
|
3939
4335
|
}
|
|
3940
|
-
const e =
|
|
3941
|
-
s.info("开始打印PDF", { platform:
|
|
4336
|
+
const e = mi(t);
|
|
4337
|
+
s.info("开始打印PDF", { platform: l.type }), hi(e);
|
|
3942
4338
|
}, {
|
|
3943
4339
|
context: "printPdf",
|
|
3944
4340
|
options: t
|
|
3945
4341
|
});
|
|
3946
4342
|
}
|
|
3947
|
-
function
|
|
4343
|
+
function Ei() {
|
|
3948
4344
|
return {
|
|
3949
|
-
supported:
|
|
3950
|
-
environment:
|
|
4345
|
+
supported: Ut(),
|
|
4346
|
+
environment: l.type,
|
|
3951
4347
|
implementation: "uniapp",
|
|
3952
4348
|
features: {
|
|
3953
4349
|
asyncSupport: !0
|
|
3954
4350
|
}
|
|
3955
4351
|
};
|
|
3956
4352
|
}
|
|
3957
|
-
const
|
|
3958
|
-
function
|
|
4353
|
+
const De = "/pages/face/index";
|
|
4354
|
+
function yi(t = {}) {
|
|
3959
4355
|
const e = g({}, t);
|
|
3960
4356
|
if (!e.name || typeof e.name != "string" || !e.name.trim())
|
|
3961
4357
|
throw {
|
|
@@ -3969,26 +4365,26 @@ function Jn(t = {}) {
|
|
|
3969
4365
|
};
|
|
3970
4366
|
return e.idCardNumber = e.idCardNumber.trim(), e;
|
|
3971
4367
|
}
|
|
3972
|
-
function
|
|
3973
|
-
return
|
|
4368
|
+
function Wt() {
|
|
4369
|
+
return A();
|
|
3974
4370
|
}
|
|
3975
|
-
function
|
|
4371
|
+
function Ii() {
|
|
3976
4372
|
return typeof window != "undefined" && window.wx && window.wx.miniProgram && typeof window.wx.miniProgram.navigateTo == "function";
|
|
3977
4373
|
}
|
|
3978
|
-
function
|
|
3979
|
-
const e =
|
|
4374
|
+
function Ai(t) {
|
|
4375
|
+
const e = m(g({}, t), {
|
|
3980
4376
|
title: document.title || "",
|
|
3981
4377
|
url: window.location.href || ""
|
|
3982
4378
|
}), r = Object.entries(e).filter(([, n]) => n != null && n !== "").map(([n, i]) => `${encodeURIComponent(n)}=${encodeURIComponent(String(i))}`).join("&");
|
|
3983
|
-
return r ? `${
|
|
4379
|
+
return r ? `${De}?${r}` : De;
|
|
3984
4380
|
}
|
|
3985
|
-
function
|
|
3986
|
-
return
|
|
3987
|
-
if (!
|
|
4381
|
+
function Oi(t) {
|
|
4382
|
+
return f.safeExecute(() => {
|
|
4383
|
+
if (!Ii()) {
|
|
3988
4384
|
s.error("微信小程序导航API不可用");
|
|
3989
4385
|
return;
|
|
3990
4386
|
}
|
|
3991
|
-
const e =
|
|
4387
|
+
const e = Ai(t);
|
|
3992
4388
|
s.debug("跳转宿主人脸识别页面", {
|
|
3993
4389
|
name: t.name,
|
|
3994
4390
|
targetUrl: e
|
|
@@ -4006,33 +4402,33 @@ function Xn(t) {
|
|
|
4006
4402
|
platform: "weixin"
|
|
4007
4403
|
});
|
|
4008
4404
|
}
|
|
4009
|
-
function
|
|
4010
|
-
return
|
|
4011
|
-
if (!
|
|
4012
|
-
s.error("平台不支持人脸识别", { platform:
|
|
4405
|
+
function _i(t = {}) {
|
|
4406
|
+
return f.safeExecute(() => {
|
|
4407
|
+
if (!Wt()) {
|
|
4408
|
+
s.error("平台不支持人脸识别", { platform: l.type });
|
|
4013
4409
|
return;
|
|
4014
4410
|
}
|
|
4015
4411
|
let e;
|
|
4016
4412
|
try {
|
|
4017
|
-
e =
|
|
4413
|
+
e = yi(t);
|
|
4018
4414
|
} catch (r) {
|
|
4019
4415
|
s.error("人脸识别参数校验失败", r);
|
|
4020
4416
|
return;
|
|
4021
4417
|
}
|
|
4022
4418
|
s.info("开始人脸识别", {
|
|
4023
|
-
platform:
|
|
4419
|
+
platform: l.type,
|
|
4024
4420
|
name: e.name,
|
|
4025
|
-
pagePath:
|
|
4026
|
-
}),
|
|
4421
|
+
pagePath: De
|
|
4422
|
+
}), Oi(e);
|
|
4027
4423
|
}, {
|
|
4028
4424
|
context: "faceVerify",
|
|
4029
4425
|
options: t
|
|
4030
4426
|
});
|
|
4031
4427
|
}
|
|
4032
|
-
function
|
|
4428
|
+
function Ci() {
|
|
4033
4429
|
return {
|
|
4034
|
-
supported:
|
|
4035
|
-
environment:
|
|
4430
|
+
supported: Wt(),
|
|
4431
|
+
environment: l.type,
|
|
4036
4432
|
implementation: "weixin",
|
|
4037
4433
|
features: {
|
|
4038
4434
|
asyncSupport: !0,
|
|
@@ -4040,181 +4436,192 @@ function Qn() {
|
|
|
4040
4436
|
}
|
|
4041
4437
|
};
|
|
4042
4438
|
}
|
|
4043
|
-
const
|
|
4044
|
-
function
|
|
4439
|
+
const Bt = oe();
|
|
4440
|
+
function Pi() {
|
|
4045
4441
|
if (typeof window == "undefined" || !oe(!0).isWeixinMiniProgram)
|
|
4046
4442
|
return !1;
|
|
4047
|
-
const e =
|
|
4443
|
+
const e = xe().getRuntimeConfig();
|
|
4048
4444
|
return typeof e.clientId == "string" && e.clientId.length > 0;
|
|
4049
4445
|
}
|
|
4050
|
-
function
|
|
4051
|
-
return
|
|
4052
|
-
yield
|
|
4446
|
+
function Si() {
|
|
4447
|
+
return h(this, null, function* () {
|
|
4448
|
+
yield lr(), Pi() && (yield K());
|
|
4053
4449
|
});
|
|
4054
4450
|
}
|
|
4055
|
-
|
|
4056
|
-
let
|
|
4057
|
-
function
|
|
4058
|
-
if (
|
|
4059
|
-
|
|
4060
|
-
{ name: "load-weixin-sdk", run:
|
|
4061
|
-
{ 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 }
|
|
4062
4458
|
], {
|
|
4063
4459
|
onError: (e, r) => {
|
|
4064
4460
|
console.error(`[QSH-SDK] 初始化失败(${(r == null ? void 0 : r.name) || "unknown"}):`, e);
|
|
4065
4461
|
}
|
|
4066
4462
|
});
|
|
4067
4463
|
}
|
|
4068
|
-
typeof window != "undefined" && (document.readyState === "complete" || document.readyState === "interactive" ? setTimeout(
|
|
4069
|
-
function
|
|
4464
|
+
typeof window != "undefined" && (document.readyState === "complete" || document.readyState === "interactive" ? setTimeout(nt, 0) : document.addEventListener("DOMContentLoaded", nt));
|
|
4465
|
+
function I(t, { apiName: e } = {}) {
|
|
4070
4466
|
return function(r = {}, ...n) {
|
|
4071
|
-
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((
|
|
4072
|
-
const
|
|
4073
|
-
success: (
|
|
4074
|
-
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(_);
|
|
4075
4471
|
},
|
|
4076
|
-
fail: (
|
|
4077
|
-
typeof a.fail == "function" && a.fail(
|
|
4472
|
+
fail: (_) => {
|
|
4473
|
+
typeof a.fail == "function" && a.fail(_), O(_);
|
|
4078
4474
|
},
|
|
4079
4475
|
complete: a.complete
|
|
4080
4476
|
});
|
|
4081
|
-
t(
|
|
4477
|
+
t(R, ...n);
|
|
4082
4478
|
});
|
|
4083
|
-
return (typeof window == "undefined" ? Promise.resolve() :
|
|
4084
|
-
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;
|
|
4085
4481
|
});
|
|
4086
4482
|
};
|
|
4087
4483
|
}
|
|
4088
|
-
function
|
|
4484
|
+
function Ae(t) {
|
|
4089
4485
|
return typeof t == "function" ? { success: t } : t && typeof t == "object" ? t : {};
|
|
4090
4486
|
}
|
|
4091
|
-
const
|
|
4092
|
-
function
|
|
4093
|
-
const e = () =>
|
|
4094
|
-
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());
|
|
4095
4491
|
}
|
|
4096
|
-
const
|
|
4097
|
-
function
|
|
4492
|
+
const Fe = I(dn, { apiName: "getCode" });
|
|
4493
|
+
function Ni(t = {}) {
|
|
4098
4494
|
return new Promise((e, r) => {
|
|
4099
|
-
|
|
4495
|
+
Fe(m(g({}, t), {
|
|
4100
4496
|
success: e,
|
|
4101
4497
|
fail: r
|
|
4102
4498
|
}));
|
|
4103
4499
|
});
|
|
4104
4500
|
}
|
|
4105
|
-
const
|
|
4106
|
-
function
|
|
4501
|
+
const Ke = I(hn);
|
|
4502
|
+
function Ri(t = {}) {
|
|
4107
4503
|
return new Promise((e, r) => {
|
|
4108
|
-
|
|
4504
|
+
Ke(m(g({}, t), {
|
|
4109
4505
|
success: e,
|
|
4110
4506
|
fail: r
|
|
4111
4507
|
}));
|
|
4112
4508
|
});
|
|
4113
4509
|
}
|
|
4114
|
-
const
|
|
4115
|
-
function
|
|
4510
|
+
const qt = I(wi);
|
|
4511
|
+
function bi(t = {}) {
|
|
4116
4512
|
return new Promise((e, r) => {
|
|
4117
|
-
|
|
4513
|
+
qt(m(g({}, t), {
|
|
4118
4514
|
success: e,
|
|
4119
4515
|
fail: r
|
|
4120
4516
|
}));
|
|
4121
4517
|
});
|
|
4122
4518
|
}
|
|
4123
|
-
const
|
|
4124
|
-
function
|
|
4519
|
+
const ze = I(On), Ti = I(_i);
|
|
4520
|
+
function Mi(t = {}) {
|
|
4125
4521
|
return new Promise((e, r) => {
|
|
4126
|
-
|
|
4522
|
+
ze(m(g({}, t), {
|
|
4127
4523
|
success: e,
|
|
4128
4524
|
fail: r
|
|
4129
4525
|
}));
|
|
4130
4526
|
});
|
|
4131
4527
|
}
|
|
4132
|
-
const
|
|
4133
|
-
function
|
|
4528
|
+
const Li = I(vt), xi = I(ei), Ge = I(Mn);
|
|
4529
|
+
function vi(t = {}) {
|
|
4134
4530
|
return new Promise((e, r) => {
|
|
4135
|
-
|
|
4531
|
+
Ge(m(g({}, t), {
|
|
4136
4532
|
success: e,
|
|
4137
4533
|
fail: r
|
|
4138
4534
|
}));
|
|
4139
4535
|
});
|
|
4140
4536
|
}
|
|
4141
|
-
const
|
|
4142
|
-
function
|
|
4537
|
+
const Ve = I(Ln);
|
|
4538
|
+
function Di(t = {}) {
|
|
4143
4539
|
return new Promise((e, r) => {
|
|
4144
|
-
|
|
4540
|
+
Ve(m(g({}, t), {
|
|
4145
4541
|
success: e,
|
|
4146
4542
|
fail: r
|
|
4147
4543
|
}));
|
|
4148
4544
|
});
|
|
4149
4545
|
}
|
|
4150
|
-
const
|
|
4151
|
-
function
|
|
4546
|
+
const qe = I(zn);
|
|
4547
|
+
function Ui(t = {}) {
|
|
4152
4548
|
return new Promise((e, r) => {
|
|
4153
|
-
|
|
4549
|
+
qe(m(g({}, t), {
|
|
4154
4550
|
success: e,
|
|
4155
4551
|
fail: r
|
|
4156
4552
|
}));
|
|
4157
4553
|
});
|
|
4158
4554
|
}
|
|
4159
|
-
const
|
|
4160
|
-
function
|
|
4555
|
+
const jt = I(li);
|
|
4556
|
+
function Wi(t = {}) {
|
|
4161
4557
|
return new Promise((e, r) => {
|
|
4162
|
-
|
|
4558
|
+
jt(m(g({}, t), {
|
|
4163
4559
|
success: e,
|
|
4164
4560
|
fail: r
|
|
4165
4561
|
}));
|
|
4166
4562
|
});
|
|
4167
4563
|
}
|
|
4168
|
-
const
|
|
4169
|
-
function
|
|
4564
|
+
const Jt = I(fi);
|
|
4565
|
+
function Bi(t = {}) {
|
|
4170
4566
|
return new Promise((e, r) => {
|
|
4171
|
-
|
|
4567
|
+
Jt(m(g({}, t), {
|
|
4172
4568
|
success: e,
|
|
4173
4569
|
fail: r
|
|
4174
4570
|
}));
|
|
4175
4571
|
});
|
|
4176
4572
|
}
|
|
4177
|
-
const
|
|
4178
|
-
function
|
|
4573
|
+
const Ht = I(Dt);
|
|
4574
|
+
function $i(t = {}) {
|
|
4575
|
+
return new Promise((e, r) => {
|
|
4576
|
+
Ht(m(g({}, t), {
|
|
4577
|
+
success: e,
|
|
4578
|
+
fail: r
|
|
4579
|
+
}));
|
|
4580
|
+
});
|
|
4581
|
+
}
|
|
4582
|
+
const Yt = I(di);
|
|
4583
|
+
function ki(t = {}) {
|
|
4179
4584
|
return new Promise((e, r) => {
|
|
4180
|
-
|
|
4585
|
+
Yt(m(g({}, t), {
|
|
4181
4586
|
success: e,
|
|
4182
4587
|
fail: r
|
|
4183
4588
|
}));
|
|
4184
4589
|
});
|
|
4185
4590
|
}
|
|
4186
|
-
const
|
|
4591
|
+
const ae = {
|
|
4187
4592
|
// 导航 API
|
|
4188
|
-
navigateTo:
|
|
4189
|
-
navigateBack:
|
|
4190
|
-
switchTab:
|
|
4191
|
-
reLaunch:
|
|
4192
|
-
redirectTo:
|
|
4593
|
+
navigateTo: $t,
|
|
4594
|
+
navigateBack: kt,
|
|
4595
|
+
switchTab: Ft,
|
|
4596
|
+
reLaunch: Kt,
|
|
4597
|
+
redirectTo: zt,
|
|
4193
4598
|
// 消息 API
|
|
4194
|
-
postMessage:
|
|
4195
|
-
getEnv:
|
|
4599
|
+
postMessage: Gt,
|
|
4600
|
+
getEnv: Vt,
|
|
4601
|
+
getCode: Fe,
|
|
4602
|
+
getCodeAsync: Ni,
|
|
4196
4603
|
// 图片 API
|
|
4197
|
-
chooseImage:
|
|
4198
|
-
chooseImageAsync:
|
|
4604
|
+
chooseImage: Ke,
|
|
4605
|
+
chooseImageAsync: Ri,
|
|
4199
4606
|
// 扫码 API
|
|
4200
|
-
scanCode:
|
|
4201
|
-
scanCodeAsync:
|
|
4607
|
+
scanCode: ze,
|
|
4608
|
+
scanCodeAsync: Mi,
|
|
4202
4609
|
// 位置 API
|
|
4203
|
-
getLocation:
|
|
4204
|
-
getLocationAsync:
|
|
4205
|
-
openLocation:
|
|
4206
|
-
openLocationAsync:
|
|
4207
|
-
chooseLocation:
|
|
4208
|
-
chooseLocationAsync:
|
|
4610
|
+
getLocation: Ge,
|
|
4611
|
+
getLocationAsync: vi,
|
|
4612
|
+
openLocation: Ve,
|
|
4613
|
+
openLocationAsync: Di,
|
|
4614
|
+
chooseLocation: qe,
|
|
4615
|
+
chooseLocationAsync: Ui,
|
|
4209
4616
|
// 位置监听 API(保留回调签名)
|
|
4210
|
-
onLocationChange: (t) =>
|
|
4211
|
-
offLocationChange: (t) =>
|
|
4212
|
-
onLocationChangeError: (t) =>
|
|
4213
|
-
offLocationChangeError: (t) =>
|
|
4214
|
-
startLocationUpdate:
|
|
4215
|
-
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" }),
|
|
4216
4623
|
// 环境信息
|
|
4217
|
-
environment:
|
|
4624
|
+
environment: Bt,
|
|
4218
4625
|
/**
|
|
4219
4626
|
* Wait for SDK readiness.
|
|
4220
4627
|
* In Weixin mini-program web-view, if qsh.config({ clientId }) was called,
|
|
@@ -4224,7 +4631,7 @@ const te = {
|
|
|
4224
4631
|
* await qsh.ready()
|
|
4225
4632
|
* @since 2.0.0
|
|
4226
4633
|
*/
|
|
4227
|
-
ready:
|
|
4634
|
+
ready: Si,
|
|
4228
4635
|
/**
|
|
4229
4636
|
* 手动初始化 JSBridge
|
|
4230
4637
|
* 默认会在 DOM 就绪时自动初始化;如需更早或手动控制,可调用本方法。
|
|
@@ -4233,7 +4640,7 @@ const te = {
|
|
|
4233
4640
|
* await qsh.init()
|
|
4234
4641
|
* @since 2.0.0
|
|
4235
4642
|
*/
|
|
4236
|
-
init:
|
|
4643
|
+
init: ot,
|
|
4237
4644
|
/**
|
|
4238
4645
|
* 检查 JSBridge 是否就绪
|
|
4239
4646
|
* @returns {boolean}
|
|
@@ -4241,7 +4648,7 @@ const te = {
|
|
|
4241
4648
|
* if (qsh.isReady()) { console.log('ready') }
|
|
4242
4649
|
* @since 2.0.0
|
|
4243
4650
|
*/
|
|
4244
|
-
isReady:
|
|
4651
|
+
isReady: ir,
|
|
4245
4652
|
/**
|
|
4246
4653
|
* 获取当前 SDK 状态
|
|
4247
4654
|
* @returns {string}
|
|
@@ -4249,8 +4656,8 @@ const te = {
|
|
|
4249
4656
|
* console.log(qsh.getState()) // 'ready'
|
|
4250
4657
|
* @since 2.0.0
|
|
4251
4658
|
*/
|
|
4252
|
-
getState:
|
|
4253
|
-
config:
|
|
4659
|
+
getState: sr,
|
|
4660
|
+
config: Qe,
|
|
4254
4661
|
// 微信配置 API
|
|
4255
4662
|
weixin: {
|
|
4256
4663
|
/**
|
|
@@ -4260,8 +4667,8 @@ const te = {
|
|
|
4260
4667
|
* await qsh.weixin.waitForConfig()
|
|
4261
4668
|
* @since 2.0.0
|
|
4262
4669
|
*/
|
|
4263
|
-
config:
|
|
4264
|
-
waitForConfig:
|
|
4670
|
+
config: Qe,
|
|
4671
|
+
waitForConfig: K,
|
|
4265
4672
|
/**
|
|
4266
4673
|
* 检查微信配置是否完成
|
|
4267
4674
|
* @returns {boolean}
|
|
@@ -4269,7 +4676,7 @@ const te = {
|
|
|
4269
4676
|
* if (qsh.weixin.isConfigReady()) { wx.chooseImage({}) }
|
|
4270
4677
|
* @since 2.0.0
|
|
4271
4678
|
*/
|
|
4272
|
-
isConfigReady:
|
|
4679
|
+
isConfigReady: j,
|
|
4273
4680
|
/**
|
|
4274
4681
|
* 获取微信配置状态
|
|
4275
4682
|
* @returns {string}
|
|
@@ -4277,7 +4684,7 @@ const te = {
|
|
|
4277
4684
|
* console.log(qsh.weixin.getConfigState()) // 'configured'
|
|
4278
4685
|
* @since 2.0.0
|
|
4279
4686
|
*/
|
|
4280
|
-
getConfigState:
|
|
4687
|
+
getConfigState: mr,
|
|
4281
4688
|
/**
|
|
4282
4689
|
* 手动重试微信配置
|
|
4283
4690
|
* @returns {Promise<void>}
|
|
@@ -4285,13 +4692,13 @@ const te = {
|
|
|
4285
4692
|
* await qsh.weixin.retryConfig()
|
|
4286
4693
|
* @since 2.0.0
|
|
4287
4694
|
*/
|
|
4288
|
-
retryConfig:
|
|
4695
|
+
retryConfig: hr
|
|
4289
4696
|
},
|
|
4290
4697
|
// WebView 对象(兼容旧版本)
|
|
4291
4698
|
webView: null,
|
|
4292
4699
|
// 图片相关常量
|
|
4293
|
-
ImageSourceTypes:
|
|
4294
|
-
ImageSizeTypes:
|
|
4700
|
+
ImageSourceTypes: Ce,
|
|
4701
|
+
ImageSizeTypes: Pe,
|
|
4295
4702
|
/**
|
|
4296
4703
|
* 获取图片功能能力信息
|
|
4297
4704
|
* @returns {Object} 能力信息对象
|
|
@@ -4300,9 +4707,9 @@ const te = {
|
|
|
4300
4707
|
* console.log('是否支持:', capabilities.supported)
|
|
4301
4708
|
* @since 2.0.0
|
|
4302
4709
|
*/
|
|
4303
|
-
getImageCapabilities:
|
|
4710
|
+
getImageCapabilities: wn,
|
|
4304
4711
|
// 扫码相关常量
|
|
4305
|
-
ScanTypes:
|
|
4712
|
+
ScanTypes: Z,
|
|
4306
4713
|
/**
|
|
4307
4714
|
* 获取扫码功能能力信息
|
|
4308
4715
|
* @returns {Object} 能力信息对象
|
|
@@ -4311,9 +4718,9 @@ const te = {
|
|
|
4311
4718
|
* console.log('是否支持:', capabilities.supported)
|
|
4312
4719
|
* @since 2.1.0
|
|
4313
4720
|
*/
|
|
4314
|
-
getScanCapabilities:
|
|
4721
|
+
getScanCapabilities: _n,
|
|
4315
4722
|
// 位置相关常量
|
|
4316
|
-
CoordinateTypes:
|
|
4723
|
+
CoordinateTypes: se,
|
|
4317
4724
|
/**
|
|
4318
4725
|
* 获取位置功能能力信息
|
|
4319
4726
|
* @returns {Object} 能力信息对象
|
|
@@ -4322,7 +4729,7 @@ const te = {
|
|
|
4322
4729
|
* console.log('是否支持:', capabilities.supported)
|
|
4323
4730
|
* @since 2.1.0
|
|
4324
4731
|
*/
|
|
4325
|
-
getLocationCapabilities:
|
|
4732
|
+
getLocationCapabilities: xn,
|
|
4326
4733
|
/**
|
|
4327
4734
|
* 获取位置选择功能能力信息
|
|
4328
4735
|
* @returns {Object} 能力信息对象
|
|
@@ -4331,23 +4738,27 @@ const te = {
|
|
|
4331
4738
|
* console.log('是否支持:', capabilities.supported)
|
|
4332
4739
|
* @since 2.1.0
|
|
4333
4740
|
*/
|
|
4334
|
-
getChooseLocationCapabilities:
|
|
4741
|
+
getChooseLocationCapabilities: Gn,
|
|
4335
4742
|
// 蓝牙 API
|
|
4336
|
-
openBluetoothAdapter:
|
|
4337
|
-
openBluetoothAdapterAsync:
|
|
4338
|
-
startBluetoothDevicesDiscovery:
|
|
4339
|
-
startBluetoothDevicesDiscoveryAsync:
|
|
4340
|
-
onBluetoothDeviceFound:
|
|
4341
|
-
onBluetoothDeviceFoundAsync:
|
|
4342
|
-
createBLEConnection:
|
|
4343
|
-
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,
|
|
4344
4751
|
// 蓝牙相关常量
|
|
4345
|
-
BluetoothStates:
|
|
4752
|
+
BluetoothStates: ni,
|
|
4346
4753
|
//微信分享
|
|
4347
|
-
toShare:
|
|
4348
|
-
toShareAsync:
|
|
4349
|
-
|
|
4350
|
-
|
|
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,
|
|
4351
4762
|
/**
|
|
4352
4763
|
* 获取蓝牙功能能力信息
|
|
4353
4764
|
* @returns {Object} 能力信息对象
|
|
@@ -4355,10 +4766,10 @@ const te = {
|
|
|
4355
4766
|
* const capabilities = qsh.getBluetoothCapabilities()
|
|
4356
4767
|
* console.log('是否支持:', capabilities.supported)
|
|
4357
4768
|
*/
|
|
4358
|
-
getBluetoothCapabilities:
|
|
4769
|
+
getBluetoothCapabilities: gi,
|
|
4359
4770
|
// 打印PDF API
|
|
4360
|
-
printPdf:
|
|
4361
|
-
printPdfAsync:
|
|
4771
|
+
printPdf: qt,
|
|
4772
|
+
printPdfAsync: bi,
|
|
4362
4773
|
/**
|
|
4363
4774
|
* 获取打印PDF功能能力信息
|
|
4364
4775
|
* @returns {Object} 能力信息对象
|
|
@@ -4366,16 +4777,16 @@ const te = {
|
|
|
4366
4777
|
* const capabilities = qsh.getPrintCapabilities()
|
|
4367
4778
|
* console.log('是否支持:', capabilities.supported)
|
|
4368
4779
|
*/
|
|
4369
|
-
getPrintCapabilities:
|
|
4780
|
+
getPrintCapabilities: Ei,
|
|
4370
4781
|
// 人脸识别 API(仅支持微信小程序环境)
|
|
4371
|
-
faceVerify:
|
|
4372
|
-
getFaceCapabilities:
|
|
4782
|
+
faceVerify: Ti,
|
|
4783
|
+
getFaceCapabilities: Ci,
|
|
4373
4784
|
// 插件系统
|
|
4374
4785
|
plugins: {
|
|
4375
4786
|
/**
|
|
4376
4787
|
* 插件管理器
|
|
4377
4788
|
*/
|
|
4378
|
-
manager:
|
|
4789
|
+
manager: le,
|
|
4379
4790
|
/**
|
|
4380
4791
|
* 注册插件
|
|
4381
4792
|
* @param {Object} plugin - 插件对象
|
|
@@ -4383,7 +4794,7 @@ const te = {
|
|
|
4383
4794
|
* @example
|
|
4384
4795
|
* qsh.plugins.register(myPlugin)
|
|
4385
4796
|
*/
|
|
4386
|
-
register: (t) =>
|
|
4797
|
+
register: (t) => le.register(t),
|
|
4387
4798
|
/**
|
|
4388
4799
|
* 安装插件
|
|
4389
4800
|
* @param {string} name - 插件名称
|
|
@@ -4391,21 +4802,21 @@ const te = {
|
|
|
4391
4802
|
* @example
|
|
4392
4803
|
* await qsh.plugins.install('image')
|
|
4393
4804
|
*/
|
|
4394
|
-
install: (t) =>
|
|
4805
|
+
install: (t) => le.install(t, ae),
|
|
4395
4806
|
/**
|
|
4396
4807
|
* 获取插件列表
|
|
4397
4808
|
* @returns {Array} 插件列表
|
|
4398
4809
|
* @example
|
|
4399
4810
|
* console.log(qsh.plugins.list())
|
|
4400
4811
|
*/
|
|
4401
|
-
list: () =>
|
|
4812
|
+
list: () => le.getPluginList()
|
|
4402
4813
|
},
|
|
4403
4814
|
// 拦截器系统
|
|
4404
4815
|
interceptors: {
|
|
4405
4816
|
/**
|
|
4406
4817
|
* 拦截器链
|
|
4407
4818
|
*/
|
|
4408
|
-
chain:
|
|
4819
|
+
chain: Y,
|
|
4409
4820
|
/**
|
|
4410
4821
|
* 注册请求拦截器
|
|
4411
4822
|
* @param {Function} interceptor - 拦截器函数
|
|
@@ -4417,7 +4828,7 @@ const te = {
|
|
|
4417
4828
|
* return ctx
|
|
4418
4829
|
* })
|
|
4419
4830
|
*/
|
|
4420
|
-
useRequest: (t, e) =>
|
|
4831
|
+
useRequest: (t, e) => Y.useRequest(t, e),
|
|
4421
4832
|
/**
|
|
4422
4833
|
* 注册响应拦截器
|
|
4423
4834
|
* @param {Function} interceptor - 拦截器函数
|
|
@@ -4429,16 +4840,16 @@ const te = {
|
|
|
4429
4840
|
* return result
|
|
4430
4841
|
* })
|
|
4431
4842
|
*/
|
|
4432
|
-
useResponse: (t, e) =>
|
|
4843
|
+
useResponse: (t, e) => Y.useResponse(t, e),
|
|
4433
4844
|
/**
|
|
4434
4845
|
* 内置拦截器
|
|
4435
4846
|
*/
|
|
4436
4847
|
builtin: {
|
|
4437
|
-
logging:
|
|
4438
|
-
performance:
|
|
4439
|
-
createRetry:
|
|
4440
|
-
createValidation:
|
|
4441
|
-
errorNormalizer:
|
|
4848
|
+
logging: yr,
|
|
4849
|
+
performance: G,
|
|
4850
|
+
createRetry: Ir,
|
|
4851
|
+
createValidation: Ar,
|
|
4852
|
+
errorNormalizer: dt
|
|
4442
4853
|
}
|
|
4443
4854
|
},
|
|
4444
4855
|
// 观测指标
|
|
@@ -4446,11 +4857,11 @@ const te = {
|
|
|
4446
4857
|
/**
|
|
4447
4858
|
* 获取性能指标报告
|
|
4448
4859
|
*/
|
|
4449
|
-
getPerformanceReport: () =>
|
|
4860
|
+
getPerformanceReport: () => G.getReport(),
|
|
4450
4861
|
/**
|
|
4451
4862
|
* 清空性能指标
|
|
4452
4863
|
*/
|
|
4453
|
-
clearPerformanceMetrics: () =>
|
|
4864
|
+
clearPerformanceMetrics: () => G.clearMetrics()
|
|
4454
4865
|
},
|
|
4455
4866
|
// 错误处理工具
|
|
4456
4867
|
errors: {
|
|
@@ -4461,11 +4872,11 @@ const te = {
|
|
|
4461
4872
|
/**
|
|
4462
4873
|
* 错误消息
|
|
4463
4874
|
*/
|
|
4464
|
-
messages:
|
|
4875
|
+
messages: ve,
|
|
4465
4876
|
/**
|
|
4466
4877
|
* 错误分类
|
|
4467
4878
|
*/
|
|
4468
|
-
categories:
|
|
4879
|
+
categories: W,
|
|
4469
4880
|
/**
|
|
4470
4881
|
* 标准化错误
|
|
4471
4882
|
* @param {any} error - 原始错误
|
|
@@ -4474,7 +4885,7 @@ const te = {
|
|
|
4474
4885
|
* @example
|
|
4475
4886
|
* const standardError = qsh.errors.normalize(error, { apiName: 'chooseImage' })
|
|
4476
4887
|
*/
|
|
4477
|
-
normalize:
|
|
4888
|
+
normalize: ft,
|
|
4478
4889
|
/**
|
|
4479
4890
|
* 创建标准错误
|
|
4480
4891
|
* @param {string} code - 错误码
|
|
@@ -4483,7 +4894,7 @@ const te = {
|
|
|
4483
4894
|
* @example
|
|
4484
4895
|
* const error = qsh.errors.create('E_IMG_001', { apiName: 'chooseImage' })
|
|
4485
4896
|
*/
|
|
4486
|
-
create:
|
|
4897
|
+
create: Rr,
|
|
4487
4898
|
/**
|
|
4488
4899
|
* 判断是否为标准错误
|
|
4489
4900
|
* @param {any} error - 错误对象
|
|
@@ -4491,14 +4902,14 @@ const te = {
|
|
|
4491
4902
|
* @example
|
|
4492
4903
|
* if (qsh.errors.isStandard(error)) { ... }
|
|
4493
4904
|
*/
|
|
4494
|
-
isStandard:
|
|
4905
|
+
isStandard: br
|
|
4495
4906
|
},
|
|
4496
4907
|
// 状态管理
|
|
4497
4908
|
store: {
|
|
4498
4909
|
/**
|
|
4499
4910
|
* 状态仓库实例
|
|
4500
4911
|
*/
|
|
4501
|
-
instance:
|
|
4912
|
+
instance: $,
|
|
4502
4913
|
/**
|
|
4503
4914
|
* 获取状态
|
|
4504
4915
|
* @param {string} path - 状态路径
|
|
@@ -4506,7 +4917,7 @@ const te = {
|
|
|
4506
4917
|
* @example
|
|
4507
4918
|
* const status = qsh.store.get('sdk.status')
|
|
4508
4919
|
*/
|
|
4509
|
-
get: (t) =>
|
|
4920
|
+
get: (t) => $.get(t),
|
|
4510
4921
|
/**
|
|
4511
4922
|
* 设置状态
|
|
4512
4923
|
* @param {string} path - 状态路径
|
|
@@ -4514,7 +4925,7 @@ const te = {
|
|
|
4514
4925
|
* @example
|
|
4515
4926
|
* qsh.store.set('sdk.status', 'ready')
|
|
4516
4927
|
*/
|
|
4517
|
-
set: (t, e) =>
|
|
4928
|
+
set: (t, e) => $.set(t, e),
|
|
4518
4929
|
/**
|
|
4519
4930
|
* 订阅状态变化
|
|
4520
4931
|
* @param {string} path - 状态路径
|
|
@@ -4525,39 +4936,39 @@ const te = {
|
|
|
4525
4936
|
* console.log('网络状态:', online)
|
|
4526
4937
|
* })
|
|
4527
4938
|
*/
|
|
4528
|
-
subscribe: (t, e) =>
|
|
4939
|
+
subscribe: (t, e) => $.subscribe(t, e),
|
|
4529
4940
|
/**
|
|
4530
4941
|
* 获取状态快照
|
|
4531
4942
|
* @returns {Object} 状态快照
|
|
4532
4943
|
* @example
|
|
4533
4944
|
* console.log(qsh.store.getSnapshot())
|
|
4534
4945
|
*/
|
|
4535
|
-
getSnapshot: () =>
|
|
4946
|
+
getSnapshot: () => $.getSnapshot()
|
|
4536
4947
|
},
|
|
4537
4948
|
// 调试工具(生产环境可能被优化掉)
|
|
4538
4949
|
debug: {
|
|
4539
4950
|
/**
|
|
4540
4951
|
* 日志记录器
|
|
4541
4952
|
*/
|
|
4542
|
-
logger:
|
|
4953
|
+
logger: M,
|
|
4543
4954
|
/**
|
|
4544
4955
|
* 设置外部日志 reporter,便于对接埋点/观测
|
|
4545
4956
|
*/
|
|
4546
|
-
setLogReporter: (t) =>
|
|
4957
|
+
setLogReporter: (t) => M.setReporter(t),
|
|
4547
4958
|
/**
|
|
4548
4959
|
* 错误处理器
|
|
4549
4960
|
*/
|
|
4550
|
-
errorHandler:
|
|
4961
|
+
errorHandler: f,
|
|
4551
4962
|
/**
|
|
4552
4963
|
* 状态管理器
|
|
4553
4964
|
*/
|
|
4554
|
-
stateManager:
|
|
4965
|
+
stateManager: X,
|
|
4555
4966
|
/**
|
|
4556
4967
|
* 启用调试模式
|
|
4557
4968
|
* @example
|
|
4558
4969
|
* qsh.debug.enableDevMode()
|
|
4559
4970
|
*/
|
|
4560
|
-
enableDevMode: () =>
|
|
4971
|
+
enableDevMode: () => M.enableDevMode(),
|
|
4561
4972
|
/**
|
|
4562
4973
|
* 获取日志历史
|
|
4563
4974
|
* @param {number} [count] - 获取条数
|
|
@@ -4565,7 +4976,7 @@ const te = {
|
|
|
4565
4976
|
* @example
|
|
4566
4977
|
* console.log(qsh.debug.getLogs(10))
|
|
4567
4978
|
*/
|
|
4568
|
-
getLogs: (t) =>
|
|
4979
|
+
getLogs: (t) => M.getHistory(t),
|
|
4569
4980
|
/**
|
|
4570
4981
|
* 获取 SDK 统计信息
|
|
4571
4982
|
* @returns {Object} 统计信息
|
|
@@ -4573,12 +4984,12 @@ const te = {
|
|
|
4573
4984
|
* console.log(qsh.debug.getStats())
|
|
4574
4985
|
*/
|
|
4575
4986
|
getStats: () => ({
|
|
4576
|
-
logger:
|
|
4577
|
-
state:
|
|
4578
|
-
weixinConfig:
|
|
4579
|
-
plugins:
|
|
4580
|
-
interceptors:
|
|
4581
|
-
store:
|
|
4987
|
+
logger: M.getStats(),
|
|
4988
|
+
state: X.getStats(),
|
|
4989
|
+
weixinConfig: xe().getStats(),
|
|
4990
|
+
plugins: le.getStats(),
|
|
4991
|
+
interceptors: Y.getStats(),
|
|
4992
|
+
store: $.getStats()
|
|
4582
4993
|
}),
|
|
4583
4994
|
/**
|
|
4584
4995
|
* 获取微信配置管理器
|
|
@@ -4586,36 +4997,37 @@ const te = {
|
|
|
4586
4997
|
* @example
|
|
4587
4998
|
* console.log(qsh.debug.getWeixinConfigManager().getStats())
|
|
4588
4999
|
*/
|
|
4589
|
-
getWeixinConfigManager:
|
|
5000
|
+
getWeixinConfigManager: xe,
|
|
4590
5001
|
/**
|
|
4591
5002
|
* 导出调试信息
|
|
4592
5003
|
* @returns {string} JSON 格式的调试信息
|
|
4593
5004
|
* @example
|
|
4594
5005
|
* console.log(qsh.debug.exportDebugInfo())
|
|
4595
5006
|
*/
|
|
4596
|
-
exportDebugInfo: () =>
|
|
5007
|
+
exportDebugInfo: () => M.exportToJSON()
|
|
4597
5008
|
}
|
|
4598
5009
|
};
|
|
4599
|
-
|
|
4600
|
-
navigateTo:
|
|
4601
|
-
navigateBack:
|
|
4602
|
-
switchTab:
|
|
4603
|
-
reLaunch:
|
|
4604
|
-
redirectTo:
|
|
4605
|
-
postMessage:
|
|
4606
|
-
getEnv:
|
|
4607
|
-
|
|
4608
|
-
|
|
4609
|
-
|
|
4610
|
-
|
|
4611
|
-
|
|
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
|
|
4612
5024
|
};
|
|
4613
|
-
const
|
|
4614
|
-
Object.keys(
|
|
4615
|
-
|
|
5025
|
+
const it = typeof window.uni != "undefined" ? window.uni : {};
|
|
5026
|
+
Object.keys(it).forEach((t) => {
|
|
5027
|
+
ae.hasOwnProperty(t) || (ae[t] = it[t]);
|
|
4616
5028
|
});
|
|
4617
|
-
typeof window != "undefined" && (window.qsh =
|
|
5029
|
+
typeof window != "undefined" && (window.qsh = ae);
|
|
4618
5030
|
export {
|
|
4619
|
-
|
|
5031
|
+
ae as default
|
|
4620
5032
|
};
|
|
4621
5033
|
//# sourceMappingURL=qsh-webview-sdk.es.js.map
|