qsh-webview-sdk 2.3.3 → 2.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +42 -7
- package/dist/qsh-webview-sdk.es.js +1231 -1081
- package/dist/qsh-webview-sdk.es.js.map +1 -1
- package/dist/qsh-webview-sdk.umd.js +1 -1
- package/dist/qsh-webview-sdk.umd.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,71 +1,71 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
1
|
+
var qt = Object.defineProperty, zt = Object.defineProperties;
|
|
2
|
+
var jt = Object.getOwnPropertyDescriptors;
|
|
3
|
+
var qe = Object.getOwnPropertySymbols;
|
|
4
|
+
var Jt = Object.prototype.hasOwnProperty, Ht = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var Ne = (t, e, r) => e in t ? qt(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r, h = (t, e) => {
|
|
6
6
|
for (var r in e || (e = {}))
|
|
7
|
-
|
|
8
|
-
if (
|
|
9
|
-
for (var r of
|
|
10
|
-
|
|
7
|
+
Jt.call(e, r) && Ne(t, r, e[r]);
|
|
8
|
+
if (qe)
|
|
9
|
+
for (var r of qe(e))
|
|
10
|
+
Ht.call(e, r) && Ne(t, r, e[r]);
|
|
11
11
|
return t;
|
|
12
|
-
}, m = (t, e) =>
|
|
13
|
-
var
|
|
14
|
-
var
|
|
15
|
-
var s = (
|
|
12
|
+
}, m = (t, e) => zt(t, jt(e));
|
|
13
|
+
var k = (t, e, r) => Ne(t, typeof e != "symbol" ? e + "" : e, r);
|
|
14
|
+
var p = (t, e, r) => new Promise((n, i) => {
|
|
15
|
+
var s = (l) => {
|
|
16
16
|
try {
|
|
17
|
-
|
|
18
|
-
} catch (
|
|
19
|
-
i(
|
|
17
|
+
d(r.next(l));
|
|
18
|
+
} catch (w) {
|
|
19
|
+
i(w);
|
|
20
20
|
}
|
|
21
|
-
},
|
|
21
|
+
}, o = (l) => {
|
|
22
22
|
try {
|
|
23
|
-
|
|
24
|
-
} catch (
|
|
25
|
-
i(
|
|
23
|
+
d(r.throw(l));
|
|
24
|
+
} catch (w) {
|
|
25
|
+
i(w);
|
|
26
26
|
}
|
|
27
|
-
},
|
|
28
|
-
|
|
27
|
+
}, d = (l) => l.done ? n(l.value) : Promise.resolve(l.value).then(s, o);
|
|
28
|
+
d((r = r.apply(t, e)).next());
|
|
29
29
|
});
|
|
30
|
-
function
|
|
30
|
+
function ge() {
|
|
31
31
|
return typeof window != "undefined" ? window : void 0;
|
|
32
32
|
}
|
|
33
|
-
function
|
|
33
|
+
function be() {
|
|
34
34
|
return typeof navigator == "undefined" ? "" : navigator.userAgent || "";
|
|
35
35
|
}
|
|
36
|
-
function
|
|
37
|
-
const t =
|
|
36
|
+
function _() {
|
|
37
|
+
const t = ge();
|
|
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 = be();
|
|
42
42
|
return !!(e && /micromessenger/i.test(e) && /miniProgram/i.test(e));
|
|
43
43
|
}
|
|
44
|
-
function
|
|
45
|
-
const t =
|
|
44
|
+
function _e() {
|
|
45
|
+
const t = ge();
|
|
46
46
|
return !!(t && t.plus);
|
|
47
47
|
}
|
|
48
|
-
function
|
|
49
|
-
const t =
|
|
48
|
+
function Ce() {
|
|
49
|
+
const t = ge();
|
|
50
50
|
return !!(t && (t.__dcloud_weex_postMessage || t.__dcloud_weex_));
|
|
51
51
|
}
|
|
52
|
-
function
|
|
53
|
-
const t =
|
|
52
|
+
function Me() {
|
|
53
|
+
const t = ge();
|
|
54
54
|
return !!(t && (t.__uniapp_x_postMessage || t.__uniapp_x_));
|
|
55
55
|
}
|
|
56
|
-
function
|
|
57
|
-
const t =
|
|
56
|
+
function Oe() {
|
|
57
|
+
const t = be();
|
|
58
58
|
return /uni-app/i.test(t);
|
|
59
59
|
}
|
|
60
|
-
function
|
|
61
|
-
const t =
|
|
60
|
+
function ve() {
|
|
61
|
+
const t = be();
|
|
62
62
|
return /Html5Plus/i.test(t);
|
|
63
63
|
}
|
|
64
|
-
function
|
|
65
|
-
return
|
|
64
|
+
function Qe() {
|
|
65
|
+
return Oe() || ve();
|
|
66
66
|
}
|
|
67
|
-
function
|
|
68
|
-
const t =
|
|
67
|
+
function X() {
|
|
68
|
+
const t = ge();
|
|
69
69
|
if (!t) return !1;
|
|
70
70
|
if (t.__offline_bridge_postMessage) return !0;
|
|
71
71
|
try {
|
|
@@ -75,31 +75,31 @@ function J() {
|
|
|
75
75
|
}
|
|
76
76
|
return !1;
|
|
77
77
|
}
|
|
78
|
-
function
|
|
79
|
-
return
|
|
80
|
-
}
|
|
81
|
-
let
|
|
82
|
-
function
|
|
83
|
-
return
|
|
84
|
-
isWeixinMiniProgram:
|
|
85
|
-
isAppPlus:
|
|
86
|
-
isNvue:
|
|
87
|
-
isUvue:
|
|
88
|
-
isUniApp:
|
|
89
|
-
isHtml5Plus:
|
|
90
|
-
isUniAppWebView:
|
|
91
|
-
isOfflineWebview:
|
|
92
|
-
type:
|
|
93
|
-
}),
|
|
94
|
-
}
|
|
95
|
-
const
|
|
78
|
+
function Yt() {
|
|
79
|
+
return Me() ? "uvue" : Ce() ? "nvue" : _() ? "weixin" : X() ? "offline" : _e() ? "plus" : Qe() ? "webview" : Oe() ? "UniApp" : "h5";
|
|
80
|
+
}
|
|
81
|
+
let pe = null;
|
|
82
|
+
function Z(t = !1) {
|
|
83
|
+
return pe && !t || (pe = {
|
|
84
|
+
isWeixinMiniProgram: _(),
|
|
85
|
+
isAppPlus: _e(),
|
|
86
|
+
isNvue: Ce(),
|
|
87
|
+
isUvue: Me(),
|
|
88
|
+
isUniApp: Oe(),
|
|
89
|
+
isHtml5Plus: ve(),
|
|
90
|
+
isUniAppWebView: Qe(),
|
|
91
|
+
isOfflineWebview: X(),
|
|
92
|
+
type: Yt()
|
|
93
|
+
}), pe;
|
|
94
|
+
}
|
|
95
|
+
const f = Z(), x = {
|
|
96
96
|
PLATFORM_NOT_SUPPORTED: "PLATFORM_NOT_SUPPORTED",
|
|
97
97
|
API_CALL_FAILED: "API_CALL_FAILED",
|
|
98
98
|
BRIDGE_NOT_READY: "BRIDGE_NOT_READY",
|
|
99
99
|
INVALID_PARAMETERS: "INVALID_PARAMETERS",
|
|
100
100
|
NETWORK_ERROR: "NETWORK_ERROR"
|
|
101
101
|
};
|
|
102
|
-
class
|
|
102
|
+
class T extends Error {
|
|
103
103
|
/**
|
|
104
104
|
* 构造函数
|
|
105
105
|
* @param {string} type - 错误类型
|
|
@@ -108,7 +108,7 @@ class M extends Error {
|
|
|
108
108
|
* @param {Error} [originalError] - 原始错误对象
|
|
109
109
|
*/
|
|
110
110
|
constructor(e, r, n = {}, i = null) {
|
|
111
|
-
super(r), this.name = "QshError", this.type = e, this.context = n, this.originalError = i, this.timestamp = (/* @__PURE__ */ new Date()).toISOString(), Error.captureStackTrace && Error.captureStackTrace(this,
|
|
111
|
+
super(r), this.name = "QshError", this.type = e, this.context = n, this.originalError = i, this.timestamp = (/* @__PURE__ */ new Date()).toISOString(), Error.captureStackTrace && Error.captureStackTrace(this, T);
|
|
112
112
|
}
|
|
113
113
|
/**
|
|
114
114
|
* 转换为 JSON 格式
|
|
@@ -125,28 +125,28 @@ class M extends Error {
|
|
|
125
125
|
};
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
|
-
const
|
|
128
|
+
const M = class M {
|
|
129
129
|
/**
|
|
130
130
|
* 设置调试模式
|
|
131
131
|
* @param {boolean} enabled - 是否启用调试模式
|
|
132
132
|
*/
|
|
133
133
|
static setDebugMode(e) {
|
|
134
|
-
|
|
134
|
+
M.isDebugMode = e;
|
|
135
135
|
}
|
|
136
136
|
/**
|
|
137
137
|
* 添加错误回调
|
|
138
138
|
* @param {Function} callback - 错误处理回调函数
|
|
139
139
|
*/
|
|
140
140
|
static addErrorCallback(e) {
|
|
141
|
-
typeof e == "function" &&
|
|
141
|
+
typeof e == "function" && M.errorCallbacks.push(e);
|
|
142
142
|
}
|
|
143
143
|
/**
|
|
144
144
|
* 移除错误回调
|
|
145
145
|
* @param {Function} callback - 要移除的回调函数
|
|
146
146
|
*/
|
|
147
147
|
static removeErrorCallback(e) {
|
|
148
|
-
const r =
|
|
149
|
-
r > -1 &&
|
|
148
|
+
const r = M.errorCallbacks.indexOf(e);
|
|
149
|
+
r > -1 && M.errorCallbacks.splice(r, 1);
|
|
150
150
|
}
|
|
151
151
|
/**
|
|
152
152
|
* 处理 API 调用错误
|
|
@@ -156,16 +156,16 @@ const _ = class _ {
|
|
|
156
156
|
*/
|
|
157
157
|
static handleApiError(e, r = {}) {
|
|
158
158
|
let n;
|
|
159
|
-
return e instanceof
|
|
160
|
-
|
|
159
|
+
return e instanceof T ? n = e : e instanceof Error ? n = new T(
|
|
160
|
+
x.API_CALL_FAILED,
|
|
161
161
|
e.message,
|
|
162
162
|
r,
|
|
163
163
|
e
|
|
164
|
-
) : n = new
|
|
165
|
-
|
|
164
|
+
) : n = new T(
|
|
165
|
+
x.API_CALL_FAILED,
|
|
166
166
|
String(e),
|
|
167
167
|
r
|
|
168
|
-
),
|
|
168
|
+
), M.logError(n), M.notifyCallbacks(n), n;
|
|
169
169
|
}
|
|
170
170
|
/**
|
|
171
171
|
* 处理平台不支持错误
|
|
@@ -174,12 +174,12 @@ const _ = class _ {
|
|
|
174
174
|
* @returns {QshError} 错误对象
|
|
175
175
|
*/
|
|
176
176
|
static handlePlatformNotSupported(e, r) {
|
|
177
|
-
const n = new
|
|
178
|
-
|
|
177
|
+
const n = new T(
|
|
178
|
+
x.PLATFORM_NOT_SUPPORTED,
|
|
179
179
|
`API "${r}" is not supported on platform "${e}"`,
|
|
180
180
|
{ platformType: e, apiName: r }
|
|
181
181
|
);
|
|
182
|
-
return
|
|
182
|
+
return M.logError(n), M.notifyCallbacks(n), n;
|
|
183
183
|
}
|
|
184
184
|
/**
|
|
185
185
|
* 处理桥接未就绪错误
|
|
@@ -187,12 +187,12 @@ const _ = class _ {
|
|
|
187
187
|
* @returns {QshError} 错误对象
|
|
188
188
|
*/
|
|
189
189
|
static handleBridgeNotReady(e) {
|
|
190
|
-
const r = new
|
|
191
|
-
|
|
190
|
+
const r = new T(
|
|
191
|
+
x.BRIDGE_NOT_READY,
|
|
192
192
|
`Bridge is not ready when calling "${e}"`,
|
|
193
193
|
{ apiName: e }
|
|
194
194
|
);
|
|
195
|
-
return
|
|
195
|
+
return M.logError(r), M.notifyCallbacks(r), r;
|
|
196
196
|
}
|
|
197
197
|
/**
|
|
198
198
|
* 处理参数验证错误
|
|
@@ -203,12 +203,12 @@ const _ = class _ {
|
|
|
203
203
|
* @returns {QshError} 错误对象
|
|
204
204
|
*/
|
|
205
205
|
static handleInvalidParameters(e, r, n, i) {
|
|
206
|
-
const s = new
|
|
207
|
-
|
|
206
|
+
const s = new T(
|
|
207
|
+
x.INVALID_PARAMETERS,
|
|
208
208
|
`Invalid parameter "${r}" in "${e}": expected ${n}, got ${typeof i}`,
|
|
209
209
|
{ apiName: e, paramName: r, expectedType: n, actualValue: i }
|
|
210
210
|
);
|
|
211
|
-
return
|
|
211
|
+
return M.logError(s), M.notifyCallbacks(s), s;
|
|
212
212
|
}
|
|
213
213
|
/**
|
|
214
214
|
* 安全地包装函数执行,捕获并处理错误
|
|
@@ -220,7 +220,7 @@ const _ = class _ {
|
|
|
220
220
|
try {
|
|
221
221
|
return e();
|
|
222
222
|
} catch (n) {
|
|
223
|
-
return
|
|
223
|
+
return M.handleApiError(n, r);
|
|
224
224
|
}
|
|
225
225
|
}
|
|
226
226
|
/**
|
|
@@ -230,11 +230,11 @@ const _ = class _ {
|
|
|
230
230
|
* @returns {Promise} Promise 对象
|
|
231
231
|
*/
|
|
232
232
|
static safeExecuteAsync(n) {
|
|
233
|
-
return
|
|
233
|
+
return p(this, arguments, function* (e, r = {}) {
|
|
234
234
|
try {
|
|
235
235
|
return yield e();
|
|
236
236
|
} catch (i) {
|
|
237
|
-
return
|
|
237
|
+
return M.handleApiError(i, r);
|
|
238
238
|
}
|
|
239
239
|
});
|
|
240
240
|
}
|
|
@@ -246,7 +246,7 @@ const _ = class _ {
|
|
|
246
246
|
static logError(e) {
|
|
247
247
|
if (typeof console != "undefined") {
|
|
248
248
|
const r = `[QSH-SDK Error] ${e.type}: ${e.message}`;
|
|
249
|
-
|
|
249
|
+
M.isDebugMode ? console.error(r, {
|
|
250
250
|
context: e.context,
|
|
251
251
|
originalError: e.originalError,
|
|
252
252
|
stack: e.stack,
|
|
@@ -260,7 +260,7 @@ const _ = class _ {
|
|
|
260
260
|
* @private
|
|
261
261
|
*/
|
|
262
262
|
static notifyCallbacks(e) {
|
|
263
|
-
|
|
263
|
+
M.errorCallbacks.forEach((r) => {
|
|
264
264
|
try {
|
|
265
265
|
r(e);
|
|
266
266
|
} catch (n) {
|
|
@@ -276,23 +276,23 @@ const _ = class _ {
|
|
|
276
276
|
static createErrorDecorator(e = {}) {
|
|
277
277
|
return function(r, n, i) {
|
|
278
278
|
const s = i.value;
|
|
279
|
-
return i.value = function(...
|
|
280
|
-
return
|
|
279
|
+
return i.value = function(...o) {
|
|
280
|
+
return M.safeExecute(() => s.apply(this, o), m(h({}, e), { method: n, target: r.constructor.name }));
|
|
281
281
|
}, i;
|
|
282
282
|
};
|
|
283
283
|
}
|
|
284
284
|
};
|
|
285
|
-
|
|
286
|
-
let u =
|
|
287
|
-
const
|
|
285
|
+
k(M, "isDebugMode", !1), k(M, "errorCallbacks", []);
|
|
286
|
+
let u = M;
|
|
287
|
+
const v = {
|
|
288
288
|
UNINITIALIZED: "uninitialized",
|
|
289
289
|
INITIALIZING: "initializing",
|
|
290
290
|
READY: "ready",
|
|
291
291
|
ERROR: "error"
|
|
292
292
|
};
|
|
293
|
-
class
|
|
293
|
+
class Xt {
|
|
294
294
|
constructor() {
|
|
295
|
-
this.state =
|
|
295
|
+
this.state = v.UNINITIALIZED, this.readyPromise = null, this.readyCallbacks = [], this.errorCallbacks = [], this.initializationError = null, this.handleBridgeReady = this.handleBridgeReady.bind(this), this.handleInitializationError = this.handleInitializationError.bind(this);
|
|
296
296
|
}
|
|
297
297
|
/**
|
|
298
298
|
* 获取当前状态
|
|
@@ -306,21 +306,21 @@ class Kt {
|
|
|
306
306
|
* @returns {boolean} 是否就绪
|
|
307
307
|
*/
|
|
308
308
|
isReady() {
|
|
309
|
-
return this.state ===
|
|
309
|
+
return this.state === v.READY;
|
|
310
310
|
}
|
|
311
311
|
/**
|
|
312
312
|
* 检查是否正在初始化
|
|
313
313
|
* @returns {boolean} 是否正在初始化
|
|
314
314
|
*/
|
|
315
315
|
isInitializing() {
|
|
316
|
-
return this.state ===
|
|
316
|
+
return this.state === v.INITIALIZING;
|
|
317
317
|
}
|
|
318
318
|
/**
|
|
319
319
|
* 检查是否出错
|
|
320
320
|
* @returns {boolean} 是否出错
|
|
321
321
|
*/
|
|
322
322
|
hasError() {
|
|
323
|
-
return this.state ===
|
|
323
|
+
return this.state === v.ERROR;
|
|
324
324
|
}
|
|
325
325
|
/**
|
|
326
326
|
* 获取初始化错误
|
|
@@ -344,10 +344,10 @@ class Kt {
|
|
|
344
344
|
* @returns {Promise<void>} 初始化 Promise
|
|
345
345
|
*/
|
|
346
346
|
startInitialization(e) {
|
|
347
|
-
return
|
|
348
|
-
if (this.state !==
|
|
347
|
+
return p(this, null, function* () {
|
|
348
|
+
if (this.state !== v.UNINITIALIZED)
|
|
349
349
|
return this.waitForReady();
|
|
350
|
-
this.state =
|
|
350
|
+
this.state = v.INITIALIZING;
|
|
351
351
|
try {
|
|
352
352
|
yield e(), this.handleBridgeReady();
|
|
353
353
|
} catch (r) {
|
|
@@ -361,7 +361,7 @@ class Kt {
|
|
|
361
361
|
* @private
|
|
362
362
|
*/
|
|
363
363
|
handleBridgeReady() {
|
|
364
|
-
this.state ===
|
|
364
|
+
this.state === v.INITIALIZING && (this.state = v.READY, this.readyCallbacks.forEach((e) => {
|
|
365
365
|
try {
|
|
366
366
|
e();
|
|
367
367
|
} catch (r) {
|
|
@@ -375,7 +375,7 @@ class Kt {
|
|
|
375
375
|
* @private
|
|
376
376
|
*/
|
|
377
377
|
handleInitializationError(e) {
|
|
378
|
-
this.state =
|
|
378
|
+
this.state = v.ERROR, this.initializationError = e, this.errorCallbacks.forEach((r) => {
|
|
379
379
|
try {
|
|
380
380
|
r(e);
|
|
381
381
|
} catch (n) {
|
|
@@ -387,7 +387,7 @@ class Kt {
|
|
|
387
387
|
* 重置状态管理器(用于测试或重新初始化)
|
|
388
388
|
*/
|
|
389
389
|
reset() {
|
|
390
|
-
this.state =
|
|
390
|
+
this.state = v.UNINITIALIZED, this.readyPromise = null, this.readyCallbacks = [], this.errorCallbacks = [], this.initializationError = null;
|
|
391
391
|
}
|
|
392
392
|
/**
|
|
393
393
|
* 添加状态变化监听器
|
|
@@ -402,7 +402,7 @@ class Kt {
|
|
|
402
402
|
const n = () => {
|
|
403
403
|
this.state === e && r(this.state);
|
|
404
404
|
};
|
|
405
|
-
return e ===
|
|
405
|
+
return e === v.READY ? this.readyCallbacks.push(n) : e === v.ERROR && this.errorCallbacks.push(n), () => {
|
|
406
406
|
const i = this.readyCallbacks.indexOf(n);
|
|
407
407
|
i > -1 && this.readyCallbacks.splice(i, 1);
|
|
408
408
|
const s = this.errorCallbacks.indexOf(n);
|
|
@@ -423,18 +423,18 @@ class Kt {
|
|
|
423
423
|
};
|
|
424
424
|
}
|
|
425
425
|
}
|
|
426
|
-
const
|
|
426
|
+
const H = new Xt(), et = () => H.waitForReady(), Zt = () => H.isReady(), Qt = () => H.getState(), P = {
|
|
427
427
|
ERROR: 0,
|
|
428
428
|
WARN: 1,
|
|
429
429
|
INFO: 2,
|
|
430
430
|
DEBUG: 3,
|
|
431
431
|
TRACE: 4
|
|
432
|
-
},
|
|
433
|
-
[
|
|
434
|
-
[
|
|
435
|
-
[
|
|
436
|
-
[
|
|
437
|
-
[
|
|
432
|
+
}, ce = {
|
|
433
|
+
[P.ERROR]: "ERROR",
|
|
434
|
+
[P.WARN]: "WARN",
|
|
435
|
+
[P.INFO]: "INFO",
|
|
436
|
+
[P.DEBUG]: "DEBUG",
|
|
437
|
+
[P.TRACE]: "TRACE"
|
|
438
438
|
}, g = class g {
|
|
439
439
|
// 可注入的外部 reporter
|
|
440
440
|
/**
|
|
@@ -442,33 +442,33 @@ const V = new Kt(), je = () => V.waitForReady(), Gt = () => V.isReady(), zt = ()
|
|
|
442
442
|
* @param {number} level - 日志级别
|
|
443
443
|
*/
|
|
444
444
|
static setLevel(e) {
|
|
445
|
-
e >=
|
|
445
|
+
e >= P.ERROR && e <= P.TRACE && (g.currentLevel = e, g.log(P.INFO, "Logger", `日志级别设置为: ${ce[e]}`));
|
|
446
446
|
}
|
|
447
447
|
/**
|
|
448
448
|
* 启用开发模式(显示所有日志)
|
|
449
449
|
*/
|
|
450
450
|
static enableDevMode() {
|
|
451
|
-
g.setLevel(
|
|
451
|
+
g.setLevel(P.DEBUG), g.log(P.INFO, "Logger", "开发模式已启用");
|
|
452
452
|
}
|
|
453
453
|
/**
|
|
454
454
|
* 启用生产模式(只显示错误和警告)
|
|
455
455
|
*/
|
|
456
456
|
static enableProdMode() {
|
|
457
|
-
g.setLevel(
|
|
457
|
+
g.setLevel(P.WARN), g.log(P.INFO, "Logger", "生产模式已启用");
|
|
458
458
|
}
|
|
459
459
|
/**
|
|
460
460
|
* 启用特定模块的日志
|
|
461
461
|
* @param {string} module - 模块名称
|
|
462
462
|
*/
|
|
463
463
|
static enableModule(e) {
|
|
464
|
-
g.enabledModules.add(e), g.log(
|
|
464
|
+
g.enabledModules.add(e), g.log(P.INFO, "Logger", `模块日志已启用: ${e}`);
|
|
465
465
|
}
|
|
466
466
|
/**
|
|
467
467
|
* 禁用特定模块的日志
|
|
468
468
|
* @param {string} module - 模块名称
|
|
469
469
|
*/
|
|
470
470
|
static disableModule(e) {
|
|
471
|
-
g.enabledModules.delete(e), g.log(
|
|
471
|
+
g.enabledModules.delete(e), g.log(P.INFO, "Logger", `模块日志已禁用: ${e}`);
|
|
472
472
|
}
|
|
473
473
|
/**
|
|
474
474
|
* 检查是否应该记录日志
|
|
@@ -491,20 +491,20 @@ const V = new Kt(), je = () => V.waitForReady(), Gt = () => V.isReady(), zt = ()
|
|
|
491
491
|
static log(e, r, n, ...i) {
|
|
492
492
|
if (!g.shouldLog(e, r))
|
|
493
493
|
return;
|
|
494
|
-
const s = (/* @__PURE__ */ new Date()).toISOString(),
|
|
494
|
+
const s = (/* @__PURE__ */ new Date()).toISOString(), o = ce[e], d = r ? `[${r}]` : "", l = `${g.prefix} ${d} ${n}`, w = {
|
|
495
495
|
timestamp: s,
|
|
496
496
|
level: e,
|
|
497
|
-
levelName:
|
|
497
|
+
levelName: o,
|
|
498
498
|
module: r,
|
|
499
499
|
message: n,
|
|
500
500
|
args: i
|
|
501
501
|
};
|
|
502
|
-
if (g.addToHistory(
|
|
502
|
+
if (g.addToHistory(w), typeof g.reporter == "function")
|
|
503
503
|
try {
|
|
504
|
-
g.reporter(
|
|
505
|
-
} catch (
|
|
504
|
+
g.reporter(w);
|
|
505
|
+
} catch (N) {
|
|
506
506
|
}
|
|
507
|
-
g.outputToConsole(e,
|
|
507
|
+
g.outputToConsole(e, l, ...i);
|
|
508
508
|
}
|
|
509
509
|
/**
|
|
510
510
|
* 添加日志到历史记录
|
|
@@ -526,17 +526,17 @@ const V = new Kt(), je = () => V.waitForReady(), Gt = () => V.isReady(), zt = ()
|
|
|
526
526
|
return;
|
|
527
527
|
const i = n && n.length > 0;
|
|
528
528
|
switch (e) {
|
|
529
|
-
case
|
|
529
|
+
case P.ERROR:
|
|
530
530
|
i ? console.error(r, ...n) : console.error(r);
|
|
531
531
|
break;
|
|
532
|
-
case
|
|
532
|
+
case P.WARN:
|
|
533
533
|
i ? console.warn(r, ...n) : console.warn(r);
|
|
534
534
|
break;
|
|
535
|
-
case
|
|
535
|
+
case P.INFO:
|
|
536
536
|
i ? console.info(r, ...n) : console.info(r);
|
|
537
537
|
break;
|
|
538
|
-
case
|
|
539
|
-
case
|
|
538
|
+
case P.DEBUG:
|
|
539
|
+
case P.TRACE:
|
|
540
540
|
i ? console.log(r, ...n) : console.log(r);
|
|
541
541
|
break;
|
|
542
542
|
}
|
|
@@ -548,7 +548,7 @@ const V = new Kt(), je = () => V.waitForReady(), Gt = () => V.isReady(), zt = ()
|
|
|
548
548
|
* @param {any[]} args - 额外参数
|
|
549
549
|
*/
|
|
550
550
|
static error(e, r, ...n) {
|
|
551
|
-
g.log(
|
|
551
|
+
g.log(P.ERROR, e, r, ...n);
|
|
552
552
|
}
|
|
553
553
|
/**
|
|
554
554
|
* 警告级别日志
|
|
@@ -557,7 +557,7 @@ const V = new Kt(), je = () => V.waitForReady(), Gt = () => V.isReady(), zt = ()
|
|
|
557
557
|
* @param {any[]} args - 额外参数
|
|
558
558
|
*/
|
|
559
559
|
static warn(e, r, ...n) {
|
|
560
|
-
g.log(
|
|
560
|
+
g.log(P.WARN, e, r, ...n);
|
|
561
561
|
}
|
|
562
562
|
/**
|
|
563
563
|
* 信息级别日志
|
|
@@ -566,7 +566,7 @@ const V = new Kt(), je = () => V.waitForReady(), Gt = () => V.isReady(), zt = ()
|
|
|
566
566
|
* @param {any[]} args - 额外参数
|
|
567
567
|
*/
|
|
568
568
|
static info(e, r, ...n) {
|
|
569
|
-
g.log(
|
|
569
|
+
g.log(P.INFO, e, r, ...n);
|
|
570
570
|
}
|
|
571
571
|
/**
|
|
572
572
|
* 调试级别日志
|
|
@@ -575,7 +575,7 @@ const V = new Kt(), je = () => V.waitForReady(), Gt = () => V.isReady(), zt = ()
|
|
|
575
575
|
* @param {any[]} args - 额外参数
|
|
576
576
|
*/
|
|
577
577
|
static debug(e, r, ...n) {
|
|
578
|
-
g.log(
|
|
578
|
+
g.log(P.DEBUG, e, r, ...n);
|
|
579
579
|
}
|
|
580
580
|
/**
|
|
581
581
|
* 跟踪级别日志
|
|
@@ -584,7 +584,7 @@ const V = new Kt(), je = () => V.waitForReady(), Gt = () => V.isReady(), zt = ()
|
|
|
584
584
|
* @param {any[]} args - 额外参数
|
|
585
585
|
*/
|
|
586
586
|
static trace(e, r, ...n) {
|
|
587
|
-
g.log(
|
|
587
|
+
g.log(P.TRACE, e, r, ...n);
|
|
588
588
|
}
|
|
589
589
|
/**
|
|
590
590
|
* 获取日志历史
|
|
@@ -598,7 +598,7 @@ const V = new Kt(), je = () => V.waitForReady(), Gt = () => V.isReady(), zt = ()
|
|
|
598
598
|
* 清空日志历史
|
|
599
599
|
*/
|
|
600
600
|
static clearHistory() {
|
|
601
|
-
g.logHistory = [], g.log(
|
|
601
|
+
g.logHistory = [], g.log(P.INFO, "Logger", "日志历史已清空");
|
|
602
602
|
}
|
|
603
603
|
/**
|
|
604
604
|
* 获取日志统计信息
|
|
@@ -607,13 +607,13 @@ const V = new Kt(), je = () => V.waitForReady(), Gt = () => V.isReady(), zt = ()
|
|
|
607
607
|
static getStats() {
|
|
608
608
|
const e = {
|
|
609
609
|
currentLevel: g.currentLevel,
|
|
610
|
-
currentLevelName:
|
|
610
|
+
currentLevelName: ce[g.currentLevel],
|
|
611
611
|
enabledModules: Array.from(g.enabledModules),
|
|
612
612
|
historySize: g.logHistory.length,
|
|
613
613
|
maxHistorySize: g.maxHistorySize
|
|
614
614
|
}, r = {};
|
|
615
|
-
for (const n of Object.keys(
|
|
616
|
-
r[
|
|
615
|
+
for (const n of Object.keys(ce))
|
|
616
|
+
r[ce[n]] = 0;
|
|
617
617
|
return g.logHistory.forEach((n) => {
|
|
618
618
|
r[n.levelName]++;
|
|
619
619
|
}), e.levelCounts = r, e;
|
|
@@ -653,11 +653,11 @@ const V = new Kt(), je = () => V.waitForReady(), Gt = () => V.isReady(), zt = ()
|
|
|
653
653
|
g.reporter = typeof e == "function" ? e : null;
|
|
654
654
|
}
|
|
655
655
|
};
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
let
|
|
656
|
+
k(g, "currentLevel", P.ERROR), // 生产环境默认只显示错误
|
|
657
|
+
k(g, "enabledModules", /* @__PURE__ */ new Set()), // 启用日志的模块
|
|
658
|
+
k(g, "logHistory", []), // 日志历史(最多保留1000条)
|
|
659
|
+
k(g, "maxHistorySize", 1e3), k(g, "prefix", "[QSH-SDK]"), k(g, "reporter", null);
|
|
660
|
+
let b = g;
|
|
661
661
|
if (typeof window != "undefined") {
|
|
662
662
|
const t = window.location && (window.location.hostname === "localhost" || window.location.hostname === "127.0.0.1" || window.location.hostname.includes("192.168.")), e = window.location && (window.location.search.includes("debug=true") || window.location.search.includes("qsh_debug=1"));
|
|
663
663
|
let r = !1;
|
|
@@ -665,19 +665,19 @@ if (typeof window != "undefined") {
|
|
|
665
665
|
r = localStorage && localStorage.getItem("qsh_debug") === "true";
|
|
666
666
|
} catch (n) {
|
|
667
667
|
}
|
|
668
|
-
(t || e || r) &&
|
|
668
|
+
(t || e || r) && b.enableDevMode();
|
|
669
669
|
}
|
|
670
|
-
const
|
|
671
|
-
function
|
|
672
|
-
if (!
|
|
673
|
-
|
|
670
|
+
const A = b.createModuleLogger("Bridge"), I = b.createModuleLogger("Platform"), a = b.createModuleLogger("API"), D = b.createModuleLogger("State"), ye = /complete|loaded|interactive/;
|
|
671
|
+
function er(t) {
|
|
672
|
+
if (!X()) return !1;
|
|
673
|
+
A.debug("检测到离线包环境,开始初始化");
|
|
674
674
|
const e = () => {
|
|
675
675
|
t();
|
|
676
676
|
};
|
|
677
|
-
if (
|
|
678
|
-
|
|
677
|
+
if (ye.test(document.readyState))
|
|
678
|
+
A.debug("离线包环境 DOM 已就绪,立即初始化"), setTimeout(e, 0);
|
|
679
679
|
else {
|
|
680
|
-
|
|
680
|
+
A.debug("离线包环境,等待 DOMContentLoaded");
|
|
681
681
|
let r = !1;
|
|
682
682
|
const n = () => {
|
|
683
683
|
r || (r = !0, e());
|
|
@@ -686,20 +686,20 @@ function Vt(t) {
|
|
|
686
686
|
}
|
|
687
687
|
return !0;
|
|
688
688
|
}
|
|
689
|
-
function
|
|
690
|
-
return
|
|
689
|
+
function tr(t) {
|
|
690
|
+
return Oe() || ve() ? (A.debug("检测到 APP 环境,开始初始化"), window.__uniapp_x_postMessage || window.__uniapp_x_ || window.__dcloud_weex_postMessage || window.__dcloud_weex_ ? (A.debug("NVUE/UVUE 环境,等待 DOMContentLoaded"), document.addEventListener("DOMContentLoaded", t)) : window.plus && ye.test(document.readyState) ? (A.debug("Plus 环境已就绪,立即初始化"), setTimeout(t, 0)) : window.plus ? (A.debug("Plus 环境,等待 plusready 事件"), document.addEventListener("plusready", t)) : ye.test(document.readyState) ? setTimeout(t, 0) : document.addEventListener("DOMContentLoaded", t, { once: !0 }), !0) : !1;
|
|
691
691
|
}
|
|
692
|
-
function
|
|
693
|
-
return window.wx && window.wx.miniProgram ? (
|
|
692
|
+
function rr(t) {
|
|
693
|
+
return window.wx && window.wx.miniProgram ? (A.debug("检测到微信小程序环境,开始初始化"), window.WeixinJSBridge && window.WeixinJSBridge.invoke ? (A.debug("微信 JSBridge 已就绪,立即初始化"), setTimeout(t, 0)) : (A.debug("微信 JSBridge 未就绪,等待 WeixinJSBridgeReady 事件"), document.addEventListener("WeixinJSBridgeReady", t)), !0) : !1;
|
|
694
694
|
}
|
|
695
|
-
function
|
|
696
|
-
return
|
|
695
|
+
function nr(t) {
|
|
696
|
+
return A.info("开始初始化 JSBridge"), er(t) ? (A.info("使用离线包环境初始化"), !0) : tr(t) ? (A.info("使用 APP 环境初始化"), !0) : rr(t) ? (A.info("使用微信小程序环境初始化"), !0) : (A.debug("使用默认 H5 环境初始化"), ye.test(document.readyState) ? (A.debug("DOM 已就绪,立即初始化"), setTimeout(t, 0)) : (A.debug("DOM 未就绪,等待 DOMContentLoaded"), document.addEventListener("DOMContentLoaded", t)), !0);
|
|
697
697
|
}
|
|
698
|
-
function
|
|
699
|
-
return
|
|
698
|
+
function ir() {
|
|
699
|
+
return H.waitForReady();
|
|
700
700
|
}
|
|
701
|
-
function
|
|
702
|
-
return
|
|
701
|
+
function tt() {
|
|
702
|
+
return H.startInitialization(() => p(null, null, function* () {
|
|
703
703
|
return new Promise((t, e) => {
|
|
704
704
|
const r = () => {
|
|
705
705
|
t();
|
|
@@ -710,7 +710,7 @@ function He() {
|
|
|
710
710
|
e(s);
|
|
711
711
|
};
|
|
712
712
|
try {
|
|
713
|
-
|
|
713
|
+
nr(() => {
|
|
714
714
|
r();
|
|
715
715
|
});
|
|
716
716
|
} catch (i) {
|
|
@@ -719,40 +719,40 @@ function He() {
|
|
|
719
719
|
});
|
|
720
720
|
}));
|
|
721
721
|
}
|
|
722
|
-
const
|
|
722
|
+
const S = {
|
|
723
723
|
UNINITIALIZED: "uninitialized",
|
|
724
724
|
CONFIGURING: "configuring",
|
|
725
725
|
CONFIGURED: "configured",
|
|
726
726
|
ERROR: "error"
|
|
727
727
|
};
|
|
728
|
-
function
|
|
728
|
+
function G() {
|
|
729
729
|
return typeof window == "undefined" || !window.wx ? !1 : typeof window.wx.config == "function" && typeof window.wx.ready == "function" && typeof window.wx.error == "function";
|
|
730
730
|
}
|
|
731
|
-
class
|
|
731
|
+
class ar {
|
|
732
732
|
constructor() {
|
|
733
|
-
this.state =
|
|
733
|
+
this.state = S.UNINITIALIZED, this.configPromise = null, this.readyCallbacks = [], this.errorCallbacks = [], this.lastError = null, this.runtimeConfig = {
|
|
734
734
|
clientId: null,
|
|
735
735
|
isProd: !1
|
|
736
736
|
}, this.CONFIG_API_URL = this.getConfigApiUrl(this.runtimeConfig.isProd), this.DEFAULT_JS_API_LIST = ["chooseImage", "uploadImage", "previewImage", "downloadImage", "getLocalImgData", "scanQRCode", "getLocation", "openLocation", "updateAppMessageShareData", "updateTimelineShareData"], this.handleConfigSuccess = this.handleConfigSuccess.bind(this), this.handleConfigError = this.handleConfigError.bind(this);
|
|
737
737
|
}
|
|
738
738
|
configure(e = {}) {
|
|
739
739
|
if (!e || typeof e != "object" || Array.isArray(e))
|
|
740
|
-
throw new
|
|
741
|
-
|
|
740
|
+
throw new T(
|
|
741
|
+
x.INVALID_PARAMETERS,
|
|
742
742
|
"config参数异常",
|
|
743
743
|
{ config: e }
|
|
744
744
|
);
|
|
745
745
|
if (!Object.prototype.hasOwnProperty.call(e, "clientId"))
|
|
746
746
|
throw this.createMissingClientIdError();
|
|
747
747
|
if (typeof e.clientId != "string" || !e.clientId.trim())
|
|
748
|
-
throw new
|
|
749
|
-
|
|
748
|
+
throw new T(
|
|
749
|
+
x.INVALID_PARAMETERS,
|
|
750
750
|
"clientId参数异常",
|
|
751
751
|
{ clientId: e.clientId }
|
|
752
752
|
);
|
|
753
753
|
if (Object.prototype.hasOwnProperty.call(e, "isProd") && typeof e.isProd != "boolean")
|
|
754
|
-
throw new
|
|
755
|
-
|
|
754
|
+
throw new T(
|
|
755
|
+
x.INVALID_PARAMETERS,
|
|
756
756
|
"isProd参数异常",
|
|
757
757
|
{ isProd: e.isProd }
|
|
758
758
|
);
|
|
@@ -760,7 +760,7 @@ class Yt {
|
|
|
760
760
|
return this.runtimeConfig = m(h({}, this.runtimeConfig), {
|
|
761
761
|
clientId: r,
|
|
762
762
|
isProd: n
|
|
763
|
-
}), this.CONFIG_API_URL = this.getConfigApiUrl(n), (this.state ===
|
|
763
|
+
}), this.CONFIG_API_URL = this.getConfigApiUrl(n), (this.state === S.ERROR || i && (this.state === S.CONFIGURING || this.state === S.CONFIGURED)) && this.reset(), I.info("Updated Weixin runtime config", {
|
|
764
764
|
clientId: this.runtimeConfig.clientId,
|
|
765
765
|
isProd: this.runtimeConfig.isProd,
|
|
766
766
|
configApiUrl: this.CONFIG_API_URL
|
|
@@ -776,8 +776,8 @@ class Yt {
|
|
|
776
776
|
return this.isTestMode() || this.hasClientId();
|
|
777
777
|
}
|
|
778
778
|
createMissingClientIdError() {
|
|
779
|
-
return new
|
|
780
|
-
|
|
779
|
+
return new T(
|
|
780
|
+
x.INVALID_PARAMETERS,
|
|
781
781
|
"clientId错误",
|
|
782
782
|
{ field: "clientId" }
|
|
783
783
|
);
|
|
@@ -807,32 +807,32 @@ class Yt {
|
|
|
807
807
|
* @private
|
|
808
808
|
*/
|
|
809
809
|
fetchWeixinConfig() {
|
|
810
|
-
return
|
|
810
|
+
return p(this, null, function* () {
|
|
811
811
|
const e = this.getCurrentPageUrl();
|
|
812
812
|
if (this.isTestMode())
|
|
813
|
-
return
|
|
813
|
+
return I.info("使用测试模式,返回模拟配置"), this.getMockConfig();
|
|
814
814
|
if (!this.hasClientId())
|
|
815
815
|
throw this.createMissingClientIdError();
|
|
816
816
|
const r = this.getConfigApiUrl(this.runtimeConfig.isProd);
|
|
817
817
|
this.CONFIG_API_URL = r;
|
|
818
818
|
const n = `${r}?clientId=${this.runtimeConfig.clientId}&url=${encodeURIComponent(e)}`;
|
|
819
|
-
|
|
819
|
+
I.debug("请求微信配置", { url: n });
|
|
820
820
|
try {
|
|
821
821
|
const i = yield fetch(n);
|
|
822
822
|
if (!i.ok)
|
|
823
823
|
throw new Error(`HTTP ${i.status}: ${i.statusText}`);
|
|
824
824
|
const s = yield i.json();
|
|
825
|
-
if (
|
|
825
|
+
if (I.debug("微信配置响应", s), !s.success || s.code !== 200)
|
|
826
826
|
throw new Error(`配置获取失败: ${s.message || "未知错误"}`);
|
|
827
|
-
const { data:
|
|
828
|
-
if (!
|
|
827
|
+
const { data: o } = s;
|
|
828
|
+
if (!o || !o.appId || !o.timestamp || !o.nonceStr || !o.signature)
|
|
829
829
|
throw new Error("配置数据格式不正确,缺少必需字段");
|
|
830
|
-
return
|
|
830
|
+
return o;
|
|
831
831
|
} catch (i) {
|
|
832
|
-
if (
|
|
833
|
-
return
|
|
834
|
-
throw new
|
|
835
|
-
|
|
832
|
+
if (I.error("获取微信配置失败", i), this.shouldUseTestMode(i))
|
|
833
|
+
return I.warn("网络请求失败,降级到测试模式"), this.getMockConfig();
|
|
834
|
+
throw new T(
|
|
835
|
+
x.NETWORK_ERROR,
|
|
836
836
|
`获取微信配置失败: ${i.message}`,
|
|
837
837
|
{ url: n, originalError: i }
|
|
838
838
|
);
|
|
@@ -884,12 +884,12 @@ class Yt {
|
|
|
884
884
|
*/
|
|
885
885
|
executeWeixinConfig(e) {
|
|
886
886
|
if (this.isTestMode() || e.appId === "wx_test_app_id") {
|
|
887
|
-
|
|
887
|
+
I.info("测试模式:模拟微信配置成功"), setTimeout(() => {
|
|
888
888
|
this.handleConfigSuccess();
|
|
889
889
|
}, 100);
|
|
890
890
|
return;
|
|
891
891
|
}
|
|
892
|
-
if (
|
|
892
|
+
if (!G())
|
|
893
893
|
throw new Error("微信JS-SDK未加载");
|
|
894
894
|
const r = {
|
|
895
895
|
debug: !1,
|
|
@@ -900,14 +900,14 @@ class Yt {
|
|
|
900
900
|
signature: e.signature,
|
|
901
901
|
jsApiList: this.DEFAULT_JS_API_LIST
|
|
902
902
|
};
|
|
903
|
-
|
|
903
|
+
I.info("执行微信配置", r), window.wx.ready(this.handleConfigSuccess), window.wx.error(this.handleConfigError), window.wx.config(r);
|
|
904
904
|
}
|
|
905
905
|
/**
|
|
906
906
|
* 处理配置成功
|
|
907
907
|
* @private
|
|
908
908
|
*/
|
|
909
909
|
handleConfigSuccess() {
|
|
910
|
-
|
|
910
|
+
I.info("微信配置成功"), this.state = S.CONFIGURED, this.lastError = null, this.configPromise = null;
|
|
911
911
|
const e = [...this.readyCallbacks];
|
|
912
912
|
this.readyCallbacks = [], this.errorCallbacks = [], e.forEach((r) => {
|
|
913
913
|
try {
|
|
@@ -924,19 +924,19 @@ class Yt {
|
|
|
924
924
|
*/
|
|
925
925
|
handleConfigError(e) {
|
|
926
926
|
const r = `微信配置验证失败: ${JSON.stringify(e)}`;
|
|
927
|
-
|
|
928
|
-
const n = new
|
|
929
|
-
|
|
927
|
+
I.error(r, e);
|
|
928
|
+
const n = new T(
|
|
929
|
+
x.API_CALL_FAILED,
|
|
930
930
|
r,
|
|
931
931
|
{ weixinErrorResponse: e }
|
|
932
932
|
);
|
|
933
|
-
this.state =
|
|
933
|
+
this.state = S.ERROR, this.lastError = n, this.configPromise = null;
|
|
934
934
|
const i = [...this.errorCallbacks];
|
|
935
935
|
this.readyCallbacks = [], this.errorCallbacks = [], i.forEach((s) => {
|
|
936
936
|
try {
|
|
937
937
|
s(n);
|
|
938
|
-
} catch (
|
|
939
|
-
u.handleApiError(
|
|
938
|
+
} catch (o) {
|
|
939
|
+
u.handleApiError(o, { context: "WeixinConfigManager.handleConfigError" });
|
|
940
940
|
}
|
|
941
941
|
});
|
|
942
942
|
}
|
|
@@ -945,8 +945,8 @@ class Yt {
|
|
|
945
945
|
* @returns {Promise<void>} 配置完成的Promise
|
|
946
946
|
*/
|
|
947
947
|
autoConfig() {
|
|
948
|
-
return
|
|
949
|
-
return this.hasRequiredConfig() ? this.state ===
|
|
948
|
+
return p(this, null, function* () {
|
|
949
|
+
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) : (I.warn("clientId为空,等待qsh.config({ clientId })"), Promise.resolve());
|
|
950
950
|
});
|
|
951
951
|
}
|
|
952
952
|
/**
|
|
@@ -955,27 +955,27 @@ class Yt {
|
|
|
955
955
|
* @private
|
|
956
956
|
*/
|
|
957
957
|
performAutoConfig() {
|
|
958
|
-
return
|
|
958
|
+
return p(this, null, function* () {
|
|
959
959
|
try {
|
|
960
960
|
if (typeof window == "undefined")
|
|
961
961
|
throw new Error("非浏览器环境无法执行微信配置");
|
|
962
|
-
if (
|
|
962
|
+
if (!G())
|
|
963
963
|
throw new Error("微信JS-SDK未加载,无法执行配置");
|
|
964
964
|
const e = yield this.fetchWeixinConfig();
|
|
965
965
|
return this.executeWeixinConfig(e), yield new Promise((r, n) => {
|
|
966
|
-
if (this.state ===
|
|
966
|
+
if (this.state === S.CONFIGURED) {
|
|
967
967
|
r();
|
|
968
968
|
return;
|
|
969
969
|
}
|
|
970
|
-
if (this.state ===
|
|
970
|
+
if (this.state === S.ERROR) {
|
|
971
971
|
n(this.lastError);
|
|
972
972
|
return;
|
|
973
973
|
}
|
|
974
974
|
this.readyCallbacks.push(r), this.errorCallbacks.push(n);
|
|
975
975
|
});
|
|
976
976
|
} catch (e) {
|
|
977
|
-
const r = e instanceof
|
|
978
|
-
this.state =
|
|
977
|
+
const r = e instanceof T ? e : u.handleApiError(e, { context: "WeixinConfigManager.performAutoConfig" });
|
|
978
|
+
this.state = S.ERROR, this.lastError = r, this.configPromise = null;
|
|
979
979
|
const n = [...this.errorCallbacks];
|
|
980
980
|
throw this.readyCallbacks = [], this.errorCallbacks = [], n.forEach((i) => {
|
|
981
981
|
try {
|
|
@@ -992,7 +992,7 @@ class Yt {
|
|
|
992
992
|
* @returns {Promise<void>} 配置完成的Promise
|
|
993
993
|
*/
|
|
994
994
|
waitForReady() {
|
|
995
|
-
return this.state ===
|
|
995
|
+
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) => {
|
|
996
996
|
this.readyCallbacks.push(e), this.errorCallbacks.push(r);
|
|
997
997
|
}) : Promise.reject(this.createMissingClientIdError());
|
|
998
998
|
}
|
|
@@ -1001,7 +1001,7 @@ class Yt {
|
|
|
1001
1001
|
* @returns {boolean} 是否已配置
|
|
1002
1002
|
*/
|
|
1003
1003
|
isReady() {
|
|
1004
|
-
return this.state ===
|
|
1004
|
+
return this.state === S.CONFIGURED;
|
|
1005
1005
|
}
|
|
1006
1006
|
/**
|
|
1007
1007
|
* 获取当前状态
|
|
@@ -1021,7 +1021,7 @@ class Yt {
|
|
|
1021
1021
|
* 重置配置管理器(用于重试或测试)
|
|
1022
1022
|
*/
|
|
1023
1023
|
reset() {
|
|
1024
|
-
this.state =
|
|
1024
|
+
this.state = S.UNINITIALIZED, this.configPromise = null, this.readyCallbacks = [], this.errorCallbacks = [], this.lastError = null, I.debug("微信配置管理器已重置");
|
|
1025
1025
|
}
|
|
1026
1026
|
/**
|
|
1027
1027
|
* 获取配置统计信息
|
|
@@ -1041,129 +1041,129 @@ class Yt {
|
|
|
1041
1041
|
};
|
|
1042
1042
|
}
|
|
1043
1043
|
}
|
|
1044
|
-
const
|
|
1045
|
-
let
|
|
1046
|
-
function
|
|
1044
|
+
const L = new ar();
|
|
1045
|
+
let re = !1, fe = !1, U = null, Ie = !1;
|
|
1046
|
+
function sr(t) {
|
|
1047
1047
|
return new Promise((e) => {
|
|
1048
1048
|
let r = !1, n = null;
|
|
1049
|
-
const i = (
|
|
1049
|
+
const i = (d) => p(null, null, function* () {
|
|
1050
1050
|
if (!r) {
|
|
1051
|
-
if (r = !0, n && clearTimeout(n),
|
|
1051
|
+
if (r = !0, n && clearTimeout(n), re = !1, fe = d, d)
|
|
1052
1052
|
try {
|
|
1053
|
-
yield
|
|
1054
|
-
} catch (
|
|
1055
|
-
|
|
1053
|
+
yield rt();
|
|
1054
|
+
} catch (l) {
|
|
1055
|
+
I.error("微信配置失败,将使用消息桥作为后备", l);
|
|
1056
1056
|
}
|
|
1057
1057
|
e();
|
|
1058
1058
|
}
|
|
1059
|
-
}), s = () => i(
|
|
1060
|
-
|
|
1059
|
+
}), s = () => i(G()), o = () => {
|
|
1060
|
+
I.warn("已存在的微信 JS-SDK 脚本加载失败,SDK 将使用消息桥作为后备"), i(!1);
|
|
1061
1061
|
};
|
|
1062
|
-
t.addEventListener("load", s, { once: !0 }), t.addEventListener("error",
|
|
1063
|
-
|
|
1062
|
+
t.addEventListener("load", s, { once: !0 }), t.addEventListener("error", o, { once: !0 }), setTimeout(() => {
|
|
1063
|
+
G() && s();
|
|
1064
1064
|
}, 0), n = setTimeout(() => {
|
|
1065
|
-
i(
|
|
1065
|
+
i(G());
|
|
1066
1066
|
}, 3e3);
|
|
1067
1067
|
});
|
|
1068
1068
|
}
|
|
1069
|
-
function
|
|
1070
|
-
return
|
|
1069
|
+
function xe() {
|
|
1070
|
+
return p(this, arguments, function* (t = {}) {
|
|
1071
1071
|
const { force: e = !1, recoverFromError: r = !1 } = t;
|
|
1072
|
-
if (yield
|
|
1072
|
+
if (yield nt({ force: e }), !G())
|
|
1073
1073
|
throw new Error("微信 JS-SDK 未正确加载,无法执行配置");
|
|
1074
|
-
r &&
|
|
1074
|
+
r && cr();
|
|
1075
1075
|
});
|
|
1076
1076
|
}
|
|
1077
|
-
function
|
|
1077
|
+
function or(t = !1) {
|
|
1078
1078
|
if (typeof window == "undefined") return !1;
|
|
1079
|
-
if (
|
|
1080
|
-
return
|
|
1081
|
-
if (
|
|
1079
|
+
if (G())
|
|
1080
|
+
return fe = !0, !1;
|
|
1081
|
+
if (fe || X()) return !1;
|
|
1082
1082
|
if (t) return !0;
|
|
1083
1083
|
const e = navigator.userAgent || "", r = /micromessenger/i.test(e), n = /miniProgram/i.test(e), i = typeof window.__wxjs_environment != "undefined" && window.__wxjs_environment === "miniprogram", s = !!(window.wx && window.wx.miniProgram);
|
|
1084
1084
|
return r && (n || i || s);
|
|
1085
1085
|
}
|
|
1086
|
-
function
|
|
1087
|
-
|
|
1086
|
+
function cr() {
|
|
1087
|
+
L.getState() === "error" && (L.reset(), Ie = !1);
|
|
1088
1088
|
}
|
|
1089
|
-
function
|
|
1090
|
-
return
|
|
1091
|
-
if (
|
|
1092
|
-
return
|
|
1093
|
-
|
|
1089
|
+
function rt() {
|
|
1090
|
+
return p(this, null, function* () {
|
|
1091
|
+
if (Ie)
|
|
1092
|
+
return L.waitForReady();
|
|
1093
|
+
Ie = !0, I.info("开始自动配置微信JS-SDK");
|
|
1094
1094
|
try {
|
|
1095
|
-
yield
|
|
1095
|
+
yield L.autoConfig(), I.info("微信JS-SDK自动配置完成");
|
|
1096
1096
|
} catch (t) {
|
|
1097
|
-
|
|
1097
|
+
I.error("微信JS-SDK自动配置失败", t);
|
|
1098
1098
|
}
|
|
1099
1099
|
});
|
|
1100
1100
|
}
|
|
1101
|
-
function
|
|
1101
|
+
function nt(t = {}) {
|
|
1102
1102
|
const { force: e = !1 } = t;
|
|
1103
1103
|
if (typeof window == "undefined")
|
|
1104
1104
|
return Promise.resolve();
|
|
1105
|
-
if (
|
|
1106
|
-
return
|
|
1105
|
+
if (G())
|
|
1106
|
+
return fe = !0, Promise.resolve();
|
|
1107
1107
|
const r = document.getElementById("weixin-jssdk");
|
|
1108
|
-
return r ?
|
|
1109
|
-
|
|
1110
|
-
}),
|
|
1111
|
-
|
|
1108
|
+
return r ? U || (re = !0, U = sr(r).finally(() => {
|
|
1109
|
+
U = null;
|
|
1110
|
+
}), U) : or(e) ? U || (U = new Promise((n) => {
|
|
1111
|
+
re = !0;
|
|
1112
1112
|
try {
|
|
1113
1113
|
const i = document.createElement("script");
|
|
1114
1114
|
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() {
|
|
1115
|
-
return
|
|
1116
|
-
|
|
1115
|
+
return p(this, null, function* () {
|
|
1116
|
+
fe = !0, re = !1, I.info("微信 JS-SDK 已自动加载");
|
|
1117
1117
|
try {
|
|
1118
|
-
yield
|
|
1119
|
-
} catch (
|
|
1120
|
-
|
|
1118
|
+
yield rt();
|
|
1119
|
+
} catch (o) {
|
|
1120
|
+
I.error("微信配置失败,将使用消息桥作为后备", o);
|
|
1121
1121
|
}
|
|
1122
1122
|
n();
|
|
1123
1123
|
});
|
|
1124
1124
|
}, i.onerror = function() {
|
|
1125
|
-
|
|
1125
|
+
re = !1, I.warn("微信 JS-SDK 加载失败,SDK 将使用消息桥作为后备"), n();
|
|
1126
1126
|
}, (document.getElementsByTagName("head")[0] || document.documentElement).appendChild(i);
|
|
1127
1127
|
} catch (i) {
|
|
1128
|
-
|
|
1128
|
+
re = !1, I.error("注入微信 JS-SDK 失败", i), n();
|
|
1129
1129
|
}
|
|
1130
1130
|
}).finally(() => {
|
|
1131
|
-
|
|
1132
|
-
}),
|
|
1131
|
+
U = null;
|
|
1132
|
+
}), U) : Promise.resolve();
|
|
1133
1133
|
}
|
|
1134
|
-
function
|
|
1135
|
-
return
|
|
1134
|
+
function j() {
|
|
1135
|
+
return xe({ force: !0, recoverFromError: !0 }).then(() => L.waitForReady());
|
|
1136
1136
|
}
|
|
1137
|
-
function
|
|
1138
|
-
const e =
|
|
1139
|
-
return typeof window == "undefined" ||
|
|
1137
|
+
function ze(t = {}) {
|
|
1138
|
+
const e = L.configure(t);
|
|
1139
|
+
return typeof window == "undefined" || xe({
|
|
1140
1140
|
force: !0,
|
|
1141
|
-
recoverFromError:
|
|
1141
|
+
recoverFromError: L.getState() === "error"
|
|
1142
1142
|
}).then(() => {
|
|
1143
|
-
if (!
|
|
1144
|
-
return
|
|
1145
|
-
|
|
1143
|
+
if (!L.isReady())
|
|
1144
|
+
return L.waitForReady().catch((r) => {
|
|
1145
|
+
I.error("Failed to auto-configure Weixin after qsh.config()", r);
|
|
1146
1146
|
});
|
|
1147
|
-
window.wx &&
|
|
1147
|
+
window.wx && !G() && I.warn("window.wx 已存在,但微信 JS-SDK 尚未就绪,跳过自动配置");
|
|
1148
1148
|
}).catch((r) => {
|
|
1149
|
-
|
|
1149
|
+
I.error("Failed to preload Weixin JS-SDK", r);
|
|
1150
1150
|
}), e;
|
|
1151
1151
|
}
|
|
1152
|
-
function
|
|
1153
|
-
return
|
|
1152
|
+
function Q() {
|
|
1153
|
+
return L.isReady();
|
|
1154
1154
|
}
|
|
1155
|
-
function
|
|
1156
|
-
return
|
|
1155
|
+
function ur() {
|
|
1156
|
+
return L.getState();
|
|
1157
1157
|
}
|
|
1158
|
-
function
|
|
1159
|
-
return
|
|
1158
|
+
function Se() {
|
|
1159
|
+
return L;
|
|
1160
1160
|
}
|
|
1161
|
-
function
|
|
1162
|
-
return
|
|
1163
|
-
return
|
|
1161
|
+
function lr() {
|
|
1162
|
+
return p(this, null, function* () {
|
|
1163
|
+
return I.info("手动重试微信配置"), L.reset(), Ie = !1, yield xe({ force: !0 }), L.waitForReady();
|
|
1164
1164
|
});
|
|
1165
1165
|
}
|
|
1166
|
-
class
|
|
1166
|
+
class fr {
|
|
1167
1167
|
constructor() {
|
|
1168
1168
|
this.plugins = /* @__PURE__ */ new Map(), this.installed = /* @__PURE__ */ new Set(), this.installOrder = [], a.debug("插件管理器已初始化");
|
|
1169
1169
|
}
|
|
@@ -1215,8 +1215,8 @@ class rr {
|
|
|
1215
1215
|
* await pluginManager.install('image', qsh)
|
|
1216
1216
|
*/
|
|
1217
1217
|
install(e, r) {
|
|
1218
|
-
return
|
|
1219
|
-
return u.safeExecute(() =>
|
|
1218
|
+
return p(this, null, function* () {
|
|
1219
|
+
return u.safeExecute(() => p(this, null, function* () {
|
|
1220
1220
|
if (!this.plugins.has(e))
|
|
1221
1221
|
throw new Error(`插件 ${e} 未注册`);
|
|
1222
1222
|
if (this.installed.has(e)) {
|
|
@@ -1245,8 +1245,8 @@ class rr {
|
|
|
1245
1245
|
* await pluginManager.uninstall('image', qsh)
|
|
1246
1246
|
*/
|
|
1247
1247
|
uninstall(e, r) {
|
|
1248
|
-
return
|
|
1249
|
-
return u.safeExecute(() =>
|
|
1248
|
+
return p(this, null, function* () {
|
|
1249
|
+
return u.safeExecute(() => p(this, null, function* () {
|
|
1250
1250
|
if (!this.installed.has(e)) {
|
|
1251
1251
|
a.debug(`插件 ${e} 未安装,跳过卸载`);
|
|
1252
1252
|
return;
|
|
@@ -1267,7 +1267,7 @@ class rr {
|
|
|
1267
1267
|
* @returns {Promise<void>}
|
|
1268
1268
|
*/
|
|
1269
1269
|
uninstallAll(e) {
|
|
1270
|
-
return
|
|
1270
|
+
return p(this, null, function* () {
|
|
1271
1271
|
const r = [...this.installOrder].reverse();
|
|
1272
1272
|
for (const n of r)
|
|
1273
1273
|
yield this.uninstall(n, e);
|
|
@@ -1294,7 +1294,7 @@ class rr {
|
|
|
1294
1294
|
* await pluginManager.installAll(['image', 'location'], qsh)
|
|
1295
1295
|
*/
|
|
1296
1296
|
installAll(e, r) {
|
|
1297
|
-
return
|
|
1297
|
+
return p(this, null, function* () {
|
|
1298
1298
|
if (!Array.isArray(e))
|
|
1299
1299
|
throw new Error("names 必须是数组");
|
|
1300
1300
|
for (const n of e)
|
|
@@ -1356,8 +1356,8 @@ class rr {
|
|
|
1356
1356
|
this.plugins.clear(), this.installed.clear(), this.installOrder = [];
|
|
1357
1357
|
}
|
|
1358
1358
|
}
|
|
1359
|
-
const
|
|
1360
|
-
class
|
|
1359
|
+
const ue = new fr();
|
|
1360
|
+
class dr {
|
|
1361
1361
|
constructor() {
|
|
1362
1362
|
this.requestInterceptors = [], this.responseInterceptors = [], a.debug("拦截器链已初始化");
|
|
1363
1363
|
}
|
|
@@ -1416,7 +1416,7 @@ class nr {
|
|
|
1416
1416
|
* @private
|
|
1417
1417
|
*/
|
|
1418
1418
|
runRequest(e) {
|
|
1419
|
-
return
|
|
1419
|
+
return p(this, null, function* () {
|
|
1420
1420
|
let r = h({}, e);
|
|
1421
1421
|
for (const { fn: n } of this.requestInterceptors) {
|
|
1422
1422
|
if (r.abort) {
|
|
@@ -1442,7 +1442,7 @@ class nr {
|
|
|
1442
1442
|
* @private
|
|
1443
1443
|
*/
|
|
1444
1444
|
runResponse(e, r) {
|
|
1445
|
-
return
|
|
1445
|
+
return p(this, null, function* () {
|
|
1446
1446
|
let n = e;
|
|
1447
1447
|
for (const { fn: i } of this.responseInterceptors)
|
|
1448
1448
|
try {
|
|
@@ -1471,7 +1471,7 @@ class nr {
|
|
|
1471
1471
|
};
|
|
1472
1472
|
}
|
|
1473
1473
|
}
|
|
1474
|
-
const
|
|
1474
|
+
const J = new dr(), gr = {
|
|
1475
1475
|
/**
|
|
1476
1476
|
* 请求日志
|
|
1477
1477
|
*/
|
|
@@ -1488,7 +1488,7 @@ const z = new nr(), ir = {
|
|
|
1488
1488
|
success: t == null ? void 0 : t.success
|
|
1489
1489
|
}), t;
|
|
1490
1490
|
}
|
|
1491
|
-
},
|
|
1491
|
+
}, V = {
|
|
1492
1492
|
// 性能数据存储
|
|
1493
1493
|
metrics: /* @__PURE__ */ new Map(),
|
|
1494
1494
|
/**
|
|
@@ -1500,14 +1500,14 @@ const z = new nr(), ir = {
|
|
|
1500
1500
|
*/
|
|
1501
1501
|
response: (t, e) => {
|
|
1502
1502
|
const r = performance.now() - e.perfStartTime;
|
|
1503
|
-
|
|
1503
|
+
V.metrics.has(e.apiName) || V.metrics.set(e.apiName, {
|
|
1504
1504
|
count: 0,
|
|
1505
1505
|
totalTime: 0,
|
|
1506
1506
|
minTime: 1 / 0,
|
|
1507
1507
|
maxTime: 0,
|
|
1508
1508
|
avgTime: 0
|
|
1509
1509
|
});
|
|
1510
|
-
const n =
|
|
1510
|
+
const n = V.metrics.get(e.apiName);
|
|
1511
1511
|
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;
|
|
1512
1512
|
},
|
|
1513
1513
|
/**
|
|
@@ -1515,7 +1515,7 @@ const z = new nr(), ir = {
|
|
|
1515
1515
|
*/
|
|
1516
1516
|
getReport: () => {
|
|
1517
1517
|
const t = {};
|
|
1518
|
-
return
|
|
1518
|
+
return V.metrics.forEach((e, r) => {
|
|
1519
1519
|
t[r] = h({}, e);
|
|
1520
1520
|
}), t;
|
|
1521
1521
|
},
|
|
@@ -1523,22 +1523,22 @@ const z = new nr(), ir = {
|
|
|
1523
1523
|
* 清空性能数据
|
|
1524
1524
|
*/
|
|
1525
1525
|
clearMetrics: () => {
|
|
1526
|
-
|
|
1526
|
+
V.metrics.clear();
|
|
1527
1527
|
}
|
|
1528
1528
|
};
|
|
1529
|
-
function
|
|
1529
|
+
function hr(t = {}) {
|
|
1530
1530
|
const {
|
|
1531
1531
|
maxRetries: e = 3,
|
|
1532
1532
|
retryDelay: r = 1e3,
|
|
1533
1533
|
shouldRetry: n = (i) => !i.success
|
|
1534
1534
|
} = t;
|
|
1535
1535
|
return {
|
|
1536
|
-
response: (i, s) =>
|
|
1537
|
-
return s.retryCount || (s.retryCount = 0), n(i) && s.retryCount < e && (s.retryCount++, a.warn(`API 调用失败,第 ${s.retryCount} 次重试: ${s.apiName}`), yield new Promise((
|
|
1536
|
+
response: (i, s) => p(null, null, function* () {
|
|
1537
|
+
return s.retryCount || (s.retryCount = 0), n(i) && s.retryCount < e && (s.retryCount++, a.warn(`API 调用失败,第 ${s.retryCount} 次重试: ${s.apiName}`), yield new Promise((o) => setTimeout(o, r)), i.shouldRetry = !0, i.retryContext = s), i;
|
|
1538
1538
|
})
|
|
1539
1539
|
};
|
|
1540
1540
|
}
|
|
1541
|
-
function
|
|
1541
|
+
function mr(t = {}) {
|
|
1542
1542
|
return {
|
|
1543
1543
|
request: (e) => {
|
|
1544
1544
|
const r = t[e.apiName];
|
|
@@ -1550,7 +1550,7 @@ function sr(t = {}) {
|
|
|
1550
1550
|
}
|
|
1551
1551
|
};
|
|
1552
1552
|
}
|
|
1553
|
-
class
|
|
1553
|
+
class pr {
|
|
1554
1554
|
constructor() {
|
|
1555
1555
|
this.state = {
|
|
1556
1556
|
// SDK 状态
|
|
@@ -1562,12 +1562,12 @@ class or {
|
|
|
1562
1562
|
},
|
|
1563
1563
|
// 平台信息
|
|
1564
1564
|
platform: {
|
|
1565
|
-
type:
|
|
1566
|
-
isWeixinMiniProgram:
|
|
1567
|
-
isAppPlus:
|
|
1568
|
-
isNvue:
|
|
1569
|
-
isUvue:
|
|
1570
|
-
isOfflineWebview:
|
|
1565
|
+
type: f.type,
|
|
1566
|
+
isWeixinMiniProgram: f.isWeixinMiniProgram,
|
|
1567
|
+
isAppPlus: f.isAppPlus,
|
|
1568
|
+
isNvue: f.isNvue,
|
|
1569
|
+
isUvue: f.isUvue,
|
|
1570
|
+
isOfflineWebview: f.isOfflineWebview,
|
|
1571
1571
|
features: {}
|
|
1572
1572
|
// 平台支持的特性
|
|
1573
1573
|
},
|
|
@@ -1595,7 +1595,7 @@ class or {
|
|
|
1595
1595
|
api: {
|
|
1596
1596
|
// 格式: { apiName: { loading: boolean, lastCall: timestamp, lastResult: any } }
|
|
1597
1597
|
}
|
|
1598
|
-
}, this.listeners = /* @__PURE__ */ new Map(), this.wildcardListeners = /* @__PURE__ */ new Set(), this.initNetworkListener(),
|
|
1598
|
+
}, this.listeners = /* @__PURE__ */ new Map(), this.wildcardListeners = /* @__PURE__ */ new Set(), this.initNetworkListener(), D.debug("状态仓库已初始化");
|
|
1599
1599
|
}
|
|
1600
1600
|
/**
|
|
1601
1601
|
* 获取状态值
|
|
@@ -1617,8 +1617,8 @@ class or {
|
|
|
1617
1617
|
* store.set('network.online', false)
|
|
1618
1618
|
*/
|
|
1619
1619
|
set(e, r) {
|
|
1620
|
-
const n = e.split("."), i = n.pop(), s = n.reduce((
|
|
1621
|
-
|
|
1620
|
+
const n = e.split("."), i = n.pop(), s = n.reduce((d, l) => ((!d[l] || typeof d[l] != "object") && (d[l] = {}), d[l]), this.state), o = s[i];
|
|
1621
|
+
o !== r && (s[i] = r, D.debug(`状态已更新: ${e}`, { oldValue: o, newValue: r }), this.notify(e, r, o));
|
|
1622
1622
|
}
|
|
1623
1623
|
/**
|
|
1624
1624
|
* 批量更新状态
|
|
@@ -1649,11 +1649,11 @@ class or {
|
|
|
1649
1649
|
subscribe(e, r) {
|
|
1650
1650
|
if (typeof r != "function")
|
|
1651
1651
|
throw new Error("listener 必须是函数");
|
|
1652
|
-
return e === "*" ? (this.wildcardListeners.add(r),
|
|
1653
|
-
this.wildcardListeners.delete(r),
|
|
1654
|
-
}) : (this.listeners.has(e) || this.listeners.set(e, /* @__PURE__ */ new Set()), this.listeners.get(e).add(r),
|
|
1652
|
+
return e === "*" ? (this.wildcardListeners.add(r), D.debug("添加通配符订阅者"), () => {
|
|
1653
|
+
this.wildcardListeners.delete(r), D.debug("移除通配符订阅者");
|
|
1654
|
+
}) : (this.listeners.has(e) || this.listeners.set(e, /* @__PURE__ */ new Set()), this.listeners.get(e).add(r), D.debug(`添加订阅者: ${e}`), () => {
|
|
1655
1655
|
const n = this.listeners.get(e);
|
|
1656
|
-
n && (n.delete(r), n.size === 0 && this.listeners.delete(e),
|
|
1656
|
+
n && (n.delete(r), n.size === 0 && this.listeners.delete(e), D.debug(`移除订阅者: ${e}`));
|
|
1657
1657
|
});
|
|
1658
1658
|
}
|
|
1659
1659
|
/**
|
|
@@ -1663,8 +1663,8 @@ class or {
|
|
|
1663
1663
|
* @returns {Function} 取消订阅的函数
|
|
1664
1664
|
*/
|
|
1665
1665
|
subscribeOnce(e, r) {
|
|
1666
|
-
const n = this.subscribe(e, (i, s,
|
|
1667
|
-
r(i, s,
|
|
1666
|
+
const n = this.subscribe(e, (i, s, o) => {
|
|
1667
|
+
r(i, s, o), n();
|
|
1668
1668
|
});
|
|
1669
1669
|
return n;
|
|
1670
1670
|
}
|
|
@@ -1677,32 +1677,32 @@ class or {
|
|
|
1677
1677
|
*/
|
|
1678
1678
|
notify(e, r, n) {
|
|
1679
1679
|
const i = this.listeners.get(e);
|
|
1680
|
-
i && i.forEach((
|
|
1680
|
+
i && i.forEach((o) => {
|
|
1681
1681
|
try {
|
|
1682
|
-
|
|
1683
|
-
} catch (
|
|
1684
|
-
|
|
1682
|
+
o(r, n, e);
|
|
1683
|
+
} catch (d) {
|
|
1684
|
+
D.error("订阅者执行失败", d);
|
|
1685
1685
|
}
|
|
1686
1686
|
});
|
|
1687
1687
|
const s = e.split(".");
|
|
1688
|
-
for (let
|
|
1689
|
-
const
|
|
1690
|
-
if (
|
|
1691
|
-
const
|
|
1692
|
-
|
|
1688
|
+
for (let o = 1; o < s.length; o++) {
|
|
1689
|
+
const d = s.slice(0, o).join("."), l = this.listeners.get(d);
|
|
1690
|
+
if (l) {
|
|
1691
|
+
const w = this.get(d);
|
|
1692
|
+
l.forEach((N) => {
|
|
1693
1693
|
try {
|
|
1694
|
-
|
|
1694
|
+
N(w, void 0, d);
|
|
1695
1695
|
} catch (O) {
|
|
1696
|
-
|
|
1696
|
+
D.error("父路径订阅者执行失败", O);
|
|
1697
1697
|
}
|
|
1698
1698
|
});
|
|
1699
1699
|
}
|
|
1700
1700
|
}
|
|
1701
|
-
this.wildcardListeners.forEach((
|
|
1701
|
+
this.wildcardListeners.forEach((o) => {
|
|
1702
1702
|
try {
|
|
1703
|
-
|
|
1704
|
-
} catch (
|
|
1705
|
-
|
|
1703
|
+
o(r, n, e);
|
|
1704
|
+
} catch (d) {
|
|
1705
|
+
D.error("通配符订阅者执行失败", d);
|
|
1706
1706
|
}
|
|
1707
1707
|
});
|
|
1708
1708
|
}
|
|
@@ -1781,7 +1781,7 @@ class or {
|
|
|
1781
1781
|
album: "prompt"
|
|
1782
1782
|
},
|
|
1783
1783
|
api: {}
|
|
1784
|
-
},
|
|
1784
|
+
}, D.debug("状态已重置");
|
|
1785
1785
|
}
|
|
1786
1786
|
/**
|
|
1787
1787
|
* 获取统计信息
|
|
@@ -1795,7 +1795,7 @@ class or {
|
|
|
1795
1795
|
};
|
|
1796
1796
|
}
|
|
1797
1797
|
}
|
|
1798
|
-
const
|
|
1798
|
+
const B = new pr(), c = {
|
|
1799
1799
|
// SDK 核心错误 (E_SDK_xxx)
|
|
1800
1800
|
SDK_NOT_READY: "E_SDK_001",
|
|
1801
1801
|
SDK_INIT_FAILED: "E_SDK_002",
|
|
@@ -1846,48 +1846,48 @@ const W = new or(), o = {
|
|
|
1846
1846
|
API_TIMEOUT: "E_TIMEOUT_001",
|
|
1847
1847
|
// 通用错误
|
|
1848
1848
|
UNKNOWN_ERROR: "E_UNKNOWN_999"
|
|
1849
|
-
},
|
|
1849
|
+
}, Te = {
|
|
1850
1850
|
// SDK 核心
|
|
1851
|
-
[
|
|
1852
|
-
[
|
|
1853
|
-
[
|
|
1854
|
-
[
|
|
1851
|
+
[c.SDK_NOT_READY]: "SDK 未就绪",
|
|
1852
|
+
[c.SDK_INIT_FAILED]: "SDK 初始化失败",
|
|
1853
|
+
[c.SDK_CONFIG_FAILED]: "SDK 配置失败",
|
|
1854
|
+
[c.PLATFORM_NOT_SUPPORTED]: "当前平台不支持此功能",
|
|
1855
1855
|
// 网络
|
|
1856
|
-
[
|
|
1857
|
-
[
|
|
1858
|
-
[
|
|
1856
|
+
[c.NETWORK_ERROR]: "网络错误",
|
|
1857
|
+
[c.NETWORK_TIMEOUT]: "网络超时",
|
|
1858
|
+
[c.NETWORK_OFFLINE]: "网络已断开",
|
|
1859
1859
|
// 图片
|
|
1860
|
-
[
|
|
1861
|
-
[
|
|
1862
|
-
[
|
|
1863
|
-
[
|
|
1864
|
-
[
|
|
1865
|
-
[
|
|
1860
|
+
[c.IMAGE_CANCELLED]: "用户取消选择图片",
|
|
1861
|
+
[c.IMAGE_NO_PERMISSION]: "无相机/相册权限",
|
|
1862
|
+
[c.IMAGE_SIZE_EXCEED]: "图片大小超出限制",
|
|
1863
|
+
[c.IMAGE_COUNT_EXCEED]: "图片数量超出限制",
|
|
1864
|
+
[c.IMAGE_FORMAT_ERROR]: "图片格式不支持",
|
|
1865
|
+
[c.IMAGE_CONFIG_NOT_READY]: "微信配置未完成",
|
|
1866
1866
|
// 定位
|
|
1867
|
-
[
|
|
1868
|
-
[
|
|
1869
|
-
[
|
|
1870
|
-
[
|
|
1867
|
+
[c.LOCATION_CANCELLED]: "用户取消定位",
|
|
1868
|
+
[c.LOCATION_NO_PERMISSION]: "无定位权限",
|
|
1869
|
+
[c.LOCATION_UNAVAILABLE]: "定位服务不可用",
|
|
1870
|
+
[c.LOCATION_TIMEOUT]: "定位超时",
|
|
1871
1871
|
// 扫码
|
|
1872
|
-
[
|
|
1873
|
-
[
|
|
1874
|
-
[
|
|
1875
|
-
[
|
|
1872
|
+
[c.SCAN_CANCELLED]: "用户取消扫码",
|
|
1873
|
+
[c.SCAN_NO_PERMISSION]: "无相机权限",
|
|
1874
|
+
[c.SCAN_INVALID_CODE]: "无效的二维码/条形码",
|
|
1875
|
+
[c.SCAN_CONFIG_NOT_READY]: "微信配置未完成",
|
|
1876
1876
|
// 权限
|
|
1877
|
-
[
|
|
1878
|
-
[
|
|
1879
|
-
[
|
|
1880
|
-
[
|
|
1881
|
-
[
|
|
1877
|
+
[c.PERMISSION_DENIED]: "权限被拒绝",
|
|
1878
|
+
[c.PERMISSION_CAMERA]: "无相机权限",
|
|
1879
|
+
[c.PERMISSION_LOCATION]: "无定位权限",
|
|
1880
|
+
[c.PERMISSION_ALBUM]: "无相册权限",
|
|
1881
|
+
[c.PERMISSION_MICROPHONE]: "无麦克风权限",
|
|
1882
1882
|
// 参数
|
|
1883
|
-
[
|
|
1884
|
-
[
|
|
1885
|
-
[
|
|
1883
|
+
[c.PARAM_INVALID]: "参数无效",
|
|
1884
|
+
[c.PARAM_MISSING]: "缺少必需参数",
|
|
1885
|
+
[c.PARAM_TYPE_ERROR]: "参数类型错误",
|
|
1886
1886
|
// 超时
|
|
1887
|
-
[
|
|
1887
|
+
[c.API_TIMEOUT]: "API 调用超时",
|
|
1888
1888
|
// 通用
|
|
1889
|
-
[
|
|
1890
|
-
},
|
|
1889
|
+
[c.UNKNOWN_ERROR]: "未知错误"
|
|
1890
|
+
}, W = {
|
|
1891
1891
|
USER_CANCEL: "user_cancel",
|
|
1892
1892
|
// 用户主动取消
|
|
1893
1893
|
PERMISSION: "permission",
|
|
@@ -1902,75 +1902,75 @@ const W = new or(), o = {
|
|
|
1902
1902
|
// 配置问题
|
|
1903
1903
|
UNKNOWN: "unknown"
|
|
1904
1904
|
// 未知问题
|
|
1905
|
-
},
|
|
1905
|
+
}, wr = {
|
|
1906
1906
|
// 图片相关
|
|
1907
|
-
"IMAGE/USER_CANCEL":
|
|
1908
|
-
"IMAGE/PERMISSION_DENIED":
|
|
1907
|
+
"IMAGE/USER_CANCEL": c.IMAGE_CANCELLED,
|
|
1908
|
+
"IMAGE/PERMISSION_DENIED": c.IMAGE_NO_PERMISSION,
|
|
1909
1909
|
// 通用错误
|
|
1910
|
-
"COMMON/UNKNOWN":
|
|
1911
|
-
"COMMON/CONFIG_NOT_READY":
|
|
1912
|
-
"COMMON/PLATFORM_NOT_SUPPORTED":
|
|
1913
|
-
},
|
|
1910
|
+
"COMMON/UNKNOWN": c.UNKNOWN_ERROR,
|
|
1911
|
+
"COMMON/CONFIG_NOT_READY": c.IMAGE_CONFIG_NOT_READY,
|
|
1912
|
+
"COMMON/PLATFORM_NOT_SUPPORTED": c.PLATFORM_NOT_SUPPORTED
|
|
1913
|
+
}, je = {
|
|
1914
1914
|
// 微信平台错误模式
|
|
1915
1915
|
weixin: {
|
|
1916
1916
|
patterns: [
|
|
1917
|
-
{ pattern: /cancel/i, code:
|
|
1918
|
-
{ pattern: /permission|auth\s*deny/i, code:
|
|
1919
|
-
{ pattern: /config/i, code:
|
|
1920
|
-
{ pattern: /timeout/i, code:
|
|
1921
|
-
{ pattern: /network/i, code:
|
|
1917
|
+
{ pattern: /cancel/i, code: c.IMAGE_CANCELLED },
|
|
1918
|
+
{ pattern: /permission|auth\s*deny/i, code: c.IMAGE_NO_PERMISSION },
|
|
1919
|
+
{ pattern: /config/i, code: c.IMAGE_CONFIG_NOT_READY },
|
|
1920
|
+
{ pattern: /timeout/i, code: c.API_TIMEOUT },
|
|
1921
|
+
{ pattern: /network/i, code: c.NETWORK_ERROR }
|
|
1922
1922
|
],
|
|
1923
|
-
default:
|
|
1923
|
+
default: c.UNKNOWN_ERROR
|
|
1924
1924
|
},
|
|
1925
1925
|
// UniApp 平台错误模式
|
|
1926
1926
|
uniapp: {
|
|
1927
1927
|
patterns: [
|
|
1928
|
-
{ pattern: /cancel/i, code:
|
|
1929
|
-
{ pattern: /permission|denied/i, code:
|
|
1930
|
-
{ pattern: /timeout/i, code:
|
|
1931
|
-
{ pattern: /network/i, code:
|
|
1932
|
-
{ pattern: /not_in_container/i, code:
|
|
1928
|
+
{ pattern: /cancel/i, code: c.IMAGE_CANCELLED },
|
|
1929
|
+
{ pattern: /permission|denied/i, code: c.IMAGE_NO_PERMISSION },
|
|
1930
|
+
{ pattern: /timeout/i, code: c.API_TIMEOUT },
|
|
1931
|
+
{ pattern: /network/i, code: c.NETWORK_ERROR },
|
|
1932
|
+
{ pattern: /not_in_container/i, code: c.PLATFORM_NOT_SUPPORTED }
|
|
1933
1933
|
],
|
|
1934
|
-
default:
|
|
1934
|
+
default: c.UNKNOWN_ERROR
|
|
1935
1935
|
},
|
|
1936
1936
|
// 离线包环境错误模式(与 uniapp 一致,走消息桥)
|
|
1937
1937
|
offline: {
|
|
1938
1938
|
patterns: [
|
|
1939
|
-
{ pattern: /cancel/i, code:
|
|
1940
|
-
{ pattern: /permission|denied/i, code:
|
|
1941
|
-
{ pattern: /timeout/i, code:
|
|
1942
|
-
{ pattern: /network/i, code:
|
|
1943
|
-
{ pattern: /not_in_container/i, code:
|
|
1939
|
+
{ pattern: /cancel/i, code: c.IMAGE_CANCELLED },
|
|
1940
|
+
{ pattern: /permission|denied/i, code: c.IMAGE_NO_PERMISSION },
|
|
1941
|
+
{ pattern: /timeout/i, code: c.API_TIMEOUT },
|
|
1942
|
+
{ pattern: /network/i, code: c.NETWORK_ERROR },
|
|
1943
|
+
{ pattern: /not_in_container/i, code: c.PLATFORM_NOT_SUPPORTED }
|
|
1944
1944
|
],
|
|
1945
|
-
default:
|
|
1945
|
+
default: c.UNKNOWN_ERROR
|
|
1946
1946
|
}
|
|
1947
|
-
},
|
|
1947
|
+
}, Je = {
|
|
1948
1948
|
chooseImage: {
|
|
1949
|
-
"fail cancel":
|
|
1950
|
-
"fail auth deny":
|
|
1951
|
-
"fail No Permission":
|
|
1952
|
-
NOT_IN_CONTAINER:
|
|
1949
|
+
"fail cancel": c.IMAGE_CANCELLED,
|
|
1950
|
+
"fail auth deny": c.IMAGE_NO_PERMISSION,
|
|
1951
|
+
"fail No Permission": c.IMAGE_NO_PERMISSION,
|
|
1952
|
+
NOT_IN_CONTAINER: c.PLATFORM_NOT_SUPPORTED
|
|
1953
1953
|
},
|
|
1954
1954
|
scanCode: {
|
|
1955
|
-
"fail cancel":
|
|
1956
|
-
"fail auth deny":
|
|
1957
|
-
"fail No Permission":
|
|
1958
|
-
NOT_IN_CONTAINER:
|
|
1955
|
+
"fail cancel": c.SCAN_CANCELLED,
|
|
1956
|
+
"fail auth deny": c.SCAN_NO_PERMISSION,
|
|
1957
|
+
"fail No Permission": c.SCAN_NO_PERMISSION,
|
|
1958
|
+
NOT_IN_CONTAINER: c.PLATFORM_NOT_SUPPORTED
|
|
1959
1959
|
}
|
|
1960
1960
|
};
|
|
1961
|
-
function
|
|
1962
|
-
return t ? t.includes("CANCEL") ?
|
|
1961
|
+
function it(t) {
|
|
1962
|
+
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;
|
|
1963
1963
|
}
|
|
1964
|
-
function
|
|
1965
|
-
return t.includes("NET_") || t.includes("TIMEOUT") || t ===
|
|
1964
|
+
function Er(t) {
|
|
1965
|
+
return t.includes("NET_") || t.includes("TIMEOUT") || t === c.NETWORK_ERROR || t === c.NETWORK_TIMEOUT || t === c.API_TIMEOUT;
|
|
1966
1966
|
}
|
|
1967
|
-
function
|
|
1968
|
-
return t.includes("CANCEL") ||
|
|
1967
|
+
function yr(t) {
|
|
1968
|
+
return t.includes("CANCEL") || it(t) === W.USER_CANCEL;
|
|
1969
1969
|
}
|
|
1970
|
-
function
|
|
1971
|
-
return
|
|
1970
|
+
function ne(t) {
|
|
1971
|
+
return Te[t] || Te[c.UNKNOWN_ERROR];
|
|
1972
1972
|
}
|
|
1973
|
-
class
|
|
1973
|
+
class K extends Error {
|
|
1974
1974
|
/**
|
|
1975
1975
|
* 构造函数
|
|
1976
1976
|
* @param {string} code - 错误码
|
|
@@ -1978,7 +1978,7 @@ class F extends Error {
|
|
|
1978
1978
|
* @param {Object} options - 选项
|
|
1979
1979
|
*/
|
|
1980
1980
|
constructor(e, r, n = {}) {
|
|
1981
|
-
super(r), this.name = "StandardError", this.code = e, this.message = r ||
|
|
1981
|
+
super(r), this.name = "StandardError", this.code = e, this.message = r || ne(e), this.platform = n.platform || f.type, this.apiName = n.apiName, this.category = n.category || it(e), this.retriable = n.retriable !== void 0 ? n.retriable : Er(e), this.originalError = n.originalError, this.details = n.details || {}, this.timestamp = Date.now();
|
|
1982
1982
|
}
|
|
1983
1983
|
/**
|
|
1984
1984
|
* 是否可重试
|
|
@@ -1992,7 +1992,7 @@ class F extends Error {
|
|
|
1992
1992
|
* @returns {boolean}
|
|
1993
1993
|
*/
|
|
1994
1994
|
isUserAction() {
|
|
1995
|
-
return
|
|
1995
|
+
return yr(this.code);
|
|
1996
1996
|
}
|
|
1997
1997
|
/**
|
|
1998
1998
|
* 转为普通对象
|
|
@@ -2013,16 +2013,16 @@ class F extends Error {
|
|
|
2013
2013
|
} : {});
|
|
2014
2014
|
}
|
|
2015
2015
|
}
|
|
2016
|
-
function
|
|
2017
|
-
if (t instanceof
|
|
2016
|
+
function at(t, e = {}) {
|
|
2017
|
+
if (t instanceof K)
|
|
2018
2018
|
return t;
|
|
2019
|
-
const { apiName: r, platform: n =
|
|
2020
|
-
return t && typeof t.code == "string" && t.code.includes("/") ?
|
|
2021
|
-
|
|
2019
|
+
const { apiName: r, platform: n = f.type } = e;
|
|
2020
|
+
return t && typeof t.code == "string" && t.code.includes("/") ? Ir(t, { apiName: r, platform: n }) : t && (t.errMsg || t.message) ? Ar(t, { apiName: r, platform: n }) : typeof t == "string" ? new K(
|
|
2021
|
+
c.UNKNOWN_ERROR,
|
|
2022
2022
|
t,
|
|
2023
2023
|
{ apiName: r, platform: n, originalError: t }
|
|
2024
|
-
) : new
|
|
2025
|
-
|
|
2024
|
+
) : new K(
|
|
2025
|
+
c.UNKNOWN_ERROR,
|
|
2026
2026
|
"未知错误",
|
|
2027
2027
|
{
|
|
2028
2028
|
apiName: r,
|
|
@@ -2032,14 +2032,14 @@ function Qe(t, e = {}) {
|
|
|
2032
2032
|
}
|
|
2033
2033
|
);
|
|
2034
2034
|
}
|
|
2035
|
-
function
|
|
2036
|
-
const { apiName: r, platform: n } = e, i = t.code, s =
|
|
2035
|
+
function Ir(t, e) {
|
|
2036
|
+
const { apiName: r, platform: n } = e, i = t.code, s = wr[i] || c.UNKNOWN_ERROR;
|
|
2037
2037
|
return a.debug("转换旧版错误码", {
|
|
2038
2038
|
legacy: i,
|
|
2039
2039
|
new: s
|
|
2040
|
-
}), new
|
|
2040
|
+
}), new K(
|
|
2041
2041
|
s,
|
|
2042
|
-
t.message ||
|
|
2042
|
+
t.message || ne(s),
|
|
2043
2043
|
{
|
|
2044
2044
|
apiName: r,
|
|
2045
2045
|
platform: t.platform || n,
|
|
@@ -2051,30 +2051,30 @@ function fr(t, e) {
|
|
|
2051
2051
|
}
|
|
2052
2052
|
);
|
|
2053
2053
|
}
|
|
2054
|
-
function
|
|
2054
|
+
function Ar(t, e) {
|
|
2055
2055
|
const { apiName: r, platform: n } = e, i = (t.errMsg || t.message || "").toLowerCase();
|
|
2056
|
-
if (r &&
|
|
2057
|
-
const
|
|
2058
|
-
for (const [
|
|
2059
|
-
if (i.includes(
|
|
2060
|
-
return new
|
|
2056
|
+
if (r && Je[r]) {
|
|
2057
|
+
const d = Je[r];
|
|
2058
|
+
for (const [l, w] of Object.entries(d))
|
|
2059
|
+
if (i.includes(l.toLowerCase()))
|
|
2060
|
+
return new K(w, ne(w), {
|
|
2061
2061
|
apiName: r,
|
|
2062
2062
|
platform: n,
|
|
2063
2063
|
originalError: t
|
|
2064
2064
|
});
|
|
2065
2065
|
}
|
|
2066
|
-
const s =
|
|
2067
|
-
for (const { pattern:
|
|
2068
|
-
if (
|
|
2069
|
-
return new
|
|
2066
|
+
const s = je[n] || je.uniapp;
|
|
2067
|
+
for (const { pattern: d, code: l } of s.patterns)
|
|
2068
|
+
if (d.test(i))
|
|
2069
|
+
return new K(l, ne(l), {
|
|
2070
2070
|
apiName: r,
|
|
2071
2071
|
platform: n,
|
|
2072
2072
|
originalError: t
|
|
2073
2073
|
});
|
|
2074
|
-
const
|
|
2075
|
-
return new
|
|
2076
|
-
|
|
2077
|
-
t.errMsg || t.message ||
|
|
2074
|
+
const o = s.default || c.UNKNOWN_ERROR;
|
|
2075
|
+
return new K(
|
|
2076
|
+
o,
|
|
2077
|
+
t.errMsg || t.message || ne(o),
|
|
2078
2078
|
{
|
|
2079
2079
|
apiName: r,
|
|
2080
2080
|
platform: n,
|
|
@@ -2082,7 +2082,7 @@ function dr(t, e) {
|
|
|
2082
2082
|
}
|
|
2083
2083
|
);
|
|
2084
2084
|
}
|
|
2085
|
-
const
|
|
2085
|
+
const st = {
|
|
2086
2086
|
/**
|
|
2087
2087
|
* 响应拦截器
|
|
2088
2088
|
* @param {Object} result - API 响应结果
|
|
@@ -2091,9 +2091,9 @@ const et = {
|
|
|
2091
2091
|
*/
|
|
2092
2092
|
response: (t, e) => {
|
|
2093
2093
|
if (!t.success && t.error) {
|
|
2094
|
-
const r =
|
|
2094
|
+
const r = at(t.error, {
|
|
2095
2095
|
apiName: e.apiName,
|
|
2096
|
-
platform:
|
|
2096
|
+
platform: f.type
|
|
2097
2097
|
});
|
|
2098
2098
|
t.error = r.toJSON(), t.errorCode = r.code, t.errorCategory = r.category, t.retriable = r.isRetriable(), a.debug("错误已标准化", {
|
|
2099
2099
|
api: e.apiName,
|
|
@@ -2104,25 +2104,25 @@ const et = {
|
|
|
2104
2104
|
return t;
|
|
2105
2105
|
}
|
|
2106
2106
|
};
|
|
2107
|
-
function
|
|
2108
|
-
return new
|
|
2107
|
+
function Pr(t, e = {}) {
|
|
2108
|
+
return new K(t, ne(t), e);
|
|
2109
2109
|
}
|
|
2110
|
-
function
|
|
2111
|
-
return t instanceof
|
|
2110
|
+
function _r(t) {
|
|
2111
|
+
return t instanceof K;
|
|
2112
2112
|
}
|
|
2113
|
-
function
|
|
2113
|
+
function Cr(t, e, r) {
|
|
2114
2114
|
return e ? Promise.race([
|
|
2115
2115
|
t(),
|
|
2116
2116
|
new Promise((n, i) => setTimeout(() => i(new Error(`Init task timeout: ${r}`)), e))
|
|
2117
2117
|
]) : t();
|
|
2118
2118
|
}
|
|
2119
|
-
function
|
|
2120
|
-
return
|
|
2119
|
+
function Mr() {
|
|
2120
|
+
return p(this, arguments, function* (t = [], e = {}) {
|
|
2121
2121
|
for (const r of t) {
|
|
2122
2122
|
const n = (r == null ? void 0 : r.name) || "anonymous-task", i = (r == null ? void 0 : r.run) || r;
|
|
2123
2123
|
if (typeof i == "function")
|
|
2124
2124
|
try {
|
|
2125
|
-
yield
|
|
2125
|
+
yield Cr(() => Promise.resolve().then(() => i()), r.timeoutMs, n), typeof r.onSuccess == "function" && r.onSuccess();
|
|
2126
2126
|
} catch (s) {
|
|
2127
2127
|
if (typeof r.onError == "function" && r.onError(s), typeof e.onError == "function")
|
|
2128
2128
|
e.onError(s, r);
|
|
@@ -2132,7 +2132,7 @@ function pr() {
|
|
|
2132
2132
|
}
|
|
2133
2133
|
});
|
|
2134
2134
|
}
|
|
2135
|
-
class
|
|
2135
|
+
class ot {
|
|
2136
2136
|
/**
|
|
2137
2137
|
* 构造函数
|
|
2138
2138
|
* @param {string} name - 平台名称
|
|
@@ -2258,18 +2258,18 @@ class tt {
|
|
|
2258
2258
|
throw new Error(`${this.name} platform must implement performGetEnv method`);
|
|
2259
2259
|
}
|
|
2260
2260
|
}
|
|
2261
|
-
let
|
|
2262
|
-
function
|
|
2263
|
-
if (
|
|
2261
|
+
let le = [];
|
|
2262
|
+
function Or() {
|
|
2263
|
+
if (le.length === 0 && window.plus) {
|
|
2264
2264
|
const t = plus.webview.currentWebview();
|
|
2265
2265
|
if (!t)
|
|
2266
2266
|
throw new Error("plus.webview.currentWebview() is undefined");
|
|
2267
2267
|
const e = t.parent(), r = e ? e.id : t.id;
|
|
2268
|
-
|
|
2268
|
+
le.push(r);
|
|
2269
2269
|
}
|
|
2270
|
-
return
|
|
2270
|
+
return le;
|
|
2271
2271
|
}
|
|
2272
|
-
function
|
|
2272
|
+
function Rr(t, e) {
|
|
2273
2273
|
const r = {
|
|
2274
2274
|
options: {
|
|
2275
2275
|
timestamp: +/* @__PURE__ */ new Date()
|
|
@@ -2285,12 +2285,12 @@ function Er(t, e) {
|
|
|
2285
2285
|
type: "WEB_INVOKE_APPSERVICE",
|
|
2286
2286
|
args: {
|
|
2287
2287
|
data: r,
|
|
2288
|
-
webviewIds:
|
|
2288
|
+
webviewIds: le
|
|
2289
2289
|
}
|
|
2290
2290
|
};
|
|
2291
2291
|
window.__uniapp_x_postMessage ? window.__uniapp_x_postMessageToService(n) : window.__uniapp_x_.postMessageToService(JSON.stringify(n));
|
|
2292
2292
|
}
|
|
2293
|
-
function
|
|
2293
|
+
function Nr(t, e) {
|
|
2294
2294
|
const r = {
|
|
2295
2295
|
options: {
|
|
2296
2296
|
timestamp: +/* @__PURE__ */ new Date()
|
|
@@ -2306,19 +2306,19 @@ function yr(t, e) {
|
|
|
2306
2306
|
type: "WEB_INVOKE_APPSERVICE",
|
|
2307
2307
|
args: {
|
|
2308
2308
|
data: r,
|
|
2309
|
-
webviewIds:
|
|
2309
|
+
webviewIds: le
|
|
2310
2310
|
}
|
|
2311
2311
|
};
|
|
2312
2312
|
window.__dcloud_weex_postMessage ? window.__dcloud_weex_postMessageToService(n) : window.__dcloud_weex_.postMessageToService(JSON.stringify(n));
|
|
2313
2313
|
}
|
|
2314
|
-
function
|
|
2314
|
+
function Sr(t, e) {
|
|
2315
2315
|
const r = {
|
|
2316
2316
|
options: {
|
|
2317
2317
|
timestamp: +/* @__PURE__ */ new Date()
|
|
2318
2318
|
},
|
|
2319
2319
|
name: t,
|
|
2320
2320
|
arg: e
|
|
2321
|
-
}, n =
|
|
2321
|
+
}, n = Or();
|
|
2322
2322
|
if (plus.webview.getWebviewById("__uniapp__service"))
|
|
2323
2323
|
plus.webview.postMessageToUniNView({
|
|
2324
2324
|
type: "WEB_INVOKE_APPSERVICE",
|
|
@@ -2334,7 +2334,7 @@ function Ir(t, e) {
|
|
|
2334
2334
|
);
|
|
2335
2335
|
}
|
|
2336
2336
|
}
|
|
2337
|
-
function
|
|
2337
|
+
function Tr(t, e) {
|
|
2338
2338
|
const r = {
|
|
2339
2339
|
options: {
|
|
2340
2340
|
timestamp: +/* @__PURE__ */ new Date()
|
|
@@ -2348,10 +2348,10 @@ function Ar(t, e) {
|
|
|
2348
2348
|
pageId: ""
|
|
2349
2349
|
}, "*");
|
|
2350
2350
|
}
|
|
2351
|
-
function
|
|
2351
|
+
function Lr(t) {
|
|
2352
2352
|
return !!(t && typeof t == "object" && t.type === "qsh_api_call" && typeof t.api == "string" && typeof t.callbackId == "string");
|
|
2353
2353
|
}
|
|
2354
|
-
function
|
|
2354
|
+
function br(t, e) {
|
|
2355
2355
|
const r = {
|
|
2356
2356
|
options: {
|
|
2357
2357
|
timestamp: +/* @__PURE__ */ new Date()
|
|
@@ -2359,7 +2359,7 @@ function _r(t, e) {
|
|
|
2359
2359
|
name: t,
|
|
2360
2360
|
arg: e
|
|
2361
2361
|
};
|
|
2362
|
-
if (t === "postMessage" &&
|
|
2362
|
+
if (t === "postMessage" && Lr(e))
|
|
2363
2363
|
return window.__offline_bridge_postMessage(e);
|
|
2364
2364
|
window.__offline_bridge_postMessage({
|
|
2365
2365
|
type: "WEB_INVOKE_APPSERVICE",
|
|
@@ -2367,10 +2367,10 @@ function _r(t, e) {
|
|
|
2367
2367
|
pageId: ""
|
|
2368
2368
|
});
|
|
2369
2369
|
}
|
|
2370
|
-
function
|
|
2371
|
-
|
|
2370
|
+
function de(t, e) {
|
|
2371
|
+
Me() ? Rr(t, e) : Ce() ? Nr(t, e) : X() ? br(t, e) : _e() ? Sr(t, e) : Tr(t, e);
|
|
2372
2372
|
}
|
|
2373
|
-
class
|
|
2373
|
+
class ct extends ot {
|
|
2374
2374
|
constructor() {
|
|
2375
2375
|
super("weixin");
|
|
2376
2376
|
}
|
|
@@ -2391,15 +2391,15 @@ class rt extends tt {
|
|
|
2391
2391
|
performNavigation(e, r) {
|
|
2392
2392
|
return u.safeExecute(() => {
|
|
2393
2393
|
const { url: n, delta: i } = r;
|
|
2394
|
-
if (
|
|
2395
|
-
const
|
|
2396
|
-
if (typeof
|
|
2397
|
-
|
|
2398
|
-
const
|
|
2399
|
-
return
|
|
2394
|
+
if (I.debug(`微信平台执行导航操作: ${e}`, r), this.isWeixinApiAvailable()) {
|
|
2395
|
+
const o = window.wx.miniProgram[e];
|
|
2396
|
+
if (typeof o == "function") {
|
|
2397
|
+
I.debug(`使用微信原生 API: wx.miniProgram.${e}`);
|
|
2398
|
+
const d = e === "navigateBack" ? { delta: i } : { url: n };
|
|
2399
|
+
return o.call(window.wx.miniProgram, d);
|
|
2400
2400
|
}
|
|
2401
2401
|
}
|
|
2402
|
-
|
|
2402
|
+
I.debug(`使用消息桥接执行: ${e}`), de(e, e === "navigateBack" ? { delta: i } : { url: n });
|
|
2403
2403
|
}, {
|
|
2404
2404
|
platform: this.name,
|
|
2405
2405
|
method: "performNavigation",
|
|
@@ -2417,7 +2417,7 @@ class rt extends tt {
|
|
|
2417
2417
|
const { data: r } = e;
|
|
2418
2418
|
if (this.isWeixinApiAvailable())
|
|
2419
2419
|
return window.wx.miniProgram.postMessage({ data: r });
|
|
2420
|
-
|
|
2420
|
+
de("postMessage", r);
|
|
2421
2421
|
}, {
|
|
2422
2422
|
platform: this.name,
|
|
2423
2423
|
method: "performPostMessage",
|
|
@@ -2445,19 +2445,19 @@ class rt extends tt {
|
|
|
2445
2445
|
});
|
|
2446
2446
|
}
|
|
2447
2447
|
}
|
|
2448
|
-
const
|
|
2449
|
-
var
|
|
2448
|
+
const ee = new ct(), vr = (t) => ee.navigateTo(t), xr = (t) => ee.navigateBack(t), Dr = (t) => ee.switchTab(t), Ur = (t) => ee.reLaunch(t), Wr = (t) => ee.redirectTo(t), $r = (t) => ee.postMessage(t), Fr = (t) => ee.getEnv(t);
|
|
2449
|
+
var ut = /* @__PURE__ */ Object.freeze({
|
|
2450
2450
|
__proto__: null,
|
|
2451
|
-
WeixinPlatform:
|
|
2452
|
-
getEnv:
|
|
2453
|
-
navigateBack:
|
|
2454
|
-
navigateTo:
|
|
2455
|
-
postMessage:
|
|
2456
|
-
reLaunch:
|
|
2457
|
-
redirectTo:
|
|
2458
|
-
switchTab:
|
|
2451
|
+
WeixinPlatform: ct,
|
|
2452
|
+
getEnv: Fr,
|
|
2453
|
+
navigateBack: xr,
|
|
2454
|
+
navigateTo: vr,
|
|
2455
|
+
postMessage: $r,
|
|
2456
|
+
reLaunch: Ur,
|
|
2457
|
+
redirectTo: Wr,
|
|
2458
|
+
switchTab: Dr
|
|
2459
2459
|
});
|
|
2460
|
-
class
|
|
2460
|
+
class lt extends ot {
|
|
2461
2461
|
constructor() {
|
|
2462
2462
|
super("app");
|
|
2463
2463
|
}
|
|
@@ -2470,7 +2470,7 @@ class it extends tt {
|
|
|
2470
2470
|
performNavigation(e, r) {
|
|
2471
2471
|
return u.safeExecute(() => {
|
|
2472
2472
|
const { url: n, delta: i } = r;
|
|
2473
|
-
|
|
2473
|
+
de(e, e === "navigateBack" ? { delta: i } : { url: n });
|
|
2474
2474
|
}, {
|
|
2475
2475
|
platform: this.name,
|
|
2476
2476
|
method: "performNavigation",
|
|
@@ -2486,7 +2486,7 @@ class it extends tt {
|
|
|
2486
2486
|
performPostMessage(e) {
|
|
2487
2487
|
return u.safeExecute(() => {
|
|
2488
2488
|
const { data: r } = e;
|
|
2489
|
-
|
|
2489
|
+
de("postMessage", r);
|
|
2490
2490
|
}, {
|
|
2491
2491
|
platform: this.name,
|
|
2492
2492
|
method: "performPostMessage",
|
|
@@ -2504,61 +2504,61 @@ class it extends tt {
|
|
|
2504
2504
|
throw new Error("Callback function is required for getEnv");
|
|
2505
2505
|
const r = {};
|
|
2506
2506
|
let n = !1;
|
|
2507
|
-
|
|
2507
|
+
Me() ? (r.uvue = !0, n = !0) : Ce() ? (r.nvue = !0, n = !0) : _e() ? (r.plus = !0, n = !0) : X() && (r.offline = !0, n = !0), n ? r.app = !0 : r.h5 = !0, e(r);
|
|
2508
2508
|
}, {
|
|
2509
2509
|
platform: this.name,
|
|
2510
2510
|
method: "performGetEnv"
|
|
2511
2511
|
});
|
|
2512
2512
|
}
|
|
2513
2513
|
}
|
|
2514
|
-
const
|
|
2515
|
-
var
|
|
2514
|
+
const te = new lt(), kr = (t) => te.navigateTo(t), Br = (t) => te.navigateBack(t), Gr = (t) => te.switchTab(t), Kr = (t) => te.reLaunch(t), Vr = (t) => te.redirectTo(t), qr = (t) => te.postMessage(t), zr = (t) => te.getEnv(t);
|
|
2515
|
+
var ft = /* @__PURE__ */ Object.freeze({
|
|
2516
2516
|
__proto__: null,
|
|
2517
|
-
AppPlatform:
|
|
2518
|
-
getEnv:
|
|
2519
|
-
navigateBack:
|
|
2520
|
-
navigateTo:
|
|
2521
|
-
postMessage:
|
|
2522
|
-
reLaunch:
|
|
2523
|
-
redirectTo:
|
|
2524
|
-
switchTab:
|
|
2517
|
+
AppPlatform: lt,
|
|
2518
|
+
getEnv: zr,
|
|
2519
|
+
navigateBack: Br,
|
|
2520
|
+
navigateTo: kr,
|
|
2521
|
+
postMessage: qr,
|
|
2522
|
+
reLaunch: Kr,
|
|
2523
|
+
redirectTo: Vr,
|
|
2524
|
+
switchTab: Gr
|
|
2525
2525
|
});
|
|
2526
|
-
function
|
|
2527
|
-
return
|
|
2526
|
+
function he() {
|
|
2527
|
+
return _() ? ut : ft;
|
|
2528
2528
|
}
|
|
2529
|
-
function
|
|
2530
|
-
return
|
|
2529
|
+
function jr(t) {
|
|
2530
|
+
return he().navigateTo(t);
|
|
2531
2531
|
}
|
|
2532
|
-
function
|
|
2533
|
-
return
|
|
2532
|
+
function Jr(t) {
|
|
2533
|
+
return he().navigateBack(t);
|
|
2534
2534
|
}
|
|
2535
|
-
function
|
|
2536
|
-
return
|
|
2535
|
+
function Hr(t) {
|
|
2536
|
+
return he().switchTab(t);
|
|
2537
2537
|
}
|
|
2538
|
-
function
|
|
2539
|
-
return
|
|
2538
|
+
function Yr(t) {
|
|
2539
|
+
return he().reLaunch(t);
|
|
2540
2540
|
}
|
|
2541
|
-
function
|
|
2542
|
-
return
|
|
2541
|
+
function Xr(t) {
|
|
2542
|
+
return he().redirectTo(t);
|
|
2543
2543
|
}
|
|
2544
|
-
function
|
|
2545
|
-
return
|
|
2544
|
+
function dt() {
|
|
2545
|
+
return _() ? ut : ft;
|
|
2546
2546
|
}
|
|
2547
|
-
function
|
|
2548
|
-
return
|
|
2547
|
+
function Zr(t = {}) {
|
|
2548
|
+
return dt().postMessage(t);
|
|
2549
2549
|
}
|
|
2550
|
-
function
|
|
2551
|
-
return
|
|
2550
|
+
function Qr(t) {
|
|
2551
|
+
return dt().getEnv(t);
|
|
2552
2552
|
}
|
|
2553
|
-
function
|
|
2553
|
+
function en(t) {
|
|
2554
2554
|
return t && typeof t == "object" && t.__v_raw ? t.__v_raw : t;
|
|
2555
2555
|
}
|
|
2556
|
-
function
|
|
2556
|
+
function tn() {
|
|
2557
2557
|
return "qsh_callback_" + Date.now() + "_" + Math.random().toString(36).substring(2, 9);
|
|
2558
2558
|
}
|
|
2559
|
-
class
|
|
2559
|
+
class rn {
|
|
2560
2560
|
constructor() {
|
|
2561
|
-
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 = {})),
|
|
2561
|
+
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 = {})), A.debug("WebView 桥接器已初始化");
|
|
2562
2562
|
}
|
|
2563
2563
|
/**
|
|
2564
2564
|
* 向主应用发送 API 调用消息
|
|
@@ -2568,18 +2568,18 @@ class Jr {
|
|
|
2568
2568
|
* @returns {void}
|
|
2569
2569
|
*/
|
|
2570
2570
|
callApi(i) {
|
|
2571
|
-
return
|
|
2572
|
-
return u.safeExecute(() =>
|
|
2573
|
-
var
|
|
2574
|
-
if (typeof window != "undefined" && window === window.parent && !window.plus && !window.__uniapp_x_postMessage && !window.__uniapp_x_ && !window.__dcloud_weex_postMessage && !window.__dcloud_weex_ && !
|
|
2575
|
-
const
|
|
2576
|
-
|
|
2571
|
+
return p(this, arguments, function* (e, r = {}, n = {}) {
|
|
2572
|
+
return u.safeExecute(() => p(this, null, function* () {
|
|
2573
|
+
var w;
|
|
2574
|
+
if (typeof window != "undefined" && window === window.parent && !window.plus && !window.__uniapp_x_postMessage && !window.__uniapp_x_ && !window.__dcloud_weex_postMessage && !window.__dcloud_weex_ && !X()) {
|
|
2575
|
+
const N = new T(
|
|
2576
|
+
x.PLATFORM_NOT_SUPPORTED,
|
|
2577
2577
|
"当前不在宿主 WebView 容器中,无法发送消息"
|
|
2578
2578
|
);
|
|
2579
|
-
n && typeof n.fail == "function" && n.fail({ errMsg:
|
|
2579
|
+
n && typeof n.fail == "function" && n.fail({ errMsg: N.message, code: "NOT_IN_CONTAINER" }), n && typeof n.complete == "function" && n.complete({ success: !1, error: { errMsg: N.message } });
|
|
2580
2580
|
return;
|
|
2581
2581
|
}
|
|
2582
|
-
const
|
|
2582
|
+
const o = {
|
|
2583
2583
|
apiName: e,
|
|
2584
2584
|
params: r,
|
|
2585
2585
|
callbacks: n,
|
|
@@ -2587,50 +2587,50 @@ class Jr {
|
|
|
2587
2587
|
abort: !1,
|
|
2588
2588
|
metadata: {}
|
|
2589
2589
|
};
|
|
2590
|
-
|
|
2591
|
-
const
|
|
2592
|
-
if (
|
|
2593
|
-
|
|
2594
|
-
errMsg: ((
|
|
2590
|
+
B.setApiLoading(e, !0);
|
|
2591
|
+
const d = yield J.runRequest(o);
|
|
2592
|
+
if (d.abort) {
|
|
2593
|
+
A.warn("API 调用被拦截器中止", { api: e }), B.setApiLoading(e, !1), n.fail && n.fail({
|
|
2594
|
+
errMsg: ((w = d.error) == null ? void 0 : w.message) || "API 调用被中止",
|
|
2595
2595
|
code: "INTERCEPTED"
|
|
2596
2596
|
}), n.complete && n.complete({ success: !1 });
|
|
2597
2597
|
return;
|
|
2598
2598
|
}
|
|
2599
|
-
const
|
|
2599
|
+
const l = tn();
|
|
2600
2600
|
if (n.success || n.fail || n.complete) {
|
|
2601
|
-
if (this.callbacks.set(
|
|
2602
|
-
context:
|
|
2601
|
+
if (this.callbacks.set(l, m(h({}, n), {
|
|
2602
|
+
context: d
|
|
2603
2603
|
// 保存上下文用于响应拦截
|
|
2604
|
-
})), window.qshWebviewCallbacks[
|
|
2605
|
-
this.handleCallback(
|
|
2606
|
-
}, r.isPersistent && (this.persistentCallbacksByApi.has(e) || this.persistentCallbacksByApi.set(e, /* @__PURE__ */ new Set()), this.persistentCallbacksByApi.get(e).add(
|
|
2607
|
-
|
|
2608
|
-
callbackId:
|
|
2604
|
+
})), window.qshWebviewCallbacks[l] = (C) => {
|
|
2605
|
+
this.handleCallback(l, C);
|
|
2606
|
+
}, r.isPersistent && (this.persistentCallbacksByApi.has(e) || this.persistentCallbacksByApi.set(e, /* @__PURE__ */ new Set()), this.persistentCallbacksByApi.get(e).add(l)), r.isPersistent || r.disableTimeout)
|
|
2607
|
+
A.info(`API ${e} 禁用超时清理,将等待回调返回后清理`, {
|
|
2608
|
+
callbackId: l,
|
|
2609
2609
|
isPersistent: r.isPersistent,
|
|
2610
2610
|
disableTimeout: r.disableTimeout
|
|
2611
2611
|
});
|
|
2612
2612
|
else {
|
|
2613
|
-
const
|
|
2614
|
-
|
|
2613
|
+
const C = setTimeout(() => {
|
|
2614
|
+
A.warn("API 调用超时,自动清理回调", { api: e, callbackId: l }), n.fail && n.fail({
|
|
2615
2615
|
errMsg: `API ${e} 调用超时`,
|
|
2616
2616
|
code: "TIMEOUT"
|
|
2617
|
-
}), this.cleanupCallback(
|
|
2617
|
+
}), this.cleanupCallback(l);
|
|
2618
2618
|
}, r.timeout || this.defaultTimeout);
|
|
2619
|
-
this.timeouts.set(
|
|
2619
|
+
this.timeouts.set(l, C);
|
|
2620
2620
|
}
|
|
2621
2621
|
const O = {
|
|
2622
2622
|
type: "qsh_api_call",
|
|
2623
2623
|
api: e,
|
|
2624
|
-
params:
|
|
2625
|
-
callbackId:
|
|
2624
|
+
params: d.params,
|
|
2625
|
+
callbackId: l,
|
|
2626
2626
|
timestamp: Date.now()
|
|
2627
2627
|
};
|
|
2628
|
-
|
|
2628
|
+
A.info("发送 API 调用消息", {
|
|
2629
2629
|
api: e,
|
|
2630
|
-
callbackId:
|
|
2630
|
+
callbackId: l,
|
|
2631
2631
|
hasSuccess: !!n.success,
|
|
2632
2632
|
hasFail: !!n.fail
|
|
2633
|
-
}), console.log("message:", JSON.stringify(
|
|
2633
|
+
}), console.log("message:", JSON.stringify(en(O), null, 2)), de("postMessage", O);
|
|
2634
2634
|
}
|
|
2635
2635
|
}), {
|
|
2636
2636
|
context: "WebViewBridge.callApi",
|
|
@@ -2645,18 +2645,18 @@ class Jr {
|
|
|
2645
2645
|
* @private
|
|
2646
2646
|
*/
|
|
2647
2647
|
handleCallback(e, r) {
|
|
2648
|
-
return
|
|
2649
|
-
return u.safeExecute(() =>
|
|
2650
|
-
var
|
|
2648
|
+
return p(this, null, function* () {
|
|
2649
|
+
return u.safeExecute(() => p(this, null, function* () {
|
|
2650
|
+
var N, O;
|
|
2651
2651
|
const n = this.callbacks.get(e);
|
|
2652
2652
|
if (!n) {
|
|
2653
|
-
|
|
2653
|
+
A.warn("未找到回调函数", { callbackId: e });
|
|
2654
2654
|
return;
|
|
2655
2655
|
}
|
|
2656
|
-
const { success: i, fail: s, complete:
|
|
2657
|
-
|
|
2658
|
-
const
|
|
2659
|
-
|
|
2656
|
+
const { success: i, fail: s, complete: o, context: d } = n;
|
|
2657
|
+
A.debug("处理回调", { callbackId: e, result: r });
|
|
2658
|
+
const l = yield J.runResponse(r, d);
|
|
2659
|
+
d && B.setApiResult(d.apiName, l), l.success && i ? i(l.data) : !l.success && s && s(l.error || { errMsg: "操作失败" }), o && o(l), ((O = (N = n.context) == null ? void 0 : N.params) == null ? void 0 : O.isPersistent) ? A.debug("持久监听API:保留回调", { callbackId: e }) : (this.cleanupCallback(e), A.debug("回调执行完成,已清理", { callbackId: e }));
|
|
2660
2660
|
}), {
|
|
2661
2661
|
context: "WebViewBridge.handleCallback",
|
|
2662
2662
|
callbackId: e
|
|
@@ -2681,7 +2681,7 @@ class Jr {
|
|
|
2681
2681
|
* 清理所有待处理的回调
|
|
2682
2682
|
*/
|
|
2683
2683
|
clearCallbacks() {
|
|
2684
|
-
|
|
2684
|
+
A.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) => {
|
|
2685
2685
|
e.startsWith("qsh_callback_") && delete window.qshWebviewCallbacks[e];
|
|
2686
2686
|
});
|
|
2687
2687
|
}
|
|
@@ -2695,7 +2695,7 @@ class Jr {
|
|
|
2695
2695
|
if (!r || r.size === 0)
|
|
2696
2696
|
return 0;
|
|
2697
2697
|
const n = Array.from(r);
|
|
2698
|
-
return n.forEach((i) => this.cleanupCallback(i)), this.persistentCallbacksByApi.delete(e),
|
|
2698
|
+
return n.forEach((i) => this.cleanupCallback(i)), this.persistentCallbacksByApi.delete(e), A.info("已清理持久回调", { api: e, count: n.length }), n.length;
|
|
2699
2699
|
}
|
|
2700
2700
|
/**
|
|
2701
2701
|
* 获取桥接器状态信息
|
|
@@ -2709,18 +2709,18 @@ class Jr {
|
|
|
2709
2709
|
};
|
|
2710
2710
|
}
|
|
2711
2711
|
}
|
|
2712
|
-
const
|
|
2713
|
-
function
|
|
2714
|
-
return
|
|
2712
|
+
const gt = new rn(), R = (t, e, r) => gt.callApi(t, e, r), ie = (t) => gt.cleanupPersistentCallbacksByApi(t);
|
|
2713
|
+
function ht() {
|
|
2714
|
+
return Z(!0);
|
|
2715
2715
|
}
|
|
2716
|
-
function
|
|
2716
|
+
function nn(t) {
|
|
2717
2717
|
return t === "offline";
|
|
2718
2718
|
}
|
|
2719
|
-
function
|
|
2719
|
+
function an(t = {}) {
|
|
2720
2720
|
return u.safeExecute(() => {
|
|
2721
2721
|
a.debug("Call getCode through offline webview bridge", {
|
|
2722
2722
|
clientId: t.clientId
|
|
2723
|
-
}),
|
|
2723
|
+
}), R(
|
|
2724
2724
|
"getCode",
|
|
2725
2725
|
{
|
|
2726
2726
|
clientId: t.clientId
|
|
@@ -2739,13 +2739,13 @@ function Hr(t = {}) {
|
|
|
2739
2739
|
);
|
|
2740
2740
|
}, {
|
|
2741
2741
|
context: "getCodeInHost",
|
|
2742
|
-
platform:
|
|
2742
|
+
platform: ht().type
|
|
2743
2743
|
});
|
|
2744
2744
|
}
|
|
2745
|
-
function
|
|
2745
|
+
function sn(t = {}) {
|
|
2746
2746
|
return u.safeExecute(() => {
|
|
2747
2747
|
var n, i;
|
|
2748
|
-
const e =
|
|
2748
|
+
const e = ht(), r = String((t == null ? void 0 : t.clientId) || "").trim();
|
|
2749
2749
|
if (!r) {
|
|
2750
2750
|
const s = {
|
|
2751
2751
|
errMsg: "clientId is required",
|
|
@@ -2754,7 +2754,7 @@ function Yr(t = {}) {
|
|
|
2754
2754
|
a.error("Get code missing clientId"), (n = t.fail) == null || n.call(t, s);
|
|
2755
2755
|
return;
|
|
2756
2756
|
}
|
|
2757
|
-
if (!
|
|
2757
|
+
if (!nn(e.type)) {
|
|
2758
2758
|
const s = {
|
|
2759
2759
|
errMsg: `Current environment (${e.type}) does not support getCode`,
|
|
2760
2760
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
@@ -2764,7 +2764,7 @@ function Yr(t = {}) {
|
|
|
2764
2764
|
}), (i = t.fail) == null || i.call(t, s);
|
|
2765
2765
|
return;
|
|
2766
2766
|
}
|
|
2767
|
-
|
|
2767
|
+
an(m(h({}, t), {
|
|
2768
2768
|
clientId: r
|
|
2769
2769
|
}));
|
|
2770
2770
|
}, {
|
|
@@ -2772,11 +2772,11 @@ function Yr(t = {}) {
|
|
|
2772
2772
|
options: t
|
|
2773
2773
|
});
|
|
2774
2774
|
}
|
|
2775
|
-
function
|
|
2776
|
-
return
|
|
2775
|
+
function mt() {
|
|
2776
|
+
return Z(!0);
|
|
2777
2777
|
}
|
|
2778
|
-
const
|
|
2779
|
-
function
|
|
2778
|
+
const He = ["release", "trial", "develop"];
|
|
2779
|
+
function on(t = {}) {
|
|
2780
2780
|
const e = String((t == null ? void 0 : t.appid) || "").trim(), r = (t == null ? void 0 : t.path) == null ? "" : t.path, n = t == null ? void 0 : t.env, i = n == null || n === "" ? void 0 : String(n).trim();
|
|
2781
2781
|
if (!e)
|
|
2782
2782
|
throw {
|
|
@@ -2788,9 +2788,9 @@ function Zr(t = {}) {
|
|
|
2788
2788
|
errMsg: "path must be a string",
|
|
2789
2789
|
code: "PARAM_TYPE_ERROR"
|
|
2790
2790
|
};
|
|
2791
|
-
if (i !== void 0 && !
|
|
2791
|
+
if (i !== void 0 && !He.includes(i))
|
|
2792
2792
|
throw {
|
|
2793
|
-
errMsg: `env must be one of ${
|
|
2793
|
+
errMsg: `env must be one of ${He.join("/")}`,
|
|
2794
2794
|
code: "PARAM_INVALID"
|
|
2795
2795
|
};
|
|
2796
2796
|
return m(h({}, t), {
|
|
@@ -2799,13 +2799,13 @@ function Zr(t = {}) {
|
|
|
2799
2799
|
env: i
|
|
2800
2800
|
});
|
|
2801
2801
|
}
|
|
2802
|
-
function
|
|
2802
|
+
function cn() {
|
|
2803
2803
|
return typeof window != "undefined" && window.wx && window.wx.miniProgram && typeof window.wx.miniProgram.postMessage == "function" && typeof window.wx.miniProgram.navigateBack == "function";
|
|
2804
2804
|
}
|
|
2805
|
-
function
|
|
2805
|
+
function un(t = {}) {
|
|
2806
2806
|
return u.safeExecute(() => {
|
|
2807
2807
|
var r;
|
|
2808
|
-
if (!
|
|
2808
|
+
if (!cn()) {
|
|
2809
2809
|
const n = {
|
|
2810
2810
|
errMsg: "wx.miniProgram.postMessage or wx.miniProgram.navigateBack is not available",
|
|
2811
2811
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
@@ -2831,26 +2831,26 @@ function Qr(t = {}) {
|
|
|
2831
2831
|
var s;
|
|
2832
2832
|
try {
|
|
2833
2833
|
window.wx.miniProgram.postMessage({ data: e });
|
|
2834
|
-
} catch (
|
|
2835
|
-
a.error("Post navigateToMiniProgram message failed",
|
|
2834
|
+
} catch (o) {
|
|
2835
|
+
a.error("Post navigateToMiniProgram message failed", o), (s = t.fail) == null || s.call(t, o), i(o);
|
|
2836
2836
|
return;
|
|
2837
2837
|
}
|
|
2838
2838
|
window.wx.miniProgram.navigateBack({
|
|
2839
2839
|
delta: 1,
|
|
2840
|
-
success: (
|
|
2841
|
-
var
|
|
2842
|
-
const
|
|
2843
|
-
errMsg: (
|
|
2840
|
+
success: (o) => {
|
|
2841
|
+
var l;
|
|
2842
|
+
const d = m(h({}, o), {
|
|
2843
|
+
errMsg: (o == null ? void 0 : o.errMsg) || "navigateToMiniProgram:queued"
|
|
2844
2844
|
});
|
|
2845
2845
|
a.info("Navigate to mini program request queued in weixin web-view", {
|
|
2846
2846
|
appid: t.appid,
|
|
2847
2847
|
path: t.path,
|
|
2848
2848
|
env: t.env
|
|
2849
|
-
}), (
|
|
2849
|
+
}), (l = t.success) == null || l.call(t, d), n(d);
|
|
2850
2850
|
},
|
|
2851
|
-
fail: (
|
|
2852
|
-
var
|
|
2853
|
-
a.error("Navigate back after posting mini program message failed",
|
|
2851
|
+
fail: (o) => {
|
|
2852
|
+
var d;
|
|
2853
|
+
a.error("Navigate back after posting mini program message failed", o), (d = t.fail) == null || d.call(t, o), i(o);
|
|
2854
2854
|
},
|
|
2855
2855
|
complete: t.complete
|
|
2856
2856
|
});
|
|
@@ -2860,13 +2860,13 @@ function Qr(t = {}) {
|
|
|
2860
2860
|
platform: "weixin"
|
|
2861
2861
|
});
|
|
2862
2862
|
}
|
|
2863
|
-
function
|
|
2863
|
+
function ln(t = {}) {
|
|
2864
2864
|
return u.safeExecute(() => (a.debug("Call navigateToMiniProgram through webview bridge", {
|
|
2865
2865
|
appid: t.appid,
|
|
2866
2866
|
path: t.path,
|
|
2867
2867
|
env: t.env
|
|
2868
2868
|
}), new Promise((e, r) => {
|
|
2869
|
-
|
|
2869
|
+
R(
|
|
2870
2870
|
"navigateToMiniProgram",
|
|
2871
2871
|
{
|
|
2872
2872
|
appid: t.appid,
|
|
@@ -2887,16 +2887,16 @@ function en(t = {}) {
|
|
|
2887
2887
|
);
|
|
2888
2888
|
})), {
|
|
2889
2889
|
context: "navigateToMiniProgramInHost",
|
|
2890
|
-
platform:
|
|
2890
|
+
platform: mt().type
|
|
2891
2891
|
});
|
|
2892
2892
|
}
|
|
2893
|
-
function
|
|
2893
|
+
function fn(t = {}) {
|
|
2894
2894
|
return u.safeExecute(() => {
|
|
2895
2895
|
var n;
|
|
2896
|
-
const e =
|
|
2896
|
+
const e = mt();
|
|
2897
2897
|
let r;
|
|
2898
2898
|
try {
|
|
2899
|
-
r =
|
|
2899
|
+
r = on(t);
|
|
2900
2900
|
} catch (i) {
|
|
2901
2901
|
a.error("Navigate to mini program params validation failed", i), (n = t.fail) == null || n.call(t, i);
|
|
2902
2902
|
return;
|
|
@@ -2906,35 +2906,35 @@ function tn(t = {}) {
|
|
|
2906
2906
|
appid: r.appid,
|
|
2907
2907
|
path: r.path,
|
|
2908
2908
|
env: r.env
|
|
2909
|
-
}), e.isWeixinMiniProgram ?
|
|
2909
|
+
}), e.isWeixinMiniProgram ? un(r) : ln(r);
|
|
2910
2910
|
}, {
|
|
2911
2911
|
context: "navigateToMiniProgram",
|
|
2912
2912
|
options: t
|
|
2913
2913
|
});
|
|
2914
2914
|
}
|
|
2915
|
-
const
|
|
2915
|
+
const Ae = {
|
|
2916
2916
|
ALBUM: "album",
|
|
2917
2917
|
// 相册
|
|
2918
2918
|
CAMERA: "camera"
|
|
2919
2919
|
// 相机
|
|
2920
|
-
},
|
|
2920
|
+
}, Pe = {
|
|
2921
2921
|
ORIGINAL: "original",
|
|
2922
2922
|
// 原图
|
|
2923
2923
|
COMPRESSED: "compressed"
|
|
2924
2924
|
// 压缩图
|
|
2925
|
-
},
|
|
2925
|
+
}, dn = {
|
|
2926
2926
|
count: 9,
|
|
2927
|
-
sizeType: [
|
|
2928
|
-
sourceType: [
|
|
2927
|
+
sizeType: [Pe.ORIGINAL, Pe.COMPRESSED],
|
|
2928
|
+
sourceType: [Ae.ALBUM, Ae.CAMERA]
|
|
2929
2929
|
};
|
|
2930
|
-
function
|
|
2931
|
-
const e = h(h({},
|
|
2932
|
-
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 = [
|
|
2930
|
+
function gn(t = {}) {
|
|
2931
|
+
const e = h(h({}, dn), t);
|
|
2932
|
+
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 = [Ae.ALBUM]), e;
|
|
2933
2933
|
}
|
|
2934
|
-
function
|
|
2935
|
-
return ["weixin", "webview", "UniApp", "plus", "nvue", "uvue", "offline"].includes(
|
|
2934
|
+
function pt() {
|
|
2935
|
+
return ["weixin", "webview", "UniApp", "plus", "nvue", "uvue", "offline"].includes(f.type);
|
|
2936
2936
|
}
|
|
2937
|
-
function
|
|
2937
|
+
function wt(t) {
|
|
2938
2938
|
return u.safeExecute(() => {
|
|
2939
2939
|
var e;
|
|
2940
2940
|
if (!window.wx) {
|
|
@@ -2945,8 +2945,8 @@ function ft(t) {
|
|
|
2945
2945
|
(e = t.fail) == null || e.call(t, r);
|
|
2946
2946
|
return;
|
|
2947
2947
|
}
|
|
2948
|
-
if (!
|
|
2949
|
-
a.info("等待微信配置完成"),
|
|
2948
|
+
if (!Q()) {
|
|
2949
|
+
a.info("等待微信配置完成"), j().then(() => wt(t)).catch((r) => {
|
|
2950
2950
|
var n;
|
|
2951
2951
|
a.error("微信配置失败", r), (n = t.fail) == null || n.call(t, { errMsg: `微信配置失败: ${r.message}` });
|
|
2952
2952
|
});
|
|
@@ -2971,9 +2971,9 @@ function ft(t) {
|
|
|
2971
2971
|
platform: "weixin"
|
|
2972
2972
|
});
|
|
2973
2973
|
}
|
|
2974
|
-
function
|
|
2974
|
+
function hn(t) {
|
|
2975
2975
|
return u.safeExecute(() => {
|
|
2976
|
-
a.debug("通过 WebView 桥接调用图片选择", t),
|
|
2976
|
+
a.debug("通过 WebView 桥接调用图片选择", t), R("chooseImage", m(h({}, t), { disableTimeout: !0 }), {
|
|
2977
2977
|
success: (e) => {
|
|
2978
2978
|
var r, n;
|
|
2979
2979
|
a.info("UniApp 图片选择成功", {
|
|
@@ -2991,34 +2991,34 @@ function an(t) {
|
|
|
2991
2991
|
platform: "uniapp"
|
|
2992
2992
|
});
|
|
2993
2993
|
}
|
|
2994
|
-
function
|
|
2994
|
+
function mn(t = {}) {
|
|
2995
2995
|
return u.safeExecute(() => {
|
|
2996
2996
|
var r;
|
|
2997
|
-
if (!
|
|
2997
|
+
if (!pt()) {
|
|
2998
2998
|
const n = {
|
|
2999
|
-
errMsg: `当前环境 (${
|
|
2999
|
+
errMsg: `当前环境 (${f.type}) 不支持图片选择功能`,
|
|
3000
3000
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
3001
3001
|
};
|
|
3002
|
-
a.error("平台不支持图片选择", { platform:
|
|
3002
|
+
a.error("平台不支持图片选择", { platform: f.type }), (r = t.fail) == null || r.call(t, n);
|
|
3003
3003
|
return;
|
|
3004
3004
|
}
|
|
3005
|
-
const e =
|
|
3005
|
+
const e = gn(t);
|
|
3006
3006
|
a.info("开始选择图片", {
|
|
3007
|
-
platform:
|
|
3007
|
+
platform: f.type,
|
|
3008
3008
|
count: e.count,
|
|
3009
3009
|
sizeType: e.sizeType,
|
|
3010
3010
|
sourceType: e.sourceType
|
|
3011
|
-
}),
|
|
3011
|
+
}), _() ? wt(e) : hn(e);
|
|
3012
3012
|
}, {
|
|
3013
3013
|
context: "chooseImage",
|
|
3014
3014
|
options: t
|
|
3015
3015
|
});
|
|
3016
3016
|
}
|
|
3017
|
-
function
|
|
3017
|
+
function pn() {
|
|
3018
3018
|
return {
|
|
3019
|
-
supported:
|
|
3020
|
-
environment:
|
|
3021
|
-
implementation:
|
|
3019
|
+
supported: pt(),
|
|
3020
|
+
environment: f.type,
|
|
3021
|
+
implementation: _() ? "weixin" : "webview",
|
|
3022
3022
|
features: {
|
|
3023
3023
|
multipleSelection: !0,
|
|
3024
3024
|
// 支持多选
|
|
@@ -3031,7 +3031,7 @@ function on() {
|
|
|
3031
3031
|
}
|
|
3032
3032
|
};
|
|
3033
3033
|
}
|
|
3034
|
-
const
|
|
3034
|
+
const Y = {
|
|
3035
3035
|
QR_CODE: "qrCode",
|
|
3036
3036
|
// 二维码
|
|
3037
3037
|
BAR_CODE: "barCode",
|
|
@@ -3040,20 +3040,20 @@ const q = {
|
|
|
3040
3040
|
// Data Matrix 码
|
|
3041
3041
|
PDF417: "pdf417"
|
|
3042
3042
|
// PDF417 条码
|
|
3043
|
-
},
|
|
3043
|
+
}, wn = {
|
|
3044
3044
|
onlyFromCamera: !0,
|
|
3045
3045
|
// 只从相机扫码
|
|
3046
|
-
scanType: [
|
|
3046
|
+
scanType: [Y.QR_CODE, Y.BAR_CODE]
|
|
3047
3047
|
// 支持二维码和一维码
|
|
3048
3048
|
};
|
|
3049
|
-
function
|
|
3050
|
-
const e = h(h({},
|
|
3051
|
-
return Array.isArray(e.scanType) || (e.scanType = [e.scanType].filter(Boolean)), e.scanType.length === 0 && (e.scanType = [
|
|
3049
|
+
function En(t = {}) {
|
|
3050
|
+
const e = h(h({}, wn), t);
|
|
3051
|
+
return Array.isArray(e.scanType) || (e.scanType = [e.scanType].filter(Boolean)), e.scanType.length === 0 && (e.scanType = [Y.QR_CODE, Y.BAR_CODE]), e.onlyFromCamera = !!e.onlyFromCamera, e;
|
|
3052
3052
|
}
|
|
3053
|
-
function
|
|
3054
|
-
return ["weixin", "webview", "UniApp", "plus", "nvue", "uvue", "offline"].includes(
|
|
3053
|
+
function Et() {
|
|
3054
|
+
return ["weixin", "webview", "UniApp", "plus", "nvue", "uvue", "offline"].includes(f.type);
|
|
3055
3055
|
}
|
|
3056
|
-
function
|
|
3056
|
+
function yt(t) {
|
|
3057
3057
|
return u.safeExecute(() => {
|
|
3058
3058
|
var e;
|
|
3059
3059
|
if (!window.wx) {
|
|
@@ -3064,8 +3064,8 @@ function gt(t) {
|
|
|
3064
3064
|
(e = t.fail) == null || e.call(t, r);
|
|
3065
3065
|
return;
|
|
3066
3066
|
}
|
|
3067
|
-
if (!
|
|
3068
|
-
a.info("等待微信配置完成"),
|
|
3067
|
+
if (!Q()) {
|
|
3068
|
+
a.info("等待微信配置完成"), j().then(() => yt(t)).catch((r) => {
|
|
3069
3069
|
var n;
|
|
3070
3070
|
a.error("微信配置失败", r), (n = t.fail) == null || n.call(t, { errMsg: `微信配置失败: ${r.message}` });
|
|
3071
3071
|
});
|
|
@@ -3081,7 +3081,7 @@ function gt(t) {
|
|
|
3081
3081
|
const n = {
|
|
3082
3082
|
result: r.resultStr,
|
|
3083
3083
|
// 扫码内容
|
|
3084
|
-
scanType:
|
|
3084
|
+
scanType: yn(r.resultStr),
|
|
3085
3085
|
// 推测扫码类型
|
|
3086
3086
|
charSet: "utf-8",
|
|
3087
3087
|
// 微信默认 UTF-8
|
|
@@ -3100,12 +3100,12 @@ function gt(t) {
|
|
|
3100
3100
|
platform: "weixin"
|
|
3101
3101
|
});
|
|
3102
3102
|
}
|
|
3103
|
-
function
|
|
3104
|
-
return t ? t.length > 50 || /[^\d]/.test(t) ?
|
|
3103
|
+
function yn(t) {
|
|
3104
|
+
return t ? t.length > 50 || /[^\d]/.test(t) ? Y.QR_CODE : Y.BAR_CODE : "unknown";
|
|
3105
3105
|
}
|
|
3106
|
-
function
|
|
3106
|
+
function In(t) {
|
|
3107
3107
|
return u.safeExecute(() => {
|
|
3108
|
-
a.debug("通过 WebView 桥接调用扫码", t),
|
|
3108
|
+
a.debug("通过 WebView 桥接调用扫码", t), R("scanCode", m(h({}, t), { disableTimeout: !0 }), {
|
|
3109
3109
|
success: (e) => {
|
|
3110
3110
|
var r;
|
|
3111
3111
|
a.info("UniApp 扫码成功", {
|
|
@@ -3124,33 +3124,33 @@ function fn(t) {
|
|
|
3124
3124
|
platform: "uniapp"
|
|
3125
3125
|
});
|
|
3126
3126
|
}
|
|
3127
|
-
function
|
|
3127
|
+
function An(t = {}) {
|
|
3128
3128
|
return u.safeExecute(() => {
|
|
3129
3129
|
var r;
|
|
3130
|
-
if (!
|
|
3130
|
+
if (!Et()) {
|
|
3131
3131
|
const n = {
|
|
3132
|
-
errMsg: `当前环境 (${
|
|
3132
|
+
errMsg: `当前环境 (${f.type}) 不支持扫码功能`,
|
|
3133
3133
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
3134
3134
|
};
|
|
3135
|
-
a.error("平台不支持扫码", { platform:
|
|
3135
|
+
a.error("平台不支持扫码", { platform: f.type }), (r = t.fail) == null || r.call(t, n);
|
|
3136
3136
|
return;
|
|
3137
3137
|
}
|
|
3138
|
-
const e =
|
|
3138
|
+
const e = En(t);
|
|
3139
3139
|
a.info("开始扫码", {
|
|
3140
|
-
platform:
|
|
3140
|
+
platform: f.type,
|
|
3141
3141
|
onlyFromCamera: e.onlyFromCamera,
|
|
3142
3142
|
scanType: e.scanType
|
|
3143
|
-
}),
|
|
3143
|
+
}), _() ? yt(e) : In(e);
|
|
3144
3144
|
}, {
|
|
3145
3145
|
context: "scanCode",
|
|
3146
3146
|
options: t
|
|
3147
3147
|
});
|
|
3148
3148
|
}
|
|
3149
|
-
function
|
|
3149
|
+
function Pn() {
|
|
3150
3150
|
return {
|
|
3151
|
-
supported:
|
|
3152
|
-
environment:
|
|
3153
|
-
implementation:
|
|
3151
|
+
supported: Et(),
|
|
3152
|
+
environment: f.type,
|
|
3153
|
+
implementation: _() ? "weixin" : "webview",
|
|
3154
3154
|
features: {
|
|
3155
3155
|
onlyFromCamera: !0,
|
|
3156
3156
|
// 支持只从相机扫码
|
|
@@ -3163,30 +3163,30 @@ function gn() {
|
|
|
3163
3163
|
}
|
|
3164
3164
|
};
|
|
3165
3165
|
}
|
|
3166
|
-
const
|
|
3166
|
+
const ae = {
|
|
3167
3167
|
WGS84: "wgs84",
|
|
3168
3168
|
// GPS 坐标
|
|
3169
3169
|
GCJ02: "gcj02",
|
|
3170
3170
|
// 国测局坐标(火星坐标)
|
|
3171
3171
|
BD09: "bd09"
|
|
3172
3172
|
// 百度坐标
|
|
3173
|
-
},
|
|
3174
|
-
type:
|
|
3173
|
+
}, _n = {
|
|
3174
|
+
type: ae.WGS84,
|
|
3175
3175
|
altitude: !1
|
|
3176
|
-
},
|
|
3176
|
+
}, Cn = {
|
|
3177
3177
|
scale: 18
|
|
3178
3178
|
// 地图缩放级别 1-28
|
|
3179
3179
|
};
|
|
3180
|
-
function
|
|
3181
|
-
const e = h(h({},
|
|
3182
|
-
return Object.values(
|
|
3180
|
+
function Mn(t = {}) {
|
|
3181
|
+
const e = h(h({}, _n), t);
|
|
3182
|
+
return Object.values(ae).includes(e.type) || (e.type = ae.WGS84), e.altitude = !!e.altitude, e;
|
|
3183
3183
|
}
|
|
3184
|
-
function
|
|
3184
|
+
function On(t = {}) {
|
|
3185
3185
|
const e = h({}, t);
|
|
3186
|
-
return Object.values(
|
|
3186
|
+
return Object.values(ae).includes(e.type) || (e.type = ae.WGS84), e.needFullAccuracy = !!e.needFullAccuracy, e;
|
|
3187
3187
|
}
|
|
3188
|
-
function
|
|
3189
|
-
const e = h(h({},
|
|
3188
|
+
function Rn(t = {}) {
|
|
3189
|
+
const e = h(h({}, Cn), t);
|
|
3190
3190
|
if (e.latitude === void 0 || e.latitude === null)
|
|
3191
3191
|
throw {
|
|
3192
3192
|
errMsg: "缺少必需参数:latitude(纬度)",
|
|
@@ -3245,10 +3245,10 @@ function En(t = {}) {
|
|
|
3245
3245
|
}
|
|
3246
3246
|
return e;
|
|
3247
3247
|
}
|
|
3248
|
-
function
|
|
3249
|
-
return ["weixin", "webview", "UniApp", "plus", "nvue", "uvue", "offline"].includes(
|
|
3248
|
+
function De() {
|
|
3249
|
+
return ["weixin", "webview", "UniApp", "plus", "nvue", "uvue", "offline"].includes(f.type);
|
|
3250
3250
|
}
|
|
3251
|
-
function
|
|
3251
|
+
function It(t) {
|
|
3252
3252
|
return u.safeExecute(() => {
|
|
3253
3253
|
var e;
|
|
3254
3254
|
if (!window.wx) {
|
|
@@ -3259,8 +3259,8 @@ function ht(t) {
|
|
|
3259
3259
|
(e = t.fail) == null || e.call(t, r);
|
|
3260
3260
|
return;
|
|
3261
3261
|
}
|
|
3262
|
-
if (!
|
|
3263
|
-
a.info("等待微信配置完成"),
|
|
3262
|
+
if (!Q()) {
|
|
3263
|
+
a.info("等待微信配置完成"), j().then(() => It(t)).catch((r) => {
|
|
3264
3264
|
var n;
|
|
3265
3265
|
a.error("微信配置失败", r), (n = t.fail) == null || n.call(t, { errMsg: `微信配置失败: ${r.message}` });
|
|
3266
3266
|
});
|
|
@@ -3286,7 +3286,7 @@ function ht(t) {
|
|
|
3286
3286
|
platform: "weixin"
|
|
3287
3287
|
});
|
|
3288
3288
|
}
|
|
3289
|
-
function
|
|
3289
|
+
function At(t) {
|
|
3290
3290
|
return u.safeExecute(() => {
|
|
3291
3291
|
var e;
|
|
3292
3292
|
if (!window.wx) {
|
|
@@ -3297,8 +3297,8 @@ function mt(t) {
|
|
|
3297
3297
|
(e = t.fail) == null || e.call(t, r);
|
|
3298
3298
|
return;
|
|
3299
3299
|
}
|
|
3300
|
-
if (!
|
|
3301
|
-
a.info("等待微信配置完成"),
|
|
3300
|
+
if (!Q()) {
|
|
3301
|
+
a.info("等待微信配置完成"), j().then(() => At(t)).catch((r) => {
|
|
3302
3302
|
var n;
|
|
3303
3303
|
a.error("微信配置失败", r), (n = t.fail) == null || n.call(t, { errMsg: `微信配置失败: ${r.message}` });
|
|
3304
3304
|
});
|
|
@@ -3326,9 +3326,9 @@ function mt(t) {
|
|
|
3326
3326
|
platform: "weixin"
|
|
3327
3327
|
});
|
|
3328
3328
|
}
|
|
3329
|
-
function
|
|
3329
|
+
function Nn(t) {
|
|
3330
3330
|
return u.safeExecute(() => {
|
|
3331
|
-
a.debug("通过 WebView 桥接调用获取位置", t),
|
|
3331
|
+
a.debug("通过 WebView 桥接调用获取位置", t), R("getLocation", t, {
|
|
3332
3332
|
success: (e) => {
|
|
3333
3333
|
var r;
|
|
3334
3334
|
a.info("UniApp 获取位置成功", {
|
|
@@ -3347,9 +3347,9 @@ function yn(t) {
|
|
|
3347
3347
|
platform: "uniapp"
|
|
3348
3348
|
});
|
|
3349
3349
|
}
|
|
3350
|
-
function
|
|
3350
|
+
function Sn(t) {
|
|
3351
3351
|
return u.safeExecute(() => {
|
|
3352
|
-
a.debug("通过 WebView 桥接调用查看位置", t),
|
|
3352
|
+
a.debug("通过 WebView 桥接调用查看位置", t), R("openLocation", t, {
|
|
3353
3353
|
success: (e) => {
|
|
3354
3354
|
var r;
|
|
3355
3355
|
a.info("UniApp 查看位置成功"), (r = t.success) == null || r.call(t, e);
|
|
@@ -3365,62 +3365,62 @@ function In(t) {
|
|
|
3365
3365
|
platform: "uniapp"
|
|
3366
3366
|
});
|
|
3367
3367
|
}
|
|
3368
|
-
function
|
|
3368
|
+
function Tn(t = {}) {
|
|
3369
3369
|
return u.safeExecute(() => {
|
|
3370
3370
|
var r;
|
|
3371
|
-
if (!
|
|
3371
|
+
if (!De()) {
|
|
3372
3372
|
const n = {
|
|
3373
|
-
errMsg: `当前环境 (${
|
|
3373
|
+
errMsg: `当前环境 (${f.type}) 不支持定位功能`,
|
|
3374
3374
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
3375
3375
|
};
|
|
3376
|
-
a.error("平台不支持定位", { platform:
|
|
3376
|
+
a.error("平台不支持定位", { platform: f.type }), (r = t.fail) == null || r.call(t, n);
|
|
3377
3377
|
return;
|
|
3378
3378
|
}
|
|
3379
|
-
const e =
|
|
3379
|
+
const e = Mn(t);
|
|
3380
3380
|
a.info("开始获取位置", {
|
|
3381
|
-
platform:
|
|
3381
|
+
platform: f.type,
|
|
3382
3382
|
type: e.type,
|
|
3383
3383
|
altitude: e.altitude
|
|
3384
|
-
}),
|
|
3384
|
+
}), _() ? It(e) : Nn(e);
|
|
3385
3385
|
}, {
|
|
3386
3386
|
context: "getLocation",
|
|
3387
3387
|
options: t
|
|
3388
3388
|
});
|
|
3389
3389
|
}
|
|
3390
|
-
function
|
|
3390
|
+
function Ln(t = {}) {
|
|
3391
3391
|
return u.safeExecute(() => {
|
|
3392
3392
|
var r, n, i;
|
|
3393
|
-
if (!
|
|
3393
|
+
if (!De()) {
|
|
3394
3394
|
const s = {
|
|
3395
|
-
errMsg: `当前环境 (${
|
|
3395
|
+
errMsg: `当前环境 (${f.type}) 不支持查看位置功能`,
|
|
3396
3396
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
3397
3397
|
};
|
|
3398
|
-
a.error("平台不支持查看位置", { platform:
|
|
3398
|
+
a.error("平台不支持查看位置", { platform: f.type }), (r = t.fail) == null || r.call(t, s);
|
|
3399
3399
|
return;
|
|
3400
3400
|
}
|
|
3401
3401
|
let e;
|
|
3402
3402
|
try {
|
|
3403
|
-
e =
|
|
3403
|
+
e = Rn(t);
|
|
3404
3404
|
} catch (s) {
|
|
3405
3405
|
a.error("参数验证失败", s), (n = t.fail) == null || n.call(t, s), (i = t.complete) == null || i.call(t);
|
|
3406
3406
|
return;
|
|
3407
3407
|
}
|
|
3408
3408
|
a.info("开始查看位置", {
|
|
3409
|
-
platform:
|
|
3409
|
+
platform: f.type,
|
|
3410
3410
|
latitude: e.latitude,
|
|
3411
3411
|
longitude: e.longitude,
|
|
3412
3412
|
name: e.name
|
|
3413
|
-
}),
|
|
3413
|
+
}), _() ? At(e) : Sn(e);
|
|
3414
3414
|
}, {
|
|
3415
3415
|
context: "openLocation",
|
|
3416
3416
|
options: t
|
|
3417
3417
|
});
|
|
3418
3418
|
}
|
|
3419
|
-
function
|
|
3420
|
-
const t =
|
|
3419
|
+
function bn() {
|
|
3420
|
+
const t = _();
|
|
3421
3421
|
return {
|
|
3422
|
-
supported:
|
|
3423
|
-
environment:
|
|
3422
|
+
supported: De(),
|
|
3423
|
+
environment: f.type,
|
|
3424
3424
|
implementation: t ? "weixin" : "webview",
|
|
3425
3425
|
features: {
|
|
3426
3426
|
getLocation: !0,
|
|
@@ -3438,8 +3438,8 @@ function _n() {
|
|
|
3438
3438
|
}
|
|
3439
3439
|
};
|
|
3440
3440
|
}
|
|
3441
|
-
const
|
|
3442
|
-
function
|
|
3441
|
+
const q = /* @__PURE__ */ new Set(), z = /* @__PURE__ */ new Set();
|
|
3442
|
+
function Pt(t, e, r) {
|
|
3443
3443
|
t.forEach((n) => {
|
|
3444
3444
|
if (typeof n == "function") {
|
|
3445
3445
|
u.safeExecute(() => n(e), { context: r });
|
|
@@ -3448,19 +3448,19 @@ function pt(t, e, r) {
|
|
|
3448
3448
|
a.warn("监听回调不是函数,已跳过", { type: typeof n });
|
|
3449
3449
|
});
|
|
3450
3450
|
}
|
|
3451
|
-
function
|
|
3451
|
+
function vn(t = {}) {
|
|
3452
3452
|
return u.safeExecute(() => {
|
|
3453
3453
|
var r, n;
|
|
3454
|
-
if (
|
|
3454
|
+
if (_()) {
|
|
3455
3455
|
const i = {
|
|
3456
|
-
errMsg: `当前环境 (${
|
|
3456
|
+
errMsg: `当前环境 (${f.type}) 不支持该接口`,
|
|
3457
3457
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
3458
3458
|
};
|
|
3459
|
-
a.error("当前环境不支持此接口", { platform:
|
|
3459
|
+
a.error("当前环境不支持此接口", { platform: f.type }), (r = t.fail) == null || r.call(t, i), (n = t.complete) == null || n.call(t, i);
|
|
3460
3460
|
return;
|
|
3461
3461
|
}
|
|
3462
|
-
const e =
|
|
3463
|
-
a.info("正在开启定位监听"),
|
|
3462
|
+
const e = On(t);
|
|
3463
|
+
a.info("正在开启定位监听"), R("startLocationUpdate", {
|
|
3464
3464
|
type: e.type,
|
|
3465
3465
|
needFullAccuracy: e.needFullAccuracy
|
|
3466
3466
|
}, {
|
|
@@ -3476,18 +3476,18 @@ function On(t = {}) {
|
|
|
3476
3476
|
});
|
|
3477
3477
|
}, { context: "startLocationUpdate" });
|
|
3478
3478
|
}
|
|
3479
|
-
function
|
|
3479
|
+
function xn(t = {}) {
|
|
3480
3480
|
return u.safeExecute(() => {
|
|
3481
3481
|
var e, r;
|
|
3482
|
-
if (
|
|
3482
|
+
if (_()) {
|
|
3483
3483
|
const n = {
|
|
3484
|
-
errMsg: `当前环境 (${
|
|
3484
|
+
errMsg: `当前环境 (${f.type}) 不支持该接口`,
|
|
3485
3485
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
3486
3486
|
};
|
|
3487
|
-
a.error("当前环境不支持此接口", { platform:
|
|
3487
|
+
a.error("当前环境不支持此接口", { platform: f.type }), (e = t.fail) == null || e.call(t, n), (r = t.complete) == null || r.call(t, n);
|
|
3488
3488
|
return;
|
|
3489
3489
|
}
|
|
3490
|
-
a.info("正在停止定位监听"),
|
|
3490
|
+
a.info("正在停止定位监听"), R("stopLocationUpdate", t, {
|
|
3491
3491
|
success: (n) => {
|
|
3492
3492
|
var i;
|
|
3493
3493
|
a.info("定位监听已停止"), (i = t.success) == null || i.call(t, n);
|
|
@@ -3500,10 +3500,10 @@ function Pn(t = {}) {
|
|
|
3500
3500
|
});
|
|
3501
3501
|
}, { context: "stopLocationUpdate" });
|
|
3502
3502
|
}
|
|
3503
|
-
function
|
|
3503
|
+
function Dn(t) {
|
|
3504
3504
|
return u.safeExecute(() => {
|
|
3505
|
-
if (
|
|
3506
|
-
a.warn("当前环境不支持此接口", { platform:
|
|
3505
|
+
if (_()) {
|
|
3506
|
+
a.warn("当前环境不支持此接口", { platform: f.type });
|
|
3507
3507
|
return;
|
|
3508
3508
|
}
|
|
3509
3509
|
if (typeof t != "function")
|
|
@@ -3511,21 +3511,21 @@ function Rn(t) {
|
|
|
3511
3511
|
errMsg: "onLocationChange 回调必须是函数",
|
|
3512
3512
|
code: "INVALID_CALLBACK"
|
|
3513
3513
|
};
|
|
3514
|
-
const e =
|
|
3515
|
-
|
|
3514
|
+
const e = q.size > 0;
|
|
3515
|
+
q.add(t), e || (a.debug("注册实时位置变化监听器"), R("onLocationChange", { isPersistent: !0 }, {
|
|
3516
3516
|
success: (r) => {
|
|
3517
|
-
a.debug("收到实时位置推送", r),
|
|
3517
|
+
a.debug("收到实时位置推送", r), Pt(q, r, "onLocationChange");
|
|
3518
3518
|
},
|
|
3519
3519
|
fail: (r) => {
|
|
3520
|
-
a.warn("位置变化监听出错,请通过 onLocationChangeError 监听错误", r),
|
|
3520
|
+
a.warn("位置变化监听出错,请通过 onLocationChangeError 监听错误", r), q.delete(t), q.size === 0 && ie("onLocationChange");
|
|
3521
3521
|
}
|
|
3522
3522
|
}));
|
|
3523
3523
|
}, { context: "onLocationChange" });
|
|
3524
3524
|
}
|
|
3525
|
-
function
|
|
3525
|
+
function Un(t) {
|
|
3526
3526
|
return u.safeExecute(() => {
|
|
3527
|
-
if (
|
|
3528
|
-
a.warn("当前环境不支持此接口", { platform:
|
|
3527
|
+
if (_()) {
|
|
3528
|
+
a.warn("当前环境不支持此接口", { platform: f.type });
|
|
3529
3529
|
return;
|
|
3530
3530
|
}
|
|
3531
3531
|
if (t && typeof t != "function")
|
|
@@ -3533,20 +3533,20 @@ function Nn(t) {
|
|
|
3533
3533
|
errMsg: "offLocationChange 回调必须是函数",
|
|
3534
3534
|
code: "INVALID_CALLBACK"
|
|
3535
3535
|
};
|
|
3536
|
-
t ?
|
|
3536
|
+
t ? q.delete(t) : q.clear(), !(q.size > 0) && (a.info("移除位置变化监听器"), R("offLocationChange", {}, {
|
|
3537
3537
|
success: () => {
|
|
3538
|
-
a.info("位置变化监听已移除"),
|
|
3538
|
+
a.info("位置变化监听已移除"), ie("onLocationChange");
|
|
3539
3539
|
},
|
|
3540
3540
|
fail: (e) => {
|
|
3541
|
-
a.error("移除位置变化监听失败", e),
|
|
3541
|
+
a.error("移除位置变化监听失败", e), ie("onLocationChange");
|
|
3542
3542
|
}
|
|
3543
3543
|
}));
|
|
3544
3544
|
}, { context: "offLocationChange" });
|
|
3545
3545
|
}
|
|
3546
|
-
function
|
|
3546
|
+
function Wn(t) {
|
|
3547
3547
|
return u.safeExecute(() => {
|
|
3548
|
-
if (
|
|
3549
|
-
a.warn("当前环境不支持此接口", { platform:
|
|
3548
|
+
if (_()) {
|
|
3549
|
+
a.warn("当前环境不支持此接口", { platform: f.type });
|
|
3550
3550
|
return;
|
|
3551
3551
|
}
|
|
3552
3552
|
if (typeof t != "function")
|
|
@@ -3554,21 +3554,21 @@ function Mn(t) {
|
|
|
3554
3554
|
errMsg: "onLocationChangeError 回调必须是函数",
|
|
3555
3555
|
code: "INVALID_CALLBACK"
|
|
3556
3556
|
};
|
|
3557
|
-
const e =
|
|
3558
|
-
|
|
3557
|
+
const e = z.size > 0;
|
|
3558
|
+
z.add(t), e || (a.debug("注册位置更新错误监听器"), R("onLocationChangeError", { isPersistent: !0 }, {
|
|
3559
3559
|
success: (r) => {
|
|
3560
|
-
a.warn("持续定位发生异常", r),
|
|
3560
|
+
a.warn("持续定位发生异常", r), Pt(z, r, "onLocationChangeError");
|
|
3561
3561
|
},
|
|
3562
3562
|
fail: (r) => {
|
|
3563
|
-
a.warn("位置更新错误监听注册失败", r),
|
|
3563
|
+
a.warn("位置更新错误监听注册失败", r), z.delete(t), z.size === 0 && ie("onLocationChangeError");
|
|
3564
3564
|
}
|
|
3565
3565
|
}));
|
|
3566
3566
|
}, { context: "onLocationChangeError" });
|
|
3567
3567
|
}
|
|
3568
|
-
function
|
|
3568
|
+
function $n(t) {
|
|
3569
3569
|
return u.safeExecute(() => {
|
|
3570
|
-
if (
|
|
3571
|
-
a.warn("当前环境不支持此接口", { platform:
|
|
3570
|
+
if (_()) {
|
|
3571
|
+
a.warn("当前环境不支持此接口", { platform: f.type });
|
|
3572
3572
|
return;
|
|
3573
3573
|
}
|
|
3574
3574
|
if (t && typeof t != "function")
|
|
@@ -3576,24 +3576,24 @@ function Sn(t) {
|
|
|
3576
3576
|
errMsg: "offLocationChangeError 回调必须是函数",
|
|
3577
3577
|
code: "INVALID_CALLBACK"
|
|
3578
3578
|
};
|
|
3579
|
-
t ?
|
|
3579
|
+
t ? z.delete(t) : z.clear(), !(z.size > 0) && (a.info("移除定位错误监听器"), R("offLocationChangeError", {}, {
|
|
3580
3580
|
success: () => {
|
|
3581
|
-
a.info("定位错误监听已移除"),
|
|
3581
|
+
a.info("定位错误监听已移除"), ie("onLocationChangeError");
|
|
3582
3582
|
},
|
|
3583
3583
|
fail: (e) => {
|
|
3584
|
-
a.error("移除定位错误监听失败", e),
|
|
3584
|
+
a.error("移除定位错误监听失败", e), ie("onLocationChangeError");
|
|
3585
3585
|
}
|
|
3586
3586
|
}));
|
|
3587
3587
|
}, { context: "offLocationChangeError" });
|
|
3588
3588
|
}
|
|
3589
|
-
const
|
|
3589
|
+
const Fn = {
|
|
3590
3590
|
latitude: null,
|
|
3591
3591
|
// 目标地纬度
|
|
3592
3592
|
longitude: null
|
|
3593
3593
|
// 目标地经度
|
|
3594
3594
|
};
|
|
3595
|
-
function
|
|
3596
|
-
const e = h(h({},
|
|
3595
|
+
function kn(t = {}) {
|
|
3596
|
+
const e = h(h({}, Fn), t);
|
|
3597
3597
|
return e.latitude !== null && e.latitude !== void 0 && (typeof e.latitude != "number" ? (a.warn("latitude 参数类型错误,已忽略", {
|
|
3598
3598
|
latitude: e.latitude
|
|
3599
3599
|
}), e.latitude = null) : (e.latitude < -90 || e.latitude > 90) && (a.warn("latitude 超出范围,已忽略", {
|
|
@@ -3604,10 +3604,10 @@ function Ln(t = {}) {
|
|
|
3604
3604
|
longitude: e.longitude
|
|
3605
3605
|
}), e.longitude = null)), e;
|
|
3606
3606
|
}
|
|
3607
|
-
function
|
|
3608
|
-
return ["weixin", "webview", "UniApp", "plus", "nvue", "uvue", "offline"].includes(
|
|
3607
|
+
function _t() {
|
|
3608
|
+
return ["weixin", "webview", "UniApp", "plus", "nvue", "uvue", "offline"].includes(f.type);
|
|
3609
3609
|
}
|
|
3610
|
-
function
|
|
3610
|
+
function Ct(t) {
|
|
3611
3611
|
return u.safeExecute(() => {
|
|
3612
3612
|
var n;
|
|
3613
3613
|
if (!window.wx) {
|
|
@@ -3618,8 +3618,8 @@ function Et(t) {
|
|
|
3618
3618
|
(n = t.fail) == null || n.call(t, i);
|
|
3619
3619
|
return;
|
|
3620
3620
|
}
|
|
3621
|
-
if (!
|
|
3622
|
-
a.info("等待微信配置完成"),
|
|
3621
|
+
if (!Q()) {
|
|
3622
|
+
a.info("等待微信配置完成"), j().then(() => Ct(t)).catch((i) => {
|
|
3623
3623
|
var s;
|
|
3624
3624
|
a.error("微信配置失败", i), (s = t.fail) == null || s.call(t, { errMsg: `微信配置失败: ${i.message}` });
|
|
3625
3625
|
});
|
|
@@ -3628,7 +3628,7 @@ function Et(t) {
|
|
|
3628
3628
|
a.debug("调用微信位置选择", t);
|
|
3629
3629
|
const e = {
|
|
3630
3630
|
success: (i) => {
|
|
3631
|
-
var
|
|
3631
|
+
var o;
|
|
3632
3632
|
a.info("微信位置选择成功", {
|
|
3633
3633
|
name: i.name,
|
|
3634
3634
|
address: i.address,
|
|
@@ -3646,7 +3646,7 @@ function Et(t) {
|
|
|
3646
3646
|
// 经度
|
|
3647
3647
|
errMsg: "chooseLocation:ok"
|
|
3648
3648
|
};
|
|
3649
|
-
(
|
|
3649
|
+
(o = t.success) == null || o.call(t, s);
|
|
3650
3650
|
},
|
|
3651
3651
|
fail: (i) => {
|
|
3652
3652
|
var s;
|
|
@@ -3664,7 +3664,7 @@ function Et(t) {
|
|
|
3664
3664
|
platform: "weixin"
|
|
3665
3665
|
});
|
|
3666
3666
|
}
|
|
3667
|
-
function
|
|
3667
|
+
function Bn(t) {
|
|
3668
3668
|
return u.safeExecute(() => {
|
|
3669
3669
|
a.debug("通过 WebView 桥接调用位置选择", t);
|
|
3670
3670
|
const e = {
|
|
@@ -3685,7 +3685,7 @@ function bn(t) {
|
|
|
3685
3685
|
},
|
|
3686
3686
|
complete: t.complete
|
|
3687
3687
|
};
|
|
3688
|
-
t.latitude !== null && t.latitude !== void 0 && (e.latitude = t.latitude), t.longitude !== null && t.longitude !== void 0 && (e.longitude = t.longitude),
|
|
3688
|
+
t.latitude !== null && t.latitude !== void 0 && (e.latitude = t.latitude), t.longitude !== null && t.longitude !== void 0 && (e.longitude = t.longitude), R("chooseLocation", e, {
|
|
3689
3689
|
success: (r) => {
|
|
3690
3690
|
e.success(r);
|
|
3691
3691
|
},
|
|
@@ -3699,33 +3699,33 @@ function bn(t) {
|
|
|
3699
3699
|
platform: "uniapp"
|
|
3700
3700
|
});
|
|
3701
3701
|
}
|
|
3702
|
-
function
|
|
3702
|
+
function Gn(t = {}) {
|
|
3703
3703
|
return u.safeExecute(() => {
|
|
3704
3704
|
var r;
|
|
3705
|
-
if (!
|
|
3705
|
+
if (!_t()) {
|
|
3706
3706
|
const n = {
|
|
3707
|
-
errMsg: `当前环境 (${
|
|
3707
|
+
errMsg: `当前环境 (${f.type}) 不支持位置选择功能`,
|
|
3708
3708
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
3709
3709
|
};
|
|
3710
|
-
a.error("平台不支持位置选择", { platform:
|
|
3710
|
+
a.error("平台不支持位置选择", { platform: f.type }), (r = t.fail) == null || r.call(t, n);
|
|
3711
3711
|
return;
|
|
3712
3712
|
}
|
|
3713
|
-
const e =
|
|
3713
|
+
const e = kn(t);
|
|
3714
3714
|
a.info("开始选择位置", {
|
|
3715
|
-
platform:
|
|
3715
|
+
platform: f.type,
|
|
3716
3716
|
latitude: e.latitude,
|
|
3717
3717
|
longitude: e.longitude
|
|
3718
|
-
}),
|
|
3718
|
+
}), _() ? Ct(e) : Bn(e);
|
|
3719
3719
|
}, {
|
|
3720
3720
|
context: "chooseLocation",
|
|
3721
3721
|
options: t
|
|
3722
3722
|
});
|
|
3723
3723
|
}
|
|
3724
|
-
function
|
|
3724
|
+
function Kn() {
|
|
3725
3725
|
return {
|
|
3726
|
-
supported:
|
|
3727
|
-
environment:
|
|
3728
|
-
implementation:
|
|
3726
|
+
supported: _t(),
|
|
3727
|
+
environment: f.type,
|
|
3728
|
+
implementation: _() ? "weixin" : "webview",
|
|
3729
3729
|
features: {
|
|
3730
3730
|
chooseLocation: !0,
|
|
3731
3731
|
// 支持位置选择
|
|
@@ -3736,89 +3736,236 @@ function xn() {
|
|
|
3736
3736
|
}
|
|
3737
3737
|
};
|
|
3738
3738
|
}
|
|
3739
|
-
|
|
3739
|
+
const Mt = "https://iafs.xjy2.cn/img/bg.143351f0.jpg";
|
|
3740
|
+
function Vn(t) {
|
|
3740
3741
|
return t === "timeline" || Number(t) === 1 ? 1 : 0;
|
|
3741
3742
|
}
|
|
3742
|
-
function
|
|
3743
|
+
function Ue(t = "", e = "targetPath") {
|
|
3744
|
+
if (!t || typeof t != "string")
|
|
3745
|
+
throw { errMsg: `share: ${e} 必须是最终小程序页面路径,例如 /pages/xxx/index?foo=1`, code: "PARAM_INVALID" };
|
|
3746
|
+
const r = t.trim();
|
|
3747
|
+
if (!/^\/pages\//.test(r))
|
|
3748
|
+
throw { errMsg: `share: ${e} 必须是最终小程序页面路径,例如 /pages/xxx/index?foo=1`, code: "PARAM_INVALID" };
|
|
3749
|
+
const [, n = ""] = r.split("?");
|
|
3750
|
+
return { path: r, query: n };
|
|
3751
|
+
}
|
|
3752
|
+
function qn() {
|
|
3753
|
+
return new Promise((t, e) => {
|
|
3754
|
+
var s, o;
|
|
3755
|
+
const r = typeof window != "undefined" ? window : null;
|
|
3756
|
+
if (!r) return e({ errMsg: "当前环境不支持 plus", code: "PLUS_UNAVAILABLE" });
|
|
3757
|
+
if (r.plus) return t(r.plus);
|
|
3758
|
+
const n = setTimeout(() => {
|
|
3759
|
+
var d, l;
|
|
3760
|
+
(l = (d = r.document) == null ? void 0 : d.removeEventListener) == null || l.call(d, "plusready", i), e({ errMsg: "等待 plusready 超时", code: "PLUS_READY_TIMEOUT" });
|
|
3761
|
+
}, 8e3);
|
|
3762
|
+
function i() {
|
|
3763
|
+
clearTimeout(n), t(r.plus);
|
|
3764
|
+
}
|
|
3765
|
+
(o = (s = r.document) == null ? void 0 : s.addEventListener) == null || o.call(s, "plusready", i, { once: !0 });
|
|
3766
|
+
});
|
|
3767
|
+
}
|
|
3768
|
+
function zn() {
|
|
3769
|
+
return new Promise((t, e) => {
|
|
3770
|
+
const r = typeof window != "undefined" ? window.plus : null;
|
|
3771
|
+
if (!r || !r.share || typeof r.share.getServices != "function")
|
|
3772
|
+
return e({ errMsg: "当前环境不支持 plus.share", code: "PLUS_SHARE_UNSUPPORTED" });
|
|
3773
|
+
r.share.getServices(
|
|
3774
|
+
(n) => {
|
|
3775
|
+
const i = n.find((s) => s.id === "weixin");
|
|
3776
|
+
if (!i) return e({ errMsg: "未找到微信分享服务", code: "WEIXIN_SERVICE_NOT_FOUND" });
|
|
3777
|
+
t(i);
|
|
3778
|
+
},
|
|
3779
|
+
(n) => e(n || { errMsg: "获取分享服务失败", code: "GET_SHARE_SERVICES_FAILED" })
|
|
3780
|
+
);
|
|
3781
|
+
});
|
|
3782
|
+
}
|
|
3783
|
+
function jn(t) {
|
|
3784
|
+
return t.isWeixinMiniProgram ? "已同步分享内容,请点击右上角“···”选择发送给朋友或分享到朋友圈。" : "正在拉起微信分享面板,请选择聊天框或朋友圈。";
|
|
3785
|
+
}
|
|
3786
|
+
function Jn(t = {}) {
|
|
3743
3787
|
if (!t || typeof t != "object")
|
|
3744
3788
|
throw { errMsg: "shareDirected 参数必须是对象", code: "PARAM_TYPE_ERROR" };
|
|
3745
|
-
const e = String(t.kind || "").trim(), r = t.payload || {}, n =
|
|
3789
|
+
const e = String(t.kind || "").trim(), r = t.payload || {}, n = Vn(t.scene);
|
|
3746
3790
|
if (!["web", "image", "text"].includes(e))
|
|
3747
3791
|
throw { errMsg: 'shareDirected: kind 仅支持 "web"|"image"|"text"', code: "PARAM_INVALID" };
|
|
3748
|
-
if (
|
|
3749
|
-
|
|
3750
|
-
|
|
3751
|
-
|
|
3752
|
-
|
|
3753
|
-
|
|
3792
|
+
if (![0, 1].includes(n))
|
|
3793
|
+
throw { errMsg: "shareDirected: scene 仅支持 0|1", code: "PARAM_INVALID" };
|
|
3794
|
+
if (!r.targetPath) throw { errMsg: "shareDirected: payload.targetPath 必填", code: "PARAM_MISSING" };
|
|
3795
|
+
if (!r.shareLink) throw { errMsg: "shareDirected: payload.shareLink 必填", code: "PARAM_MISSING" };
|
|
3796
|
+
if (e === "web" && (!r.title || !r.description || !r.imageUrl))
|
|
3797
|
+
throw { errMsg: "shareDirected(web): title/description/imageUrl 必填", code: "PARAM_MISSING" };
|
|
3754
3798
|
if (e === "image" && !r.imageUrl)
|
|
3755
3799
|
throw { errMsg: "shareDirected(image): payload.imageUrl 必填", code: "PARAM_MISSING" };
|
|
3756
|
-
if (e === "text" && !r.
|
|
3757
|
-
throw { errMsg: "shareDirected(text): payload.
|
|
3800
|
+
if (e === "text" && !r.description)
|
|
3801
|
+
throw { errMsg: "shareDirected(text): payload.description 必填", code: "PARAM_MISSING" };
|
|
3802
|
+
return { kind: e, scene: n, payload: r, success: t.success, fail: t.fail, complete: t.complete };
|
|
3803
|
+
}
|
|
3804
|
+
function Hn(t) {
|
|
3805
|
+
const { kind: e, payload: r } = t, n = Ue(r.targetPath, "targetPath"), i = r.imageUrl || Mt;
|
|
3758
3806
|
return {
|
|
3759
|
-
|
|
3760
|
-
|
|
3761
|
-
|
|
3762
|
-
|
|
3763
|
-
|
|
3764
|
-
complete: t.complete
|
|
3807
|
+
title: r.title || "分享",
|
|
3808
|
+
path: n.path,
|
|
3809
|
+
query: n.query,
|
|
3810
|
+
imageUrl: i,
|
|
3811
|
+
custom: { kind: e, targetPath: r.targetPath, shareLink: r.shareLink, description: r.description || "" }
|
|
3765
3812
|
};
|
|
3766
3813
|
}
|
|
3767
|
-
function
|
|
3768
|
-
|
|
3814
|
+
function Yn(t) {
|
|
3815
|
+
const { kind: e, scene: r, payload: n } = t, i = r === 1 ? "WXSceneTimeline" : "WXSceneSession", s = n.imageUrl || Mt;
|
|
3816
|
+
return e === "image" ? { message: { type: "image", pictures: [n.imageUrl], extra: { scene: i } }, degradedFromText: !1 } : {
|
|
3817
|
+
message: { type: "web", title: n.title || "分享", content: n.description || "", href: n.shareLink, thumbs: [s], extra: { scene: i } },
|
|
3818
|
+
degradedFromText: e === "text"
|
|
3819
|
+
};
|
|
3769
3820
|
}
|
|
3770
|
-
function
|
|
3821
|
+
function Xn(t) {
|
|
3822
|
+
return p(this, null, function* () {
|
|
3823
|
+
yield qn();
|
|
3824
|
+
const e = yield zn(), { message: r, degradedFromText: n } = Yn(t);
|
|
3825
|
+
return new Promise((i, s) => {
|
|
3826
|
+
e.send(
|
|
3827
|
+
r,
|
|
3828
|
+
() => i({ success: !0, data: { degradedFromText: n, hint: n ? "纯文字已自动降级为图文分享,避免微信通道不支持纯文本" : void 0 } }),
|
|
3829
|
+
(o) => s(o || { errMsg: "微信分享失败", code: "WEIXIN_SHARE_FAILED" })
|
|
3830
|
+
);
|
|
3831
|
+
});
|
|
3832
|
+
});
|
|
3833
|
+
}
|
|
3834
|
+
function Ot(t, e = "share") {
|
|
3835
|
+
const r = typeof window != "undefined" && window.wx && window.wx.miniProgram;
|
|
3836
|
+
if (!r || typeof r.postMessage != "function")
|
|
3837
|
+
throw { errMsg: `当前微信小程序容器未注入 postMessage 能力,无法发起 ${e}`, code: "MINIPROGRAM_BRIDGE_UNAVAILABLE" };
|
|
3838
|
+
r.postMessage({ data: [t] });
|
|
3839
|
+
}
|
|
3840
|
+
function Zn(t) {
|
|
3841
|
+
return { type: "qsh_api_call", api: "shareDirected", params: { miniProgramShare: Hn(t) }, timestamp: Date.now() };
|
|
3842
|
+
}
|
|
3843
|
+
function Qn(t = {}) {
|
|
3844
|
+
if (!t || typeof t != "object")
|
|
3845
|
+
throw { errMsg: "shareMiniProgramCard 参数必须是对象", code: "PARAM_TYPE_ERROR" };
|
|
3846
|
+
const e = t.payload || {};
|
|
3847
|
+
if (!e.title) throw { errMsg: "shareMiniProgramCard: payload.title 必填", code: "PARAM_MISSING" };
|
|
3848
|
+
if (!e.imageUrl) throw { errMsg: "shareMiniProgramCard: payload.imageUrl 必填", code: "PARAM_MISSING" };
|
|
3849
|
+
if (!e.targetPath) throw { errMsg: "shareMiniProgramCard: payload.targetPath 必填", code: "PARAM_MISSING" };
|
|
3850
|
+
if (!e.appid) throw { errMsg: "shareMiniProgramCard: payload.appid 必填", code: "PARAM_MISSING" };
|
|
3851
|
+
return Ue(e.targetPath, "targetPath"), { payload: e, success: t.success, fail: t.fail, complete: t.complete };
|
|
3852
|
+
}
|
|
3853
|
+
function ei(t) {
|
|
3854
|
+
const { payload: e } = t, r = Ue(e.targetPath, "targetPath");
|
|
3855
|
+
return {
|
|
3856
|
+
title: e.title,
|
|
3857
|
+
path: r.path,
|
|
3858
|
+
query: r.query,
|
|
3859
|
+
imageUrl: e.imageUrl,
|
|
3860
|
+
appid: e.appid,
|
|
3861
|
+
envVersion: e.envVersion || "release",
|
|
3862
|
+
description: e.description || "",
|
|
3863
|
+
fallbackWebUrl: e.fallbackWebUrl || ""
|
|
3864
|
+
};
|
|
3865
|
+
}
|
|
3866
|
+
function ti(t) {
|
|
3867
|
+
const { payload: e } = t;
|
|
3868
|
+
return {
|
|
3869
|
+
provider: "weixin",
|
|
3870
|
+
scene: "WXSceneSession",
|
|
3871
|
+
type: 5,
|
|
3872
|
+
title: e.title,
|
|
3873
|
+
imageUrl: e.imageUrl,
|
|
3874
|
+
miniProgram: {
|
|
3875
|
+
id: e.appid,
|
|
3876
|
+
path: e.targetPath,
|
|
3877
|
+
type: e.envVersion || "release",
|
|
3878
|
+
webUrl: e.fallbackWebUrl || e.shareLink || ""
|
|
3879
|
+
}
|
|
3880
|
+
};
|
|
3881
|
+
}
|
|
3882
|
+
function ri(t) {
|
|
3883
|
+
return { type: "qsh_api_call", api: "shareMiniProgramCard", params: { miniProgramShare: ei(t) }, timestamp: Date.now() };
|
|
3884
|
+
}
|
|
3885
|
+
function ni(t) {
|
|
3886
|
+
return p(this, null, function* () {
|
|
3887
|
+
return new Promise((e, r) => {
|
|
3888
|
+
R("shareMiniProgramCard", { appShare: ti(t) }, { success: (n) => e(n || {}), fail: (n) => r(n) });
|
|
3889
|
+
});
|
|
3890
|
+
});
|
|
3891
|
+
}
|
|
3892
|
+
function Rt(t = {}) {
|
|
3771
3893
|
return u.safeExecute(() => {
|
|
3772
|
-
var
|
|
3894
|
+
var s, o, d, l, w, N, O, C, $;
|
|
3773
3895
|
let e;
|
|
3774
3896
|
try {
|
|
3775
|
-
e =
|
|
3776
|
-
} catch (
|
|
3777
|
-
return (
|
|
3897
|
+
e = Jn(t);
|
|
3898
|
+
} catch (y) {
|
|
3899
|
+
return (s = t.fail) == null || s.call(t, y), Promise.reject(y);
|
|
3778
3900
|
}
|
|
3779
|
-
const r =
|
|
3780
|
-
if (r.
|
|
3781
|
-
|
|
3782
|
-
|
|
3783
|
-
|
|
3784
|
-
|
|
3785
|
-
|
|
3901
|
+
const r = Z(!0), n = jn(r);
|
|
3902
|
+
if (r.isAppPlus)
|
|
3903
|
+
return Xn(e).then((y) => {
|
|
3904
|
+
var oe, Ve;
|
|
3905
|
+
const F = m(h({}, (y == null ? void 0 : y.data) || {}), { hint: n });
|
|
3906
|
+
return (oe = e.success) == null || oe.call(e, F), (Ve = e.complete) == null || Ve.call(e, F), F;
|
|
3907
|
+
}).catch((y) => {
|
|
3908
|
+
var F, oe;
|
|
3909
|
+
return (F = e.fail) == null || F.call(e, y), (oe = e.complete) == null || oe.call(e, y), Promise.reject(y);
|
|
3910
|
+
});
|
|
3911
|
+
if (r.isWeixinMiniProgram)
|
|
3912
|
+
try {
|
|
3913
|
+
Ot(Zn(e), "shareDirected");
|
|
3914
|
+
const y = { success: !0, hint: n };
|
|
3915
|
+
return (o = e.success) == null || o.call(e, y), (d = e.complete) == null || d.call(e, y), Promise.resolve(y);
|
|
3916
|
+
} catch (y) {
|
|
3917
|
+
return (l = e.fail) == null || l.call(e, y), (w = e.complete) == null || w.call(e, y), Promise.reject(y);
|
|
3918
|
+
}
|
|
3919
|
+
if (r.type === "h5" && !r.isUniAppWebView && !r.isOfflineWebview) {
|
|
3920
|
+
const y = { errMsg: "当前页面不在宿主 WebView 中,无法分享。请在 unified-platform-app 内打开该 H5 再重试。", code: "NOT_IN_CONTAINER" };
|
|
3921
|
+
return (N = e.fail) == null || N.call(e, y), (O = e.complete) == null || O.call(e, y), Promise.reject(y);
|
|
3786
3922
|
}
|
|
3787
|
-
|
|
3788
|
-
|
|
3789
|
-
|
|
3790
|
-
|
|
3791
|
-
|
|
3792
|
-
|
|
3793
|
-
|
|
3794
|
-
},
|
|
3795
|
-
{
|
|
3796
|
-
success: (p) => {
|
|
3797
|
-
var O, Z;
|
|
3798
|
-
const R = m(h({}, p), { hint: n });
|
|
3799
|
-
(O = e.success) == null || O.call(e, R), (Z = e.complete) == null || Z.call(e, R), f(R);
|
|
3800
|
-
},
|
|
3801
|
-
fail: (p) => {
|
|
3802
|
-
var R, O;
|
|
3803
|
-
(R = e.fail) == null || R.call(e, p), (O = e.complete) == null || O.call(e, p), d(p);
|
|
3804
|
-
}
|
|
3805
|
-
}
|
|
3806
|
-
);
|
|
3807
|
-
});
|
|
3808
|
-
}, {
|
|
3809
|
-
context: "shareDirected",
|
|
3810
|
-
options: t
|
|
3923
|
+
const i = { errMsg: "当前环境暂不支持 shareDirected,请在 App 或微信小程序容器内使用。", code: "ENV_NOT_SUPPORTED" };
|
|
3924
|
+
return (C = e.fail) == null || C.call(e, i), ($ = e.complete) == null || $.call(e, i), Promise.reject(i);
|
|
3925
|
+
}, { context: "shareDirected", options: t });
|
|
3926
|
+
}
|
|
3927
|
+
function ii(t = {}) {
|
|
3928
|
+
return new Promise((e, r) => {
|
|
3929
|
+
Rt(m(h({}, t), { success: e, fail: r }));
|
|
3811
3930
|
});
|
|
3812
3931
|
}
|
|
3813
|
-
function
|
|
3932
|
+
function Nt(t = {}) {
|
|
3933
|
+
return u.safeExecute(() => {
|
|
3934
|
+
var s, o, d, l, w, N, O;
|
|
3935
|
+
let e;
|
|
3936
|
+
try {
|
|
3937
|
+
e = Qn(t);
|
|
3938
|
+
} catch (C) {
|
|
3939
|
+
return (s = t.fail) == null || s.call(t, C), Promise.reject(C);
|
|
3940
|
+
}
|
|
3941
|
+
const r = Z(!0), n = r.isWeixinMiniProgram ? "已同步小程序卡片内容,请点击右上角“···”后发送给朋友。" : "正在拉起微信发送给朋友面板,请继续完成小程序卡片分享。";
|
|
3942
|
+
if (r.isAppPlus)
|
|
3943
|
+
return ni(e).then((C) => {
|
|
3944
|
+
var y, F;
|
|
3945
|
+
const $ = m(h({}, C || {}), { hint: n });
|
|
3946
|
+
return (y = e.success) == null || y.call(e, $), (F = e.complete) == null || F.call(e, $), $;
|
|
3947
|
+
}).catch((C) => {
|
|
3948
|
+
var $, y;
|
|
3949
|
+
return ($ = e.fail) == null || $.call(e, C), (y = e.complete) == null || y.call(e, C), Promise.reject(C);
|
|
3950
|
+
});
|
|
3951
|
+
if (r.isWeixinMiniProgram)
|
|
3952
|
+
try {
|
|
3953
|
+
Ot(ri(e), "shareMiniProgramCard");
|
|
3954
|
+
const C = { success: !0, hint: n };
|
|
3955
|
+
return (o = e.success) == null || o.call(e, C), (d = e.complete) == null || d.call(e, C), Promise.resolve(C);
|
|
3956
|
+
} catch (C) {
|
|
3957
|
+
return (l = e.fail) == null || l.call(e, C), (w = e.complete) == null || w.call(e, C), Promise.reject(C);
|
|
3958
|
+
}
|
|
3959
|
+
const i = { errMsg: "当前环境暂不支持 shareMiniProgramCard,请在 App 或微信小程序容器内使用。", code: "ENV_NOT_SUPPORTED" };
|
|
3960
|
+
return (N = e.fail) == null || N.call(e, i), (O = e.complete) == null || O.call(e, i), Promise.reject(i);
|
|
3961
|
+
}, { context: "shareMiniProgramCard", options: t });
|
|
3962
|
+
}
|
|
3963
|
+
function ai(t = {}) {
|
|
3814
3964
|
return new Promise((e, r) => {
|
|
3815
|
-
|
|
3816
|
-
success: e,
|
|
3817
|
-
fail: r
|
|
3818
|
-
}));
|
|
3965
|
+
Nt(m(h({}, t), { success: e, fail: r }));
|
|
3819
3966
|
});
|
|
3820
3967
|
}
|
|
3821
|
-
const
|
|
3968
|
+
const si = {
|
|
3822
3969
|
OFF: "off",
|
|
3823
3970
|
// 蓝牙关闭
|
|
3824
3971
|
ON: "on",
|
|
@@ -3827,29 +3974,29 @@ const Fn = {
|
|
|
3827
3974
|
// 不支持蓝牙
|
|
3828
3975
|
UNAUTHORIZED: "unauthorized"
|
|
3829
3976
|
// 未授权
|
|
3830
|
-
},
|
|
3977
|
+
}, oi = {
|
|
3831
3978
|
allowDuplicatesKey: !1,
|
|
3832
3979
|
// 是否允许重复上报同一设备
|
|
3833
3980
|
services: []
|
|
3834
3981
|
// 指定服务 UUID 列表
|
|
3835
3982
|
};
|
|
3836
|
-
function
|
|
3837
|
-
return h(h({},
|
|
3983
|
+
function Re(t = {}) {
|
|
3984
|
+
return h(h({}, oi), t);
|
|
3838
3985
|
}
|
|
3839
|
-
function
|
|
3840
|
-
return ["weixin", "webview", "UniApp", "plus", "nvue", "uvue", "offline"].includes(
|
|
3986
|
+
function me() {
|
|
3987
|
+
return ["weixin", "webview", "UniApp", "plus", "nvue", "uvue", "offline"].includes(f.type);
|
|
3841
3988
|
}
|
|
3842
|
-
function
|
|
3843
|
-
return u.safeExecute(() =>
|
|
3989
|
+
function ci(t) {
|
|
3990
|
+
return u.safeExecute(() => p(null, null, function* () {
|
|
3844
3991
|
var e;
|
|
3845
3992
|
if (!window.wx) {
|
|
3846
3993
|
const r = { errMsg: "微信JS-SDK未加载", code: "WEIXIN_SDK_NOT_LOADED" };
|
|
3847
3994
|
(e = t.fail) == null || e.call(t, r);
|
|
3848
3995
|
return;
|
|
3849
3996
|
}
|
|
3850
|
-
|
|
3997
|
+
Q() || (a.info("等待微信配置完成"), yield j()), wx.openBluetoothAdapter({
|
|
3851
3998
|
success: () => {
|
|
3852
|
-
a.info("微信蓝牙适配器已打开"),
|
|
3999
|
+
a.info("微信蓝牙适配器已打开"), St(t);
|
|
3853
4000
|
},
|
|
3854
4001
|
fail: (r) => {
|
|
3855
4002
|
var n;
|
|
@@ -3858,9 +4005,9 @@ function kn(t) {
|
|
|
3858
4005
|
});
|
|
3859
4006
|
}), { context: "openBluetoothAdapterInWeixin" });
|
|
3860
4007
|
}
|
|
3861
|
-
function
|
|
4008
|
+
function ui(t) {
|
|
3862
4009
|
return u.safeExecute(() => {
|
|
3863
|
-
a.debug("通过 WebView 桥接调用蓝牙功能", t),
|
|
4010
|
+
a.debug("通过 WebView 桥接调用蓝牙功能", t), R("bluetooth", t, {
|
|
3864
4011
|
success: (e) => {
|
|
3865
4012
|
var r;
|
|
3866
4013
|
a.info("UniApp 蓝牙调用成功", e), (r = t.success) == null || r.call(t, e);
|
|
@@ -3873,10 +4020,10 @@ function Kn(t) {
|
|
|
3873
4020
|
});
|
|
3874
4021
|
}, { context: "bluetoothInUniApp" });
|
|
3875
4022
|
}
|
|
3876
|
-
function
|
|
4023
|
+
function li(t) {
|
|
3877
4024
|
return u.safeExecute(() => {
|
|
3878
4025
|
var e;
|
|
3879
|
-
a.debug("通过 WebView 桥接调用蓝牙设备搜索功能", t),
|
|
4026
|
+
a.debug("通过 WebView 桥接调用蓝牙设备搜索功能", t), R("bluetoothDevicesDiscovery", {
|
|
3880
4027
|
action: "startBluetoothDevicesDiscovery",
|
|
3881
4028
|
params: {
|
|
3882
4029
|
services: t.services || [],
|
|
@@ -3895,11 +4042,11 @@ function Gn(t) {
|
|
|
3895
4042
|
});
|
|
3896
4043
|
}, { context: "startBluetoothDevicesDiscoveryInUniApp" });
|
|
3897
4044
|
}
|
|
3898
|
-
const
|
|
3899
|
-
function
|
|
4045
|
+
const we = /* @__PURE__ */ new Set();
|
|
4046
|
+
function fi(t, e = {}) {
|
|
3900
4047
|
return u.safeExecute(() => {
|
|
3901
4048
|
var r;
|
|
3902
|
-
return
|
|
4049
|
+
return we.add(t), we.size === 1 && R("onBluetoothDeviceFound", {
|
|
3903
4050
|
action: "onBluetoothDeviceFound",
|
|
3904
4051
|
isPersistent: !0,
|
|
3905
4052
|
params: {
|
|
@@ -3908,7 +4055,7 @@ function zn(t, e = {}) {
|
|
|
3908
4055
|
}
|
|
3909
4056
|
}, {
|
|
3910
4057
|
success: (n) => {
|
|
3911
|
-
|
|
4058
|
+
we.forEach((i) => {
|
|
3912
4059
|
typeof i == "function" ? u.safeExecute(() => i(n), { context: "BluetoothDeviceCallback" }) : console.warn("[BluetoothDeviceCallback] 不是函数:", i);
|
|
3913
4060
|
});
|
|
3914
4061
|
},
|
|
@@ -3917,13 +4064,13 @@ function zn(t, e = {}) {
|
|
|
3917
4064
|
console.error("[Bluetooth] 搜索失败:", n), (i = e.fail) == null || i.call(e, n);
|
|
3918
4065
|
},
|
|
3919
4066
|
complete: e.complete
|
|
3920
|
-
}), () =>
|
|
4067
|
+
}), () => we.delete(t);
|
|
3921
4068
|
}, { context: "qsh_onBluetoothDeviceFound" });
|
|
3922
4069
|
}
|
|
3923
|
-
function
|
|
4070
|
+
function di(t) {
|
|
3924
4071
|
return u.safeExecute(() => {
|
|
3925
4072
|
var e;
|
|
3926
|
-
a.debug("通过 WebView 桥接调用蓝牙连接功能", t),
|
|
4073
|
+
a.debug("通过 WebView 桥接调用蓝牙连接功能", t), R("bluetoothConnection", {
|
|
3927
4074
|
action: "createBLEConnection",
|
|
3928
4075
|
params: {
|
|
3929
4076
|
deviceId: t.deviceId,
|
|
@@ -3943,90 +4090,90 @@ function Vn(t) {
|
|
|
3943
4090
|
});
|
|
3944
4091
|
}, { context: "createBLEConnectionInUniApp" });
|
|
3945
4092
|
}
|
|
3946
|
-
function
|
|
4093
|
+
function gi(t = {}) {
|
|
3947
4094
|
return u.safeExecute(() => {
|
|
3948
4095
|
var r;
|
|
3949
|
-
if (!
|
|
4096
|
+
if (!me()) {
|
|
3950
4097
|
const n = {
|
|
3951
|
-
errMsg: `当前环境 (${
|
|
4098
|
+
errMsg: `当前环境 (${f.type}) 不支持蓝牙功能`,
|
|
3952
4099
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
3953
4100
|
};
|
|
3954
|
-
a.error("平台不支持蓝牙", { platform:
|
|
4101
|
+
a.error("平台不支持蓝牙", { platform: f.type }), (r = t.fail) == null || r.call(t, n);
|
|
3955
4102
|
return;
|
|
3956
4103
|
}
|
|
3957
|
-
const e =
|
|
4104
|
+
const e = Re(t);
|
|
3958
4105
|
a.info("开始蓝牙操作", {
|
|
3959
|
-
platform:
|
|
4106
|
+
platform: f.type,
|
|
3960
4107
|
services: e.services,
|
|
3961
4108
|
allowDuplicatesKey: e.allowDuplicatesKey
|
|
3962
|
-
}),
|
|
4109
|
+
}), _() ? ci(e) : ui(e);
|
|
3963
4110
|
}, { context: "openBluetoothAdapter", options: t });
|
|
3964
4111
|
}
|
|
3965
|
-
function
|
|
4112
|
+
function hi(t = {}) {
|
|
3966
4113
|
return u.safeExecute(() => {
|
|
3967
4114
|
var r, n;
|
|
3968
|
-
if (!
|
|
4115
|
+
if (!me()) {
|
|
3969
4116
|
const i = {
|
|
3970
|
-
errMsg: `当前环境 (${
|
|
4117
|
+
errMsg: `当前环境 (${f.type}) 不支持蓝牙功能`,
|
|
3971
4118
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
3972
4119
|
};
|
|
3973
|
-
a.error("平台不支持蓝牙", { platform:
|
|
4120
|
+
a.error("平台不支持蓝牙", { platform: f.type }), (r = t.fail) == null || r.call(t, i), (n = t.complete) == null || n.call(t, i);
|
|
3974
4121
|
return;
|
|
3975
4122
|
}
|
|
3976
|
-
const e =
|
|
4123
|
+
const e = Re(t);
|
|
3977
4124
|
a.info("开始搜索蓝牙设备", {
|
|
3978
|
-
platform:
|
|
4125
|
+
platform: f.type,
|
|
3979
4126
|
services: e.services,
|
|
3980
4127
|
allowDuplicatesKey: e.allowDuplicatesKey
|
|
3981
|
-
}),
|
|
4128
|
+
}), _() ? startBluetoothDevicesDiscoveryInWeixin(e) : li(e);
|
|
3982
4129
|
}, { context: "startBluetoothDevicesDiscovery", options: t });
|
|
3983
4130
|
}
|
|
3984
|
-
function
|
|
4131
|
+
function St(t, e = {}) {
|
|
3985
4132
|
return u.safeExecute(() => {
|
|
3986
4133
|
var n, i;
|
|
3987
|
-
if (!
|
|
4134
|
+
if (!me()) {
|
|
3988
4135
|
const s = {
|
|
3989
|
-
errMsg: `当前环境 (${
|
|
4136
|
+
errMsg: `当前环境 (${f.type}) 不支持蓝牙功能`,
|
|
3990
4137
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
3991
4138
|
};
|
|
3992
|
-
a.error("平台不支持蓝牙", { platform:
|
|
4139
|
+
a.error("平台不支持蓝牙", { platform: f.type }), (n = e.fail) == null || n.call(e, s), (i = e.complete) == null || i.call(e, s);
|
|
3993
4140
|
return;
|
|
3994
4141
|
}
|
|
3995
|
-
const r =
|
|
3996
|
-
a.info("注册蓝牙设备发现监听", { platform:
|
|
4142
|
+
const r = Re(e);
|
|
4143
|
+
a.info("注册蓝牙设备发现监听", { platform: f.type }), _() ? onBluetoothDeviceFoundInWeixin(r) : fi(t, r);
|
|
3997
4144
|
}, { context: "onBluetoothDeviceFound", options: e });
|
|
3998
4145
|
}
|
|
3999
|
-
function
|
|
4146
|
+
function mi(t = {}) {
|
|
4000
4147
|
return u.safeExecute(() => {
|
|
4001
|
-
var s,
|
|
4002
|
-
if (!
|
|
4003
|
-
const
|
|
4004
|
-
errMsg: `当前环境 (${
|
|
4148
|
+
var s, o, d, l;
|
|
4149
|
+
if (!me()) {
|
|
4150
|
+
const w = {
|
|
4151
|
+
errMsg: `当前环境 (${f.type}) 不支持蓝牙功能`,
|
|
4005
4152
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
4006
4153
|
};
|
|
4007
|
-
a.error("平台不支持蓝牙连接", { platform:
|
|
4154
|
+
a.error("平台不支持蓝牙连接", { platform: f.type }), (s = t.fail) == null || s.call(t, w), (o = t.complete) == null || o.call(t, w);
|
|
4008
4155
|
return;
|
|
4009
4156
|
}
|
|
4010
|
-
const e =
|
|
4157
|
+
const e = Re(t), { name: r, deviceId: n, autoConnect: i = !1 } = e;
|
|
4011
4158
|
if (!n) {
|
|
4012
|
-
const
|
|
4013
|
-
(
|
|
4159
|
+
const w = { errMsg: "缺少 deviceId 参数", code: "INVALID_PARAMS" };
|
|
4160
|
+
(d = t.fail) == null || d.call(t, w), (l = t.complete) == null || l.call(t, w);
|
|
4014
4161
|
return;
|
|
4015
4162
|
}
|
|
4016
|
-
a.info("创建蓝牙连接", { deviceId: n, autoConnect: i, platform:
|
|
4163
|
+
a.info("创建蓝牙连接", { deviceId: n, autoConnect: i, platform: f.type }), _() ? uni.createBLEConnection({
|
|
4017
4164
|
deviceId: n,
|
|
4018
4165
|
autoConnect: i,
|
|
4019
4166
|
success: t.success,
|
|
4020
4167
|
fail: t.fail,
|
|
4021
4168
|
complete: t.complete
|
|
4022
|
-
}) :
|
|
4169
|
+
}) : di(e);
|
|
4023
4170
|
}, { context: "createBLEConnection", options: t });
|
|
4024
4171
|
}
|
|
4025
|
-
function
|
|
4172
|
+
function pi() {
|
|
4026
4173
|
return {
|
|
4027
|
-
supported:
|
|
4028
|
-
environment:
|
|
4029
|
-
implementation:
|
|
4174
|
+
supported: me(),
|
|
4175
|
+
environment: f.type,
|
|
4176
|
+
implementation: _() ? "weixin" : "webview",
|
|
4030
4177
|
features: {
|
|
4031
4178
|
discovery: !0,
|
|
4032
4179
|
connect: !0,
|
|
@@ -4036,18 +4183,18 @@ function Hn() {
|
|
|
4036
4183
|
}
|
|
4037
4184
|
};
|
|
4038
4185
|
}
|
|
4039
|
-
const
|
|
4186
|
+
const wi = {
|
|
4040
4187
|
// TODO: 添加更多默认配置
|
|
4041
4188
|
};
|
|
4042
|
-
function
|
|
4043
|
-
return h(h({},
|
|
4189
|
+
function Ei(t = {}) {
|
|
4190
|
+
return h(h({}, wi), t);
|
|
4044
4191
|
}
|
|
4045
|
-
function
|
|
4046
|
-
return ["webview", "UniApp", "plus", "nvue", "uvue", "offline"].includes(
|
|
4192
|
+
function Tt() {
|
|
4193
|
+
return ["webview", "UniApp", "plus", "nvue", "uvue", "offline"].includes(f.type);
|
|
4047
4194
|
}
|
|
4048
|
-
function
|
|
4195
|
+
function yi(t) {
|
|
4049
4196
|
return u.safeExecute(() => {
|
|
4050
|
-
a.debug("通过 WebView 桥接调用打印PDF", t),
|
|
4197
|
+
a.debug("通过 WebView 桥接调用打印PDF", t), R("printPdf", m(h({}, t), {
|
|
4051
4198
|
isPersistent: !0
|
|
4052
4199
|
// 强制禁用超时自动清理
|
|
4053
4200
|
}), {
|
|
@@ -4066,36 +4213,36 @@ function Xn(t) {
|
|
|
4066
4213
|
platform: "uniapp"
|
|
4067
4214
|
});
|
|
4068
4215
|
}
|
|
4069
|
-
function
|
|
4216
|
+
function Ii(t = {}) {
|
|
4070
4217
|
return u.safeExecute(() => {
|
|
4071
4218
|
var r;
|
|
4072
|
-
if (!
|
|
4219
|
+
if (!Tt()) {
|
|
4073
4220
|
const n = {
|
|
4074
|
-
errMsg: `当前环境 (${
|
|
4221
|
+
errMsg: `当前环境 (${f.type}) 不支持打印PDF功能`,
|
|
4075
4222
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
4076
4223
|
};
|
|
4077
|
-
a.error("平台不支持打印PDF", { platform:
|
|
4224
|
+
a.error("平台不支持打印PDF", { platform: f.type }), (r = t.fail) == null || r.call(t, n);
|
|
4078
4225
|
return;
|
|
4079
4226
|
}
|
|
4080
|
-
const e =
|
|
4081
|
-
a.info("开始打印PDF", { platform:
|
|
4227
|
+
const e = Ei(t);
|
|
4228
|
+
a.info("开始打印PDF", { platform: f.type }), yi(e);
|
|
4082
4229
|
}, {
|
|
4083
4230
|
context: "printPdf",
|
|
4084
4231
|
options: t
|
|
4085
4232
|
});
|
|
4086
4233
|
}
|
|
4087
|
-
function
|
|
4234
|
+
function Ai() {
|
|
4088
4235
|
return {
|
|
4089
|
-
supported:
|
|
4090
|
-
environment:
|
|
4236
|
+
supported: Tt(),
|
|
4237
|
+
environment: f.type,
|
|
4091
4238
|
implementation: "uniapp",
|
|
4092
4239
|
features: {
|
|
4093
4240
|
asyncSupport: !0
|
|
4094
4241
|
}
|
|
4095
4242
|
};
|
|
4096
4243
|
}
|
|
4097
|
-
const
|
|
4098
|
-
function
|
|
4244
|
+
const Le = "/pages/face/index";
|
|
4245
|
+
function Pi(t = {}) {
|
|
4099
4246
|
const e = h({}, t);
|
|
4100
4247
|
if (!e.name || typeof e.name != "string" || !e.name.trim())
|
|
4101
4248
|
throw {
|
|
@@ -4109,26 +4256,26 @@ function ti(t = {}) {
|
|
|
4109
4256
|
};
|
|
4110
4257
|
return e.idCardNumber = e.idCardNumber.trim(), e;
|
|
4111
4258
|
}
|
|
4112
|
-
function
|
|
4113
|
-
return
|
|
4259
|
+
function Lt() {
|
|
4260
|
+
return _();
|
|
4114
4261
|
}
|
|
4115
|
-
function
|
|
4262
|
+
function _i() {
|
|
4116
4263
|
return typeof window != "undefined" && window.wx && window.wx.miniProgram && typeof window.wx.miniProgram.navigateTo == "function";
|
|
4117
4264
|
}
|
|
4118
|
-
function
|
|
4265
|
+
function Ci(t) {
|
|
4119
4266
|
const e = m(h({}, t), {
|
|
4120
4267
|
title: document.title || "",
|
|
4121
4268
|
url: window.location.href || ""
|
|
4122
4269
|
}), r = Object.entries(e).filter(([, n]) => n != null && n !== "").map(([n, i]) => `${encodeURIComponent(n)}=${encodeURIComponent(String(i))}`).join("&");
|
|
4123
|
-
return r ? `${
|
|
4270
|
+
return r ? `${Le}?${r}` : Le;
|
|
4124
4271
|
}
|
|
4125
|
-
function
|
|
4272
|
+
function Mi(t) {
|
|
4126
4273
|
return u.safeExecute(() => {
|
|
4127
|
-
if (!
|
|
4274
|
+
if (!_i()) {
|
|
4128
4275
|
a.error("微信小程序导航API不可用");
|
|
4129
4276
|
return;
|
|
4130
4277
|
}
|
|
4131
|
-
const e =
|
|
4278
|
+
const e = Ci(t);
|
|
4132
4279
|
a.debug("跳转宿主人脸识别页面", {
|
|
4133
4280
|
name: t.name,
|
|
4134
4281
|
targetUrl: e
|
|
@@ -4146,33 +4293,33 @@ function ii(t) {
|
|
|
4146
4293
|
platform: "weixin"
|
|
4147
4294
|
});
|
|
4148
4295
|
}
|
|
4149
|
-
function
|
|
4296
|
+
function Oi(t = {}) {
|
|
4150
4297
|
return u.safeExecute(() => {
|
|
4151
|
-
if (!
|
|
4152
|
-
a.error("平台不支持人脸识别", { platform:
|
|
4298
|
+
if (!Lt()) {
|
|
4299
|
+
a.error("平台不支持人脸识别", { platform: f.type });
|
|
4153
4300
|
return;
|
|
4154
4301
|
}
|
|
4155
4302
|
let e;
|
|
4156
4303
|
try {
|
|
4157
|
-
e =
|
|
4304
|
+
e = Pi(t);
|
|
4158
4305
|
} catch (r) {
|
|
4159
4306
|
a.error("人脸识别参数校验失败", r);
|
|
4160
4307
|
return;
|
|
4161
4308
|
}
|
|
4162
4309
|
a.info("开始人脸识别", {
|
|
4163
|
-
platform:
|
|
4310
|
+
platform: f.type,
|
|
4164
4311
|
name: e.name,
|
|
4165
|
-
pagePath:
|
|
4166
|
-
}),
|
|
4312
|
+
pagePath: Le
|
|
4313
|
+
}), Mi(e);
|
|
4167
4314
|
}, {
|
|
4168
4315
|
context: "faceVerify",
|
|
4169
4316
|
options: t
|
|
4170
4317
|
});
|
|
4171
4318
|
}
|
|
4172
|
-
function
|
|
4319
|
+
function Ri() {
|
|
4173
4320
|
return {
|
|
4174
|
-
supported:
|
|
4175
|
-
environment:
|
|
4321
|
+
supported: Lt(),
|
|
4322
|
+
environment: f.type,
|
|
4176
4323
|
implementation: "weixin",
|
|
4177
4324
|
features: {
|
|
4178
4325
|
asyncSupport: !0,
|
|
@@ -4180,205 +4327,205 @@ function si() {
|
|
|
4180
4327
|
}
|
|
4181
4328
|
};
|
|
4182
4329
|
}
|
|
4183
|
-
const
|
|
4184
|
-
function
|
|
4185
|
-
if (typeof window == "undefined" || !
|
|
4330
|
+
const bt = Z();
|
|
4331
|
+
function Ni() {
|
|
4332
|
+
if (typeof window == "undefined" || !Z(!0).isWeixinMiniProgram)
|
|
4186
4333
|
return !1;
|
|
4187
|
-
const e =
|
|
4334
|
+
const e = Se().getRuntimeConfig();
|
|
4188
4335
|
return typeof e.clientId == "string" && e.clientId.length > 0;
|
|
4189
4336
|
}
|
|
4190
|
-
function
|
|
4191
|
-
return
|
|
4192
|
-
yield
|
|
4337
|
+
function Si() {
|
|
4338
|
+
return p(this, null, function* () {
|
|
4339
|
+
yield ir(), Ni() && (yield j());
|
|
4193
4340
|
});
|
|
4194
4341
|
}
|
|
4195
|
-
|
|
4196
|
-
let
|
|
4197
|
-
function
|
|
4198
|
-
if (
|
|
4199
|
-
|
|
4200
|
-
{ name: "load-weixin-sdk", run:
|
|
4201
|
-
{ name: "init-bridge", run:
|
|
4342
|
+
J.useResponse(st.response, { priority: 1e3 });
|
|
4343
|
+
let Ye = !1;
|
|
4344
|
+
function Xe() {
|
|
4345
|
+
if (Ye) return;
|
|
4346
|
+
Ye = !0, Mr([
|
|
4347
|
+
{ name: "load-weixin-sdk", run: nt, timeoutMs: 8e3 },
|
|
4348
|
+
{ name: "init-bridge", run: tt, timeoutMs: 8e3 }
|
|
4202
4349
|
], {
|
|
4203
4350
|
onError: (e, r) => {
|
|
4204
4351
|
console.error(`[QSH-SDK] 初始化失败(${(r == null ? void 0 : r.name) || "unknown"}):`, e);
|
|
4205
4352
|
}
|
|
4206
4353
|
});
|
|
4207
4354
|
}
|
|
4208
|
-
typeof window != "undefined" && (document.readyState === "complete" || document.readyState === "interactive" ? setTimeout(
|
|
4209
|
-
function
|
|
4355
|
+
typeof window != "undefined" && (document.readyState === "complete" || document.readyState === "interactive" ? setTimeout(Xe, 0) : document.addEventListener("DOMContentLoaded", Xe));
|
|
4356
|
+
function E(t, { apiName: e } = {}) {
|
|
4210
4357
|
return function(r = {}, ...n) {
|
|
4211
|
-
const i = r && typeof r == "object" && (typeof r.success == "function" || typeof r.fail == "function" || typeof r.complete == "function"), s = r && typeof r == "object" ? r : {},
|
|
4212
|
-
const
|
|
4358
|
+
const i = r && typeof r == "object" && (typeof r.success == "function" || typeof r.fail == "function" || typeof r.complete == "function"), s = r && typeof r == "object" ? r : {}, o = () => i ? t(s, ...n) : new Promise((l, w) => {
|
|
4359
|
+
const N = m(h({}, s), {
|
|
4213
4360
|
success: (O) => {
|
|
4214
|
-
typeof s.success == "function" && s.success(O),
|
|
4361
|
+
typeof s.success == "function" && s.success(O), l(O);
|
|
4215
4362
|
},
|
|
4216
4363
|
fail: (O) => {
|
|
4217
|
-
typeof s.fail == "function" && s.fail(O),
|
|
4364
|
+
typeof s.fail == "function" && s.fail(O), w(O);
|
|
4218
4365
|
},
|
|
4219
4366
|
complete: s.complete
|
|
4220
4367
|
});
|
|
4221
|
-
t(
|
|
4368
|
+
t(N, ...n);
|
|
4222
4369
|
});
|
|
4223
|
-
return (typeof window == "undefined" ? Promise.resolve() :
|
|
4224
|
-
throw console.error(`[QSH-SDK] ${e || "API"} call failed:`,
|
|
4370
|
+
return (typeof window == "undefined" ? Promise.resolve() : et()).then(() => o()).catch((l) => {
|
|
4371
|
+
throw console.error(`[QSH-SDK] ${e || "API"} call failed:`, l), l;
|
|
4225
4372
|
});
|
|
4226
4373
|
};
|
|
4227
4374
|
}
|
|
4228
|
-
function
|
|
4375
|
+
function Ee(t) {
|
|
4229
4376
|
return typeof t == "function" ? { success: t } : t && typeof t == "object" ? t : {};
|
|
4230
4377
|
}
|
|
4231
|
-
const
|
|
4232
|
-
function
|
|
4233
|
-
const e = () =>
|
|
4234
|
-
return (typeof window == "undefined" ? Promise.resolve() :
|
|
4378
|
+
const vt = E(jr), xt = E(Jr), Dt = E(Hr), Ut = E(Yr), Wt = E(Xr), $t = E(Zr);
|
|
4379
|
+
function Ft(t) {
|
|
4380
|
+
const e = () => Qr(t);
|
|
4381
|
+
return (typeof window == "undefined" ? Promise.resolve() : et()).then(() => e());
|
|
4235
4382
|
}
|
|
4236
|
-
const
|
|
4237
|
-
function
|
|
4383
|
+
const We = E(sn, { apiName: "getCode" });
|
|
4384
|
+
function Ti(t = {}) {
|
|
4238
4385
|
return new Promise((e, r) => {
|
|
4239
|
-
|
|
4386
|
+
We(m(h({}, t), {
|
|
4240
4387
|
success: e,
|
|
4241
4388
|
fail: r
|
|
4242
4389
|
}));
|
|
4243
4390
|
});
|
|
4244
4391
|
}
|
|
4245
|
-
const
|
|
4392
|
+
const $e = E(fn, {
|
|
4246
4393
|
apiName: "navigateToMiniProgram"
|
|
4247
4394
|
});
|
|
4248
|
-
function
|
|
4395
|
+
function Li(t = {}) {
|
|
4249
4396
|
return new Promise((e, r) => {
|
|
4250
|
-
|
|
4397
|
+
$e(m(h({}, t), {
|
|
4251
4398
|
success: e,
|
|
4252
4399
|
fail: r
|
|
4253
4400
|
}));
|
|
4254
4401
|
});
|
|
4255
4402
|
}
|
|
4256
|
-
const
|
|
4257
|
-
function
|
|
4403
|
+
const Fe = E(mn);
|
|
4404
|
+
function bi(t = {}) {
|
|
4258
4405
|
return new Promise((e, r) => {
|
|
4259
|
-
|
|
4406
|
+
Fe(m(h({}, t), {
|
|
4260
4407
|
success: e,
|
|
4261
4408
|
fail: r
|
|
4262
4409
|
}));
|
|
4263
4410
|
});
|
|
4264
4411
|
}
|
|
4265
|
-
const
|
|
4266
|
-
function
|
|
4412
|
+
const kt = E(Ii);
|
|
4413
|
+
function vi(t = {}) {
|
|
4267
4414
|
return new Promise((e, r) => {
|
|
4268
|
-
|
|
4415
|
+
kt(m(h({}, t), {
|
|
4269
4416
|
success: e,
|
|
4270
4417
|
fail: r
|
|
4271
4418
|
}));
|
|
4272
4419
|
});
|
|
4273
4420
|
}
|
|
4274
|
-
const
|
|
4275
|
-
function
|
|
4421
|
+
const ke = E(An), xi = E(Oi);
|
|
4422
|
+
function Di(t = {}) {
|
|
4276
4423
|
return new Promise((e, r) => {
|
|
4277
|
-
|
|
4424
|
+
ke(m(h({}, t), {
|
|
4278
4425
|
success: e,
|
|
4279
4426
|
fail: r
|
|
4280
4427
|
}));
|
|
4281
4428
|
});
|
|
4282
4429
|
}
|
|
4283
|
-
const
|
|
4284
|
-
function
|
|
4430
|
+
const Ui = E(Rt, { apiName: "shareDirected" }), Wi = E(ii, { apiName: "shareDirectedAsync" }), Be = E(Tn);
|
|
4431
|
+
function $i(t = {}) {
|
|
4285
4432
|
return new Promise((e, r) => {
|
|
4286
|
-
|
|
4433
|
+
Be(m(h({}, t), {
|
|
4287
4434
|
success: e,
|
|
4288
4435
|
fail: r
|
|
4289
4436
|
}));
|
|
4290
4437
|
});
|
|
4291
4438
|
}
|
|
4292
|
-
const
|
|
4293
|
-
function
|
|
4439
|
+
const Ge = E(Ln);
|
|
4440
|
+
function Fi(t = {}) {
|
|
4294
4441
|
return new Promise((e, r) => {
|
|
4295
|
-
|
|
4442
|
+
Ge(m(h({}, t), {
|
|
4296
4443
|
success: e,
|
|
4297
4444
|
fail: r
|
|
4298
4445
|
}));
|
|
4299
4446
|
});
|
|
4300
4447
|
}
|
|
4301
|
-
const
|
|
4302
|
-
function
|
|
4448
|
+
const Ke = E(Gn);
|
|
4449
|
+
function ki(t = {}) {
|
|
4303
4450
|
return new Promise((e, r) => {
|
|
4304
|
-
|
|
4451
|
+
Ke(m(h({}, t), {
|
|
4305
4452
|
success: e,
|
|
4306
4453
|
fail: r
|
|
4307
4454
|
}));
|
|
4308
4455
|
});
|
|
4309
4456
|
}
|
|
4310
|
-
const
|
|
4311
|
-
function
|
|
4457
|
+
const Bt = E(gi);
|
|
4458
|
+
function Bi(t = {}) {
|
|
4312
4459
|
return new Promise((e, r) => {
|
|
4313
|
-
|
|
4460
|
+
Bt(m(h({}, t), {
|
|
4314
4461
|
success: e,
|
|
4315
4462
|
fail: r
|
|
4316
4463
|
}));
|
|
4317
4464
|
});
|
|
4318
4465
|
}
|
|
4319
|
-
const
|
|
4320
|
-
function
|
|
4466
|
+
const Gt = E(hi);
|
|
4467
|
+
function Gi(t = {}) {
|
|
4321
4468
|
return new Promise((e, r) => {
|
|
4322
|
-
|
|
4469
|
+
Gt(m(h({}, t), {
|
|
4323
4470
|
success: e,
|
|
4324
4471
|
fail: r
|
|
4325
4472
|
}));
|
|
4326
4473
|
});
|
|
4327
4474
|
}
|
|
4328
|
-
const
|
|
4329
|
-
function
|
|
4475
|
+
const Kt = E(St);
|
|
4476
|
+
function Ki(t = {}) {
|
|
4330
4477
|
return new Promise((e, r) => {
|
|
4331
|
-
|
|
4478
|
+
Kt(m(h({}, t), {
|
|
4332
4479
|
success: e,
|
|
4333
4480
|
fail: r
|
|
4334
4481
|
}));
|
|
4335
4482
|
});
|
|
4336
4483
|
}
|
|
4337
|
-
const
|
|
4338
|
-
function
|
|
4484
|
+
const Vt = E(mi);
|
|
4485
|
+
function Vi(t = {}) {
|
|
4339
4486
|
return new Promise((e, r) => {
|
|
4340
|
-
|
|
4487
|
+
Vt(m(h({}, t), {
|
|
4341
4488
|
success: e,
|
|
4342
4489
|
fail: r
|
|
4343
4490
|
}));
|
|
4344
4491
|
});
|
|
4345
4492
|
}
|
|
4346
|
-
const
|
|
4493
|
+
const qi = E(Nt, { apiName: "shareMiniProgramCard" }), zi = E(ai, { apiName: "shareMiniProgramCardAsync" }), se = {
|
|
4347
4494
|
// 导航 API
|
|
4348
|
-
navigateTo:
|
|
4349
|
-
navigateBack:
|
|
4350
|
-
switchTab:
|
|
4351
|
-
reLaunch:
|
|
4352
|
-
redirectTo:
|
|
4495
|
+
navigateTo: vt,
|
|
4496
|
+
navigateBack: xt,
|
|
4497
|
+
switchTab: Dt,
|
|
4498
|
+
reLaunch: Ut,
|
|
4499
|
+
redirectTo: Wt,
|
|
4353
4500
|
// 消息 API
|
|
4354
|
-
postMessage:
|
|
4355
|
-
getEnv:
|
|
4356
|
-
getCode:
|
|
4357
|
-
getCodeAsync:
|
|
4358
|
-
navigateToMiniProgram:
|
|
4359
|
-
navigateToMiniProgramAsync:
|
|
4501
|
+
postMessage: $t,
|
|
4502
|
+
getEnv: Ft,
|
|
4503
|
+
getCode: We,
|
|
4504
|
+
getCodeAsync: Ti,
|
|
4505
|
+
navigateToMiniProgram: $e,
|
|
4506
|
+
navigateToMiniProgramAsync: Li,
|
|
4360
4507
|
// 图片 API
|
|
4361
|
-
chooseImage:
|
|
4362
|
-
chooseImageAsync:
|
|
4508
|
+
chooseImage: Fe,
|
|
4509
|
+
chooseImageAsync: bi,
|
|
4363
4510
|
// 扫码 API
|
|
4364
|
-
scanCode:
|
|
4365
|
-
scanCodeAsync:
|
|
4511
|
+
scanCode: ke,
|
|
4512
|
+
scanCodeAsync: Di,
|
|
4366
4513
|
// 位置 API
|
|
4367
|
-
getLocation:
|
|
4368
|
-
getLocationAsync:
|
|
4369
|
-
openLocation:
|
|
4370
|
-
openLocationAsync:
|
|
4371
|
-
chooseLocation:
|
|
4372
|
-
chooseLocationAsync:
|
|
4514
|
+
getLocation: Be,
|
|
4515
|
+
getLocationAsync: $i,
|
|
4516
|
+
openLocation: Ge,
|
|
4517
|
+
openLocationAsync: Fi,
|
|
4518
|
+
chooseLocation: Ke,
|
|
4519
|
+
chooseLocationAsync: ki,
|
|
4373
4520
|
// 位置监听 API(保留回调签名)
|
|
4374
|
-
onLocationChange: (t) =>
|
|
4375
|
-
offLocationChange: (t) =>
|
|
4376
|
-
onLocationChangeError: (t) =>
|
|
4377
|
-
offLocationChangeError: (t) =>
|
|
4378
|
-
startLocationUpdate:
|
|
4379
|
-
stopLocationUpdate:
|
|
4521
|
+
onLocationChange: (t) => E((e = {}) => Dn(e.success), { apiName: "onLocationChange" })(Ee(t)),
|
|
4522
|
+
offLocationChange: (t) => E((e = {}) => Un(e.success), { apiName: "offLocationChange" })(Ee(t)),
|
|
4523
|
+
onLocationChangeError: (t) => E((e = {}) => Wn(e.success), { apiName: "onLocationChangeError" })(Ee(t)),
|
|
4524
|
+
offLocationChangeError: (t) => E((e = {}) => $n(e.success), { apiName: "offLocationChangeError" })(Ee(t)),
|
|
4525
|
+
startLocationUpdate: E(vn, { apiName: "startLocationUpdate" }),
|
|
4526
|
+
stopLocationUpdate: E(xn, { apiName: "stopLocationUpdate" }),
|
|
4380
4527
|
// 环境信息
|
|
4381
|
-
environment:
|
|
4528
|
+
environment: bt,
|
|
4382
4529
|
/**
|
|
4383
4530
|
* Wait for SDK readiness.
|
|
4384
4531
|
* In Weixin mini-program web-view, if qsh.config({ clientId }) was called,
|
|
@@ -4388,7 +4535,7 @@ const re = {
|
|
|
4388
4535
|
* await qsh.ready()
|
|
4389
4536
|
* @since 2.0.0
|
|
4390
4537
|
*/
|
|
4391
|
-
ready:
|
|
4538
|
+
ready: Si,
|
|
4392
4539
|
/**
|
|
4393
4540
|
* 手动初始化 JSBridge
|
|
4394
4541
|
* 默认会在 DOM 就绪时自动初始化;如需更早或手动控制,可调用本方法。
|
|
@@ -4397,7 +4544,7 @@ const re = {
|
|
|
4397
4544
|
* await qsh.init()
|
|
4398
4545
|
* @since 2.0.0
|
|
4399
4546
|
*/
|
|
4400
|
-
init:
|
|
4547
|
+
init: tt,
|
|
4401
4548
|
/**
|
|
4402
4549
|
* 检查 JSBridge 是否就绪
|
|
4403
4550
|
* @returns {boolean}
|
|
@@ -4405,7 +4552,7 @@ const re = {
|
|
|
4405
4552
|
* if (qsh.isReady()) { console.log('ready') }
|
|
4406
4553
|
* @since 2.0.0
|
|
4407
4554
|
*/
|
|
4408
|
-
isReady:
|
|
4555
|
+
isReady: Zt,
|
|
4409
4556
|
/**
|
|
4410
4557
|
* 获取当前 SDK 状态
|
|
4411
4558
|
* @returns {string}
|
|
@@ -4413,8 +4560,8 @@ const re = {
|
|
|
4413
4560
|
* console.log(qsh.getState()) // 'ready'
|
|
4414
4561
|
* @since 2.0.0
|
|
4415
4562
|
*/
|
|
4416
|
-
getState:
|
|
4417
|
-
config:
|
|
4563
|
+
getState: Qt,
|
|
4564
|
+
config: ze,
|
|
4418
4565
|
// 微信配置 API
|
|
4419
4566
|
weixin: {
|
|
4420
4567
|
/**
|
|
@@ -4424,8 +4571,8 @@ const re = {
|
|
|
4424
4571
|
* await qsh.weixin.waitForConfig()
|
|
4425
4572
|
* @since 2.0.0
|
|
4426
4573
|
*/
|
|
4427
|
-
config:
|
|
4428
|
-
waitForConfig:
|
|
4574
|
+
config: ze,
|
|
4575
|
+
waitForConfig: j,
|
|
4429
4576
|
/**
|
|
4430
4577
|
* 检查微信配置是否完成
|
|
4431
4578
|
* @returns {boolean}
|
|
@@ -4433,7 +4580,7 @@ const re = {
|
|
|
4433
4580
|
* if (qsh.weixin.isConfigReady()) { wx.chooseImage({}) }
|
|
4434
4581
|
* @since 2.0.0
|
|
4435
4582
|
*/
|
|
4436
|
-
isConfigReady:
|
|
4583
|
+
isConfigReady: Q,
|
|
4437
4584
|
/**
|
|
4438
4585
|
* 获取微信配置状态
|
|
4439
4586
|
* @returns {string}
|
|
@@ -4441,7 +4588,7 @@ const re = {
|
|
|
4441
4588
|
* console.log(qsh.weixin.getConfigState()) // 'configured'
|
|
4442
4589
|
* @since 2.0.0
|
|
4443
4590
|
*/
|
|
4444
|
-
getConfigState:
|
|
4591
|
+
getConfigState: ur,
|
|
4445
4592
|
/**
|
|
4446
4593
|
* 手动重试微信配置
|
|
4447
4594
|
* @returns {Promise<void>}
|
|
@@ -4449,13 +4596,13 @@ const re = {
|
|
|
4449
4596
|
* await qsh.weixin.retryConfig()
|
|
4450
4597
|
* @since 2.0.0
|
|
4451
4598
|
*/
|
|
4452
|
-
retryConfig:
|
|
4599
|
+
retryConfig: lr
|
|
4453
4600
|
},
|
|
4454
4601
|
// WebView 对象(兼容旧版本)
|
|
4455
4602
|
webView: null,
|
|
4456
4603
|
// 图片相关常量
|
|
4457
|
-
ImageSourceTypes:
|
|
4458
|
-
ImageSizeTypes:
|
|
4604
|
+
ImageSourceTypes: Ae,
|
|
4605
|
+
ImageSizeTypes: Pe,
|
|
4459
4606
|
/**
|
|
4460
4607
|
* 获取图片功能能力信息
|
|
4461
4608
|
* @returns {Object} 能力信息对象
|
|
@@ -4464,9 +4611,9 @@ const re = {
|
|
|
4464
4611
|
* console.log('是否支持:', capabilities.supported)
|
|
4465
4612
|
* @since 2.0.0
|
|
4466
4613
|
*/
|
|
4467
|
-
getImageCapabilities:
|
|
4614
|
+
getImageCapabilities: pn,
|
|
4468
4615
|
// 扫码相关常量
|
|
4469
|
-
ScanTypes:
|
|
4616
|
+
ScanTypes: Y,
|
|
4470
4617
|
/**
|
|
4471
4618
|
* 获取扫码功能能力信息
|
|
4472
4619
|
* @returns {Object} 能力信息对象
|
|
@@ -4475,9 +4622,9 @@ const re = {
|
|
|
4475
4622
|
* console.log('是否支持:', capabilities.supported)
|
|
4476
4623
|
* @since 2.1.0
|
|
4477
4624
|
*/
|
|
4478
|
-
getScanCapabilities:
|
|
4625
|
+
getScanCapabilities: Pn,
|
|
4479
4626
|
// 位置相关常量
|
|
4480
|
-
CoordinateTypes:
|
|
4627
|
+
CoordinateTypes: ae,
|
|
4481
4628
|
/**
|
|
4482
4629
|
* 获取位置功能能力信息
|
|
4483
4630
|
* @returns {Object} 能力信息对象
|
|
@@ -4486,7 +4633,7 @@ const re = {
|
|
|
4486
4633
|
* console.log('是否支持:', capabilities.supported)
|
|
4487
4634
|
* @since 2.1.0
|
|
4488
4635
|
*/
|
|
4489
|
-
getLocationCapabilities:
|
|
4636
|
+
getLocationCapabilities: bn,
|
|
4490
4637
|
/**
|
|
4491
4638
|
* 获取位置选择功能能力信息
|
|
4492
4639
|
* @returns {Object} 能力信息对象
|
|
@@ -4495,22 +4642,25 @@ const re = {
|
|
|
4495
4642
|
* console.log('是否支持:', capabilities.supported)
|
|
4496
4643
|
* @since 2.1.0
|
|
4497
4644
|
*/
|
|
4498
|
-
getChooseLocationCapabilities:
|
|
4645
|
+
getChooseLocationCapabilities: Kn,
|
|
4499
4646
|
// 蓝牙 API
|
|
4500
|
-
openBluetoothAdapter:
|
|
4501
|
-
openBluetoothAdapterAsync:
|
|
4502
|
-
startBluetoothDevicesDiscovery:
|
|
4503
|
-
startBluetoothDevicesDiscoveryAsync:
|
|
4504
|
-
onBluetoothDeviceFound:
|
|
4505
|
-
onBluetoothDeviceFoundAsync:
|
|
4506
|
-
createBLEConnection:
|
|
4507
|
-
createBLEConnectionAsync:
|
|
4647
|
+
openBluetoothAdapter: Bt,
|
|
4648
|
+
openBluetoothAdapterAsync: Bi,
|
|
4649
|
+
startBluetoothDevicesDiscovery: Gt,
|
|
4650
|
+
startBluetoothDevicesDiscoveryAsync: Gi,
|
|
4651
|
+
onBluetoothDeviceFound: Kt,
|
|
4652
|
+
onBluetoothDeviceFoundAsync: Ki,
|
|
4653
|
+
createBLEConnection: Vt,
|
|
4654
|
+
createBLEConnectionAsync: Vi,
|
|
4508
4655
|
// 蓝牙相关常量
|
|
4509
|
-
BluetoothStates:
|
|
4656
|
+
BluetoothStates: si,
|
|
4510
4657
|
//微信分享(定向模块)
|
|
4511
4658
|
/** 定向分享模块:仅 H5->宿主 WebView,图文/文字/图片到微信会话/朋友圈 */
|
|
4512
|
-
shareDirected:
|
|
4513
|
-
shareDirectedAsync:
|
|
4659
|
+
shareDirected: Ui,
|
|
4660
|
+
shareDirectedAsync: Wi,
|
|
4661
|
+
/** 微信小程序卡片:仅发送给朋友,不改现有 shareDirected */
|
|
4662
|
+
shareMiniProgramCard: qi,
|
|
4663
|
+
shareMiniProgramCardAsync: zi,
|
|
4514
4664
|
/**
|
|
4515
4665
|
* 获取蓝牙功能能力信息
|
|
4516
4666
|
* @returns {Object} 能力信息对象
|
|
@@ -4518,10 +4668,10 @@ const re = {
|
|
|
4518
4668
|
* const capabilities = qsh.getBluetoothCapabilities()
|
|
4519
4669
|
* console.log('是否支持:', capabilities.supported)
|
|
4520
4670
|
*/
|
|
4521
|
-
getBluetoothCapabilities:
|
|
4671
|
+
getBluetoothCapabilities: pi,
|
|
4522
4672
|
// 打印PDF API
|
|
4523
|
-
printPdf:
|
|
4524
|
-
printPdfAsync:
|
|
4673
|
+
printPdf: kt,
|
|
4674
|
+
printPdfAsync: vi,
|
|
4525
4675
|
/**
|
|
4526
4676
|
* 获取打印PDF功能能力信息
|
|
4527
4677
|
* @returns {Object} 能力信息对象
|
|
@@ -4529,16 +4679,16 @@ const re = {
|
|
|
4529
4679
|
* const capabilities = qsh.getPrintCapabilities()
|
|
4530
4680
|
* console.log('是否支持:', capabilities.supported)
|
|
4531
4681
|
*/
|
|
4532
|
-
getPrintCapabilities:
|
|
4682
|
+
getPrintCapabilities: Ai,
|
|
4533
4683
|
// 人脸识别 API(仅支持微信小程序环境)
|
|
4534
|
-
faceVerify:
|
|
4535
|
-
getFaceCapabilities:
|
|
4684
|
+
faceVerify: xi,
|
|
4685
|
+
getFaceCapabilities: Ri,
|
|
4536
4686
|
// 插件系统
|
|
4537
4687
|
plugins: {
|
|
4538
4688
|
/**
|
|
4539
4689
|
* 插件管理器
|
|
4540
4690
|
*/
|
|
4541
|
-
manager:
|
|
4691
|
+
manager: ue,
|
|
4542
4692
|
/**
|
|
4543
4693
|
* 注册插件
|
|
4544
4694
|
* @param {Object} plugin - 插件对象
|
|
@@ -4546,7 +4696,7 @@ const re = {
|
|
|
4546
4696
|
* @example
|
|
4547
4697
|
* qsh.plugins.register(myPlugin)
|
|
4548
4698
|
*/
|
|
4549
|
-
register: (t) =>
|
|
4699
|
+
register: (t) => ue.register(t),
|
|
4550
4700
|
/**
|
|
4551
4701
|
* 安装插件
|
|
4552
4702
|
* @param {string} name - 插件名称
|
|
@@ -4554,21 +4704,21 @@ const re = {
|
|
|
4554
4704
|
* @example
|
|
4555
4705
|
* await qsh.plugins.install('image')
|
|
4556
4706
|
*/
|
|
4557
|
-
install: (t) =>
|
|
4707
|
+
install: (t) => ue.install(t, se),
|
|
4558
4708
|
/**
|
|
4559
4709
|
* 获取插件列表
|
|
4560
4710
|
* @returns {Array} 插件列表
|
|
4561
4711
|
* @example
|
|
4562
4712
|
* console.log(qsh.plugins.list())
|
|
4563
4713
|
*/
|
|
4564
|
-
list: () =>
|
|
4714
|
+
list: () => ue.getPluginList()
|
|
4565
4715
|
},
|
|
4566
4716
|
// 拦截器系统
|
|
4567
4717
|
interceptors: {
|
|
4568
4718
|
/**
|
|
4569
4719
|
* 拦截器链
|
|
4570
4720
|
*/
|
|
4571
|
-
chain:
|
|
4721
|
+
chain: J,
|
|
4572
4722
|
/**
|
|
4573
4723
|
* 注册请求拦截器
|
|
4574
4724
|
* @param {Function} interceptor - 拦截器函数
|
|
@@ -4580,7 +4730,7 @@ const re = {
|
|
|
4580
4730
|
* return ctx
|
|
4581
4731
|
* })
|
|
4582
4732
|
*/
|
|
4583
|
-
useRequest: (t, e) =>
|
|
4733
|
+
useRequest: (t, e) => J.useRequest(t, e),
|
|
4584
4734
|
/**
|
|
4585
4735
|
* 注册响应拦截器
|
|
4586
4736
|
* @param {Function} interceptor - 拦截器函数
|
|
@@ -4592,16 +4742,16 @@ const re = {
|
|
|
4592
4742
|
* return result
|
|
4593
4743
|
* })
|
|
4594
4744
|
*/
|
|
4595
|
-
useResponse: (t, e) =>
|
|
4745
|
+
useResponse: (t, e) => J.useResponse(t, e),
|
|
4596
4746
|
/**
|
|
4597
4747
|
* 内置拦截器
|
|
4598
4748
|
*/
|
|
4599
4749
|
builtin: {
|
|
4600
|
-
logging:
|
|
4601
|
-
performance:
|
|
4602
|
-
createRetry:
|
|
4603
|
-
createValidation:
|
|
4604
|
-
errorNormalizer:
|
|
4750
|
+
logging: gr,
|
|
4751
|
+
performance: V,
|
|
4752
|
+
createRetry: hr,
|
|
4753
|
+
createValidation: mr,
|
|
4754
|
+
errorNormalizer: st
|
|
4605
4755
|
}
|
|
4606
4756
|
},
|
|
4607
4757
|
// 观测指标
|
|
@@ -4609,26 +4759,26 @@ const re = {
|
|
|
4609
4759
|
/**
|
|
4610
4760
|
* 获取性能指标报告
|
|
4611
4761
|
*/
|
|
4612
|
-
getPerformanceReport: () =>
|
|
4762
|
+
getPerformanceReport: () => V.getReport(),
|
|
4613
4763
|
/**
|
|
4614
4764
|
* 清空性能指标
|
|
4615
4765
|
*/
|
|
4616
|
-
clearPerformanceMetrics: () =>
|
|
4766
|
+
clearPerformanceMetrics: () => V.clearMetrics()
|
|
4617
4767
|
},
|
|
4618
4768
|
// 错误处理工具
|
|
4619
4769
|
errors: {
|
|
4620
4770
|
/**
|
|
4621
4771
|
* 错误码枚举
|
|
4622
4772
|
*/
|
|
4623
|
-
codes:
|
|
4773
|
+
codes: c,
|
|
4624
4774
|
/**
|
|
4625
4775
|
* 错误消息
|
|
4626
4776
|
*/
|
|
4627
|
-
messages:
|
|
4777
|
+
messages: Te,
|
|
4628
4778
|
/**
|
|
4629
4779
|
* 错误分类
|
|
4630
4780
|
*/
|
|
4631
|
-
categories:
|
|
4781
|
+
categories: W,
|
|
4632
4782
|
/**
|
|
4633
4783
|
* 标准化错误
|
|
4634
4784
|
* @param {any} error - 原始错误
|
|
@@ -4637,7 +4787,7 @@ const re = {
|
|
|
4637
4787
|
* @example
|
|
4638
4788
|
* const standardError = qsh.errors.normalize(error, { apiName: 'chooseImage' })
|
|
4639
4789
|
*/
|
|
4640
|
-
normalize:
|
|
4790
|
+
normalize: at,
|
|
4641
4791
|
/**
|
|
4642
4792
|
* 创建标准错误
|
|
4643
4793
|
* @param {string} code - 错误码
|
|
@@ -4646,7 +4796,7 @@ const re = {
|
|
|
4646
4796
|
* @example
|
|
4647
4797
|
* const error = qsh.errors.create('E_IMG_001', { apiName: 'chooseImage' })
|
|
4648
4798
|
*/
|
|
4649
|
-
create:
|
|
4799
|
+
create: Pr,
|
|
4650
4800
|
/**
|
|
4651
4801
|
* 判断是否为标准错误
|
|
4652
4802
|
* @param {any} error - 错误对象
|
|
@@ -4654,14 +4804,14 @@ const re = {
|
|
|
4654
4804
|
* @example
|
|
4655
4805
|
* if (qsh.errors.isStandard(error)) { ... }
|
|
4656
4806
|
*/
|
|
4657
|
-
isStandard:
|
|
4807
|
+
isStandard: _r
|
|
4658
4808
|
},
|
|
4659
4809
|
// 状态管理
|
|
4660
4810
|
store: {
|
|
4661
4811
|
/**
|
|
4662
4812
|
* 状态仓库实例
|
|
4663
4813
|
*/
|
|
4664
|
-
instance:
|
|
4814
|
+
instance: B,
|
|
4665
4815
|
/**
|
|
4666
4816
|
* 获取状态
|
|
4667
4817
|
* @param {string} path - 状态路径
|
|
@@ -4669,7 +4819,7 @@ const re = {
|
|
|
4669
4819
|
* @example
|
|
4670
4820
|
* const status = qsh.store.get('sdk.status')
|
|
4671
4821
|
*/
|
|
4672
|
-
get: (t) =>
|
|
4822
|
+
get: (t) => B.get(t),
|
|
4673
4823
|
/**
|
|
4674
4824
|
* 设置状态
|
|
4675
4825
|
* @param {string} path - 状态路径
|
|
@@ -4677,7 +4827,7 @@ const re = {
|
|
|
4677
4827
|
* @example
|
|
4678
4828
|
* qsh.store.set('sdk.status', 'ready')
|
|
4679
4829
|
*/
|
|
4680
|
-
set: (t, e) =>
|
|
4830
|
+
set: (t, e) => B.set(t, e),
|
|
4681
4831
|
/**
|
|
4682
4832
|
* 订阅状态变化
|
|
4683
4833
|
* @param {string} path - 状态路径
|
|
@@ -4688,25 +4838,25 @@ const re = {
|
|
|
4688
4838
|
* console.log('网络状态:', online)
|
|
4689
4839
|
* })
|
|
4690
4840
|
*/
|
|
4691
|
-
subscribe: (t, e) =>
|
|
4841
|
+
subscribe: (t, e) => B.subscribe(t, e),
|
|
4692
4842
|
/**
|
|
4693
4843
|
* 获取状态快照
|
|
4694
4844
|
* @returns {Object} 状态快照
|
|
4695
4845
|
* @example
|
|
4696
4846
|
* console.log(qsh.store.getSnapshot())
|
|
4697
4847
|
*/
|
|
4698
|
-
getSnapshot: () =>
|
|
4848
|
+
getSnapshot: () => B.getSnapshot()
|
|
4699
4849
|
},
|
|
4700
4850
|
// 调试工具(生产环境可能被优化掉)
|
|
4701
4851
|
debug: {
|
|
4702
4852
|
/**
|
|
4703
4853
|
* 日志记录器
|
|
4704
4854
|
*/
|
|
4705
|
-
logger:
|
|
4855
|
+
logger: b,
|
|
4706
4856
|
/**
|
|
4707
4857
|
* 设置外部日志 reporter,便于对接埋点/观测
|
|
4708
4858
|
*/
|
|
4709
|
-
setLogReporter: (t) =>
|
|
4859
|
+
setLogReporter: (t) => b.setReporter(t),
|
|
4710
4860
|
/**
|
|
4711
4861
|
* 错误处理器
|
|
4712
4862
|
*/
|
|
@@ -4714,13 +4864,13 @@ const re = {
|
|
|
4714
4864
|
/**
|
|
4715
4865
|
* 状态管理器
|
|
4716
4866
|
*/
|
|
4717
|
-
stateManager:
|
|
4867
|
+
stateManager: H,
|
|
4718
4868
|
/**
|
|
4719
4869
|
* 启用调试模式
|
|
4720
4870
|
* @example
|
|
4721
4871
|
* qsh.debug.enableDevMode()
|
|
4722
4872
|
*/
|
|
4723
|
-
enableDevMode: () =>
|
|
4873
|
+
enableDevMode: () => b.enableDevMode(),
|
|
4724
4874
|
/**
|
|
4725
4875
|
* 获取日志历史
|
|
4726
4876
|
* @param {number} [count] - 获取条数
|
|
@@ -4728,7 +4878,7 @@ const re = {
|
|
|
4728
4878
|
* @example
|
|
4729
4879
|
* console.log(qsh.debug.getLogs(10))
|
|
4730
4880
|
*/
|
|
4731
|
-
getLogs: (t) =>
|
|
4881
|
+
getLogs: (t) => b.getHistory(t),
|
|
4732
4882
|
/**
|
|
4733
4883
|
* 获取 SDK 统计信息
|
|
4734
4884
|
* @returns {Object} 统计信息
|
|
@@ -4736,12 +4886,12 @@ const re = {
|
|
|
4736
4886
|
* console.log(qsh.debug.getStats())
|
|
4737
4887
|
*/
|
|
4738
4888
|
getStats: () => ({
|
|
4739
|
-
logger:
|
|
4740
|
-
state:
|
|
4741
|
-
weixinConfig:
|
|
4742
|
-
plugins:
|
|
4743
|
-
interceptors:
|
|
4744
|
-
store:
|
|
4889
|
+
logger: b.getStats(),
|
|
4890
|
+
state: H.getStats(),
|
|
4891
|
+
weixinConfig: Se().getStats(),
|
|
4892
|
+
plugins: ue.getStats(),
|
|
4893
|
+
interceptors: J.getStats(),
|
|
4894
|
+
store: B.getStats()
|
|
4745
4895
|
}),
|
|
4746
4896
|
/**
|
|
4747
4897
|
* 获取微信配置管理器
|
|
@@ -4749,38 +4899,38 @@ const re = {
|
|
|
4749
4899
|
* @example
|
|
4750
4900
|
* console.log(qsh.debug.getWeixinConfigManager().getStats())
|
|
4751
4901
|
*/
|
|
4752
|
-
getWeixinConfigManager:
|
|
4902
|
+
getWeixinConfigManager: Se,
|
|
4753
4903
|
/**
|
|
4754
4904
|
* 导出调试信息
|
|
4755
4905
|
* @returns {string} JSON 格式的调试信息
|
|
4756
4906
|
* @example
|
|
4757
4907
|
* console.log(qsh.debug.exportDebugInfo())
|
|
4758
4908
|
*/
|
|
4759
|
-
exportDebugInfo: () =>
|
|
4909
|
+
exportDebugInfo: () => b.exportToJSON()
|
|
4760
4910
|
}
|
|
4761
4911
|
};
|
|
4762
|
-
|
|
4763
|
-
navigateTo:
|
|
4764
|
-
navigateBack:
|
|
4765
|
-
switchTab:
|
|
4766
|
-
reLaunch:
|
|
4767
|
-
redirectTo:
|
|
4768
|
-
postMessage:
|
|
4769
|
-
getEnv:
|
|
4770
|
-
getCode:
|
|
4771
|
-
navigateToMiniProgram:
|
|
4772
|
-
chooseImage:
|
|
4773
|
-
scanCode:
|
|
4774
|
-
getLocation:
|
|
4775
|
-
openLocation:
|
|
4776
|
-
chooseLocation:
|
|
4912
|
+
bt.isWeixinMiniProgram ? se.webView = window.wx && window.wx.miniProgram : se.webView = {
|
|
4913
|
+
navigateTo: vt,
|
|
4914
|
+
navigateBack: xt,
|
|
4915
|
+
switchTab: Dt,
|
|
4916
|
+
reLaunch: Ut,
|
|
4917
|
+
redirectTo: Wt,
|
|
4918
|
+
postMessage: $t,
|
|
4919
|
+
getEnv: Ft,
|
|
4920
|
+
getCode: We,
|
|
4921
|
+
navigateToMiniProgram: $e,
|
|
4922
|
+
chooseImage: Fe,
|
|
4923
|
+
scanCode: ke,
|
|
4924
|
+
getLocation: Be,
|
|
4925
|
+
openLocation: Ge,
|
|
4926
|
+
chooseLocation: Ke
|
|
4777
4927
|
};
|
|
4778
|
-
const
|
|
4779
|
-
Object.keys(
|
|
4780
|
-
|
|
4928
|
+
const Ze = typeof window.uni != "undefined" ? window.uni : {};
|
|
4929
|
+
Object.keys(Ze).forEach((t) => {
|
|
4930
|
+
se.hasOwnProperty(t) || (se[t] = Ze[t]);
|
|
4781
4931
|
});
|
|
4782
|
-
typeof window != "undefined" && (window.qsh =
|
|
4932
|
+
typeof window != "undefined" && (window.qsh = se);
|
|
4783
4933
|
export {
|
|
4784
|
-
|
|
4934
|
+
se as default
|
|
4785
4935
|
};
|
|
4786
4936
|
//# sourceMappingURL=qsh-webview-sdk.es.js.map
|