qsh-webview-sdk 2.4.2 → 2.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -20
- package/dist/qsh-webview-sdk.es.js +749 -718
- 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
|
@@ -2,58 +2,58 @@ var zt = Object.defineProperty, Yt = Object.defineProperties;
|
|
|
2
2
|
var Xt = Object.getOwnPropertyDescriptors;
|
|
3
3
|
var Je = Object.getOwnPropertySymbols;
|
|
4
4
|
var Zt = Object.prototype.hasOwnProperty, Qt = Object.prototype.propertyIsEnumerable;
|
|
5
|
-
var
|
|
5
|
+
var Te = (t, e, r) => e in t ? zt(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r, g = (t, e) => {
|
|
6
6
|
for (var r in e || (e = {}))
|
|
7
|
-
Zt.call(e, r) &&
|
|
7
|
+
Zt.call(e, r) && Te(t, r, e[r]);
|
|
8
8
|
if (Je)
|
|
9
9
|
for (var r of Je(e))
|
|
10
|
-
Qt.call(e, r) &&
|
|
10
|
+
Qt.call(e, r) && Te(t, r, e[r]);
|
|
11
11
|
return t;
|
|
12
|
-
},
|
|
13
|
-
var
|
|
14
|
-
var
|
|
12
|
+
}, m = (t, e) => Yt(t, Xt(e));
|
|
13
|
+
var B = (t, e, r) => Te(t, typeof e != "symbol" ? e + "" : e, r);
|
|
14
|
+
var I = (t, e, r) => new Promise((n, i) => {
|
|
15
15
|
var s = (u) => {
|
|
16
16
|
try {
|
|
17
|
-
|
|
18
|
-
} catch (
|
|
19
|
-
i(
|
|
17
|
+
l(r.next(u));
|
|
18
|
+
} catch (p) {
|
|
19
|
+
i(p);
|
|
20
20
|
}
|
|
21
21
|
}, o = (u) => {
|
|
22
22
|
try {
|
|
23
|
-
|
|
24
|
-
} catch (
|
|
25
|
-
i(
|
|
23
|
+
l(r.throw(u));
|
|
24
|
+
} catch (p) {
|
|
25
|
+
i(p);
|
|
26
26
|
}
|
|
27
|
-
},
|
|
28
|
-
|
|
27
|
+
}, l = (u) => u.done ? n(u.value) : Promise.resolve(u.value).then(s, o);
|
|
28
|
+
l((r = r.apply(t, e)).next());
|
|
29
29
|
});
|
|
30
|
-
function
|
|
30
|
+
function pe() {
|
|
31
31
|
return typeof window != "undefined" ? window : void 0;
|
|
32
32
|
}
|
|
33
33
|
function De() {
|
|
34
34
|
return typeof navigator == "undefined" ? "" : navigator.userAgent || "";
|
|
35
35
|
}
|
|
36
|
-
function
|
|
37
|
-
const t =
|
|
36
|
+
function C() {
|
|
37
|
+
const t = pe();
|
|
38
38
|
if (!t) return !1;
|
|
39
39
|
if (t.__wxjs_environment === "miniprogram" || t.wx && t.wx.miniProgram)
|
|
40
40
|
return !0;
|
|
41
41
|
const e = De();
|
|
42
42
|
return !!(e && /micromessenger/i.test(e) && /miniProgram/i.test(e));
|
|
43
43
|
}
|
|
44
|
-
function
|
|
45
|
-
const t =
|
|
44
|
+
function Me() {
|
|
45
|
+
const t = pe();
|
|
46
46
|
return !!(t && t.plus);
|
|
47
47
|
}
|
|
48
48
|
function Re() {
|
|
49
|
-
const t =
|
|
49
|
+
const t = pe();
|
|
50
50
|
return !!(t && (t.__dcloud_weex_postMessage || t.__dcloud_weex_));
|
|
51
51
|
}
|
|
52
|
-
function
|
|
53
|
-
const t =
|
|
52
|
+
function Se() {
|
|
53
|
+
const t = pe();
|
|
54
54
|
return !!(t && (t.__uniapp_x_postMessage || t.__uniapp_x_));
|
|
55
55
|
}
|
|
56
|
-
function
|
|
56
|
+
function Oe() {
|
|
57
57
|
const t = De();
|
|
58
58
|
return /uni-app/i.test(t);
|
|
59
59
|
}
|
|
@@ -62,10 +62,10 @@ function Ue() {
|
|
|
62
62
|
return /Html5Plus/i.test(t);
|
|
63
63
|
}
|
|
64
64
|
function tt() {
|
|
65
|
-
return
|
|
65
|
+
return Oe() || Ue();
|
|
66
66
|
}
|
|
67
|
-
function
|
|
68
|
-
const t =
|
|
67
|
+
function Z() {
|
|
68
|
+
const t = pe();
|
|
69
69
|
if (!t) return !1;
|
|
70
70
|
if (t.__offline_bridge_postMessage) return !0;
|
|
71
71
|
try {
|
|
@@ -76,30 +76,30 @@ function Q() {
|
|
|
76
76
|
return !1;
|
|
77
77
|
}
|
|
78
78
|
function er() {
|
|
79
|
-
return
|
|
79
|
+
return Se() ? "uvue" : Re() ? "nvue" : C() ? "weixin" : Z() ? "offline" : Me() ? "plus" : tt() ? "webview" : Oe() ? "UniApp" : "h5";
|
|
80
80
|
}
|
|
81
81
|
let Ee = null;
|
|
82
82
|
function H(t = !1) {
|
|
83
83
|
return Ee && !t || (Ee = {
|
|
84
|
-
isWeixinMiniProgram:
|
|
85
|
-
isAppPlus:
|
|
84
|
+
isWeixinMiniProgram: C(),
|
|
85
|
+
isAppPlus: Me(),
|
|
86
86
|
isNvue: Re(),
|
|
87
|
-
isUvue:
|
|
88
|
-
isUniApp:
|
|
87
|
+
isUvue: Se(),
|
|
88
|
+
isUniApp: Oe(),
|
|
89
89
|
isHtml5Plus: Ue(),
|
|
90
90
|
isUniAppWebView: tt(),
|
|
91
|
-
isOfflineWebview:
|
|
91
|
+
isOfflineWebview: Z(),
|
|
92
92
|
type: er()
|
|
93
93
|
}), Ee;
|
|
94
94
|
}
|
|
95
|
-
const
|
|
95
|
+
const f = H(), T = {
|
|
96
96
|
PLATFORM_NOT_SUPPORTED: "PLATFORM_NOT_SUPPORTED",
|
|
97
97
|
API_CALL_FAILED: "API_CALL_FAILED",
|
|
98
98
|
BRIDGE_NOT_READY: "BRIDGE_NOT_READY",
|
|
99
99
|
INVALID_PARAMETERS: "INVALID_PARAMETERS",
|
|
100
100
|
NETWORK_ERROR: "NETWORK_ERROR"
|
|
101
101
|
};
|
|
102
|
-
class
|
|
102
|
+
class N extends Error {
|
|
103
103
|
/**
|
|
104
104
|
* 构造函数
|
|
105
105
|
* @param {string} type - 错误类型
|
|
@@ -108,7 +108,7 @@ class T extends Error {
|
|
|
108
108
|
* @param {Error} [originalError] - 原始错误对象
|
|
109
109
|
*/
|
|
110
110
|
constructor(e, r, n = {}, i = null) {
|
|
111
|
-
super(r), this.name = "QshError", this.type = e, this.context = n, this.originalError = i, this.timestamp = (/* @__PURE__ */ new Date()).toISOString(), Error.captureStackTrace && Error.captureStackTrace(this,
|
|
111
|
+
super(r), this.name = "QshError", this.type = e, this.context = n, this.originalError = i, this.timestamp = (/* @__PURE__ */ new Date()).toISOString(), Error.captureStackTrace && Error.captureStackTrace(this, N);
|
|
112
112
|
}
|
|
113
113
|
/**
|
|
114
114
|
* 转换为 JSON 格式
|
|
@@ -125,28 +125,28 @@ class T extends Error {
|
|
|
125
125
|
};
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
|
-
const
|
|
128
|
+
const S = class S {
|
|
129
129
|
/**
|
|
130
130
|
* 设置调试模式
|
|
131
131
|
* @param {boolean} enabled - 是否启用调试模式
|
|
132
132
|
*/
|
|
133
133
|
static setDebugMode(e) {
|
|
134
|
-
|
|
134
|
+
S.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" && S.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 = S.errorCallbacks.indexOf(e);
|
|
149
|
+
r > -1 && S.errorCallbacks.splice(r, 1);
|
|
150
150
|
}
|
|
151
151
|
/**
|
|
152
152
|
* 处理 API 调用错误
|
|
@@ -156,16 +156,16 @@ const O = class O {
|
|
|
156
156
|
*/
|
|
157
157
|
static handleApiError(e, r = {}) {
|
|
158
158
|
let n;
|
|
159
|
-
return e instanceof
|
|
160
|
-
|
|
159
|
+
return e instanceof N ? n = e : e instanceof Error ? n = new N(
|
|
160
|
+
T.API_CALL_FAILED,
|
|
161
161
|
e.message,
|
|
162
162
|
r,
|
|
163
163
|
e
|
|
164
|
-
) : n = new
|
|
165
|
-
|
|
164
|
+
) : n = new N(
|
|
165
|
+
T.API_CALL_FAILED,
|
|
166
166
|
String(e),
|
|
167
167
|
r
|
|
168
|
-
),
|
|
168
|
+
), S.logError(n), S.notifyCallbacks(n), n;
|
|
169
169
|
}
|
|
170
170
|
/**
|
|
171
171
|
* 处理平台不支持错误
|
|
@@ -174,12 +174,12 @@ const O = class O {
|
|
|
174
174
|
* @returns {QshError} 错误对象
|
|
175
175
|
*/
|
|
176
176
|
static handlePlatformNotSupported(e, r) {
|
|
177
|
-
const n = new
|
|
178
|
-
|
|
177
|
+
const n = new N(
|
|
178
|
+
T.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 S.logError(n), S.notifyCallbacks(n), n;
|
|
183
183
|
}
|
|
184
184
|
/**
|
|
185
185
|
* 处理桥接未就绪错误
|
|
@@ -187,12 +187,12 @@ const O = class O {
|
|
|
187
187
|
* @returns {QshError} 错误对象
|
|
188
188
|
*/
|
|
189
189
|
static handleBridgeNotReady(e) {
|
|
190
|
-
const r = new
|
|
191
|
-
|
|
190
|
+
const r = new N(
|
|
191
|
+
T.BRIDGE_NOT_READY,
|
|
192
192
|
`Bridge is not ready when calling "${e}"`,
|
|
193
193
|
{ apiName: e }
|
|
194
194
|
);
|
|
195
|
-
return
|
|
195
|
+
return S.logError(r), S.notifyCallbacks(r), r;
|
|
196
196
|
}
|
|
197
197
|
/**
|
|
198
198
|
* 处理参数验证错误
|
|
@@ -203,12 +203,12 @@ const O = class O {
|
|
|
203
203
|
* @returns {QshError} 错误对象
|
|
204
204
|
*/
|
|
205
205
|
static handleInvalidParameters(e, r, n, i) {
|
|
206
|
-
const s = new
|
|
207
|
-
|
|
206
|
+
const s = new N(
|
|
207
|
+
T.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 S.logError(s), S.notifyCallbacks(s), s;
|
|
212
212
|
}
|
|
213
213
|
/**
|
|
214
214
|
* 安全地包装函数执行,捕获并处理错误
|
|
@@ -220,7 +220,7 @@ const O = class O {
|
|
|
220
220
|
try {
|
|
221
221
|
return e();
|
|
222
222
|
} catch (n) {
|
|
223
|
-
return
|
|
223
|
+
return S.handleApiError(n, r);
|
|
224
224
|
}
|
|
225
225
|
}
|
|
226
226
|
/**
|
|
@@ -230,11 +230,11 @@ const O = class O {
|
|
|
230
230
|
* @returns {Promise} Promise 对象
|
|
231
231
|
*/
|
|
232
232
|
static safeExecuteAsync(n) {
|
|
233
|
-
return
|
|
233
|
+
return I(this, arguments, function* (e, r = {}) {
|
|
234
234
|
try {
|
|
235
235
|
return yield e();
|
|
236
236
|
} catch (i) {
|
|
237
|
-
return
|
|
237
|
+
return S.handleApiError(i, r);
|
|
238
238
|
}
|
|
239
239
|
});
|
|
240
240
|
}
|
|
@@ -246,7 +246,7 @@ const O = class O {
|
|
|
246
246
|
static logError(e) {
|
|
247
247
|
if (typeof console != "undefined") {
|
|
248
248
|
const r = `[QSH-SDK Error] ${e.type}: ${e.message}`;
|
|
249
|
-
|
|
249
|
+
S.isDebugMode ? console.error(r, {
|
|
250
250
|
context: e.context,
|
|
251
251
|
originalError: e.originalError,
|
|
252
252
|
stack: e.stack,
|
|
@@ -260,7 +260,7 @@ const O = class O {
|
|
|
260
260
|
* @private
|
|
261
261
|
*/
|
|
262
262
|
static notifyCallbacks(e) {
|
|
263
|
-
|
|
263
|
+
S.errorCallbacks.forEach((r) => {
|
|
264
264
|
try {
|
|
265
265
|
r(e);
|
|
266
266
|
} catch (n) {
|
|
@@ -277,14 +277,14 @@ const O = class O {
|
|
|
277
277
|
return function(r, n, i) {
|
|
278
278
|
const s = i.value;
|
|
279
279
|
return i.value = function(...o) {
|
|
280
|
-
return
|
|
280
|
+
return S.safeExecute(() => s.apply(this, o), m(g({}, e), { method: n, target: r.constructor.name }));
|
|
281
281
|
}, i;
|
|
282
282
|
};
|
|
283
283
|
}
|
|
284
284
|
};
|
|
285
|
-
|
|
286
|
-
let
|
|
287
|
-
const
|
|
285
|
+
B(S, "isDebugMode", !1), B(S, "errorCallbacks", []);
|
|
286
|
+
let d = S;
|
|
287
|
+
const x = {
|
|
288
288
|
UNINITIALIZED: "uninitialized",
|
|
289
289
|
INITIALIZING: "initializing",
|
|
290
290
|
READY: "ready",
|
|
@@ -292,7 +292,7 @@ const L = {
|
|
|
292
292
|
};
|
|
293
293
|
class tr {
|
|
294
294
|
constructor() {
|
|
295
|
-
this.state =
|
|
295
|
+
this.state = x.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 tr {
|
|
|
306
306
|
* @returns {boolean} 是否就绪
|
|
307
307
|
*/
|
|
308
308
|
isReady() {
|
|
309
|
-
return this.state ===
|
|
309
|
+
return this.state === x.READY;
|
|
310
310
|
}
|
|
311
311
|
/**
|
|
312
312
|
* 检查是否正在初始化
|
|
313
313
|
* @returns {boolean} 是否正在初始化
|
|
314
314
|
*/
|
|
315
315
|
isInitializing() {
|
|
316
|
-
return this.state ===
|
|
316
|
+
return this.state === x.INITIALIZING;
|
|
317
317
|
}
|
|
318
318
|
/**
|
|
319
319
|
* 检查是否出错
|
|
320
320
|
* @returns {boolean} 是否出错
|
|
321
321
|
*/
|
|
322
322
|
hasError() {
|
|
323
|
-
return this.state ===
|
|
323
|
+
return this.state === x.ERROR;
|
|
324
324
|
}
|
|
325
325
|
/**
|
|
326
326
|
* 获取初始化错误
|
|
@@ -344,10 +344,10 @@ class tr {
|
|
|
344
344
|
* @returns {Promise<void>} 初始化 Promise
|
|
345
345
|
*/
|
|
346
346
|
startInitialization(e) {
|
|
347
|
-
return
|
|
348
|
-
if (this.state !==
|
|
347
|
+
return I(this, null, function* () {
|
|
348
|
+
if (this.state !== x.UNINITIALIZED)
|
|
349
349
|
return this.waitForReady();
|
|
350
|
-
this.state =
|
|
350
|
+
this.state = x.INITIALIZING;
|
|
351
351
|
try {
|
|
352
352
|
yield e(), this.handleBridgeReady();
|
|
353
353
|
} catch (r) {
|
|
@@ -361,11 +361,11 @@ class tr {
|
|
|
361
361
|
* @private
|
|
362
362
|
*/
|
|
363
363
|
handleBridgeReady() {
|
|
364
|
-
this.state ===
|
|
364
|
+
this.state === x.INITIALIZING && (this.state = x.READY, this.readyCallbacks.forEach((e) => {
|
|
365
365
|
try {
|
|
366
366
|
e();
|
|
367
367
|
} catch (r) {
|
|
368
|
-
|
|
368
|
+
d.handleApiError(r, { context: "StateManager.handleBridgeReady" });
|
|
369
369
|
}
|
|
370
370
|
}), this.readyCallbacks = [], this.errorCallbacks = []);
|
|
371
371
|
}
|
|
@@ -375,11 +375,11 @@ class tr {
|
|
|
375
375
|
* @private
|
|
376
376
|
*/
|
|
377
377
|
handleInitializationError(e) {
|
|
378
|
-
this.state =
|
|
378
|
+
this.state = x.ERROR, this.initializationError = e, this.errorCallbacks.forEach((r) => {
|
|
379
379
|
try {
|
|
380
380
|
r(e);
|
|
381
381
|
} catch (n) {
|
|
382
|
-
|
|
382
|
+
d.handleApiError(n, { context: "StateManager.handleInitializationError" });
|
|
383
383
|
}
|
|
384
384
|
}), this.readyCallbacks = [], this.errorCallbacks = [];
|
|
385
385
|
}
|
|
@@ -387,7 +387,7 @@ class tr {
|
|
|
387
387
|
* 重置状态管理器(用于测试或重新初始化)
|
|
388
388
|
*/
|
|
389
389
|
reset() {
|
|
390
|
-
this.state =
|
|
390
|
+
this.state = x.UNINITIALIZED, this.readyPromise = null, this.readyCallbacks = [], this.errorCallbacks = [], this.initializationError = null;
|
|
391
391
|
}
|
|
392
392
|
/**
|
|
393
393
|
* 添加状态变化监听器
|
|
@@ -402,7 +402,7 @@ class tr {
|
|
|
402
402
|
const n = () => {
|
|
403
403
|
this.state === e && r(this.state);
|
|
404
404
|
};
|
|
405
|
-
return e ===
|
|
405
|
+
return e === x.READY ? this.readyCallbacks.push(n) : e === x.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,7 +423,7 @@ class tr {
|
|
|
423
423
|
};
|
|
424
424
|
}
|
|
425
425
|
}
|
|
426
|
-
const
|
|
426
|
+
const Y = new tr(), rt = () => Y.waitForReady(), rr = () => Y.isReady(), nr = () => Y.getState(), P = {
|
|
427
427
|
ERROR: 0,
|
|
428
428
|
WARN: 1,
|
|
429
429
|
INFO: 2,
|
|
@@ -491,7 +491,7 @@ const X = new tr(), rt = () => X.waitForReady(), rr = () => X.isReady(), nr = ()
|
|
|
491
491
|
static log(e, r, n, ...i) {
|
|
492
492
|
if (!h.shouldLog(e, r))
|
|
493
493
|
return;
|
|
494
|
-
const s = (/* @__PURE__ */ new Date()).toISOString(), o = le[e],
|
|
494
|
+
const s = (/* @__PURE__ */ new Date()).toISOString(), o = le[e], l = r ? `[${r}]` : "", u = `${h.prefix} ${l} ${n}`, p = {
|
|
495
495
|
timestamp: s,
|
|
496
496
|
level: e,
|
|
497
497
|
levelName: o,
|
|
@@ -499,10 +499,10 @@ const X = new tr(), rt = () => X.waitForReady(), rr = () => X.isReady(), nr = ()
|
|
|
499
499
|
message: n,
|
|
500
500
|
args: i
|
|
501
501
|
};
|
|
502
|
-
if (h.addToHistory(
|
|
502
|
+
if (h.addToHistory(p), typeof h.reporter == "function")
|
|
503
503
|
try {
|
|
504
|
-
h.reporter(
|
|
505
|
-
} catch (
|
|
504
|
+
h.reporter(p);
|
|
505
|
+
} catch (M) {
|
|
506
506
|
}
|
|
507
507
|
h.outputToConsole(e, u, ...i);
|
|
508
508
|
}
|
|
@@ -653,11 +653,11 @@ const X = new tr(), rt = () => X.waitForReady(), rr = () => X.isReady(), nr = ()
|
|
|
653
653
|
h.reporter = typeof e == "function" ? e : null;
|
|
654
654
|
}
|
|
655
655
|
};
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
let
|
|
656
|
+
B(h, "currentLevel", P.ERROR), // 生产环境默认只显示错误
|
|
657
|
+
B(h, "enabledModules", /* @__PURE__ */ new Set()), // 启用日志的模块
|
|
658
|
+
B(h, "logHistory", []), // 日志历史(最多保留1000条)
|
|
659
|
+
B(h, "maxHistorySize", 1e3), B(h, "prefix", "[QSH-SDK]"), B(h, "reporter", null);
|
|
660
|
+
let L = h;
|
|
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,11 +665,11 @@ 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) && L.enableDevMode();
|
|
669
669
|
}
|
|
670
|
-
const A =
|
|
670
|
+
const A = L.createModuleLogger("Bridge"), E = L.createModuleLogger("Platform"), a = L.createModuleLogger("API"), D = L.createModuleLogger("State"), Ae = /complete|loaded|interactive/;
|
|
671
671
|
function ir(t) {
|
|
672
|
-
if (!
|
|
672
|
+
if (!Z()) return !1;
|
|
673
673
|
A.debug("检测到离线包环境,开始初始化");
|
|
674
674
|
const e = () => {
|
|
675
675
|
t();
|
|
@@ -687,7 +687,7 @@ function ir(t) {
|
|
|
687
687
|
return !0;
|
|
688
688
|
}
|
|
689
689
|
function ar(t) {
|
|
690
|
-
return
|
|
690
|
+
return Oe() || Ue() ? (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 && Ae.test(document.readyState) ? (A.debug("Plus 环境已就绪,立即初始化"), setTimeout(t, 0)) : window.plus ? (A.debug("Plus 环境,等待 plusready 事件"), document.addEventListener("plusready", t)) : Ae.test(document.readyState) ? setTimeout(t, 0) : document.addEventListener("DOMContentLoaded", t, { once: !0 }), !0) : !1;
|
|
691
691
|
}
|
|
692
692
|
function sr(t) {
|
|
693
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;
|
|
@@ -696,15 +696,15 @@ function or(t) {
|
|
|
696
696
|
return A.info("开始初始化 JSBridge"), ir(t) ? (A.info("使用离线包环境初始化"), !0) : ar(t) ? (A.info("使用 APP 环境初始化"), !0) : sr(t) ? (A.info("使用微信小程序环境初始化"), !0) : (A.debug("使用默认 H5 环境初始化"), Ae.test(document.readyState) ? (A.debug("DOM 已就绪,立即初始化"), setTimeout(t, 0)) : (A.debug("DOM 未就绪,等待 DOMContentLoaded"), document.addEventListener("DOMContentLoaded", t)), !0);
|
|
697
697
|
}
|
|
698
698
|
function cr() {
|
|
699
|
-
return
|
|
699
|
+
return Y.waitForReady();
|
|
700
700
|
}
|
|
701
701
|
function nt() {
|
|
702
|
-
return
|
|
702
|
+
return Y.startInitialization(() => I(null, null, function* () {
|
|
703
703
|
return new Promise((t, e) => {
|
|
704
704
|
const r = () => {
|
|
705
705
|
t();
|
|
706
706
|
}, n = (i) => {
|
|
707
|
-
const s =
|
|
707
|
+
const s = d.handleApiError(i, {
|
|
708
708
|
context: "bridge initialization"
|
|
709
709
|
});
|
|
710
710
|
e(s);
|
|
@@ -719,7 +719,7 @@ function nt() {
|
|
|
719
719
|
});
|
|
720
720
|
}));
|
|
721
721
|
}
|
|
722
|
-
const
|
|
722
|
+
const b = {
|
|
723
723
|
UNINITIALIZED: "uninitialized",
|
|
724
724
|
CONFIGURING: "configuring",
|
|
725
725
|
CONFIGURED: "configured",
|
|
@@ -730,45 +730,78 @@ function K() {
|
|
|
730
730
|
}
|
|
731
731
|
class ur {
|
|
732
732
|
constructor() {
|
|
733
|
-
this.state =
|
|
733
|
+
this.state = b.UNINITIALIZED, this.configPromise = null, this.readyCallbacks = [], this.errorCallbacks = [], this.lastError = null, this.configVersion = 0, this.configuredConfigKey = null, this.runtimeConfig = {
|
|
734
734
|
clientId: null,
|
|
735
|
-
isProd: !1
|
|
735
|
+
isProd: !1,
|
|
736
|
+
debug: !1,
|
|
737
|
+
url: ""
|
|
736
738
|
}, 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
739
|
}
|
|
738
740
|
configure(e = {}) {
|
|
739
741
|
if (!e || typeof e != "object" || Array.isArray(e))
|
|
740
|
-
throw new
|
|
741
|
-
|
|
742
|
+
throw new N(
|
|
743
|
+
T.INVALID_PARAMETERS,
|
|
742
744
|
"config参数异常",
|
|
743
745
|
{ config: e }
|
|
744
746
|
);
|
|
745
747
|
if (!Object.prototype.hasOwnProperty.call(e, "clientId"))
|
|
746
748
|
throw this.createMissingClientIdError();
|
|
747
749
|
if (typeof e.clientId != "string" || !e.clientId.trim())
|
|
748
|
-
throw new
|
|
749
|
-
|
|
750
|
+
throw new N(
|
|
751
|
+
T.INVALID_PARAMETERS,
|
|
750
752
|
"clientId参数异常",
|
|
751
753
|
{ clientId: e.clientId }
|
|
752
754
|
);
|
|
753
755
|
if (Object.prototype.hasOwnProperty.call(e, "isProd") && typeof e.isProd != "boolean")
|
|
754
|
-
throw new
|
|
755
|
-
|
|
756
|
+
throw new N(
|
|
757
|
+
T.INVALID_PARAMETERS,
|
|
756
758
|
"isProd参数异常",
|
|
757
759
|
{ isProd: e.isProd }
|
|
758
760
|
);
|
|
759
|
-
|
|
760
|
-
|
|
761
|
+
if (Object.prototype.hasOwnProperty.call(e, "debug") && typeof e.debug != "boolean")
|
|
762
|
+
throw new N(
|
|
763
|
+
T.INVALID_PARAMETERS,
|
|
764
|
+
"debug参数异常",
|
|
765
|
+
{ debug: e.debug }
|
|
766
|
+
);
|
|
767
|
+
if (Object.prototype.hasOwnProperty.call(e, "url") && typeof e.url != "string")
|
|
768
|
+
throw new N(
|
|
769
|
+
T.INVALID_PARAMETERS,
|
|
770
|
+
"url参数异常",
|
|
771
|
+
{ url: e.url }
|
|
772
|
+
);
|
|
773
|
+
const r = e.clientId.trim(), n = e.isProd === !0, i = n ? !1 : e.debug === !0, s = typeof e.url == "string" ? e.url.trim() : "", o = r !== this.runtimeConfig.clientId || n !== this.runtimeConfig.isProd || i !== this.runtimeConfig.debug || s !== this.runtimeConfig.url;
|
|
774
|
+
return this.runtimeConfig = m(g({}, this.runtimeConfig), {
|
|
761
775
|
clientId: r,
|
|
762
|
-
isProd: n
|
|
763
|
-
|
|
776
|
+
isProd: n,
|
|
777
|
+
debug: i,
|
|
778
|
+
url: s
|
|
779
|
+
}), this.CONFIG_API_URL = this.getConfigApiUrl(n), (this.state === b.ERROR || o && (this.state === b.CONFIGURING || this.state === b.CONFIGURED)) && this.reset({ preserveCallbacks: !0 }), E.info("Updated Weixin runtime config", {
|
|
764
780
|
clientId: this.runtimeConfig.clientId,
|
|
765
781
|
isProd: this.runtimeConfig.isProd,
|
|
782
|
+
debug: this.runtimeConfig.debug,
|
|
783
|
+
url: this.runtimeConfig.url,
|
|
766
784
|
configApiUrl: this.CONFIG_API_URL
|
|
767
785
|
}), this.getRuntimeConfig();
|
|
768
786
|
}
|
|
769
787
|
getRuntimeConfig() {
|
|
770
788
|
return g({}, this.runtimeConfig);
|
|
771
789
|
}
|
|
790
|
+
getEffectiveConfigUrl(e = {}) {
|
|
791
|
+
const { requireWindow: r = !1 } = e;
|
|
792
|
+
return this.runtimeConfig.url ? this.runtimeConfig.url : r ? this.getCurrentPageUrl() : typeof window == "undefined" || !window.location ? "" : this.getCurrentPageUrl();
|
|
793
|
+
}
|
|
794
|
+
getRuntimeConfigKey() {
|
|
795
|
+
return JSON.stringify({
|
|
796
|
+
clientId: this.runtimeConfig.clientId,
|
|
797
|
+
isProd: this.runtimeConfig.isProd,
|
|
798
|
+
debug: this.runtimeConfig.debug,
|
|
799
|
+
url: this.getEffectiveConfigUrl()
|
|
800
|
+
});
|
|
801
|
+
}
|
|
802
|
+
isCurrentConfigRun(e, r) {
|
|
803
|
+
return e === this.configVersion && r === this.getRuntimeConfigKey();
|
|
804
|
+
}
|
|
772
805
|
hasClientId() {
|
|
773
806
|
return typeof this.runtimeConfig.clientId == "string" && this.runtimeConfig.clientId.length > 0;
|
|
774
807
|
}
|
|
@@ -776,8 +809,8 @@ class ur {
|
|
|
776
809
|
return this.isTestMode() || this.hasClientId();
|
|
777
810
|
}
|
|
778
811
|
createMissingClientIdError() {
|
|
779
|
-
return new
|
|
780
|
-
|
|
812
|
+
return new N(
|
|
813
|
+
T.INVALID_PARAMETERS,
|
|
781
814
|
"clientId错误",
|
|
782
815
|
{ field: "clientId" }
|
|
783
816
|
);
|
|
@@ -807,32 +840,32 @@ class ur {
|
|
|
807
840
|
* @private
|
|
808
841
|
*/
|
|
809
842
|
fetchWeixinConfig() {
|
|
810
|
-
return
|
|
811
|
-
const e = this.
|
|
843
|
+
return I(this, null, function* () {
|
|
844
|
+
const e = this.getEffectiveConfigUrl({ requireWindow: !0 });
|
|
812
845
|
if (this.isTestMode())
|
|
813
|
-
return
|
|
846
|
+
return E.info("使用测试模式,返回模拟配置"), this.getMockConfig();
|
|
814
847
|
if (!this.hasClientId())
|
|
815
848
|
throw this.createMissingClientIdError();
|
|
816
849
|
const r = this.getConfigApiUrl(this.runtimeConfig.isProd);
|
|
817
850
|
this.CONFIG_API_URL = r;
|
|
818
851
|
const n = `${r}?clientId=${this.runtimeConfig.clientId}&url=${encodeURIComponent(e)}`;
|
|
819
|
-
|
|
852
|
+
E.debug("请求微信配置", { url: n });
|
|
820
853
|
try {
|
|
821
854
|
const i = yield fetch(n);
|
|
822
855
|
if (!i.ok)
|
|
823
856
|
throw new Error(`HTTP ${i.status}: ${i.statusText}`);
|
|
824
857
|
const s = yield i.json();
|
|
825
|
-
if (
|
|
858
|
+
if (E.debug("微信配置响应", s), !s.success || s.code !== 200)
|
|
826
859
|
throw new Error(`配置获取失败: ${s.message || "未知错误"}`);
|
|
827
860
|
const { data: o } = s;
|
|
828
861
|
if (!o || !o.appId || !o.timestamp || !o.nonceStr || !o.signature)
|
|
829
862
|
throw new Error("配置数据格式不正确,缺少必需字段");
|
|
830
863
|
return o;
|
|
831
864
|
} catch (i) {
|
|
832
|
-
if (
|
|
833
|
-
return
|
|
834
|
-
throw new
|
|
835
|
-
|
|
865
|
+
if (E.error("获取微信配置失败", i), this.shouldUseTestMode(i))
|
|
866
|
+
return E.warn("网络请求失败,降级到测试模式"), this.getMockConfig();
|
|
867
|
+
throw new N(
|
|
868
|
+
T.NETWORK_ERROR,
|
|
836
869
|
`获取微信配置失败: ${i.message}`,
|
|
837
870
|
{ url: n, originalError: i }
|
|
838
871
|
);
|
|
@@ -882,38 +915,41 @@ class ur {
|
|
|
882
915
|
* @param {Object} configData - 配置数据
|
|
883
916
|
* @private
|
|
884
917
|
*/
|
|
885
|
-
executeWeixinConfig(e) {
|
|
918
|
+
executeWeixinConfig(e, r, n) {
|
|
886
919
|
if (this.isTestMode() || e.appId === "wx_test_app_id") {
|
|
887
|
-
|
|
888
|
-
this.handleConfigSuccess();
|
|
920
|
+
E.info("测试模式:模拟微信配置成功"), setTimeout(() => {
|
|
921
|
+
this.handleConfigSuccess(r, n);
|
|
889
922
|
}, 100);
|
|
890
923
|
return;
|
|
891
924
|
}
|
|
892
925
|
if (!K())
|
|
893
926
|
throw new Error("微信JS-SDK未加载");
|
|
894
|
-
const
|
|
895
|
-
debug:
|
|
896
|
-
// 生产环境关闭调试
|
|
927
|
+
const i = {
|
|
928
|
+
debug: this.runtimeConfig.debug,
|
|
897
929
|
appId: e.appId,
|
|
898
930
|
timestamp: parseInt(e.timestamp),
|
|
899
931
|
nonceStr: e.nonceStr,
|
|
900
932
|
signature: e.signature,
|
|
901
933
|
jsApiList: this.DEFAULT_JS_API_LIST
|
|
902
934
|
};
|
|
903
|
-
|
|
935
|
+
E.info("执行微信配置", i), window.wx.ready(() => this.handleConfigSuccess(r, n)), window.wx.error((s) => this.handleConfigError(s, r, n)), window.wx.config(i);
|
|
904
936
|
}
|
|
905
937
|
/**
|
|
906
938
|
* 处理配置成功
|
|
907
939
|
* @private
|
|
908
940
|
*/
|
|
909
|
-
handleConfigSuccess() {
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
941
|
+
handleConfigSuccess(e = this.configVersion, r = this.getRuntimeConfigKey()) {
|
|
942
|
+
if (!this.isCurrentConfigRun(e, r)) {
|
|
943
|
+
E.debug("忽略过期的微信配置成功回调");
|
|
944
|
+
return;
|
|
945
|
+
}
|
|
946
|
+
E.info("微信配置成功"), this.state = b.CONFIGURED, this.configuredConfigKey = r, this.lastError = null, this.configPromise = null;
|
|
947
|
+
const n = [...this.readyCallbacks];
|
|
948
|
+
this.readyCallbacks = [], this.errorCallbacks = [], n.forEach((i) => {
|
|
913
949
|
try {
|
|
914
|
-
|
|
915
|
-
} catch (
|
|
916
|
-
|
|
950
|
+
i();
|
|
951
|
+
} catch (s) {
|
|
952
|
+
d.handleApiError(s, { context: "WeixinConfigManager.handleConfigSuccess" });
|
|
917
953
|
}
|
|
918
954
|
});
|
|
919
955
|
}
|
|
@@ -922,21 +958,25 @@ class ur {
|
|
|
922
958
|
* @param {Object} res - 微信返回的错误信息
|
|
923
959
|
* @private
|
|
924
960
|
*/
|
|
925
|
-
handleConfigError(e) {
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
961
|
+
handleConfigError(e, r = this.configVersion, n = this.getRuntimeConfigKey()) {
|
|
962
|
+
if (!this.isCurrentConfigRun(r, n)) {
|
|
963
|
+
E.debug("忽略过期的微信配置错误回调", e);
|
|
964
|
+
return;
|
|
965
|
+
}
|
|
966
|
+
const i = `微信配置验证失败: ${JSON.stringify(e)}`;
|
|
967
|
+
E.error(i, e);
|
|
968
|
+
const s = new N(
|
|
969
|
+
T.API_CALL_FAILED,
|
|
970
|
+
i,
|
|
931
971
|
{ weixinErrorResponse: e }
|
|
932
972
|
);
|
|
933
|
-
this.state =
|
|
934
|
-
const
|
|
935
|
-
this.readyCallbacks = [], this.errorCallbacks = [],
|
|
973
|
+
this.state = b.ERROR, this.lastError = s, this.configPromise = null;
|
|
974
|
+
const o = [...this.errorCallbacks];
|
|
975
|
+
this.readyCallbacks = [], this.errorCallbacks = [], o.forEach((l) => {
|
|
936
976
|
try {
|
|
937
|
-
s
|
|
938
|
-
} catch (
|
|
939
|
-
|
|
977
|
+
l(s);
|
|
978
|
+
} catch (u) {
|
|
979
|
+
d.handleApiError(u, { context: "WeixinConfigManager.handleConfigError" });
|
|
940
980
|
}
|
|
941
981
|
});
|
|
942
982
|
}
|
|
@@ -945,8 +985,18 @@ class ur {
|
|
|
945
985
|
* @returns {Promise<void>} 配置完成的Promise
|
|
946
986
|
*/
|
|
947
987
|
autoConfig() {
|
|
948
|
-
return
|
|
949
|
-
|
|
988
|
+
return I(this, null, function* () {
|
|
989
|
+
if (!this.hasRequiredConfig())
|
|
990
|
+
return E.warn("clientId为空,等待qsh.config({ clientId })"), Promise.resolve();
|
|
991
|
+
if (this.isReady())
|
|
992
|
+
return Promise.resolve();
|
|
993
|
+
if (this.state === b.CONFIGURED && this.reset({ preserveCallbacks: !0 }), this.state === b.ERROR)
|
|
994
|
+
return Promise.reject(this.lastError);
|
|
995
|
+
if (this.configPromise)
|
|
996
|
+
return this.configPromise;
|
|
997
|
+
this.state = b.CONFIGURING;
|
|
998
|
+
const e = this.configVersion, r = this.getRuntimeConfigKey();
|
|
999
|
+
return this.configPromise = this.performAutoConfig(e, r), this.configPromise;
|
|
950
1000
|
});
|
|
951
1001
|
}
|
|
952
1002
|
/**
|
|
@@ -954,36 +1004,44 @@ class ur {
|
|
|
954
1004
|
* @returns {Promise<void>}
|
|
955
1005
|
* @private
|
|
956
1006
|
*/
|
|
957
|
-
performAutoConfig() {
|
|
958
|
-
return
|
|
1007
|
+
performAutoConfig(e, r) {
|
|
1008
|
+
return I(this, null, function* () {
|
|
959
1009
|
try {
|
|
960
1010
|
if (typeof window == "undefined")
|
|
961
1011
|
throw new Error("非浏览器环境无法执行微信配置");
|
|
962
1012
|
if (!K())
|
|
963
1013
|
throw new Error("微信JS-SDK未加载,无法执行配置");
|
|
964
|
-
const
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
1014
|
+
const n = yield this.fetchWeixinConfig();
|
|
1015
|
+
if (!this.isCurrentConfigRun(e, r)) {
|
|
1016
|
+
E.debug("忽略过期的微信配置响应");
|
|
1017
|
+
return;
|
|
1018
|
+
}
|
|
1019
|
+
return this.executeWeixinConfig(n, e, r), yield new Promise((i, s) => {
|
|
1020
|
+
if (this.isReady()) {
|
|
1021
|
+
i();
|
|
968
1022
|
return;
|
|
969
1023
|
}
|
|
970
|
-
if (this.state ===
|
|
971
|
-
|
|
1024
|
+
if (this.state === b.ERROR) {
|
|
1025
|
+
s(this.lastError);
|
|
972
1026
|
return;
|
|
973
1027
|
}
|
|
974
|
-
this.readyCallbacks.push(
|
|
1028
|
+
this.readyCallbacks.push(i), this.errorCallbacks.push(s);
|
|
975
1029
|
});
|
|
976
|
-
} catch (
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
1030
|
+
} catch (n) {
|
|
1031
|
+
if (!this.isCurrentConfigRun(e, r)) {
|
|
1032
|
+
E.debug("忽略过期的微信配置异常", n);
|
|
1033
|
+
return;
|
|
1034
|
+
}
|
|
1035
|
+
const i = n instanceof N ? n : d.handleApiError(n, { context: "WeixinConfigManager.performAutoConfig" });
|
|
1036
|
+
this.state = b.ERROR, this.lastError = i, this.configPromise = null;
|
|
1037
|
+
const s = [...this.errorCallbacks];
|
|
1038
|
+
throw this.readyCallbacks = [], this.errorCallbacks = [], s.forEach((o) => {
|
|
981
1039
|
try {
|
|
982
|
-
i
|
|
983
|
-
} catch (
|
|
984
|
-
|
|
1040
|
+
o(i);
|
|
1041
|
+
} catch (l) {
|
|
1042
|
+
d.handleApiError(l, { context: "WeixinConfigManager.performAutoConfig.errorCallback" });
|
|
985
1043
|
}
|
|
986
|
-
}),
|
|
1044
|
+
}), i;
|
|
987
1045
|
}
|
|
988
1046
|
});
|
|
989
1047
|
}
|
|
@@ -992,16 +1050,16 @@ class ur {
|
|
|
992
1050
|
* @returns {Promise<void>} 配置完成的Promise
|
|
993
1051
|
*/
|
|
994
1052
|
waitForReady() {
|
|
995
|
-
return this.state ===
|
|
1053
|
+
return this.isReady() ? Promise.resolve() : (this.state === b.CONFIGURED && this.reset({ preserveCallbacks: !0 }), this.state === b.ERROR ? Promise.reject(this.lastError) : this.hasRequiredConfig() ? this.state === b.UNINITIALIZED ? this.autoConfig() : new Promise((e, r) => {
|
|
996
1054
|
this.readyCallbacks.push(e), this.errorCallbacks.push(r);
|
|
997
|
-
}) : Promise.reject(this.createMissingClientIdError());
|
|
1055
|
+
}) : Promise.reject(this.createMissingClientIdError()));
|
|
998
1056
|
}
|
|
999
1057
|
/**
|
|
1000
1058
|
* 检查配置状态
|
|
1001
1059
|
* @returns {boolean} 是否已配置
|
|
1002
1060
|
*/
|
|
1003
1061
|
isReady() {
|
|
1004
|
-
return this.state ===
|
|
1062
|
+
return this.state === b.CONFIGURED && this.configuredConfigKey === this.getRuntimeConfigKey();
|
|
1005
1063
|
}
|
|
1006
1064
|
/**
|
|
1007
1065
|
* 获取当前状态
|
|
@@ -1020,8 +1078,9 @@ class ur {
|
|
|
1020
1078
|
/**
|
|
1021
1079
|
* 重置配置管理器(用于重试或测试)
|
|
1022
1080
|
*/
|
|
1023
|
-
reset() {
|
|
1024
|
-
|
|
1081
|
+
reset(e = {}) {
|
|
1082
|
+
const { preserveCallbacks: r = !1 } = e;
|
|
1083
|
+
this.configVersion += 1, this.state = b.UNINITIALIZED, this.configPromise = null, r || (this.readyCallbacks = [], this.errorCallbacks = []), this.lastError = null, this.configuredConfigKey = null, E.debug("微信配置管理器已重置");
|
|
1025
1084
|
}
|
|
1026
1085
|
/**
|
|
1027
1086
|
* 获取配置统计信息
|
|
@@ -1034,30 +1093,35 @@ class ur {
|
|
|
1034
1093
|
errorCallbacksCount: this.errorCallbacks.length,
|
|
1035
1094
|
hasConfigPromise: !!this.configPromise,
|
|
1036
1095
|
hasLastError: !!this.lastError,
|
|
1096
|
+
configVersion: this.configVersion,
|
|
1097
|
+
configuredConfigKey: this.configuredConfigKey,
|
|
1037
1098
|
configApiUrl: this.CONFIG_API_URL,
|
|
1038
1099
|
clientId: this.runtimeConfig.clientId,
|
|
1039
1100
|
isProd: this.runtimeConfig.isProd,
|
|
1101
|
+
debug: this.runtimeConfig.debug,
|
|
1102
|
+
url: this.runtimeConfig.url,
|
|
1103
|
+
effectiveUrl: this.getEffectiveConfigUrl(),
|
|
1040
1104
|
jsApiList: this.DEFAULT_JS_API_LIST
|
|
1041
1105
|
};
|
|
1042
1106
|
}
|
|
1043
1107
|
}
|
|
1044
|
-
const
|
|
1045
|
-
let
|
|
1108
|
+
const v = new ur();
|
|
1109
|
+
let re = !1, ge = !1, U = null, Pe = !1;
|
|
1046
1110
|
function lr(t) {
|
|
1047
1111
|
return new Promise((e) => {
|
|
1048
1112
|
let r = !1, n = null;
|
|
1049
|
-
const i = (
|
|
1113
|
+
const i = (l) => I(null, null, function* () {
|
|
1050
1114
|
if (!r) {
|
|
1051
|
-
if (r = !0, n && clearTimeout(n),
|
|
1115
|
+
if (r = !0, n && clearTimeout(n), re = !1, ge = l, l)
|
|
1052
1116
|
try {
|
|
1053
1117
|
yield it();
|
|
1054
1118
|
} catch (u) {
|
|
1055
|
-
|
|
1119
|
+
E.error("微信配置失败,将使用消息桥作为后备", u);
|
|
1056
1120
|
}
|
|
1057
1121
|
e();
|
|
1058
1122
|
}
|
|
1059
1123
|
}), s = () => i(K()), o = () => {
|
|
1060
|
-
|
|
1124
|
+
E.warn("已存在的微信 JS-SDK 脚本加载失败,SDK 将使用消息桥作为后备"), i(!1);
|
|
1061
1125
|
};
|
|
1062
1126
|
t.addEventListener("load", s, { once: !0 }), t.addEventListener("error", o, { once: !0 }), setTimeout(() => {
|
|
1063
1127
|
K() && s();
|
|
@@ -1067,7 +1131,7 @@ function lr(t) {
|
|
|
1067
1131
|
});
|
|
1068
1132
|
}
|
|
1069
1133
|
function We() {
|
|
1070
|
-
return
|
|
1134
|
+
return I(this, arguments, function* (t = {}) {
|
|
1071
1135
|
const { force: e = !1, recoverFromError: r = !1 } = t;
|
|
1072
1136
|
if (yield at({ force: e }), !K())
|
|
1073
1137
|
throw new Error("微信 JS-SDK 未正确加载,无法执行配置");
|
|
@@ -1078,23 +1142,23 @@ function fr(t = !1) {
|
|
|
1078
1142
|
if (typeof window == "undefined") return !1;
|
|
1079
1143
|
if (K())
|
|
1080
1144
|
return ge = !0, !1;
|
|
1081
|
-
if (ge ||
|
|
1145
|
+
if (ge || Z()) return !1;
|
|
1082
1146
|
if (t) return !0;
|
|
1083
1147
|
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
1148
|
return r && (n || i || s);
|
|
1085
1149
|
}
|
|
1086
1150
|
function dr() {
|
|
1087
|
-
|
|
1151
|
+
v.getState() === "error" && (v.reset(), Pe = !1);
|
|
1088
1152
|
}
|
|
1089
1153
|
function it() {
|
|
1090
|
-
return
|
|
1154
|
+
return I(this, null, function* () {
|
|
1091
1155
|
if (Pe)
|
|
1092
|
-
return
|
|
1093
|
-
Pe = !0,
|
|
1156
|
+
return v.waitForReady();
|
|
1157
|
+
Pe = !0, E.info("开始自动配置微信JS-SDK");
|
|
1094
1158
|
try {
|
|
1095
|
-
yield
|
|
1159
|
+
yield v.autoConfig(), E.info("微信JS-SDK自动配置完成");
|
|
1096
1160
|
} catch (t) {
|
|
1097
|
-
|
|
1161
|
+
E.error("微信JS-SDK自动配置失败", t);
|
|
1098
1162
|
}
|
|
1099
1163
|
});
|
|
1100
1164
|
}
|
|
@@ -1105,65 +1169,65 @@ function at(t = {}) {
|
|
|
1105
1169
|
if (K())
|
|
1106
1170
|
return ge = !0, Promise.resolve();
|
|
1107
1171
|
const r = document.getElementById("weixin-jssdk");
|
|
1108
|
-
return r ? U || (
|
|
1172
|
+
return r ? U || (re = !0, U = lr(r).finally(() => {
|
|
1109
1173
|
U = null;
|
|
1110
1174
|
}), U) : fr(e) ? U || (U = new Promise((n) => {
|
|
1111
|
-
|
|
1175
|
+
re = !0;
|
|
1112
1176
|
try {
|
|
1113
1177
|
const i = document.createElement("script");
|
|
1114
1178
|
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
|
-
ge = !0,
|
|
1179
|
+
return I(this, null, function* () {
|
|
1180
|
+
ge = !0, re = !1, E.info("微信 JS-SDK 已自动加载");
|
|
1117
1181
|
try {
|
|
1118
1182
|
yield it();
|
|
1119
1183
|
} catch (o) {
|
|
1120
|
-
|
|
1184
|
+
E.error("微信配置失败,将使用消息桥作为后备", o);
|
|
1121
1185
|
}
|
|
1122
1186
|
n();
|
|
1123
1187
|
});
|
|
1124
1188
|
}, i.onerror = function() {
|
|
1125
|
-
|
|
1189
|
+
re = !1, E.warn("微信 JS-SDK 加载失败,SDK 将使用消息桥作为后备"), n();
|
|
1126
1190
|
}, (document.getElementsByTagName("head")[0] || document.documentElement).appendChild(i);
|
|
1127
1191
|
} catch (i) {
|
|
1128
|
-
|
|
1192
|
+
re = !1, E.error("注入微信 JS-SDK 失败", i), n();
|
|
1129
1193
|
}
|
|
1130
1194
|
}).finally(() => {
|
|
1131
1195
|
U = null;
|
|
1132
1196
|
}), U) : Promise.resolve();
|
|
1133
1197
|
}
|
|
1134
|
-
function
|
|
1135
|
-
return We({ force: !0, recoverFromError: !0 }).then(() =>
|
|
1198
|
+
function Q() {
|
|
1199
|
+
return We({ force: !0, recoverFromError: !0 }).then(() => v.waitForReady());
|
|
1136
1200
|
}
|
|
1137
1201
|
function He(t = {}) {
|
|
1138
|
-
const e =
|
|
1202
|
+
const e = v.configure(t);
|
|
1139
1203
|
return typeof window == "undefined" || We({
|
|
1140
1204
|
force: !0,
|
|
1141
|
-
recoverFromError:
|
|
1205
|
+
recoverFromError: v.getState() === "error"
|
|
1142
1206
|
}).then(() => {
|
|
1143
|
-
if (!
|
|
1144
|
-
return
|
|
1145
|
-
|
|
1207
|
+
if (!v.isReady())
|
|
1208
|
+
return v.waitForReady().catch((r) => {
|
|
1209
|
+
E.error("Failed to auto-configure Weixin after qsh.config()", r);
|
|
1146
1210
|
});
|
|
1147
|
-
window.wx && !K() &&
|
|
1211
|
+
window.wx && !K() && E.warn("window.wx 已存在,但微信 JS-SDK 尚未就绪,跳过自动配置");
|
|
1148
1212
|
}).catch((r) => {
|
|
1149
|
-
|
|
1213
|
+
E.error("Failed to preload Weixin JS-SDK", r);
|
|
1150
1214
|
}), e;
|
|
1151
1215
|
}
|
|
1152
|
-
function
|
|
1153
|
-
return
|
|
1216
|
+
function oe() {
|
|
1217
|
+
return v.isReady();
|
|
1154
1218
|
}
|
|
1155
1219
|
function gr() {
|
|
1156
|
-
return
|
|
1220
|
+
return v.getState();
|
|
1157
1221
|
}
|
|
1158
1222
|
function ve() {
|
|
1159
|
-
return
|
|
1223
|
+
return v;
|
|
1160
1224
|
}
|
|
1161
1225
|
function hr() {
|
|
1162
|
-
return
|
|
1163
|
-
return
|
|
1226
|
+
return I(this, null, function* () {
|
|
1227
|
+
return E.info("手动重试微信配置"), v.reset(), Pe = !1, yield We({ force: !0 }), v.waitForReady();
|
|
1164
1228
|
});
|
|
1165
1229
|
}
|
|
1166
|
-
class
|
|
1230
|
+
class pr {
|
|
1167
1231
|
constructor() {
|
|
1168
1232
|
this.plugins = /* @__PURE__ */ new Map(), this.installed = /* @__PURE__ */ new Set(), this.installOrder = [], a.debug("插件管理器已初始化");
|
|
1169
1233
|
}
|
|
@@ -1175,7 +1239,7 @@ class mr {
|
|
|
1175
1239
|
* pluginManager.register(imagePlugin)
|
|
1176
1240
|
*/
|
|
1177
1241
|
register(e) {
|
|
1178
|
-
return
|
|
1242
|
+
return d.safeExecute(() => {
|
|
1179
1243
|
this.validatePlugin(e);
|
|
1180
1244
|
const { name: r, version: n } = e;
|
|
1181
1245
|
if (this.plugins.has(r)) {
|
|
@@ -1215,8 +1279,8 @@ class mr {
|
|
|
1215
1279
|
* await pluginManager.install('image', qsh)
|
|
1216
1280
|
*/
|
|
1217
1281
|
install(e, r) {
|
|
1218
|
-
return
|
|
1219
|
-
return
|
|
1282
|
+
return I(this, null, function* () {
|
|
1283
|
+
return d.safeExecute(() => I(this, null, function* () {
|
|
1220
1284
|
if (!this.plugins.has(e))
|
|
1221
1285
|
throw new Error(`插件 ${e} 未注册`);
|
|
1222
1286
|
if (this.installed.has(e)) {
|
|
@@ -1245,8 +1309,8 @@ class mr {
|
|
|
1245
1309
|
* await pluginManager.uninstall('image', qsh)
|
|
1246
1310
|
*/
|
|
1247
1311
|
uninstall(e, r) {
|
|
1248
|
-
return
|
|
1249
|
-
return
|
|
1312
|
+
return I(this, null, function* () {
|
|
1313
|
+
return d.safeExecute(() => I(this, null, function* () {
|
|
1250
1314
|
if (!this.installed.has(e)) {
|
|
1251
1315
|
a.debug(`插件 ${e} 未安装,跳过卸载`);
|
|
1252
1316
|
return;
|
|
@@ -1267,7 +1331,7 @@ class mr {
|
|
|
1267
1331
|
* @returns {Promise<void>}
|
|
1268
1332
|
*/
|
|
1269
1333
|
uninstallAll(e) {
|
|
1270
|
-
return
|
|
1334
|
+
return I(this, null, function* () {
|
|
1271
1335
|
const r = [...this.installOrder].reverse();
|
|
1272
1336
|
for (const n of r)
|
|
1273
1337
|
yield this.uninstall(n, e);
|
|
@@ -1294,7 +1358,7 @@ class mr {
|
|
|
1294
1358
|
* await pluginManager.installAll(['image', 'location'], qsh)
|
|
1295
1359
|
*/
|
|
1296
1360
|
installAll(e, r) {
|
|
1297
|
-
return
|
|
1361
|
+
return I(this, null, function* () {
|
|
1298
1362
|
if (!Array.isArray(e))
|
|
1299
1363
|
throw new Error("names 必须是数组");
|
|
1300
1364
|
for (const n of e)
|
|
@@ -1356,8 +1420,8 @@ class mr {
|
|
|
1356
1420
|
this.plugins.clear(), this.installed.clear(), this.installOrder = [];
|
|
1357
1421
|
}
|
|
1358
1422
|
}
|
|
1359
|
-
const fe = new
|
|
1360
|
-
class
|
|
1423
|
+
const fe = new pr();
|
|
1424
|
+
class mr {
|
|
1361
1425
|
constructor() {
|
|
1362
1426
|
this.requestInterceptors = [], this.responseInterceptors = [], a.debug("拦截器链已初始化");
|
|
1363
1427
|
}
|
|
@@ -1416,7 +1480,7 @@ class pr {
|
|
|
1416
1480
|
* @private
|
|
1417
1481
|
*/
|
|
1418
1482
|
runRequest(e) {
|
|
1419
|
-
return
|
|
1483
|
+
return I(this, null, function* () {
|
|
1420
1484
|
let r = g({}, e);
|
|
1421
1485
|
for (const { fn: n } of this.requestInterceptors) {
|
|
1422
1486
|
if (r.abort) {
|
|
@@ -1442,7 +1506,7 @@ class pr {
|
|
|
1442
1506
|
* @private
|
|
1443
1507
|
*/
|
|
1444
1508
|
runResponse(e, r) {
|
|
1445
|
-
return
|
|
1509
|
+
return I(this, null, function* () {
|
|
1446
1510
|
let n = e;
|
|
1447
1511
|
for (const { fn: i } of this.responseInterceptors)
|
|
1448
1512
|
try {
|
|
@@ -1471,7 +1535,7 @@ class pr {
|
|
|
1471
1535
|
};
|
|
1472
1536
|
}
|
|
1473
1537
|
}
|
|
1474
|
-
const
|
|
1538
|
+
const z = new mr(), wr = {
|
|
1475
1539
|
/**
|
|
1476
1540
|
* 请求日志
|
|
1477
1541
|
*/
|
|
@@ -1533,7 +1597,7 @@ function Er(t = {}) {
|
|
|
1533
1597
|
shouldRetry: n = (i) => !i.success
|
|
1534
1598
|
} = t;
|
|
1535
1599
|
return {
|
|
1536
|
-
response: (i, s) =>
|
|
1600
|
+
response: (i, s) => I(null, null, function* () {
|
|
1537
1601
|
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
1602
|
})
|
|
1539
1603
|
};
|
|
@@ -1562,12 +1626,12 @@ class Ir {
|
|
|
1562
1626
|
},
|
|
1563
1627
|
// 平台信息
|
|
1564
1628
|
platform: {
|
|
1565
|
-
type:
|
|
1566
|
-
isWeixinMiniProgram:
|
|
1567
|
-
isAppPlus:
|
|
1568
|
-
isNvue:
|
|
1569
|
-
isUvue:
|
|
1570
|
-
isOfflineWebview:
|
|
1629
|
+
type: f.type,
|
|
1630
|
+
isWeixinMiniProgram: f.isWeixinMiniProgram,
|
|
1631
|
+
isAppPlus: f.isAppPlus,
|
|
1632
|
+
isNvue: f.isNvue,
|
|
1633
|
+
isUvue: f.isUvue,
|
|
1634
|
+
isOfflineWebview: f.isOfflineWebview,
|
|
1571
1635
|
features: {}
|
|
1572
1636
|
// 平台支持的特性
|
|
1573
1637
|
},
|
|
@@ -1617,7 +1681,7 @@ class Ir {
|
|
|
1617
1681
|
* store.set('network.online', false)
|
|
1618
1682
|
*/
|
|
1619
1683
|
set(e, r) {
|
|
1620
|
-
const n = e.split("."), i = n.pop(), s = n.reduce((
|
|
1684
|
+
const n = e.split("."), i = n.pop(), s = n.reduce((l, u) => ((!l[u] || typeof l[u] != "object") && (l[u] = {}), l[u]), this.state), o = s[i];
|
|
1621
1685
|
o !== r && (s[i] = r, D.debug(`状态已更新: ${e}`, { oldValue: o, newValue: r }), this.notify(e, r, o));
|
|
1622
1686
|
}
|
|
1623
1687
|
/**
|
|
@@ -1680,20 +1744,20 @@ class Ir {
|
|
|
1680
1744
|
i && i.forEach((o) => {
|
|
1681
1745
|
try {
|
|
1682
1746
|
o(r, n, e);
|
|
1683
|
-
} catch (
|
|
1684
|
-
D.error("订阅者执行失败",
|
|
1747
|
+
} catch (l) {
|
|
1748
|
+
D.error("订阅者执行失败", l);
|
|
1685
1749
|
}
|
|
1686
1750
|
});
|
|
1687
1751
|
const s = e.split(".");
|
|
1688
1752
|
for (let o = 1; o < s.length; o++) {
|
|
1689
|
-
const
|
|
1753
|
+
const l = s.slice(0, o).join("."), u = this.listeners.get(l);
|
|
1690
1754
|
if (u) {
|
|
1691
|
-
const
|
|
1692
|
-
u.forEach((
|
|
1755
|
+
const p = this.get(l);
|
|
1756
|
+
u.forEach((M) => {
|
|
1693
1757
|
try {
|
|
1694
|
-
|
|
1695
|
-
} catch (
|
|
1696
|
-
D.error("父路径订阅者执行失败",
|
|
1758
|
+
M(p, void 0, l);
|
|
1759
|
+
} catch (_) {
|
|
1760
|
+
D.error("父路径订阅者执行失败", _);
|
|
1697
1761
|
}
|
|
1698
1762
|
});
|
|
1699
1763
|
}
|
|
@@ -1701,8 +1765,8 @@ class Ir {
|
|
|
1701
1765
|
this.wildcardListeners.forEach((o) => {
|
|
1702
1766
|
try {
|
|
1703
1767
|
o(r, n, e);
|
|
1704
|
-
} catch (
|
|
1705
|
-
D.error("通配符订阅者执行失败",
|
|
1768
|
+
} catch (l) {
|
|
1769
|
+
D.error("通配符订阅者执行失败", l);
|
|
1706
1770
|
}
|
|
1707
1771
|
});
|
|
1708
1772
|
}
|
|
@@ -1728,7 +1792,7 @@ class Ir {
|
|
|
1728
1792
|
*/
|
|
1729
1793
|
setApiLoading(e, r = !0) {
|
|
1730
1794
|
const n = `api.${e}`, i = this.get(n) || {};
|
|
1731
|
-
this.set(n,
|
|
1795
|
+
this.set(n, m(g({}, i), {
|
|
1732
1796
|
loading: r,
|
|
1733
1797
|
lastCall: r ? Date.now() : i.lastCall
|
|
1734
1798
|
}));
|
|
@@ -1740,7 +1804,7 @@ class Ir {
|
|
|
1740
1804
|
*/
|
|
1741
1805
|
setApiResult(e, r) {
|
|
1742
1806
|
const n = `api.${e}`, i = this.get(n) || {};
|
|
1743
|
-
this.set(n,
|
|
1807
|
+
this.set(n, m(g({}, i), {
|
|
1744
1808
|
loading: !1,
|
|
1745
1809
|
lastResult: r,
|
|
1746
1810
|
lastCallEnd: Date.now()
|
|
@@ -1964,10 +2028,10 @@ function st(t) {
|
|
|
1964
2028
|
function Pr(t) {
|
|
1965
2029
|
return t.includes("NET_") || t.includes("TIMEOUT") || t === c.NETWORK_ERROR || t === c.NETWORK_TIMEOUT || t === c.API_TIMEOUT;
|
|
1966
2030
|
}
|
|
1967
|
-
function
|
|
2031
|
+
function Cr(t) {
|
|
1968
2032
|
return t.includes("CANCEL") || st(t) === W.USER_CANCEL;
|
|
1969
2033
|
}
|
|
1970
|
-
function
|
|
2034
|
+
function ne(t) {
|
|
1971
2035
|
return Le[t] || Le[c.UNKNOWN_ERROR];
|
|
1972
2036
|
}
|
|
1973
2037
|
class V extends Error {
|
|
@@ -1978,7 +2042,7 @@ class V extends Error {
|
|
|
1978
2042
|
* @param {Object} options - 选项
|
|
1979
2043
|
*/
|
|
1980
2044
|
constructor(e, r, n = {}) {
|
|
1981
|
-
super(r), this.name = "StandardError", this.code = e, this.message = r ||
|
|
2045
|
+
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 || st(e), this.retriable = n.retriable !== void 0 ? n.retriable : Pr(e), this.originalError = n.originalError, this.details = n.details || {}, this.timestamp = Date.now();
|
|
1982
2046
|
}
|
|
1983
2047
|
/**
|
|
1984
2048
|
* 是否可重试
|
|
@@ -1992,7 +2056,7 @@ class V extends Error {
|
|
|
1992
2056
|
* @returns {boolean}
|
|
1993
2057
|
*/
|
|
1994
2058
|
isUserAction() {
|
|
1995
|
-
return
|
|
2059
|
+
return Cr(this.code);
|
|
1996
2060
|
}
|
|
1997
2061
|
/**
|
|
1998
2062
|
* 转为普通对象
|
|
@@ -2016,8 +2080,8 @@ class V extends Error {
|
|
|
2016
2080
|
function ot(t, e = {}) {
|
|
2017
2081
|
if (t instanceof V)
|
|
2018
2082
|
return t;
|
|
2019
|
-
const { apiName: r, platform: n =
|
|
2020
|
-
return t && typeof t.code == "string" && t.code.includes("/") ?
|
|
2083
|
+
const { apiName: r, platform: n = f.type } = e;
|
|
2084
|
+
return t && typeof t.code == "string" && t.code.includes("/") ? _r(t, { apiName: r, platform: n }) : t && (t.errMsg || t.message) ? Mr(t, { apiName: r, platform: n }) : typeof t == "string" ? new V(
|
|
2021
2085
|
c.UNKNOWN_ERROR,
|
|
2022
2086
|
t,
|
|
2023
2087
|
{ apiName: r, platform: n, originalError: t }
|
|
@@ -2032,14 +2096,14 @@ function ot(t, e = {}) {
|
|
|
2032
2096
|
}
|
|
2033
2097
|
);
|
|
2034
2098
|
}
|
|
2035
|
-
function
|
|
2099
|
+
function _r(t, e) {
|
|
2036
2100
|
const { apiName: r, platform: n } = e, i = t.code, s = Ar[i] || c.UNKNOWN_ERROR;
|
|
2037
2101
|
return a.debug("转换旧版错误码", {
|
|
2038
2102
|
legacy: i,
|
|
2039
2103
|
new: s
|
|
2040
2104
|
}), new V(
|
|
2041
2105
|
s,
|
|
2042
|
-
t.message ||
|
|
2106
|
+
t.message || ne(s),
|
|
2043
2107
|
{
|
|
2044
2108
|
apiName: r,
|
|
2045
2109
|
platform: t.platform || n,
|
|
@@ -2051,22 +2115,22 @@ function Mr(t, e) {
|
|
|
2051
2115
|
}
|
|
2052
2116
|
);
|
|
2053
2117
|
}
|
|
2054
|
-
function
|
|
2118
|
+
function Mr(t, e) {
|
|
2055
2119
|
const { apiName: r, platform: n } = e, i = (t.errMsg || t.message || "").toLowerCase();
|
|
2056
2120
|
if (r && Ye[r]) {
|
|
2057
|
-
const
|
|
2058
|
-
for (const [u,
|
|
2121
|
+
const l = Ye[r];
|
|
2122
|
+
for (const [u, p] of Object.entries(l))
|
|
2059
2123
|
if (i.includes(u.toLowerCase()))
|
|
2060
|
-
return new V(
|
|
2124
|
+
return new V(p, ne(p), {
|
|
2061
2125
|
apiName: r,
|
|
2062
2126
|
platform: n,
|
|
2063
2127
|
originalError: t
|
|
2064
2128
|
});
|
|
2065
2129
|
}
|
|
2066
2130
|
const s = ze[n] || ze.uniapp;
|
|
2067
|
-
for (const { pattern:
|
|
2068
|
-
if (
|
|
2069
|
-
return new V(u,
|
|
2131
|
+
for (const { pattern: l, code: u } of s.patterns)
|
|
2132
|
+
if (l.test(i))
|
|
2133
|
+
return new V(u, ne(u), {
|
|
2070
2134
|
apiName: r,
|
|
2071
2135
|
platform: n,
|
|
2072
2136
|
originalError: t
|
|
@@ -2074,7 +2138,7 @@ function Cr(t, e) {
|
|
|
2074
2138
|
const o = s.default || c.UNKNOWN_ERROR;
|
|
2075
2139
|
return new V(
|
|
2076
2140
|
o,
|
|
2077
|
-
t.errMsg || t.message ||
|
|
2141
|
+
t.errMsg || t.message || ne(o),
|
|
2078
2142
|
{
|
|
2079
2143
|
apiName: r,
|
|
2080
2144
|
platform: n,
|
|
@@ -2093,7 +2157,7 @@ const ct = {
|
|
|
2093
2157
|
if (!t.success && t.error) {
|
|
2094
2158
|
const r = ot(t.error, {
|
|
2095
2159
|
apiName: e.apiName,
|
|
2096
|
-
platform:
|
|
2160
|
+
platform: f.type
|
|
2097
2161
|
});
|
|
2098
2162
|
t.error = r.toJSON(), t.errorCode = r.code, t.errorCategory = r.category, t.retriable = r.isRetriable(), a.debug("错误已标准化", {
|
|
2099
2163
|
api: e.apiName,
|
|
@@ -2105,24 +2169,24 @@ const ct = {
|
|
|
2105
2169
|
}
|
|
2106
2170
|
};
|
|
2107
2171
|
function Rr(t, e = {}) {
|
|
2108
|
-
return new V(t,
|
|
2172
|
+
return new V(t, ne(t), e);
|
|
2109
2173
|
}
|
|
2110
|
-
function
|
|
2174
|
+
function Sr(t) {
|
|
2111
2175
|
return t instanceof V;
|
|
2112
2176
|
}
|
|
2113
|
-
function
|
|
2177
|
+
function Or(t, e, r) {
|
|
2114
2178
|
return e ? Promise.race([
|
|
2115
2179
|
t(),
|
|
2116
2180
|
new Promise((n, i) => setTimeout(() => i(new Error(`Init task timeout: ${r}`)), e))
|
|
2117
2181
|
]) : t();
|
|
2118
2182
|
}
|
|
2119
2183
|
function Nr() {
|
|
2120
|
-
return
|
|
2184
|
+
return I(this, arguments, function* (t = [], e = {}) {
|
|
2121
2185
|
for (const r of t) {
|
|
2122
2186
|
const n = (r == null ? void 0 : r.name) || "anonymous-task", i = (r == null ? void 0 : r.run) || r;
|
|
2123
2187
|
if (typeof i == "function")
|
|
2124
2188
|
try {
|
|
2125
|
-
yield
|
|
2189
|
+
yield Or(() => Promise.resolve().then(() => i()), r.timeoutMs, n), typeof r.onSuccess == "function" && r.onSuccess();
|
|
2126
2190
|
} catch (s) {
|
|
2127
2191
|
if (typeof r.onError == "function" && r.onError(s), typeof e.onError == "function")
|
|
2128
2192
|
e.onError(s, r);
|
|
@@ -2147,7 +2211,7 @@ class ut {
|
|
|
2147
2211
|
*/
|
|
2148
2212
|
processNavigationOptions(e = {}) {
|
|
2149
2213
|
const { url: r, delta: n = 1 } = e, i = r && encodeURI(r), s = parseInt(n) || 1;
|
|
2150
|
-
return
|
|
2214
|
+
return m(g({}, e), {
|
|
2151
2215
|
url: i,
|
|
2152
2216
|
delta: s
|
|
2153
2217
|
});
|
|
@@ -2259,7 +2323,7 @@ class ut {
|
|
|
2259
2323
|
}
|
|
2260
2324
|
}
|
|
2261
2325
|
let de = [];
|
|
2262
|
-
function
|
|
2326
|
+
function br() {
|
|
2263
2327
|
if (de.length === 0 && window.plus) {
|
|
2264
2328
|
const t = plus.webview.currentWebview();
|
|
2265
2329
|
if (!t)
|
|
@@ -2269,7 +2333,7 @@ function Tr() {
|
|
|
2269
2333
|
}
|
|
2270
2334
|
return de;
|
|
2271
2335
|
}
|
|
2272
|
-
function
|
|
2336
|
+
function Tr(t, e) {
|
|
2273
2337
|
const r = {
|
|
2274
2338
|
options: {
|
|
2275
2339
|
timestamp: +/* @__PURE__ */ new Date()
|
|
@@ -2318,7 +2382,7 @@ function Lr(t, e) {
|
|
|
2318
2382
|
},
|
|
2319
2383
|
name: t,
|
|
2320
2384
|
arg: e
|
|
2321
|
-
}, n =
|
|
2385
|
+
}, n = br();
|
|
2322
2386
|
if (plus.webview.getWebviewById("__uniapp__service"))
|
|
2323
2387
|
plus.webview.postMessageToUniNView({
|
|
2324
2388
|
type: "WEB_INVOKE_APPSERVICE",
|
|
@@ -2368,7 +2432,7 @@ function Ur(t, e) {
|
|
|
2368
2432
|
});
|
|
2369
2433
|
}
|
|
2370
2434
|
function he(t, e) {
|
|
2371
|
-
|
|
2435
|
+
Se() ? Tr(t, e) : Re() ? vr(t, e) : Z() ? Ur(t, e) : Me() ? Lr(t, e) : xr(t, e);
|
|
2372
2436
|
}
|
|
2373
2437
|
class lt extends ut {
|
|
2374
2438
|
constructor() {
|
|
@@ -2389,17 +2453,17 @@ class lt extends ut {
|
|
|
2389
2453
|
* @returns {void}
|
|
2390
2454
|
*/
|
|
2391
2455
|
performNavigation(e, r) {
|
|
2392
|
-
return
|
|
2456
|
+
return d.safeExecute(() => {
|
|
2393
2457
|
const { url: n, delta: i } = r;
|
|
2394
|
-
if (
|
|
2458
|
+
if (E.debug(`微信平台执行导航操作: ${e}`, r), this.isWeixinApiAvailable()) {
|
|
2395
2459
|
const o = window.wx.miniProgram[e];
|
|
2396
2460
|
if (typeof o == "function") {
|
|
2397
|
-
|
|
2398
|
-
const
|
|
2399
|
-
return o.call(window.wx.miniProgram,
|
|
2461
|
+
E.debug(`使用微信原生 API: wx.miniProgram.${e}`);
|
|
2462
|
+
const l = e === "navigateBack" ? { delta: i } : { url: n };
|
|
2463
|
+
return o.call(window.wx.miniProgram, l);
|
|
2400
2464
|
}
|
|
2401
2465
|
}
|
|
2402
|
-
|
|
2466
|
+
E.debug(`使用消息桥接执行: ${e}`), he(e, e === "navigateBack" ? { delta: i } : { url: n });
|
|
2403
2467
|
}, {
|
|
2404
2468
|
platform: this.name,
|
|
2405
2469
|
method: "performNavigation",
|
|
@@ -2413,7 +2477,7 @@ class lt extends ut {
|
|
|
2413
2477
|
* @returns {void}
|
|
2414
2478
|
*/
|
|
2415
2479
|
performPostMessage(e) {
|
|
2416
|
-
return
|
|
2480
|
+
return d.safeExecute(() => {
|
|
2417
2481
|
const { data: r } = e;
|
|
2418
2482
|
if (this.isWeixinApiAvailable())
|
|
2419
2483
|
return window.wx.miniProgram.postMessage({ data: r });
|
|
@@ -2430,7 +2494,7 @@ class lt extends ut {
|
|
|
2430
2494
|
* @returns {void}
|
|
2431
2495
|
*/
|
|
2432
2496
|
performGetEnv(e) {
|
|
2433
|
-
return
|
|
2497
|
+
return d.safeExecute(() => {
|
|
2434
2498
|
if (!e || typeof e != "function")
|
|
2435
2499
|
throw new Error("Callback function is required for getEnv");
|
|
2436
2500
|
if (this.isWeixinApiAvailable() && window.wx.miniProgram.getEnv)
|
|
@@ -2445,7 +2509,7 @@ class lt extends ut {
|
|
|
2445
2509
|
});
|
|
2446
2510
|
}
|
|
2447
2511
|
}
|
|
2448
|
-
const
|
|
2512
|
+
const ee = new lt(), Wr = (t) => ee.navigateTo(t), $r = (t) => ee.navigateBack(t), Fr = (t) => ee.switchTab(t), kr = (t) => ee.reLaunch(t), Br = (t) => ee.redirectTo(t), Gr = (t) => ee.postMessage(t), Kr = (t) => ee.getEnv(t);
|
|
2449
2513
|
var ft = /* @__PURE__ */ Object.freeze({
|
|
2450
2514
|
__proto__: null,
|
|
2451
2515
|
WeixinPlatform: lt,
|
|
@@ -2453,8 +2517,8 @@ var ft = /* @__PURE__ */ Object.freeze({
|
|
|
2453
2517
|
navigateBack: $r,
|
|
2454
2518
|
navigateTo: Wr,
|
|
2455
2519
|
postMessage: Gr,
|
|
2456
|
-
reLaunch:
|
|
2457
|
-
redirectTo:
|
|
2520
|
+
reLaunch: kr,
|
|
2521
|
+
redirectTo: Br,
|
|
2458
2522
|
switchTab: Fr
|
|
2459
2523
|
});
|
|
2460
2524
|
class dt extends ut {
|
|
@@ -2468,7 +2532,7 @@ class dt extends ut {
|
|
|
2468
2532
|
* @returns {void}
|
|
2469
2533
|
*/
|
|
2470
2534
|
performNavigation(e, r) {
|
|
2471
|
-
return
|
|
2535
|
+
return d.safeExecute(() => {
|
|
2472
2536
|
const { url: n, delta: i } = r;
|
|
2473
2537
|
he(e, e === "navigateBack" ? { delta: i } : { url: n });
|
|
2474
2538
|
}, {
|
|
@@ -2484,7 +2548,7 @@ class dt extends ut {
|
|
|
2484
2548
|
* @returns {void}
|
|
2485
2549
|
*/
|
|
2486
2550
|
performPostMessage(e) {
|
|
2487
|
-
return
|
|
2551
|
+
return d.safeExecute(() => {
|
|
2488
2552
|
const { data: r } = e;
|
|
2489
2553
|
he("postMessage", r);
|
|
2490
2554
|
}, {
|
|
@@ -2499,19 +2563,19 @@ class dt extends ut {
|
|
|
2499
2563
|
* @returns {void}
|
|
2500
2564
|
*/
|
|
2501
2565
|
performGetEnv(e) {
|
|
2502
|
-
return
|
|
2566
|
+
return d.safeExecute(() => {
|
|
2503
2567
|
if (!e || typeof e != "function")
|
|
2504
2568
|
throw new Error("Callback function is required for getEnv");
|
|
2505
2569
|
const r = {};
|
|
2506
2570
|
let n = !1;
|
|
2507
|
-
|
|
2571
|
+
Se() ? (r.uvue = !0, n = !0) : Re() ? (r.nvue = !0, n = !0) : Me() ? (r.plus = !0, n = !0) : Z() && (r.offline = !0, n = !0), n ? r.app = !0 : r.h5 = !0, e(r);
|
|
2508
2572
|
}, {
|
|
2509
2573
|
platform: this.name,
|
|
2510
2574
|
method: "performGetEnv"
|
|
2511
2575
|
});
|
|
2512
2576
|
}
|
|
2513
2577
|
}
|
|
2514
|
-
const
|
|
2578
|
+
const te = new dt(), Vr = (t) => te.navigateTo(t), qr = (t) => te.navigateBack(t), jr = (t) => te.switchTab(t), Jr = (t) => te.reLaunch(t), Hr = (t) => te.redirectTo(t), zr = (t) => te.postMessage(t), Yr = (t) => te.getEnv(t);
|
|
2515
2579
|
var gt = /* @__PURE__ */ Object.freeze({
|
|
2516
2580
|
__proto__: null,
|
|
2517
2581
|
AppPlatform: dt,
|
|
@@ -2523,26 +2587,26 @@ var gt = /* @__PURE__ */ Object.freeze({
|
|
|
2523
2587
|
redirectTo: Hr,
|
|
2524
2588
|
switchTab: jr
|
|
2525
2589
|
});
|
|
2526
|
-
function
|
|
2527
|
-
return
|
|
2590
|
+
function me() {
|
|
2591
|
+
return C() ? ft : gt;
|
|
2528
2592
|
}
|
|
2529
2593
|
function Xr(t) {
|
|
2530
|
-
return
|
|
2594
|
+
return me().navigateTo(t);
|
|
2531
2595
|
}
|
|
2532
2596
|
function Zr(t) {
|
|
2533
|
-
return
|
|
2597
|
+
return me().navigateBack(t);
|
|
2534
2598
|
}
|
|
2535
2599
|
function Qr(t) {
|
|
2536
|
-
return
|
|
2600
|
+
return me().switchTab(t);
|
|
2537
2601
|
}
|
|
2538
2602
|
function en(t) {
|
|
2539
|
-
return
|
|
2603
|
+
return me().reLaunch(t);
|
|
2540
2604
|
}
|
|
2541
2605
|
function tn(t) {
|
|
2542
|
-
return
|
|
2606
|
+
return me().redirectTo(t);
|
|
2543
2607
|
}
|
|
2544
2608
|
function ht() {
|
|
2545
|
-
return
|
|
2609
|
+
return C() ? ft : gt;
|
|
2546
2610
|
}
|
|
2547
2611
|
function rn(t = {}) {
|
|
2548
2612
|
return ht().postMessage(t);
|
|
@@ -2568,15 +2632,15 @@ class on {
|
|
|
2568
2632
|
* @returns {void}
|
|
2569
2633
|
*/
|
|
2570
2634
|
callApi(i) {
|
|
2571
|
-
return
|
|
2572
|
-
return
|
|
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
|
-
|
|
2635
|
+
return I(this, arguments, function* (e, r = {}, n = {}) {
|
|
2636
|
+
return d.safeExecute(() => I(this, null, function* () {
|
|
2637
|
+
var p;
|
|
2638
|
+
if (typeof window != "undefined" && window === window.parent && !window.plus && !window.__uniapp_x_postMessage && !window.__uniapp_x_ && !window.__dcloud_weex_postMessage && !window.__dcloud_weex_ && !Z()) {
|
|
2639
|
+
const M = new N(
|
|
2640
|
+
T.PLATFORM_NOT_SUPPORTED,
|
|
2577
2641
|
"当前不在宿主 WebView 容器中,无法发送消息"
|
|
2578
2642
|
);
|
|
2579
|
-
n && typeof n.fail == "function" && n.fail({ errMsg:
|
|
2643
|
+
n && typeof n.fail == "function" && n.fail({ errMsg: M.message, code: "NOT_IN_CONTAINER" }), n && typeof n.complete == "function" && n.complete({ success: !1, error: { errMsg: M.message } });
|
|
2580
2644
|
return;
|
|
2581
2645
|
}
|
|
2582
2646
|
const o = {
|
|
@@ -2588,18 +2652,18 @@ class on {
|
|
|
2588
2652
|
metadata: {}
|
|
2589
2653
|
};
|
|
2590
2654
|
G.setApiLoading(e, !0);
|
|
2591
|
-
const
|
|
2592
|
-
if (
|
|
2655
|
+
const l = yield z.runRequest(o);
|
|
2656
|
+
if (l.abort) {
|
|
2593
2657
|
A.warn("API 调用被拦截器中止", { api: e }), G.setApiLoading(e, !1), n.fail && n.fail({
|
|
2594
|
-
errMsg: ((
|
|
2658
|
+
errMsg: ((p = l.error) == null ? void 0 : p.message) || "API 调用被中止",
|
|
2595
2659
|
code: "INTERCEPTED"
|
|
2596
2660
|
}), n.complete && n.complete({ success: !1 });
|
|
2597
2661
|
return;
|
|
2598
2662
|
}
|
|
2599
2663
|
const u = sn();
|
|
2600
2664
|
if (n.success || n.fail || n.complete) {
|
|
2601
|
-
if (this.callbacks.set(u,
|
|
2602
|
-
context:
|
|
2665
|
+
if (this.callbacks.set(u, m(g({}, n), {
|
|
2666
|
+
context: l
|
|
2603
2667
|
// 保存上下文用于响应拦截
|
|
2604
2668
|
})), window.qshWebviewCallbacks[u] = ($) => {
|
|
2605
2669
|
this.handleCallback(u, $);
|
|
@@ -2618,10 +2682,10 @@ class on {
|
|
|
2618
2682
|
}, r.timeout || this.defaultTimeout);
|
|
2619
2683
|
this.timeouts.set(u, $);
|
|
2620
2684
|
}
|
|
2621
|
-
const
|
|
2685
|
+
const _ = {
|
|
2622
2686
|
type: "qsh_api_call",
|
|
2623
2687
|
api: e,
|
|
2624
|
-
params:
|
|
2688
|
+
params: l.params,
|
|
2625
2689
|
callbackId: u,
|
|
2626
2690
|
timestamp: Date.now()
|
|
2627
2691
|
};
|
|
@@ -2630,7 +2694,7 @@ class on {
|
|
|
2630
2694
|
callbackId: u,
|
|
2631
2695
|
hasSuccess: !!n.success,
|
|
2632
2696
|
hasFail: !!n.fail
|
|
2633
|
-
}), console.log("message:", JSON.stringify(an(
|
|
2697
|
+
}), console.log("message:", JSON.stringify(an(_), null, 2)), he("postMessage", _);
|
|
2634
2698
|
}
|
|
2635
2699
|
}), {
|
|
2636
2700
|
context: "WebViewBridge.callApi",
|
|
@@ -2645,18 +2709,18 @@ class on {
|
|
|
2645
2709
|
* @private
|
|
2646
2710
|
*/
|
|
2647
2711
|
handleCallback(e, r) {
|
|
2648
|
-
return
|
|
2649
|
-
return
|
|
2650
|
-
var
|
|
2712
|
+
return I(this, null, function* () {
|
|
2713
|
+
return d.safeExecute(() => I(this, null, function* () {
|
|
2714
|
+
var M, _;
|
|
2651
2715
|
const n = this.callbacks.get(e);
|
|
2652
2716
|
if (!n) {
|
|
2653
2717
|
A.warn("未找到回调函数", { callbackId: e });
|
|
2654
2718
|
return;
|
|
2655
2719
|
}
|
|
2656
|
-
const { success: i, fail: s, complete: o, context:
|
|
2720
|
+
const { success: i, fail: s, complete: o, context: l } = n;
|
|
2657
2721
|
A.debug("处理回调", { callbackId: e, result: r });
|
|
2658
|
-
const u = yield
|
|
2659
|
-
|
|
2722
|
+
const u = yield z.runResponse(r, l);
|
|
2723
|
+
l && G.setApiResult(l.apiName, u), u.success && i ? i(u.data) : !u.success && s && s(u.error || { errMsg: "操作失败" }), o && o(u), ((_ = (M = n.context) == null ? void 0 : M.params) == null ? void 0 : _.isPersistent) ? A.debug("持久监听API:保留回调", { callbackId: e }) : (this.cleanupCallback(e), A.debug("回调执行完成,已清理", { callbackId: e }));
|
|
2660
2724
|
}), {
|
|
2661
2725
|
context: "WebViewBridge.handleCallback",
|
|
2662
2726
|
callbackId: e
|
|
@@ -2709,18 +2773,18 @@ class on {
|
|
|
2709
2773
|
};
|
|
2710
2774
|
}
|
|
2711
2775
|
}
|
|
2712
|
-
const
|
|
2713
|
-
function
|
|
2776
|
+
const pt = new on(), O = (t, e, r) => pt.callApi(t, e, r), ie = (t) => pt.cleanupPersistentCallbacksByApi(t);
|
|
2777
|
+
function mt() {
|
|
2714
2778
|
return H(!0);
|
|
2715
2779
|
}
|
|
2716
2780
|
function cn(t) {
|
|
2717
2781
|
return t === "offline";
|
|
2718
2782
|
}
|
|
2719
2783
|
function un(t = {}) {
|
|
2720
|
-
return
|
|
2784
|
+
return d.safeExecute(() => {
|
|
2721
2785
|
a.debug("Call getCode through offline webview bridge", {
|
|
2722
2786
|
clientId: t.clientId
|
|
2723
|
-
}),
|
|
2787
|
+
}), O(
|
|
2724
2788
|
"getCode",
|
|
2725
2789
|
{
|
|
2726
2790
|
clientId: t.clientId
|
|
@@ -2739,13 +2803,13 @@ function un(t = {}) {
|
|
|
2739
2803
|
);
|
|
2740
2804
|
}, {
|
|
2741
2805
|
context: "getCodeInHost",
|
|
2742
|
-
platform:
|
|
2806
|
+
platform: mt().type
|
|
2743
2807
|
});
|
|
2744
2808
|
}
|
|
2745
2809
|
function ln(t = {}) {
|
|
2746
|
-
return
|
|
2810
|
+
return d.safeExecute(() => {
|
|
2747
2811
|
var n, i;
|
|
2748
|
-
const e =
|
|
2812
|
+
const e = mt(), r = String((t == null ? void 0 : t.clientId) || "").trim();
|
|
2749
2813
|
if (!r) {
|
|
2750
2814
|
const s = {
|
|
2751
2815
|
errMsg: "clientId is required",
|
|
@@ -2764,7 +2828,7 @@ function ln(t = {}) {
|
|
|
2764
2828
|
}), (i = t.fail) == null || i.call(t, s);
|
|
2765
2829
|
return;
|
|
2766
2830
|
}
|
|
2767
|
-
un(
|
|
2831
|
+
un(m(g({}, t), {
|
|
2768
2832
|
clientId: r
|
|
2769
2833
|
}));
|
|
2770
2834
|
}, {
|
|
@@ -2793,7 +2857,7 @@ function fn(t = {}) {
|
|
|
2793
2857
|
errMsg: `env must be one of ${Xe.join("/")}`,
|
|
2794
2858
|
code: "PARAM_INVALID"
|
|
2795
2859
|
};
|
|
2796
|
-
return
|
|
2860
|
+
return m(g({}, t), {
|
|
2797
2861
|
appid: e,
|
|
2798
2862
|
path: r.trim(),
|
|
2799
2863
|
env: i
|
|
@@ -2803,7 +2867,7 @@ function dn() {
|
|
|
2803
2867
|
return typeof window != "undefined" && window.wx && window.wx.miniProgram && typeof window.wx.miniProgram.postMessage == "function" && typeof window.wx.miniProgram.navigateBack == "function";
|
|
2804
2868
|
}
|
|
2805
2869
|
function gn(t = {}) {
|
|
2806
|
-
return
|
|
2870
|
+
return d.safeExecute(() => {
|
|
2807
2871
|
var r;
|
|
2808
2872
|
if (!dn()) {
|
|
2809
2873
|
const n = {
|
|
@@ -2839,18 +2903,18 @@ function gn(t = {}) {
|
|
|
2839
2903
|
delta: 1,
|
|
2840
2904
|
success: (o) => {
|
|
2841
2905
|
var u;
|
|
2842
|
-
const
|
|
2906
|
+
const l = m(g({}, o), {
|
|
2843
2907
|
errMsg: (o == null ? void 0 : o.errMsg) || "navigateToMiniProgram:queued"
|
|
2844
2908
|
});
|
|
2845
2909
|
a.info("Navigate to mini program request queued in weixin web-view", {
|
|
2846
2910
|
appid: t.appid,
|
|
2847
2911
|
path: t.path,
|
|
2848
2912
|
env: t.env
|
|
2849
|
-
}), (u = t.success) == null || u.call(t,
|
|
2913
|
+
}), (u = t.success) == null || u.call(t, l), n(l);
|
|
2850
2914
|
},
|
|
2851
2915
|
fail: (o) => {
|
|
2852
|
-
var
|
|
2853
|
-
a.error("Navigate back after posting mini program message failed", o), (
|
|
2916
|
+
var l;
|
|
2917
|
+
a.error("Navigate back after posting mini program message failed", o), (l = t.fail) == null || l.call(t, o), i(o);
|
|
2854
2918
|
},
|
|
2855
2919
|
complete: t.complete
|
|
2856
2920
|
});
|
|
@@ -2861,12 +2925,12 @@ function gn(t = {}) {
|
|
|
2861
2925
|
});
|
|
2862
2926
|
}
|
|
2863
2927
|
function hn(t = {}) {
|
|
2864
|
-
return
|
|
2928
|
+
return d.safeExecute(() => (a.debug("Call navigateToMiniProgram through webview bridge", {
|
|
2865
2929
|
appid: t.appid,
|
|
2866
2930
|
path: t.path,
|
|
2867
2931
|
env: t.env
|
|
2868
2932
|
}), new Promise((e, r) => {
|
|
2869
|
-
|
|
2933
|
+
O(
|
|
2870
2934
|
"navigateToMiniProgram",
|
|
2871
2935
|
{
|
|
2872
2936
|
appid: t.appid,
|
|
@@ -2890,8 +2954,8 @@ function hn(t = {}) {
|
|
|
2890
2954
|
platform: wt().type
|
|
2891
2955
|
});
|
|
2892
2956
|
}
|
|
2893
|
-
function
|
|
2894
|
-
return
|
|
2957
|
+
function pn(t = {}) {
|
|
2958
|
+
return d.safeExecute(() => {
|
|
2895
2959
|
var n;
|
|
2896
2960
|
const e = wt();
|
|
2897
2961
|
let r;
|
|
@@ -2912,7 +2976,7 @@ function mn(t = {}) {
|
|
|
2912
2976
|
options: t
|
|
2913
2977
|
});
|
|
2914
2978
|
}
|
|
2915
|
-
function
|
|
2979
|
+
function mn(t = "") {
|
|
2916
2980
|
return /^https?:\/\//i.test(String(t || "").trim());
|
|
2917
2981
|
}
|
|
2918
2982
|
function wn(t) {
|
|
@@ -2946,7 +3010,7 @@ function yn(t = {}) {
|
|
|
2946
3010
|
errMsg: "manualShare: clientId is required",
|
|
2947
3011
|
code: "PARAM_MISSING"
|
|
2948
3012
|
};
|
|
2949
|
-
if (r && !
|
|
3013
|
+
if (r && !mn(r))
|
|
2950
3014
|
throw {
|
|
2951
3015
|
errMsg: "manualShare: h5Url must be a valid http(s) url",
|
|
2952
3016
|
code: "PARAM_INVALID"
|
|
@@ -2994,7 +3058,7 @@ function An(t) {
|
|
|
2994
3058
|
window.wx.miniProgram.navigateBack({
|
|
2995
3059
|
delta: 1,
|
|
2996
3060
|
success: (i) => {
|
|
2997
|
-
const s =
|
|
3061
|
+
const s = m(g({}, i || {}), {
|
|
2998
3062
|
success: !0,
|
|
2999
3063
|
errMsg: (i == null ? void 0 : i.errMsg) || "manualShare:queued"
|
|
3000
3064
|
});
|
|
@@ -3014,36 +3078,36 @@ function An(t) {
|
|
|
3014
3078
|
});
|
|
3015
3079
|
}
|
|
3016
3080
|
function Et(t = {}) {
|
|
3017
|
-
return
|
|
3081
|
+
return d.safeExecute(
|
|
3018
3082
|
() => {
|
|
3019
|
-
var n, i, s, o,
|
|
3083
|
+
var n, i, s, o, l, u;
|
|
3020
3084
|
const e = H(!0);
|
|
3021
3085
|
let r;
|
|
3022
3086
|
try {
|
|
3023
3087
|
r = yn(t);
|
|
3024
|
-
} catch (
|
|
3025
|
-
return (n = t.fail) == null || n.call(t,
|
|
3088
|
+
} catch (p) {
|
|
3089
|
+
return (n = t.fail) == null || n.call(t, p), (i = t.complete) == null || i.call(t, p), Promise.reject(p);
|
|
3026
3090
|
}
|
|
3027
3091
|
if (!e.isWeixinMiniProgram) {
|
|
3028
|
-
const
|
|
3092
|
+
const p = {
|
|
3029
3093
|
errMsg: "manualShare only supports Weixin mini-program web-view environment",
|
|
3030
3094
|
code: "ENV_NOT_SUPPORTED"
|
|
3031
3095
|
};
|
|
3032
|
-
return (s = r.fail) == null || s.call(r,
|
|
3096
|
+
return (s = r.fail) == null || s.call(r, p), (o = r.complete) == null || o.call(r, p), Promise.reject(p);
|
|
3033
3097
|
}
|
|
3034
3098
|
if (!En()) {
|
|
3035
|
-
const
|
|
3099
|
+
const p = {
|
|
3036
3100
|
errMsg: "wx.miniProgram.postMessage or wx.miniProgram.navigateBack is not available",
|
|
3037
3101
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
3038
3102
|
};
|
|
3039
|
-
return (
|
|
3103
|
+
return (l = r.fail) == null || l.call(r, p), (u = r.complete) == null || u.call(r, p), Promise.reject(p);
|
|
3040
3104
|
}
|
|
3041
|
-
return An(r).then((
|
|
3042
|
-
var
|
|
3043
|
-
return (
|
|
3044
|
-
}).catch((
|
|
3045
|
-
var
|
|
3046
|
-
return (
|
|
3105
|
+
return An(r).then((p) => {
|
|
3106
|
+
var M, _;
|
|
3107
|
+
return (M = r.success) == null || M.call(r, p), (_ = r.complete) == null || _.call(r, p), p;
|
|
3108
|
+
}).catch((p) => {
|
|
3109
|
+
var M, _;
|
|
3110
|
+
return (M = r.fail) == null || M.call(r, p), (_ = r.complete) == null || _.call(r, p), Promise.reject(p);
|
|
3047
3111
|
});
|
|
3048
3112
|
},
|
|
3049
3113
|
{
|
|
@@ -3054,36 +3118,36 @@ function Et(t = {}) {
|
|
|
3054
3118
|
}
|
|
3055
3119
|
function Pn(t = {}) {
|
|
3056
3120
|
return new Promise((e, r) => {
|
|
3057
|
-
Et(
|
|
3121
|
+
Et(m(g({}, t), {
|
|
3058
3122
|
success: e,
|
|
3059
3123
|
fail: r
|
|
3060
3124
|
}));
|
|
3061
3125
|
});
|
|
3062
3126
|
}
|
|
3063
|
-
const
|
|
3127
|
+
const Ce = {
|
|
3064
3128
|
ALBUM: "album",
|
|
3065
3129
|
// 相册
|
|
3066
3130
|
CAMERA: "camera"
|
|
3067
3131
|
// 相机
|
|
3068
|
-
},
|
|
3132
|
+
}, _e = {
|
|
3069
3133
|
ORIGINAL: "original",
|
|
3070
3134
|
// 原图
|
|
3071
3135
|
COMPRESSED: "compressed"
|
|
3072
3136
|
// 压缩图
|
|
3073
|
-
},
|
|
3137
|
+
}, Cn = {
|
|
3074
3138
|
count: 9,
|
|
3075
|
-
sizeType: [
|
|
3076
|
-
sourceType: [
|
|
3139
|
+
sizeType: [_e.ORIGINAL, _e.COMPRESSED],
|
|
3140
|
+
sourceType: [Ce.ALBUM, Ce.CAMERA]
|
|
3077
3141
|
};
|
|
3078
|
-
function
|
|
3079
|
-
const e = g(g({},
|
|
3080
|
-
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 = [
|
|
3142
|
+
function _n(t = {}) {
|
|
3143
|
+
const e = g(g({}, Cn), t);
|
|
3144
|
+
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 = [_e.COMPRESSED]), e.sourceType.length === 0 && (e.sourceType = [Ce.ALBUM]), e;
|
|
3081
3145
|
}
|
|
3082
3146
|
function yt() {
|
|
3083
|
-
return ["weixin", "webview", "UniApp", "plus", "nvue", "uvue", "offline"].includes(
|
|
3147
|
+
return ["weixin", "webview", "UniApp", "plus", "nvue", "uvue", "offline"].includes(f.type);
|
|
3084
3148
|
}
|
|
3085
3149
|
function It(t) {
|
|
3086
|
-
return
|
|
3150
|
+
return d.safeExecute(() => {
|
|
3087
3151
|
var e;
|
|
3088
3152
|
if (!window.wx) {
|
|
3089
3153
|
const r = {
|
|
@@ -3093,8 +3157,8 @@ function It(t) {
|
|
|
3093
3157
|
(e = t.fail) == null || e.call(t, r);
|
|
3094
3158
|
return;
|
|
3095
3159
|
}
|
|
3096
|
-
if (!
|
|
3097
|
-
a.info("等待微信配置完成"),
|
|
3160
|
+
if (!oe()) {
|
|
3161
|
+
a.info("等待微信配置完成"), Q().then(() => It(t)).catch((r) => {
|
|
3098
3162
|
var n;
|
|
3099
3163
|
a.error("微信配置失败", r), (n = t.fail) == null || n.call(t, { errMsg: `微信配置失败: ${r.message}` });
|
|
3100
3164
|
});
|
|
@@ -3119,9 +3183,9 @@ function It(t) {
|
|
|
3119
3183
|
platform: "weixin"
|
|
3120
3184
|
});
|
|
3121
3185
|
}
|
|
3122
|
-
function
|
|
3123
|
-
return
|
|
3124
|
-
a.debug("通过 WebView 桥接调用图片选择", t),
|
|
3186
|
+
function Mn(t) {
|
|
3187
|
+
return d.safeExecute(() => {
|
|
3188
|
+
a.debug("通过 WebView 桥接调用图片选择", t), O("chooseImage", m(g({}, t), { disableTimeout: !0 }), {
|
|
3125
3189
|
success: (e) => {
|
|
3126
3190
|
var r, n;
|
|
3127
3191
|
a.info("UniApp 图片选择成功", {
|
|
@@ -3140,33 +3204,33 @@ function Cn(t) {
|
|
|
3140
3204
|
});
|
|
3141
3205
|
}
|
|
3142
3206
|
function Rn(t = {}) {
|
|
3143
|
-
return
|
|
3207
|
+
return d.safeExecute(() => {
|
|
3144
3208
|
var r;
|
|
3145
3209
|
if (!yt()) {
|
|
3146
3210
|
const n = {
|
|
3147
|
-
errMsg: `当前环境 (${
|
|
3211
|
+
errMsg: `当前环境 (${f.type}) 不支持图片选择功能`,
|
|
3148
3212
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
3149
3213
|
};
|
|
3150
|
-
a.error("平台不支持图片选择", { platform:
|
|
3214
|
+
a.error("平台不支持图片选择", { platform: f.type }), (r = t.fail) == null || r.call(t, n);
|
|
3151
3215
|
return;
|
|
3152
3216
|
}
|
|
3153
|
-
const e =
|
|
3217
|
+
const e = _n(t);
|
|
3154
3218
|
a.info("开始选择图片", {
|
|
3155
|
-
platform:
|
|
3219
|
+
platform: f.type,
|
|
3156
3220
|
count: e.count,
|
|
3157
3221
|
sizeType: e.sizeType,
|
|
3158
3222
|
sourceType: e.sourceType
|
|
3159
|
-
}),
|
|
3223
|
+
}), C() ? It(e) : Mn(e);
|
|
3160
3224
|
}, {
|
|
3161
3225
|
context: "chooseImage",
|
|
3162
3226
|
options: t
|
|
3163
3227
|
});
|
|
3164
3228
|
}
|
|
3165
|
-
function
|
|
3229
|
+
function Sn() {
|
|
3166
3230
|
return {
|
|
3167
3231
|
supported: yt(),
|
|
3168
|
-
environment:
|
|
3169
|
-
implementation:
|
|
3232
|
+
environment: f.type,
|
|
3233
|
+
implementation: C() ? "weixin" : "webview",
|
|
3170
3234
|
features: {
|
|
3171
3235
|
multipleSelection: !0,
|
|
3172
3236
|
// 支持多选
|
|
@@ -3179,7 +3243,7 @@ function On() {
|
|
|
3179
3243
|
}
|
|
3180
3244
|
};
|
|
3181
3245
|
}
|
|
3182
|
-
const
|
|
3246
|
+
const X = {
|
|
3183
3247
|
QR_CODE: "qrCode",
|
|
3184
3248
|
// 二维码
|
|
3185
3249
|
BAR_CODE: "barCode",
|
|
@@ -3188,21 +3252,21 @@ const Z = {
|
|
|
3188
3252
|
// Data Matrix 码
|
|
3189
3253
|
PDF417: "pdf417"
|
|
3190
3254
|
// PDF417 条码
|
|
3191
|
-
},
|
|
3255
|
+
}, On = {
|
|
3192
3256
|
onlyFromCamera: !0,
|
|
3193
3257
|
// 只从相机扫码
|
|
3194
|
-
scanType: [
|
|
3258
|
+
scanType: [X.QR_CODE, X.BAR_CODE]
|
|
3195
3259
|
// 支持二维码和一维码
|
|
3196
3260
|
};
|
|
3197
3261
|
function Nn(t = {}) {
|
|
3198
|
-
const e = g(g({},
|
|
3199
|
-
return Array.isArray(e.scanType) || (e.scanType = [e.scanType].filter(Boolean)), e.scanType.length === 0 && (e.scanType = [
|
|
3262
|
+
const e = g(g({}, On), t);
|
|
3263
|
+
return Array.isArray(e.scanType) || (e.scanType = [e.scanType].filter(Boolean)), e.scanType.length === 0 && (e.scanType = [X.QR_CODE, X.BAR_CODE]), e.onlyFromCamera = !!e.onlyFromCamera, e;
|
|
3200
3264
|
}
|
|
3201
3265
|
function At() {
|
|
3202
|
-
return ["weixin", "webview", "UniApp", "plus", "nvue", "uvue", "offline"].includes(
|
|
3266
|
+
return ["weixin", "webview", "UniApp", "plus", "nvue", "uvue", "offline"].includes(f.type);
|
|
3203
3267
|
}
|
|
3204
3268
|
function Pt(t) {
|
|
3205
|
-
return
|
|
3269
|
+
return d.safeExecute(() => {
|
|
3206
3270
|
var e;
|
|
3207
3271
|
if (!window.wx) {
|
|
3208
3272
|
const r = {
|
|
@@ -3212,8 +3276,8 @@ function Pt(t) {
|
|
|
3212
3276
|
(e = t.fail) == null || e.call(t, r);
|
|
3213
3277
|
return;
|
|
3214
3278
|
}
|
|
3215
|
-
if (!
|
|
3216
|
-
a.info("等待微信配置完成"),
|
|
3279
|
+
if (!oe()) {
|
|
3280
|
+
a.info("等待微信配置完成"), Q().then(() => Pt(t)).catch((r) => {
|
|
3217
3281
|
var n;
|
|
3218
3282
|
a.error("微信配置失败", r), (n = t.fail) == null || n.call(t, { errMsg: `微信配置失败: ${r.message}` });
|
|
3219
3283
|
});
|
|
@@ -3229,7 +3293,7 @@ function Pt(t) {
|
|
|
3229
3293
|
const n = {
|
|
3230
3294
|
result: r.resultStr,
|
|
3231
3295
|
// 扫码内容
|
|
3232
|
-
scanType:
|
|
3296
|
+
scanType: bn(r.resultStr),
|
|
3233
3297
|
// 推测扫码类型
|
|
3234
3298
|
charSet: "utf-8",
|
|
3235
3299
|
// 微信默认 UTF-8
|
|
@@ -3248,12 +3312,12 @@ function Pt(t) {
|
|
|
3248
3312
|
platform: "weixin"
|
|
3249
3313
|
});
|
|
3250
3314
|
}
|
|
3251
|
-
function Tn(t) {
|
|
3252
|
-
return t ? t.length > 50 || /[^\d]/.test(t) ? Z.QR_CODE : Z.BAR_CODE : "unknown";
|
|
3253
|
-
}
|
|
3254
3315
|
function bn(t) {
|
|
3255
|
-
return
|
|
3256
|
-
|
|
3316
|
+
return t ? t.length > 50 || /[^\d]/.test(t) ? X.QR_CODE : X.BAR_CODE : "unknown";
|
|
3317
|
+
}
|
|
3318
|
+
function Tn(t) {
|
|
3319
|
+
return d.safeExecute(() => {
|
|
3320
|
+
a.debug("通过 WebView 桥接调用扫码", t), O("scanCode", m(g({}, t), { disableTimeout: !0 }), {
|
|
3257
3321
|
success: (e) => {
|
|
3258
3322
|
var r;
|
|
3259
3323
|
a.info("UniApp 扫码成功", {
|
|
@@ -3273,22 +3337,22 @@ function bn(t) {
|
|
|
3273
3337
|
});
|
|
3274
3338
|
}
|
|
3275
3339
|
function vn(t = {}) {
|
|
3276
|
-
return
|
|
3340
|
+
return d.safeExecute(() => {
|
|
3277
3341
|
var r;
|
|
3278
3342
|
if (!At()) {
|
|
3279
3343
|
const n = {
|
|
3280
|
-
errMsg: `当前环境 (${
|
|
3344
|
+
errMsg: `当前环境 (${f.type}) 不支持扫码功能`,
|
|
3281
3345
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
3282
3346
|
};
|
|
3283
|
-
a.error("平台不支持扫码", { platform:
|
|
3347
|
+
a.error("平台不支持扫码", { platform: f.type }), (r = t.fail) == null || r.call(t, n);
|
|
3284
3348
|
return;
|
|
3285
3349
|
}
|
|
3286
3350
|
const e = Nn(t);
|
|
3287
3351
|
a.info("开始扫码", {
|
|
3288
|
-
platform:
|
|
3352
|
+
platform: f.type,
|
|
3289
3353
|
onlyFromCamera: e.onlyFromCamera,
|
|
3290
3354
|
scanType: e.scanType
|
|
3291
|
-
}),
|
|
3355
|
+
}), C() ? Pt(e) : Tn(e);
|
|
3292
3356
|
}, {
|
|
3293
3357
|
context: "scanCode",
|
|
3294
3358
|
options: t
|
|
@@ -3297,8 +3361,8 @@ function vn(t = {}) {
|
|
|
3297
3361
|
function Ln() {
|
|
3298
3362
|
return {
|
|
3299
3363
|
supported: At(),
|
|
3300
|
-
environment:
|
|
3301
|
-
implementation:
|
|
3364
|
+
environment: f.type,
|
|
3365
|
+
implementation: C() ? "weixin" : "webview",
|
|
3302
3366
|
features: {
|
|
3303
3367
|
onlyFromCamera: !0,
|
|
3304
3368
|
// 支持只从相机扫码
|
|
@@ -3311,7 +3375,7 @@ function Ln() {
|
|
|
3311
3375
|
}
|
|
3312
3376
|
};
|
|
3313
3377
|
}
|
|
3314
|
-
const
|
|
3378
|
+
const ae = {
|
|
3315
3379
|
WGS84: "wgs84",
|
|
3316
3380
|
// GPS 坐标
|
|
3317
3381
|
GCJ02: "gcj02",
|
|
@@ -3319,7 +3383,7 @@ const se = {
|
|
|
3319
3383
|
BD09: "bd09"
|
|
3320
3384
|
// 百度坐标
|
|
3321
3385
|
}, xn = {
|
|
3322
|
-
type:
|
|
3386
|
+
type: ae.WGS84,
|
|
3323
3387
|
altitude: !1
|
|
3324
3388
|
}, Dn = {
|
|
3325
3389
|
scale: 18
|
|
@@ -3327,11 +3391,11 @@ const se = {
|
|
|
3327
3391
|
};
|
|
3328
3392
|
function Un(t = {}) {
|
|
3329
3393
|
const e = g(g({}, xn), t);
|
|
3330
|
-
return Object.values(
|
|
3394
|
+
return Object.values(ae).includes(e.type) || (e.type = ae.WGS84), e.altitude = !!e.altitude, e;
|
|
3331
3395
|
}
|
|
3332
3396
|
function Wn(t = {}) {
|
|
3333
3397
|
const e = g({}, t);
|
|
3334
|
-
return Object.values(
|
|
3398
|
+
return Object.values(ae).includes(e.type) || (e.type = ae.WGS84), e.needFullAccuracy = !!e.needFullAccuracy, e;
|
|
3335
3399
|
}
|
|
3336
3400
|
function $n(t = {}) {
|
|
3337
3401
|
const e = g(g({}, Dn), t);
|
|
@@ -3394,10 +3458,10 @@ function $n(t = {}) {
|
|
|
3394
3458
|
return e;
|
|
3395
3459
|
}
|
|
3396
3460
|
function $e() {
|
|
3397
|
-
return ["weixin", "webview", "UniApp", "plus", "nvue", "uvue", "offline"].includes(
|
|
3461
|
+
return ["weixin", "webview", "UniApp", "plus", "nvue", "uvue", "offline"].includes(f.type);
|
|
3398
3462
|
}
|
|
3399
|
-
function
|
|
3400
|
-
return
|
|
3463
|
+
function Ct(t) {
|
|
3464
|
+
return d.safeExecute(() => {
|
|
3401
3465
|
var e;
|
|
3402
3466
|
if (!window.wx) {
|
|
3403
3467
|
const r = {
|
|
@@ -3407,8 +3471,8 @@ function _t(t) {
|
|
|
3407
3471
|
(e = t.fail) == null || e.call(t, r);
|
|
3408
3472
|
return;
|
|
3409
3473
|
}
|
|
3410
|
-
if (!
|
|
3411
|
-
a.info("等待微信配置完成"),
|
|
3474
|
+
if (!oe()) {
|
|
3475
|
+
a.info("等待微信配置完成"), Q().then(() => Ct(t)).catch((r) => {
|
|
3412
3476
|
var n;
|
|
3413
3477
|
a.error("微信配置失败", r), (n = t.fail) == null || n.call(t, { errMsg: `微信配置失败: ${r.message}` });
|
|
3414
3478
|
});
|
|
@@ -3434,8 +3498,8 @@ function _t(t) {
|
|
|
3434
3498
|
platform: "weixin"
|
|
3435
3499
|
});
|
|
3436
3500
|
}
|
|
3437
|
-
function
|
|
3438
|
-
return
|
|
3501
|
+
function _t(t) {
|
|
3502
|
+
return d.safeExecute(() => {
|
|
3439
3503
|
var e;
|
|
3440
3504
|
if (!window.wx) {
|
|
3441
3505
|
const r = {
|
|
@@ -3445,8 +3509,8 @@ function Mt(t) {
|
|
|
3445
3509
|
(e = t.fail) == null || e.call(t, r);
|
|
3446
3510
|
return;
|
|
3447
3511
|
}
|
|
3448
|
-
if (!
|
|
3449
|
-
a.info("等待微信配置完成"),
|
|
3512
|
+
if (!oe()) {
|
|
3513
|
+
a.info("等待微信配置完成"), Q().then(() => _t(t)).catch((r) => {
|
|
3450
3514
|
var n;
|
|
3451
3515
|
a.error("微信配置失败", r), (n = t.fail) == null || n.call(t, { errMsg: `微信配置失败: ${r.message}` });
|
|
3452
3516
|
});
|
|
@@ -3475,8 +3539,8 @@ function Mt(t) {
|
|
|
3475
3539
|
});
|
|
3476
3540
|
}
|
|
3477
3541
|
function Fn(t) {
|
|
3478
|
-
return
|
|
3479
|
-
a.debug("通过 WebView 桥接调用获取位置", t),
|
|
3542
|
+
return d.safeExecute(() => {
|
|
3543
|
+
a.debug("通过 WebView 桥接调用获取位置", t), O("getLocation", t, {
|
|
3480
3544
|
success: (e) => {
|
|
3481
3545
|
var r;
|
|
3482
3546
|
a.info("UniApp 获取位置成功", {
|
|
@@ -3495,9 +3559,9 @@ function Fn(t) {
|
|
|
3495
3559
|
platform: "uniapp"
|
|
3496
3560
|
});
|
|
3497
3561
|
}
|
|
3498
|
-
function
|
|
3499
|
-
return
|
|
3500
|
-
a.debug("通过 WebView 桥接调用查看位置", t),
|
|
3562
|
+
function kn(t) {
|
|
3563
|
+
return d.safeExecute(() => {
|
|
3564
|
+
a.debug("通过 WebView 桥接调用查看位置", t), O("openLocation", t, {
|
|
3501
3565
|
success: (e) => {
|
|
3502
3566
|
var r;
|
|
3503
3567
|
a.info("UniApp 查看位置成功"), (r = t.success) == null || r.call(t, e);
|
|
@@ -3513,37 +3577,37 @@ function Bn(t) {
|
|
|
3513
3577
|
platform: "uniapp"
|
|
3514
3578
|
});
|
|
3515
3579
|
}
|
|
3516
|
-
function
|
|
3517
|
-
return
|
|
3580
|
+
function Bn(t = {}) {
|
|
3581
|
+
return d.safeExecute(() => {
|
|
3518
3582
|
var r;
|
|
3519
3583
|
if (!$e()) {
|
|
3520
3584
|
const n = {
|
|
3521
|
-
errMsg: `当前环境 (${
|
|
3585
|
+
errMsg: `当前环境 (${f.type}) 不支持定位功能`,
|
|
3522
3586
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
3523
3587
|
};
|
|
3524
|
-
a.error("平台不支持定位", { platform:
|
|
3588
|
+
a.error("平台不支持定位", { platform: f.type }), (r = t.fail) == null || r.call(t, n);
|
|
3525
3589
|
return;
|
|
3526
3590
|
}
|
|
3527
3591
|
const e = Un(t);
|
|
3528
3592
|
a.info("开始获取位置", {
|
|
3529
|
-
platform:
|
|
3593
|
+
platform: f.type,
|
|
3530
3594
|
type: e.type,
|
|
3531
3595
|
altitude: e.altitude
|
|
3532
|
-
}),
|
|
3596
|
+
}), C() ? Ct(e) : Fn(e);
|
|
3533
3597
|
}, {
|
|
3534
3598
|
context: "getLocation",
|
|
3535
3599
|
options: t
|
|
3536
3600
|
});
|
|
3537
3601
|
}
|
|
3538
3602
|
function Gn(t = {}) {
|
|
3539
|
-
return
|
|
3603
|
+
return d.safeExecute(() => {
|
|
3540
3604
|
var r, n, i;
|
|
3541
3605
|
if (!$e()) {
|
|
3542
3606
|
const s = {
|
|
3543
|
-
errMsg: `当前环境 (${
|
|
3607
|
+
errMsg: `当前环境 (${f.type}) 不支持查看位置功能`,
|
|
3544
3608
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
3545
3609
|
};
|
|
3546
|
-
a.error("平台不支持查看位置", { platform:
|
|
3610
|
+
a.error("平台不支持查看位置", { platform: f.type }), (r = t.fail) == null || r.call(t, s);
|
|
3547
3611
|
return;
|
|
3548
3612
|
}
|
|
3549
3613
|
let e;
|
|
@@ -3554,21 +3618,21 @@ function Gn(t = {}) {
|
|
|
3554
3618
|
return;
|
|
3555
3619
|
}
|
|
3556
3620
|
a.info("开始查看位置", {
|
|
3557
|
-
platform:
|
|
3621
|
+
platform: f.type,
|
|
3558
3622
|
latitude: e.latitude,
|
|
3559
3623
|
longitude: e.longitude,
|
|
3560
3624
|
name: e.name
|
|
3561
|
-
}),
|
|
3625
|
+
}), C() ? _t(e) : kn(e);
|
|
3562
3626
|
}, {
|
|
3563
3627
|
context: "openLocation",
|
|
3564
3628
|
options: t
|
|
3565
3629
|
});
|
|
3566
3630
|
}
|
|
3567
3631
|
function Kn() {
|
|
3568
|
-
const t =
|
|
3632
|
+
const t = C();
|
|
3569
3633
|
return {
|
|
3570
3634
|
supported: $e(),
|
|
3571
|
-
environment:
|
|
3635
|
+
environment: f.type,
|
|
3572
3636
|
implementation: t ? "weixin" : "webview",
|
|
3573
3637
|
features: {
|
|
3574
3638
|
getLocation: !0,
|
|
@@ -3587,28 +3651,28 @@ function Kn() {
|
|
|
3587
3651
|
};
|
|
3588
3652
|
}
|
|
3589
3653
|
const j = /* @__PURE__ */ new Set(), J = /* @__PURE__ */ new Set();
|
|
3590
|
-
function
|
|
3654
|
+
function Mt(t, e, r) {
|
|
3591
3655
|
t.forEach((n) => {
|
|
3592
3656
|
if (typeof n == "function") {
|
|
3593
|
-
|
|
3657
|
+
d.safeExecute(() => n(e), { context: r });
|
|
3594
3658
|
return;
|
|
3595
3659
|
}
|
|
3596
3660
|
a.warn("监听回调不是函数,已跳过", { type: typeof n });
|
|
3597
3661
|
});
|
|
3598
3662
|
}
|
|
3599
3663
|
function Vn(t = {}) {
|
|
3600
|
-
return
|
|
3664
|
+
return d.safeExecute(() => {
|
|
3601
3665
|
var r, n;
|
|
3602
|
-
if (
|
|
3666
|
+
if (C()) {
|
|
3603
3667
|
const i = {
|
|
3604
|
-
errMsg: `当前环境 (${
|
|
3668
|
+
errMsg: `当前环境 (${f.type}) 不支持该接口`,
|
|
3605
3669
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
3606
3670
|
};
|
|
3607
|
-
a.error("当前环境不支持此接口", { platform:
|
|
3671
|
+
a.error("当前环境不支持此接口", { platform: f.type }), (r = t.fail) == null || r.call(t, i), (n = t.complete) == null || n.call(t, i);
|
|
3608
3672
|
return;
|
|
3609
3673
|
}
|
|
3610
3674
|
const e = Wn(t);
|
|
3611
|
-
a.info("正在开启定位监听"),
|
|
3675
|
+
a.info("正在开启定位监听"), O("startLocationUpdate", {
|
|
3612
3676
|
type: e.type,
|
|
3613
3677
|
needFullAccuracy: e.needFullAccuracy
|
|
3614
3678
|
}, {
|
|
@@ -3625,17 +3689,17 @@ function Vn(t = {}) {
|
|
|
3625
3689
|
}, { context: "startLocationUpdate" });
|
|
3626
3690
|
}
|
|
3627
3691
|
function qn(t = {}) {
|
|
3628
|
-
return
|
|
3692
|
+
return d.safeExecute(() => {
|
|
3629
3693
|
var e, r;
|
|
3630
|
-
if (
|
|
3694
|
+
if (C()) {
|
|
3631
3695
|
const n = {
|
|
3632
|
-
errMsg: `当前环境 (${
|
|
3696
|
+
errMsg: `当前环境 (${f.type}) 不支持该接口`,
|
|
3633
3697
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
3634
3698
|
};
|
|
3635
|
-
a.error("当前环境不支持此接口", { platform:
|
|
3699
|
+
a.error("当前环境不支持此接口", { platform: f.type }), (e = t.fail) == null || e.call(t, n), (r = t.complete) == null || r.call(t, n);
|
|
3636
3700
|
return;
|
|
3637
3701
|
}
|
|
3638
|
-
a.info("正在停止定位监听"),
|
|
3702
|
+
a.info("正在停止定位监听"), O("stopLocationUpdate", t, {
|
|
3639
3703
|
success: (n) => {
|
|
3640
3704
|
var i;
|
|
3641
3705
|
a.info("定位监听已停止"), (i = t.success) == null || i.call(t, n);
|
|
@@ -3649,9 +3713,9 @@ function qn(t = {}) {
|
|
|
3649
3713
|
}, { context: "stopLocationUpdate" });
|
|
3650
3714
|
}
|
|
3651
3715
|
function jn(t) {
|
|
3652
|
-
return
|
|
3653
|
-
if (
|
|
3654
|
-
a.warn("当前环境不支持此接口", { platform:
|
|
3716
|
+
return d.safeExecute(() => {
|
|
3717
|
+
if (C()) {
|
|
3718
|
+
a.warn("当前环境不支持此接口", { platform: f.type });
|
|
3655
3719
|
return;
|
|
3656
3720
|
}
|
|
3657
3721
|
if (typeof t != "function")
|
|
@@ -3660,20 +3724,20 @@ function jn(t) {
|
|
|
3660
3724
|
code: "INVALID_CALLBACK"
|
|
3661
3725
|
};
|
|
3662
3726
|
const e = j.size > 0;
|
|
3663
|
-
j.add(t), e || (a.debug("注册实时位置变化监听器"),
|
|
3727
|
+
j.add(t), e || (a.debug("注册实时位置变化监听器"), O("onLocationChange", { isPersistent: !0 }, {
|
|
3664
3728
|
success: (r) => {
|
|
3665
|
-
a.debug("收到实时位置推送", r),
|
|
3729
|
+
a.debug("收到实时位置推送", r), Mt(j, r, "onLocationChange");
|
|
3666
3730
|
},
|
|
3667
3731
|
fail: (r) => {
|
|
3668
|
-
a.warn("位置变化监听出错,请通过 onLocationChangeError 监听错误", r), j.delete(t), j.size === 0 &&
|
|
3732
|
+
a.warn("位置变化监听出错,请通过 onLocationChangeError 监听错误", r), j.delete(t), j.size === 0 && ie("onLocationChange");
|
|
3669
3733
|
}
|
|
3670
3734
|
}));
|
|
3671
3735
|
}, { context: "onLocationChange" });
|
|
3672
3736
|
}
|
|
3673
3737
|
function Jn(t) {
|
|
3674
|
-
return
|
|
3675
|
-
if (
|
|
3676
|
-
a.warn("当前环境不支持此接口", { platform:
|
|
3738
|
+
return d.safeExecute(() => {
|
|
3739
|
+
if (C()) {
|
|
3740
|
+
a.warn("当前环境不支持此接口", { platform: f.type });
|
|
3677
3741
|
return;
|
|
3678
3742
|
}
|
|
3679
3743
|
if (t && typeof t != "function")
|
|
@@ -3681,20 +3745,20 @@ function Jn(t) {
|
|
|
3681
3745
|
errMsg: "offLocationChange 回调必须是函数",
|
|
3682
3746
|
code: "INVALID_CALLBACK"
|
|
3683
3747
|
};
|
|
3684
|
-
t ? j.delete(t) : j.clear(), !(j.size > 0) && (a.info("移除位置变化监听器"),
|
|
3748
|
+
t ? j.delete(t) : j.clear(), !(j.size > 0) && (a.info("移除位置变化监听器"), O("offLocationChange", {}, {
|
|
3685
3749
|
success: () => {
|
|
3686
|
-
a.info("位置变化监听已移除"),
|
|
3750
|
+
a.info("位置变化监听已移除"), ie("onLocationChange");
|
|
3687
3751
|
},
|
|
3688
3752
|
fail: (e) => {
|
|
3689
|
-
a.error("移除位置变化监听失败", e),
|
|
3753
|
+
a.error("移除位置变化监听失败", e), ie("onLocationChange");
|
|
3690
3754
|
}
|
|
3691
3755
|
}));
|
|
3692
3756
|
}, { context: "offLocationChange" });
|
|
3693
3757
|
}
|
|
3694
3758
|
function Hn(t) {
|
|
3695
|
-
return
|
|
3696
|
-
if (
|
|
3697
|
-
a.warn("当前环境不支持此接口", { platform:
|
|
3759
|
+
return d.safeExecute(() => {
|
|
3760
|
+
if (C()) {
|
|
3761
|
+
a.warn("当前环境不支持此接口", { platform: f.type });
|
|
3698
3762
|
return;
|
|
3699
3763
|
}
|
|
3700
3764
|
if (typeof t != "function")
|
|
@@ -3703,20 +3767,20 @@ function Hn(t) {
|
|
|
3703
3767
|
code: "INVALID_CALLBACK"
|
|
3704
3768
|
};
|
|
3705
3769
|
const e = J.size > 0;
|
|
3706
|
-
J.add(t), e || (a.debug("注册位置更新错误监听器"),
|
|
3770
|
+
J.add(t), e || (a.debug("注册位置更新错误监听器"), O("onLocationChangeError", { isPersistent: !0 }, {
|
|
3707
3771
|
success: (r) => {
|
|
3708
|
-
a.warn("持续定位发生异常", r),
|
|
3772
|
+
a.warn("持续定位发生异常", r), Mt(J, r, "onLocationChangeError");
|
|
3709
3773
|
},
|
|
3710
3774
|
fail: (r) => {
|
|
3711
|
-
a.warn("位置更新错误监听注册失败", r), J.delete(t), J.size === 0 &&
|
|
3775
|
+
a.warn("位置更新错误监听注册失败", r), J.delete(t), J.size === 0 && ie("onLocationChangeError");
|
|
3712
3776
|
}
|
|
3713
3777
|
}));
|
|
3714
3778
|
}, { context: "onLocationChangeError" });
|
|
3715
3779
|
}
|
|
3716
3780
|
function zn(t) {
|
|
3717
|
-
return
|
|
3718
|
-
if (
|
|
3719
|
-
a.warn("当前环境不支持此接口", { platform:
|
|
3781
|
+
return d.safeExecute(() => {
|
|
3782
|
+
if (C()) {
|
|
3783
|
+
a.warn("当前环境不支持此接口", { platform: f.type });
|
|
3720
3784
|
return;
|
|
3721
3785
|
}
|
|
3722
3786
|
if (t && typeof t != "function")
|
|
@@ -3724,12 +3788,12 @@ function zn(t) {
|
|
|
3724
3788
|
errMsg: "offLocationChangeError 回调必须是函数",
|
|
3725
3789
|
code: "INVALID_CALLBACK"
|
|
3726
3790
|
};
|
|
3727
|
-
t ? J.delete(t) : J.clear(), !(J.size > 0) && (a.info("移除定位错误监听器"),
|
|
3791
|
+
t ? J.delete(t) : J.clear(), !(J.size > 0) && (a.info("移除定位错误监听器"), O("offLocationChangeError", {}, {
|
|
3728
3792
|
success: () => {
|
|
3729
|
-
a.info("定位错误监听已移除"),
|
|
3793
|
+
a.info("定位错误监听已移除"), ie("onLocationChangeError");
|
|
3730
3794
|
},
|
|
3731
3795
|
fail: (e) => {
|
|
3732
|
-
a.error("移除定位错误监听失败", e),
|
|
3796
|
+
a.error("移除定位错误监听失败", e), ie("onLocationChangeError");
|
|
3733
3797
|
}
|
|
3734
3798
|
}));
|
|
3735
3799
|
}, { context: "offLocationChangeError" });
|
|
@@ -3753,67 +3817,10 @@ function Xn(t = {}) {
|
|
|
3753
3817
|
}), e.longitude = null)), e;
|
|
3754
3818
|
}
|
|
3755
3819
|
function Rt() {
|
|
3756
|
-
return ["
|
|
3757
|
-
}
|
|
3758
|
-
function Ot(t) {
|
|
3759
|
-
return f.safeExecute(() => {
|
|
3760
|
-
var n;
|
|
3761
|
-
if (!window.wx) {
|
|
3762
|
-
const i = {
|
|
3763
|
-
errMsg: "微信JS-SDK未加载",
|
|
3764
|
-
code: "WEIXIN_SDK_NOT_LOADED"
|
|
3765
|
-
};
|
|
3766
|
-
(n = t.fail) == null || n.call(t, i);
|
|
3767
|
-
return;
|
|
3768
|
-
}
|
|
3769
|
-
if (!ee()) {
|
|
3770
|
-
a.info("等待微信配置完成"), z().then(() => Ot(t)).catch((i) => {
|
|
3771
|
-
var s;
|
|
3772
|
-
a.error("微信配置失败", i), (s = t.fail) == null || s.call(t, { errMsg: `微信配置失败: ${i.message}` });
|
|
3773
|
-
});
|
|
3774
|
-
return;
|
|
3775
|
-
}
|
|
3776
|
-
a.debug("调用微信位置选择", t);
|
|
3777
|
-
const e = {
|
|
3778
|
-
success: (i) => {
|
|
3779
|
-
var o;
|
|
3780
|
-
a.info("微信位置选择成功", {
|
|
3781
|
-
name: i.name,
|
|
3782
|
-
address: i.address,
|
|
3783
|
-
latitude: i.latitude,
|
|
3784
|
-
longitude: i.longitude
|
|
3785
|
-
});
|
|
3786
|
-
const s = {
|
|
3787
|
-
name: i.name,
|
|
3788
|
-
// 位置名称
|
|
3789
|
-
address: i.address,
|
|
3790
|
-
// 详细地址
|
|
3791
|
-
latitude: i.latitude,
|
|
3792
|
-
// 纬度
|
|
3793
|
-
longitude: i.longitude,
|
|
3794
|
-
// 经度
|
|
3795
|
-
errMsg: "chooseLocation:ok"
|
|
3796
|
-
};
|
|
3797
|
-
(o = t.success) == null || o.call(t, s);
|
|
3798
|
-
},
|
|
3799
|
-
fail: (i) => {
|
|
3800
|
-
var s;
|
|
3801
|
-
a.error("微信位置选择失败", i), (s = t.fail) == null || s.call(t, i);
|
|
3802
|
-
},
|
|
3803
|
-
complete: t.complete
|
|
3804
|
-
}, r = {};
|
|
3805
|
-
t.latitude !== null && t.latitude !== void 0 && (r.latitude = t.latitude), t.longitude !== null && t.longitude !== void 0 && (r.longitude = t.longitude), window.wx.chooseLocation(p(g({}, r), {
|
|
3806
|
-
success: e.success,
|
|
3807
|
-
fail: e.fail,
|
|
3808
|
-
complete: e.complete
|
|
3809
|
-
}));
|
|
3810
|
-
}, {
|
|
3811
|
-
context: "chooseLocationInWeixin",
|
|
3812
|
-
platform: "weixin"
|
|
3813
|
-
});
|
|
3820
|
+
return ["webview", "UniApp", "plus", "nvue", "uvue", "offline"].includes(f.type);
|
|
3814
3821
|
}
|
|
3815
3822
|
function Zn(t) {
|
|
3816
|
-
return
|
|
3823
|
+
return d.safeExecute(() => {
|
|
3817
3824
|
a.debug("通过 WebView 桥接调用位置选择", t);
|
|
3818
3825
|
const e = {
|
|
3819
3826
|
// 禁用超时清理,等待用户操作完成后才清理
|
|
@@ -3833,7 +3840,7 @@ function Zn(t) {
|
|
|
3833
3840
|
},
|
|
3834
3841
|
complete: t.complete
|
|
3835
3842
|
};
|
|
3836
|
-
t.latitude !== null && t.latitude !== void 0 && (e.latitude = t.latitude), t.longitude !== null && t.longitude !== void 0 && (e.longitude = t.longitude),
|
|
3843
|
+
t.latitude !== null && t.latitude !== void 0 && (e.latitude = t.latitude), t.longitude !== null && t.longitude !== void 0 && (e.longitude = t.longitude), O("chooseLocation", e, {
|
|
3837
3844
|
success: (r) => {
|
|
3838
3845
|
e.success(r);
|
|
3839
3846
|
},
|
|
@@ -3848,22 +3855,22 @@ function Zn(t) {
|
|
|
3848
3855
|
});
|
|
3849
3856
|
}
|
|
3850
3857
|
function Qn(t = {}) {
|
|
3851
|
-
return
|
|
3858
|
+
return d.safeExecute(() => {
|
|
3852
3859
|
var r;
|
|
3853
3860
|
if (!Rt()) {
|
|
3854
3861
|
const n = {
|
|
3855
|
-
errMsg: `当前环境 (${
|
|
3862
|
+
errMsg: `当前环境 (${f.type}) 不支持位置选择功能`,
|
|
3856
3863
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
3857
3864
|
};
|
|
3858
|
-
a.error("平台不支持位置选择", { platform:
|
|
3865
|
+
a.error("平台不支持位置选择", { platform: f.type }), (r = t.fail) == null || r.call(t, n);
|
|
3859
3866
|
return;
|
|
3860
3867
|
}
|
|
3861
3868
|
const e = Xn(t);
|
|
3862
3869
|
a.info("开始选择位置", {
|
|
3863
|
-
platform:
|
|
3870
|
+
platform: f.type,
|
|
3864
3871
|
latitude: e.latitude,
|
|
3865
3872
|
longitude: e.longitude
|
|
3866
|
-
}),
|
|
3873
|
+
}), C() || Zn(e);
|
|
3867
3874
|
}, {
|
|
3868
3875
|
context: "chooseLocation",
|
|
3869
3876
|
options: t
|
|
@@ -3872,8 +3879,8 @@ function Qn(t = {}) {
|
|
|
3872
3879
|
function ei() {
|
|
3873
3880
|
return {
|
|
3874
3881
|
supported: Rt(),
|
|
3875
|
-
environment:
|
|
3876
|
-
implementation:
|
|
3882
|
+
environment: f.type,
|
|
3883
|
+
implementation: C() ? "weixin" : "webview",
|
|
3877
3884
|
features: {
|
|
3878
3885
|
chooseLocation: !0,
|
|
3879
3886
|
// 支持位置选择
|
|
@@ -3894,7 +3901,7 @@ function Ne(t = "", e = "targetPath") {
|
|
|
3894
3901
|
const r = t.trim(), [, n = ""] = r.split("?");
|
|
3895
3902
|
return { path: r, query: n };
|
|
3896
3903
|
}
|
|
3897
|
-
function
|
|
3904
|
+
function Ot(t = "", e = "webTarget") {
|
|
3898
3905
|
if (!t || typeof t != "string")
|
|
3899
3906
|
throw { errMsg: `share: ${e} 必须是公网链接,例如 https://example.com/path?a=1`, code: "PARAM_INVALID" };
|
|
3900
3907
|
const r = t.trim();
|
|
@@ -3909,8 +3916,8 @@ function ri() {
|
|
|
3909
3916
|
if (!r) return e({ errMsg: "当前环境不支持 plus", code: "PLUS_UNAVAILABLE" });
|
|
3910
3917
|
if (r.plus) return t(r.plus);
|
|
3911
3918
|
const n = setTimeout(() => {
|
|
3912
|
-
var
|
|
3913
|
-
(u = (
|
|
3919
|
+
var l, u;
|
|
3920
|
+
(u = (l = r.document) == null ? void 0 : l.removeEventListener) == null || u.call(l, "plusready", i), e({ errMsg: "等待 plusready 超时", code: "PLUS_READY_TIMEOUT" });
|
|
3914
3921
|
}, 8e3);
|
|
3915
3922
|
function i() {
|
|
3916
3923
|
clearTimeout(n), t(r.plus);
|
|
@@ -3971,9 +3978,9 @@ function si(t, e) {
|
|
|
3971
3978
|
throw { errMsg: (n == null ? void 0 : n.errMsg) || "shareDirected: 小程序环境下 payload.target 不合法", code: (n == null ? void 0 : n.code) || "PARAM_INVALID" };
|
|
3972
3979
|
}
|
|
3973
3980
|
if (e.isAppPlus) {
|
|
3974
|
-
const n = (o,
|
|
3981
|
+
const n = (o, l) => {
|
|
3975
3982
|
try {
|
|
3976
|
-
return
|
|
3983
|
+
return Ot(o, l);
|
|
3977
3984
|
} catch (u) {
|
|
3978
3985
|
return "";
|
|
3979
3986
|
}
|
|
@@ -4008,7 +4015,7 @@ function ci(t) {
|
|
|
4008
4015
|
};
|
|
4009
4016
|
}
|
|
4010
4017
|
function ui(t) {
|
|
4011
|
-
return
|
|
4018
|
+
return I(this, null, function* () {
|
|
4012
4019
|
yield ri();
|
|
4013
4020
|
const e = yield ni(), { message: r, degradedFromText: n } = ci(t);
|
|
4014
4021
|
return new Promise((i, s) => {
|
|
@@ -4020,7 +4027,7 @@ function ui(t) {
|
|
|
4020
4027
|
});
|
|
4021
4028
|
});
|
|
4022
4029
|
}
|
|
4023
|
-
function
|
|
4030
|
+
function Nt(t, e = "share") {
|
|
4024
4031
|
const r = typeof window != "undefined" && window.wx && window.wx.miniProgram;
|
|
4025
4032
|
if (!r || typeof r.postMessage != "function")
|
|
4026
4033
|
throw { errMsg: `当前微信小程序容器未注入 postMessage 能力,无法发起 ${e}`, code: "MINIPROGRAM_BRIDGE_UNAVAILABLE" };
|
|
@@ -4036,12 +4043,36 @@ function fi(t = {}) {
|
|
|
4036
4043
|
if (!e.title) throw { errMsg: "shareMiniProgramCard: payload.title 必填", code: "PARAM_MISSING" };
|
|
4037
4044
|
if (!e.imageUrl) throw { errMsg: "shareMiniProgramCard: payload.imageUrl 必填", code: "PARAM_MISSING" };
|
|
4038
4045
|
if (!e.targetPath) throw { errMsg: "shareMiniProgramCard: payload.targetPath 必填", code: "PARAM_MISSING" };
|
|
4039
|
-
if (!e.appid) throw { errMsg: "shareMiniProgramCard: payload.appid 必填", code: "PARAM_MISSING" };
|
|
4040
4046
|
return Ne(e.targetPath, "targetPath"), { payload: e, success: t.success, fail: t.fail, complete: t.complete };
|
|
4041
4047
|
}
|
|
4048
|
+
function bt(t) {
|
|
4049
|
+
switch (String(t || "release").trim().toLowerCase()) {
|
|
4050
|
+
case "develop":
|
|
4051
|
+
case "development":
|
|
4052
|
+
case "test":
|
|
4053
|
+
return "test";
|
|
4054
|
+
case "trial":
|
|
4055
|
+
case "preview":
|
|
4056
|
+
case "experience":
|
|
4057
|
+
return "preview";
|
|
4058
|
+
case "release":
|
|
4059
|
+
case "formal":
|
|
4060
|
+
case "production":
|
|
4061
|
+
return "release";
|
|
4062
|
+
default:
|
|
4063
|
+
throw { errMsg: 'shareMiniProgramCard: payload.envVersion 仅支持 "develop"|"trial"|"release"', code: "PARAM_INVALID" };
|
|
4064
|
+
}
|
|
4065
|
+
}
|
|
4042
4066
|
function di(t) {
|
|
4043
4067
|
const { payload: e } = t;
|
|
4044
|
-
|
|
4068
|
+
if (!e.appid)
|
|
4069
|
+
throw { errMsg: "shareMiniProgramCard: App 环境下 payload.appid 必填", code: "PARAM_MISSING" };
|
|
4070
|
+
try {
|
|
4071
|
+
Ot(e.webUrl, "webUrl");
|
|
4072
|
+
} catch (r) {
|
|
4073
|
+
throw { errMsg: "shareMiniProgramCard: App 环境下 payload.webUrl 必填,且必须是公网链接", code: (r == null ? void 0 : r.code) || "PARAM_INVALID" };
|
|
4074
|
+
}
|
|
4075
|
+
return bt(e.envVersion), t;
|
|
4045
4076
|
}
|
|
4046
4077
|
function gi(t) {
|
|
4047
4078
|
const { payload: e } = t, r = Ne(e.targetPath, "targetPath");
|
|
@@ -4063,25 +4094,25 @@ function hi(t) {
|
|
|
4063
4094
|
miniProgram: {
|
|
4064
4095
|
id: e.appid,
|
|
4065
4096
|
path: e.targetPath,
|
|
4066
|
-
type: e.envVersion
|
|
4097
|
+
type: bt(e.envVersion),
|
|
4067
4098
|
webUrl: e.webUrl
|
|
4068
4099
|
}
|
|
4069
4100
|
};
|
|
4070
4101
|
}
|
|
4071
|
-
function
|
|
4102
|
+
function pi(t, e) {
|
|
4072
4103
|
return { type: "qsh_api_call", api: "shareMiniProgramCard", params: { miniProgramShare: gi(t), rowCustom: e }, timestamp: Date.now() };
|
|
4073
4104
|
}
|
|
4074
|
-
function
|
|
4075
|
-
return
|
|
4105
|
+
function mi(t) {
|
|
4106
|
+
return I(this, null, function* () {
|
|
4076
4107
|
return new Promise((e, r) => {
|
|
4077
|
-
|
|
4108
|
+
O("shareMiniProgramCard", { appShare: hi(t) }, { success: (n) => e(n || {}), fail: (n) => r(n) });
|
|
4078
4109
|
});
|
|
4079
4110
|
});
|
|
4080
4111
|
}
|
|
4081
|
-
function
|
|
4082
|
-
return
|
|
4112
|
+
function Tt(t = {}) {
|
|
4113
|
+
return d.safeExecute(
|
|
4083
4114
|
() => {
|
|
4084
|
-
var s, o,
|
|
4115
|
+
var s, o, l, u, p, M, _, $, ce, R, F;
|
|
4085
4116
|
let e;
|
|
4086
4117
|
try {
|
|
4087
4118
|
e = ai(t);
|
|
@@ -4092,25 +4123,25 @@ function bt(t = {}) {
|
|
|
4092
4123
|
try {
|
|
4093
4124
|
e = si(e, r);
|
|
4094
4125
|
} catch (w) {
|
|
4095
|
-
return (o = e.fail) == null || o.call(e, w), (
|
|
4126
|
+
return (o = e.fail) == null || o.call(e, w), (l = e.complete) == null || l.call(e, w), Promise.reject(w);
|
|
4096
4127
|
}
|
|
4097
4128
|
const n = ii(r);
|
|
4098
|
-
if (r.
|
|
4129
|
+
if (r.isAppPlus)
|
|
4099
4130
|
return ui(e).then((w) => {
|
|
4100
4131
|
var ue, je;
|
|
4101
|
-
const
|
|
4102
|
-
return (ue = e.success) == null || ue.call(e,
|
|
4132
|
+
const k = m(g({}, (w == null ? void 0 : w.data) || {}), { hint: n });
|
|
4133
|
+
return (ue = e.success) == null || ue.call(e, k), (je = e.complete) == null || je.call(e, k), k;
|
|
4103
4134
|
}).catch((w) => {
|
|
4104
|
-
var
|
|
4105
|
-
return (
|
|
4135
|
+
var k, ue;
|
|
4136
|
+
return (k = e.fail) == null || k.call(e, w), (ue = e.complete) == null || ue.call(e, w), Promise.reject(w);
|
|
4106
4137
|
});
|
|
4107
4138
|
if (r.isWeixinMiniProgram)
|
|
4108
4139
|
try {
|
|
4109
|
-
|
|
4140
|
+
Nt(li(e, t.rowCustom), "shareDirected");
|
|
4110
4141
|
const w = { success: !0, hint: n };
|
|
4111
|
-
return (u = e.success) == null || u.call(e, w), (
|
|
4142
|
+
return (u = e.success) == null || u.call(e, w), (p = e.complete) == null || p.call(e, w), Promise.resolve(w);
|
|
4112
4143
|
} catch (w) {
|
|
4113
|
-
return (
|
|
4144
|
+
return (M = e.fail) == null || M.call(e, w), (_ = e.complete) == null || _.call(e, w), Promise.reject(w);
|
|
4114
4145
|
}
|
|
4115
4146
|
if (r.type === "h5" && !r.isUniAppWebView && !r.isOfflineWebview) {
|
|
4116
4147
|
const w = { errMsg: "当前页面不在宿主 WebView 中,无法分享。请在 unified-platform-app 内打开该 H5 再重试。", code: "NOT_IN_CONTAINER" };
|
|
@@ -4124,13 +4155,13 @@ function bt(t = {}) {
|
|
|
4124
4155
|
}
|
|
4125
4156
|
function wi(t = {}) {
|
|
4126
4157
|
return new Promise((e, r) => {
|
|
4127
|
-
|
|
4158
|
+
Tt(m(g({}, t), { success: e, fail: r }));
|
|
4128
4159
|
});
|
|
4129
4160
|
}
|
|
4130
4161
|
function vt(t = {}) {
|
|
4131
|
-
return
|
|
4162
|
+
return d.safeExecute(
|
|
4132
4163
|
() => {
|
|
4133
|
-
var s, o,
|
|
4164
|
+
var s, o, l, u, p, M, _, $, ce;
|
|
4134
4165
|
let e;
|
|
4135
4166
|
try {
|
|
4136
4167
|
e = fi(t);
|
|
@@ -4138,29 +4169,29 @@ function vt(t = {}) {
|
|
|
4138
4169
|
return (s = t.fail) == null || s.call(t, R), Promise.reject(R);
|
|
4139
4170
|
}
|
|
4140
4171
|
const r = H(!0);
|
|
4141
|
-
if (r.
|
|
4172
|
+
if (r.isAppPlus)
|
|
4142
4173
|
try {
|
|
4143
4174
|
e = di(e);
|
|
4144
4175
|
} catch (R) {
|
|
4145
|
-
return (o = e.fail) == null || o.call(e, R), (
|
|
4176
|
+
return (o = e.fail) == null || o.call(e, R), (l = e.complete) == null || l.call(e, R), Promise.reject(R);
|
|
4146
4177
|
}
|
|
4147
4178
|
const n = r.isWeixinMiniProgram ? "已同步小程序卡片内容,请点击右上角“···”后发送给朋友。" : "正在拉起微信发送给朋友面板,请继续完成小程序卡片分享。";
|
|
4148
|
-
if (r.
|
|
4149
|
-
return
|
|
4150
|
-
var w,
|
|
4151
|
-
const F =
|
|
4152
|
-
return (w = e.success) == null || w.call(e, F), (
|
|
4179
|
+
if (r.isAppPlus)
|
|
4180
|
+
return mi(e).then((R) => {
|
|
4181
|
+
var w, k;
|
|
4182
|
+
const F = m(g({}, R || {}), { hint: n });
|
|
4183
|
+
return (w = e.success) == null || w.call(e, F), (k = e.complete) == null || k.call(e, F), F;
|
|
4153
4184
|
}).catch((R) => {
|
|
4154
4185
|
var F, w;
|
|
4155
4186
|
return (F = e.fail) == null || F.call(e, R), (w = e.complete) == null || w.call(e, R), Promise.reject(R);
|
|
4156
4187
|
});
|
|
4157
4188
|
if (r.isWeixinMiniProgram)
|
|
4158
4189
|
try {
|
|
4159
|
-
|
|
4190
|
+
Nt(pi(e, t.rowCustom), "shareMiniProgramCard");
|
|
4160
4191
|
const R = { success: !0, hint: n };
|
|
4161
|
-
return (u = e.success) == null || u.call(e, R), (
|
|
4192
|
+
return (u = e.success) == null || u.call(e, R), (p = e.complete) == null || p.call(e, R), Promise.resolve(R);
|
|
4162
4193
|
} catch (R) {
|
|
4163
|
-
return (
|
|
4194
|
+
return (M = e.fail) == null || M.call(e, R), (_ = e.complete) == null || _.call(e, R), Promise.reject(R);
|
|
4164
4195
|
}
|
|
4165
4196
|
const i = { errMsg: "当前环境暂不支持 shareMiniProgramCard,请在 App 或微信小程序容器内使用。", code: "ENV_NOT_SUPPORTED" };
|
|
4166
4197
|
return ($ = e.fail) == null || $.call(e, i), (ce = e.complete) == null || ce.call(e, i), Promise.reject(i);
|
|
@@ -4170,7 +4201,7 @@ function vt(t = {}) {
|
|
|
4170
4201
|
}
|
|
4171
4202
|
function Ei(t = {}) {
|
|
4172
4203
|
return new Promise((e, r) => {
|
|
4173
|
-
vt(
|
|
4204
|
+
vt(m(g({}, t), { success: e, fail: r }));
|
|
4174
4205
|
});
|
|
4175
4206
|
}
|
|
4176
4207
|
const yi = {
|
|
@@ -4188,21 +4219,21 @@ const yi = {
|
|
|
4188
4219
|
services: []
|
|
4189
4220
|
// 指定服务 UUID 列表
|
|
4190
4221
|
};
|
|
4191
|
-
function
|
|
4222
|
+
function be(t = {}) {
|
|
4192
4223
|
return g(g({}, Ii), t);
|
|
4193
4224
|
}
|
|
4194
4225
|
function we() {
|
|
4195
|
-
return ["weixin", "webview", "UniApp", "plus", "nvue", "uvue", "offline"].includes(
|
|
4226
|
+
return ["weixin", "webview", "UniApp", "plus", "nvue", "uvue", "offline"].includes(f.type);
|
|
4196
4227
|
}
|
|
4197
4228
|
function Ai(t) {
|
|
4198
|
-
return
|
|
4229
|
+
return d.safeExecute(() => I(null, null, function* () {
|
|
4199
4230
|
var e;
|
|
4200
4231
|
if (!window.wx) {
|
|
4201
4232
|
const r = { errMsg: "微信JS-SDK未加载", code: "WEIXIN_SDK_NOT_LOADED" };
|
|
4202
4233
|
(e = t.fail) == null || e.call(t, r);
|
|
4203
4234
|
return;
|
|
4204
4235
|
}
|
|
4205
|
-
|
|
4236
|
+
oe() || (a.info("等待微信配置完成"), yield Q()), wx.openBluetoothAdapter({
|
|
4206
4237
|
success: () => {
|
|
4207
4238
|
a.info("微信蓝牙适配器已打开"), Lt(t);
|
|
4208
4239
|
},
|
|
@@ -4214,8 +4245,8 @@ function Ai(t) {
|
|
|
4214
4245
|
}), { context: "openBluetoothAdapterInWeixin" });
|
|
4215
4246
|
}
|
|
4216
4247
|
function Pi(t) {
|
|
4217
|
-
return
|
|
4218
|
-
a.debug("通过 WebView 桥接调用蓝牙功能", t),
|
|
4248
|
+
return d.safeExecute(() => {
|
|
4249
|
+
a.debug("通过 WebView 桥接调用蓝牙功能", t), O("bluetooth", t, {
|
|
4219
4250
|
success: (e) => {
|
|
4220
4251
|
var r;
|
|
4221
4252
|
a.info("UniApp 蓝牙调用成功", e), (r = t.success) == null || r.call(t, e);
|
|
@@ -4228,10 +4259,10 @@ function Pi(t) {
|
|
|
4228
4259
|
});
|
|
4229
4260
|
}, { context: "bluetoothInUniApp" });
|
|
4230
4261
|
}
|
|
4231
|
-
function
|
|
4232
|
-
return
|
|
4262
|
+
function Ci(t) {
|
|
4263
|
+
return d.safeExecute(() => {
|
|
4233
4264
|
var e;
|
|
4234
|
-
a.debug("通过 WebView 桥接调用蓝牙设备搜索功能", t),
|
|
4265
|
+
a.debug("通过 WebView 桥接调用蓝牙设备搜索功能", t), O("bluetoothDevicesDiscovery", {
|
|
4235
4266
|
action: "startBluetoothDevicesDiscovery",
|
|
4236
4267
|
params: {
|
|
4237
4268
|
services: t.services || [],
|
|
@@ -4251,10 +4282,10 @@ function _i(t) {
|
|
|
4251
4282
|
}, { context: "startBluetoothDevicesDiscoveryInUniApp" });
|
|
4252
4283
|
}
|
|
4253
4284
|
const ye = /* @__PURE__ */ new Set();
|
|
4254
|
-
function
|
|
4255
|
-
return
|
|
4285
|
+
function _i(t, e = {}) {
|
|
4286
|
+
return d.safeExecute(() => {
|
|
4256
4287
|
var r;
|
|
4257
|
-
return ye.add(t), ye.size === 1 &&
|
|
4288
|
+
return ye.add(t), ye.size === 1 && O("onBluetoothDeviceFound", {
|
|
4258
4289
|
action: "onBluetoothDeviceFound",
|
|
4259
4290
|
isPersistent: !0,
|
|
4260
4291
|
params: {
|
|
@@ -4264,7 +4295,7 @@ function Mi(t, e = {}) {
|
|
|
4264
4295
|
}, {
|
|
4265
4296
|
success: (n) => {
|
|
4266
4297
|
ye.forEach((i) => {
|
|
4267
|
-
typeof i == "function" ?
|
|
4298
|
+
typeof i == "function" ? d.safeExecute(() => i(n), { context: "BluetoothDeviceCallback" }) : console.warn("[BluetoothDeviceCallback] 不是函数:", i);
|
|
4268
4299
|
});
|
|
4269
4300
|
},
|
|
4270
4301
|
fail: (n) => {
|
|
@@ -4275,10 +4306,10 @@ function Mi(t, e = {}) {
|
|
|
4275
4306
|
}), () => ye.delete(t);
|
|
4276
4307
|
}, { context: "qsh_onBluetoothDeviceFound" });
|
|
4277
4308
|
}
|
|
4278
|
-
function
|
|
4279
|
-
return
|
|
4309
|
+
function Mi(t) {
|
|
4310
|
+
return d.safeExecute(() => {
|
|
4280
4311
|
var e;
|
|
4281
|
-
a.debug("通过 WebView 桥接调用蓝牙连接功能", t),
|
|
4312
|
+
a.debug("通过 WebView 桥接调用蓝牙连接功能", t), O("bluetoothConnection", {
|
|
4282
4313
|
action: "createBLEConnection",
|
|
4283
4314
|
params: {
|
|
4284
4315
|
deviceId: t.deviceId,
|
|
@@ -4299,89 +4330,89 @@ function Ci(t) {
|
|
|
4299
4330
|
}, { context: "createBLEConnectionInUniApp" });
|
|
4300
4331
|
}
|
|
4301
4332
|
function Ri(t = {}) {
|
|
4302
|
-
return
|
|
4333
|
+
return d.safeExecute(() => {
|
|
4303
4334
|
var r;
|
|
4304
4335
|
if (!we()) {
|
|
4305
4336
|
const n = {
|
|
4306
|
-
errMsg: `当前环境 (${
|
|
4337
|
+
errMsg: `当前环境 (${f.type}) 不支持蓝牙功能`,
|
|
4307
4338
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
4308
4339
|
};
|
|
4309
|
-
a.error("平台不支持蓝牙", { platform:
|
|
4340
|
+
a.error("平台不支持蓝牙", { platform: f.type }), (r = t.fail) == null || r.call(t, n);
|
|
4310
4341
|
return;
|
|
4311
4342
|
}
|
|
4312
|
-
const e =
|
|
4343
|
+
const e = be(t);
|
|
4313
4344
|
a.info("开始蓝牙操作", {
|
|
4314
|
-
platform:
|
|
4345
|
+
platform: f.type,
|
|
4315
4346
|
services: e.services,
|
|
4316
4347
|
allowDuplicatesKey: e.allowDuplicatesKey
|
|
4317
|
-
}),
|
|
4348
|
+
}), C() ? Ai(e) : Pi(e);
|
|
4318
4349
|
}, { context: "openBluetoothAdapter", options: t });
|
|
4319
4350
|
}
|
|
4320
|
-
function
|
|
4321
|
-
return
|
|
4351
|
+
function Si(t = {}) {
|
|
4352
|
+
return d.safeExecute(() => {
|
|
4322
4353
|
var r, n;
|
|
4323
4354
|
if (!we()) {
|
|
4324
4355
|
const i = {
|
|
4325
|
-
errMsg: `当前环境 (${
|
|
4356
|
+
errMsg: `当前环境 (${f.type}) 不支持蓝牙功能`,
|
|
4326
4357
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
4327
4358
|
};
|
|
4328
|
-
a.error("平台不支持蓝牙", { platform:
|
|
4359
|
+
a.error("平台不支持蓝牙", { platform: f.type }), (r = t.fail) == null || r.call(t, i), (n = t.complete) == null || n.call(t, i);
|
|
4329
4360
|
return;
|
|
4330
4361
|
}
|
|
4331
|
-
const e =
|
|
4362
|
+
const e = be(t);
|
|
4332
4363
|
a.info("开始搜索蓝牙设备", {
|
|
4333
|
-
platform:
|
|
4364
|
+
platform: f.type,
|
|
4334
4365
|
services: e.services,
|
|
4335
4366
|
allowDuplicatesKey: e.allowDuplicatesKey
|
|
4336
|
-
}),
|
|
4367
|
+
}), C() ? startBluetoothDevicesDiscoveryInWeixin(e) : Ci(e);
|
|
4337
4368
|
}, { context: "startBluetoothDevicesDiscovery", options: t });
|
|
4338
4369
|
}
|
|
4339
4370
|
function Lt(t, e = {}) {
|
|
4340
|
-
return
|
|
4371
|
+
return d.safeExecute(() => {
|
|
4341
4372
|
var n, i;
|
|
4342
4373
|
if (!we()) {
|
|
4343
4374
|
const s = {
|
|
4344
|
-
errMsg: `当前环境 (${
|
|
4375
|
+
errMsg: `当前环境 (${f.type}) 不支持蓝牙功能`,
|
|
4345
4376
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
4346
4377
|
};
|
|
4347
|
-
a.error("平台不支持蓝牙", { platform:
|
|
4378
|
+
a.error("平台不支持蓝牙", { platform: f.type }), (n = e.fail) == null || n.call(e, s), (i = e.complete) == null || i.call(e, s);
|
|
4348
4379
|
return;
|
|
4349
4380
|
}
|
|
4350
|
-
const r =
|
|
4351
|
-
a.info("注册蓝牙设备发现监听", { platform:
|
|
4381
|
+
const r = be(e);
|
|
4382
|
+
a.info("注册蓝牙设备发现监听", { platform: f.type }), C() ? onBluetoothDeviceFoundInWeixin(r) : _i(t, r);
|
|
4352
4383
|
}, { context: "onBluetoothDeviceFound", options: e });
|
|
4353
4384
|
}
|
|
4354
|
-
function
|
|
4355
|
-
return
|
|
4356
|
-
var s, o,
|
|
4385
|
+
function Oi(t = {}) {
|
|
4386
|
+
return d.safeExecute(() => {
|
|
4387
|
+
var s, o, l, u;
|
|
4357
4388
|
if (!we()) {
|
|
4358
|
-
const
|
|
4359
|
-
errMsg: `当前环境 (${
|
|
4389
|
+
const p = {
|
|
4390
|
+
errMsg: `当前环境 (${f.type}) 不支持蓝牙功能`,
|
|
4360
4391
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
4361
4392
|
};
|
|
4362
|
-
a.error("平台不支持蓝牙连接", { platform:
|
|
4393
|
+
a.error("平台不支持蓝牙连接", { platform: f.type }), (s = t.fail) == null || s.call(t, p), (o = t.complete) == null || o.call(t, p);
|
|
4363
4394
|
return;
|
|
4364
4395
|
}
|
|
4365
|
-
const e =
|
|
4396
|
+
const e = be(t), { name: r, deviceId: n, autoConnect: i = !1 } = e;
|
|
4366
4397
|
if (!n) {
|
|
4367
|
-
const
|
|
4368
|
-
(
|
|
4398
|
+
const p = { errMsg: "缺少 deviceId 参数", code: "INVALID_PARAMS" };
|
|
4399
|
+
(l = t.fail) == null || l.call(t, p), (u = t.complete) == null || u.call(t, p);
|
|
4369
4400
|
return;
|
|
4370
4401
|
}
|
|
4371
|
-
a.info("创建蓝牙连接", { deviceId: n, autoConnect: i, platform:
|
|
4402
|
+
a.info("创建蓝牙连接", { deviceId: n, autoConnect: i, platform: f.type }), C() ? uni.createBLEConnection({
|
|
4372
4403
|
deviceId: n,
|
|
4373
4404
|
autoConnect: i,
|
|
4374
4405
|
success: t.success,
|
|
4375
4406
|
fail: t.fail,
|
|
4376
4407
|
complete: t.complete
|
|
4377
|
-
}) :
|
|
4408
|
+
}) : Mi(e);
|
|
4378
4409
|
}, { context: "createBLEConnection", options: t });
|
|
4379
4410
|
}
|
|
4380
4411
|
function Ni() {
|
|
4381
4412
|
return {
|
|
4382
4413
|
supported: we(),
|
|
4383
|
-
environment:
|
|
4384
|
-
implementation:
|
|
4414
|
+
environment: f.type,
|
|
4415
|
+
implementation: C() ? "weixin" : "webview",
|
|
4385
4416
|
features: {
|
|
4386
4417
|
discovery: !0,
|
|
4387
4418
|
connect: !0,
|
|
@@ -4391,18 +4422,18 @@ function Ni() {
|
|
|
4391
4422
|
}
|
|
4392
4423
|
};
|
|
4393
4424
|
}
|
|
4394
|
-
const
|
|
4425
|
+
const bi = {
|
|
4395
4426
|
// TODO: 添加更多默认配置
|
|
4396
4427
|
};
|
|
4397
|
-
function
|
|
4398
|
-
return g(g({},
|
|
4428
|
+
function Ti(t = {}) {
|
|
4429
|
+
return g(g({}, bi), t);
|
|
4399
4430
|
}
|
|
4400
4431
|
function xt() {
|
|
4401
|
-
return ["webview", "UniApp", "plus", "nvue", "uvue", "offline"].includes(
|
|
4432
|
+
return ["webview", "UniApp", "plus", "nvue", "uvue", "offline"].includes(f.type);
|
|
4402
4433
|
}
|
|
4403
4434
|
function vi(t) {
|
|
4404
|
-
return
|
|
4405
|
-
a.debug("通过 WebView 桥接调用打印PDF", t),
|
|
4435
|
+
return d.safeExecute(() => {
|
|
4436
|
+
a.debug("通过 WebView 桥接调用打印PDF", t), O("printPdf", m(g({}, t), {
|
|
4406
4437
|
isPersistent: !0
|
|
4407
4438
|
// 强制禁用超时自动清理
|
|
4408
4439
|
}), {
|
|
@@ -4422,18 +4453,18 @@ function vi(t) {
|
|
|
4422
4453
|
});
|
|
4423
4454
|
}
|
|
4424
4455
|
function Li(t = {}) {
|
|
4425
|
-
return
|
|
4456
|
+
return d.safeExecute(() => {
|
|
4426
4457
|
var r;
|
|
4427
4458
|
if (!xt()) {
|
|
4428
4459
|
const n = {
|
|
4429
|
-
errMsg: `当前环境 (${
|
|
4460
|
+
errMsg: `当前环境 (${f.type}) 不支持打印PDF功能`,
|
|
4430
4461
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
4431
4462
|
};
|
|
4432
|
-
a.error("平台不支持打印PDF", { platform:
|
|
4463
|
+
a.error("平台不支持打印PDF", { platform: f.type }), (r = t.fail) == null || r.call(t, n);
|
|
4433
4464
|
return;
|
|
4434
4465
|
}
|
|
4435
|
-
const e =
|
|
4436
|
-
a.info("开始打印PDF", { platform:
|
|
4466
|
+
const e = Ti(t);
|
|
4467
|
+
a.info("开始打印PDF", { platform: f.type }), vi(e);
|
|
4437
4468
|
}, {
|
|
4438
4469
|
context: "printPdf",
|
|
4439
4470
|
options: t
|
|
@@ -4442,7 +4473,7 @@ function Li(t = {}) {
|
|
|
4442
4473
|
function xi() {
|
|
4443
4474
|
return {
|
|
4444
4475
|
supported: xt(),
|
|
4445
|
-
environment:
|
|
4476
|
+
environment: f.type,
|
|
4446
4477
|
implementation: "uniapp",
|
|
4447
4478
|
features: {
|
|
4448
4479
|
asyncSupport: !0
|
|
@@ -4465,20 +4496,20 @@ function Di(t = {}) {
|
|
|
4465
4496
|
return e.idCardNumber = e.idCardNumber.trim(), e;
|
|
4466
4497
|
}
|
|
4467
4498
|
function Dt() {
|
|
4468
|
-
return ["weixin", "webview", "UniApp", "plus", "nvue", "uvue"].includes(
|
|
4499
|
+
return ["weixin", "webview", "UniApp", "plus", "nvue", "uvue"].includes(f.type);
|
|
4469
4500
|
}
|
|
4470
4501
|
function Ui() {
|
|
4471
4502
|
return typeof window != "undefined" && window.wx && window.wx.miniProgram && typeof window.wx.miniProgram.navigateTo == "function";
|
|
4472
4503
|
}
|
|
4473
4504
|
function Wi(t) {
|
|
4474
|
-
const e =
|
|
4505
|
+
const e = m(g({}, t), {
|
|
4475
4506
|
title: document.title || "",
|
|
4476
4507
|
url: window.location.href || ""
|
|
4477
4508
|
}), r = Object.entries(e).filter(([, n]) => n != null && n !== "").map(([n, i]) => `${encodeURIComponent(n)}=${encodeURIComponent(String(i))}`).join("&");
|
|
4478
4509
|
return r ? `${xe}?${r}` : xe;
|
|
4479
4510
|
}
|
|
4480
4511
|
function $i(t) {
|
|
4481
|
-
return
|
|
4512
|
+
return d.safeExecute(() => {
|
|
4482
4513
|
if (!Ui()) {
|
|
4483
4514
|
a.error("微信小程序导航API不可用");
|
|
4484
4515
|
return;
|
|
@@ -4502,11 +4533,11 @@ function $i(t) {
|
|
|
4502
4533
|
});
|
|
4503
4534
|
}
|
|
4504
4535
|
function Fi(t) {
|
|
4505
|
-
return
|
|
4536
|
+
return d.safeExecute(() => {
|
|
4506
4537
|
a.debug("通过 WebView 桥接调用人脸识别", {
|
|
4507
|
-
platform:
|
|
4538
|
+
platform: f.type,
|
|
4508
4539
|
name: t.name
|
|
4509
|
-
}),
|
|
4540
|
+
}), O("faceVerify", g({}, t), {
|
|
4510
4541
|
success: (e) => {
|
|
4511
4542
|
a.info("UniApp 人脸识别调用成功", e);
|
|
4512
4543
|
},
|
|
@@ -4519,10 +4550,10 @@ function Fi(t) {
|
|
|
4519
4550
|
platform: "uniapp"
|
|
4520
4551
|
});
|
|
4521
4552
|
}
|
|
4522
|
-
function
|
|
4523
|
-
return
|
|
4553
|
+
function ki(t = {}) {
|
|
4554
|
+
return d.safeExecute(() => {
|
|
4524
4555
|
if (!Dt()) {
|
|
4525
|
-
a.error("平台不支持人脸识别", { platform:
|
|
4556
|
+
a.error("平台不支持人脸识别", { platform: f.type });
|
|
4526
4557
|
return;
|
|
4527
4558
|
}
|
|
4528
4559
|
let e;
|
|
@@ -4533,10 +4564,10 @@ function Bi(t = {}) {
|
|
|
4533
4564
|
return;
|
|
4534
4565
|
}
|
|
4535
4566
|
if (a.info("开始人脸识别", {
|
|
4536
|
-
platform:
|
|
4567
|
+
platform: f.type,
|
|
4537
4568
|
name: e.name,
|
|
4538
4569
|
pagePath: xe
|
|
4539
|
-
}),
|
|
4570
|
+
}), C()) {
|
|
4540
4571
|
$i(e);
|
|
4541
4572
|
return;
|
|
4542
4573
|
}
|
|
@@ -4546,16 +4577,16 @@ function Bi(t = {}) {
|
|
|
4546
4577
|
options: t
|
|
4547
4578
|
});
|
|
4548
4579
|
}
|
|
4549
|
-
function
|
|
4580
|
+
function Bi() {
|
|
4550
4581
|
let t = "weixin";
|
|
4551
|
-
return
|
|
4582
|
+
return f.type === "UniApp" && (t = "uniapp"), {
|
|
4552
4583
|
supported: Dt(),
|
|
4553
|
-
environment:
|
|
4584
|
+
environment: f.type,
|
|
4554
4585
|
implementation: t,
|
|
4555
4586
|
features: {
|
|
4556
4587
|
asyncSupport: !0,
|
|
4557
|
-
hostPageNavigation:
|
|
4558
|
-
hostBridge:
|
|
4588
|
+
hostPageNavigation: C(),
|
|
4589
|
+
hostBridge: f.type === "UniApp"
|
|
4559
4590
|
}
|
|
4560
4591
|
};
|
|
4561
4592
|
}
|
|
@@ -4567,11 +4598,11 @@ function Gi() {
|
|
|
4567
4598
|
return typeof e.clientId == "string" && e.clientId.length > 0;
|
|
4568
4599
|
}
|
|
4569
4600
|
function Ki() {
|
|
4570
|
-
return
|
|
4571
|
-
yield cr(), Gi() && (yield
|
|
4601
|
+
return I(this, null, function* () {
|
|
4602
|
+
yield cr(), Gi() && (yield Q());
|
|
4572
4603
|
});
|
|
4573
4604
|
}
|
|
4574
|
-
|
|
4605
|
+
z.useResponse(ct.response, { priority: 1e3 });
|
|
4575
4606
|
let Ze = !1;
|
|
4576
4607
|
function Qe() {
|
|
4577
4608
|
if (Ze) return;
|
|
@@ -4585,19 +4616,19 @@ function Qe() {
|
|
|
4585
4616
|
});
|
|
4586
4617
|
}
|
|
4587
4618
|
typeof window != "undefined" && (document.readyState === "complete" || document.readyState === "interactive" ? setTimeout(Qe, 0) : document.addEventListener("DOMContentLoaded", Qe));
|
|
4588
|
-
function
|
|
4619
|
+
function y(t, { apiName: e } = {}) {
|
|
4589
4620
|
return function(r = {}, ...n) {
|
|
4590
|
-
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((u,
|
|
4591
|
-
const
|
|
4592
|
-
success: (
|
|
4593
|
-
typeof s.success == "function" && s.success(
|
|
4621
|
+
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((u, p) => {
|
|
4622
|
+
const M = m(g({}, s), {
|
|
4623
|
+
success: (_) => {
|
|
4624
|
+
typeof s.success == "function" && s.success(_), u(_);
|
|
4594
4625
|
},
|
|
4595
|
-
fail: (
|
|
4596
|
-
typeof s.fail == "function" && s.fail(
|
|
4626
|
+
fail: (_) => {
|
|
4627
|
+
typeof s.fail == "function" && s.fail(_), p(_);
|
|
4597
4628
|
},
|
|
4598
4629
|
complete: s.complete
|
|
4599
4630
|
});
|
|
4600
|
-
t(
|
|
4631
|
+
t(M, ...n);
|
|
4601
4632
|
});
|
|
4602
4633
|
return (typeof window == "undefined" ? Promise.resolve() : rt()).then(() => o()).catch((u) => {
|
|
4603
4634
|
throw console.error(`[QSH-SDK] ${e || "API"} call failed:`, u), u;
|
|
@@ -4607,137 +4638,137 @@ function E(t, { apiName: e } = {}) {
|
|
|
4607
4638
|
function Ie(t) {
|
|
4608
4639
|
return typeof t == "function" ? { success: t } : t && typeof t == "object" ? t : {};
|
|
4609
4640
|
}
|
|
4610
|
-
const Wt =
|
|
4641
|
+
const Wt = y(Xr), $t = y(Zr), Ft = y(Qr), kt = y(en), Bt = y(tn), Gt = y(rn);
|
|
4611
4642
|
function Kt(t) {
|
|
4612
4643
|
const e = () => nn(t);
|
|
4613
4644
|
return (typeof window == "undefined" ? Promise.resolve() : rt()).then(() => e());
|
|
4614
4645
|
}
|
|
4615
|
-
const Fe =
|
|
4646
|
+
const Fe = y(ln, { apiName: "getCode" });
|
|
4616
4647
|
function Vi(t = {}) {
|
|
4617
4648
|
return new Promise((e, r) => {
|
|
4618
|
-
Fe(
|
|
4649
|
+
Fe(m(g({}, t), {
|
|
4619
4650
|
success: e,
|
|
4620
4651
|
fail: r
|
|
4621
4652
|
}));
|
|
4622
4653
|
});
|
|
4623
4654
|
}
|
|
4624
|
-
const
|
|
4655
|
+
const ke = y(pn, {
|
|
4625
4656
|
apiName: "navigateToMiniProgram"
|
|
4626
4657
|
});
|
|
4627
4658
|
function qi(t = {}) {
|
|
4628
4659
|
return new Promise((e, r) => {
|
|
4629
|
-
|
|
4660
|
+
ke(m(g({}, t), {
|
|
4630
4661
|
success: e,
|
|
4631
4662
|
fail: r
|
|
4632
4663
|
}));
|
|
4633
4664
|
});
|
|
4634
4665
|
}
|
|
4635
|
-
const
|
|
4666
|
+
const Be = y(Rn);
|
|
4636
4667
|
function ji(t = {}) {
|
|
4637
4668
|
return new Promise((e, r) => {
|
|
4638
|
-
|
|
4669
|
+
Be(m(g({}, t), {
|
|
4639
4670
|
success: e,
|
|
4640
4671
|
fail: r
|
|
4641
4672
|
}));
|
|
4642
4673
|
});
|
|
4643
4674
|
}
|
|
4644
|
-
const Vt =
|
|
4675
|
+
const Vt = y(Li);
|
|
4645
4676
|
function Ji(t = {}) {
|
|
4646
4677
|
return new Promise((e, r) => {
|
|
4647
|
-
Vt(
|
|
4678
|
+
Vt(m(g({}, t), {
|
|
4648
4679
|
success: e,
|
|
4649
4680
|
fail: r
|
|
4650
4681
|
}));
|
|
4651
4682
|
});
|
|
4652
4683
|
}
|
|
4653
|
-
const Ge =
|
|
4684
|
+
const Ge = y(vn), Hi = y(ki);
|
|
4654
4685
|
function zi(t = {}) {
|
|
4655
4686
|
return new Promise((e, r) => {
|
|
4656
|
-
Ge(
|
|
4687
|
+
Ge(m(g({}, t), {
|
|
4657
4688
|
success: e,
|
|
4658
4689
|
fail: r
|
|
4659
4690
|
}));
|
|
4660
4691
|
});
|
|
4661
4692
|
}
|
|
4662
|
-
const Yi =
|
|
4693
|
+
const Yi = y(Tt, { apiName: "shareDirected" }), Xi = y(wi, { apiName: "shareDirectedAsync" }), Zi = y(Et, { apiName: "manualShare" }), Qi = y(Pn, { apiName: "manualShareAsync" }), Ke = y(Bn);
|
|
4663
4694
|
function ea(t = {}) {
|
|
4664
4695
|
return new Promise((e, r) => {
|
|
4665
|
-
Ke(
|
|
4696
|
+
Ke(m(g({}, t), {
|
|
4666
4697
|
success: e,
|
|
4667
4698
|
fail: r
|
|
4668
4699
|
}));
|
|
4669
4700
|
});
|
|
4670
4701
|
}
|
|
4671
|
-
const Ve =
|
|
4702
|
+
const Ve = y(Gn);
|
|
4672
4703
|
function ta(t = {}) {
|
|
4673
4704
|
return new Promise((e, r) => {
|
|
4674
|
-
Ve(
|
|
4705
|
+
Ve(m(g({}, t), {
|
|
4675
4706
|
success: e,
|
|
4676
4707
|
fail: r
|
|
4677
4708
|
}));
|
|
4678
4709
|
});
|
|
4679
4710
|
}
|
|
4680
|
-
const qe =
|
|
4711
|
+
const qe = y(Qn);
|
|
4681
4712
|
function ra(t = {}) {
|
|
4682
4713
|
return new Promise((e, r) => {
|
|
4683
|
-
qe(
|
|
4714
|
+
qe(m(g({}, t), {
|
|
4684
4715
|
success: e,
|
|
4685
4716
|
fail: r
|
|
4686
4717
|
}));
|
|
4687
4718
|
});
|
|
4688
4719
|
}
|
|
4689
|
-
const qt =
|
|
4720
|
+
const qt = y(Ri);
|
|
4690
4721
|
function na(t = {}) {
|
|
4691
4722
|
return new Promise((e, r) => {
|
|
4692
|
-
qt(
|
|
4723
|
+
qt(m(g({}, t), {
|
|
4693
4724
|
success: e,
|
|
4694
4725
|
fail: r
|
|
4695
4726
|
}));
|
|
4696
4727
|
});
|
|
4697
4728
|
}
|
|
4698
|
-
const jt =
|
|
4729
|
+
const jt = y(Si);
|
|
4699
4730
|
function ia(t = {}) {
|
|
4700
4731
|
return new Promise((e, r) => {
|
|
4701
|
-
jt(
|
|
4732
|
+
jt(m(g({}, t), {
|
|
4702
4733
|
success: e,
|
|
4703
4734
|
fail: r
|
|
4704
4735
|
}));
|
|
4705
4736
|
});
|
|
4706
4737
|
}
|
|
4707
|
-
const Jt =
|
|
4738
|
+
const Jt = y(Lt);
|
|
4708
4739
|
function aa(t = {}) {
|
|
4709
4740
|
return new Promise((e, r) => {
|
|
4710
|
-
Jt(
|
|
4741
|
+
Jt(m(g({}, t), {
|
|
4711
4742
|
success: e,
|
|
4712
4743
|
fail: r
|
|
4713
4744
|
}));
|
|
4714
4745
|
});
|
|
4715
4746
|
}
|
|
4716
|
-
const Ht =
|
|
4747
|
+
const Ht = y(Oi);
|
|
4717
4748
|
function sa(t = {}) {
|
|
4718
4749
|
return new Promise((e, r) => {
|
|
4719
|
-
Ht(
|
|
4750
|
+
Ht(m(g({}, t), {
|
|
4720
4751
|
success: e,
|
|
4721
4752
|
fail: r
|
|
4722
4753
|
}));
|
|
4723
4754
|
});
|
|
4724
4755
|
}
|
|
4725
|
-
const oa =
|
|
4756
|
+
const oa = y(vt, { apiName: "shareMiniProgramCard" }), ca = y(Ei, { apiName: "shareMiniProgramCardAsync" }), se = {
|
|
4726
4757
|
// 导航 API
|
|
4727
4758
|
navigateTo: Wt,
|
|
4728
4759
|
navigateBack: $t,
|
|
4729
4760
|
switchTab: Ft,
|
|
4730
|
-
reLaunch:
|
|
4731
|
-
redirectTo:
|
|
4761
|
+
reLaunch: kt,
|
|
4762
|
+
redirectTo: Bt,
|
|
4732
4763
|
// 消息 API
|
|
4733
4764
|
postMessage: Gt,
|
|
4734
4765
|
getEnv: Kt,
|
|
4735
4766
|
getCode: Fe,
|
|
4736
4767
|
getCodeAsync: Vi,
|
|
4737
|
-
navigateToMiniProgram:
|
|
4768
|
+
navigateToMiniProgram: ke,
|
|
4738
4769
|
navigateToMiniProgramAsync: qi,
|
|
4739
4770
|
// 图片 API
|
|
4740
|
-
chooseImage:
|
|
4771
|
+
chooseImage: Be,
|
|
4741
4772
|
chooseImageAsync: ji,
|
|
4742
4773
|
// 扫码 API
|
|
4743
4774
|
scanCode: Ge,
|
|
@@ -4750,12 +4781,12 @@ const oa = E(vt, { apiName: "shareMiniProgramCard" }), ca = E(Ei, { apiName: "sh
|
|
|
4750
4781
|
chooseLocation: qe,
|
|
4751
4782
|
chooseLocationAsync: ra,
|
|
4752
4783
|
// 位置监听 API(保留回调签名)
|
|
4753
|
-
onLocationChange: (t) =>
|
|
4754
|
-
offLocationChange: (t) =>
|
|
4755
|
-
onLocationChangeError: (t) =>
|
|
4756
|
-
offLocationChangeError: (t) =>
|
|
4757
|
-
startLocationUpdate:
|
|
4758
|
-
stopLocationUpdate:
|
|
4784
|
+
onLocationChange: (t) => y((e = {}) => jn(e.success), { apiName: "onLocationChange" })(Ie(t)),
|
|
4785
|
+
offLocationChange: (t) => y((e = {}) => Jn(e.success), { apiName: "offLocationChange" })(Ie(t)),
|
|
4786
|
+
onLocationChangeError: (t) => y((e = {}) => Hn(e.success), { apiName: "onLocationChangeError" })(Ie(t)),
|
|
4787
|
+
offLocationChangeError: (t) => y((e = {}) => zn(e.success), { apiName: "offLocationChangeError" })(Ie(t)),
|
|
4788
|
+
startLocationUpdate: y(Vn, { apiName: "startLocationUpdate" }),
|
|
4789
|
+
stopLocationUpdate: y(qn, { apiName: "stopLocationUpdate" }),
|
|
4759
4790
|
// 环境信息
|
|
4760
4791
|
environment: Ut,
|
|
4761
4792
|
/**
|
|
@@ -4804,7 +4835,7 @@ const oa = E(vt, { apiName: "shareMiniProgramCard" }), ca = E(Ei, { apiName: "sh
|
|
|
4804
4835
|
* @since 2.0.0
|
|
4805
4836
|
*/
|
|
4806
4837
|
config: He,
|
|
4807
|
-
waitForConfig:
|
|
4838
|
+
waitForConfig: Q,
|
|
4808
4839
|
/**
|
|
4809
4840
|
* 检查微信配置是否完成
|
|
4810
4841
|
* @returns {boolean}
|
|
@@ -4812,7 +4843,7 @@ const oa = E(vt, { apiName: "shareMiniProgramCard" }), ca = E(Ei, { apiName: "sh
|
|
|
4812
4843
|
* if (qsh.weixin.isConfigReady()) { wx.chooseImage({}) }
|
|
4813
4844
|
* @since 2.0.0
|
|
4814
4845
|
*/
|
|
4815
|
-
isConfigReady:
|
|
4846
|
+
isConfigReady: oe,
|
|
4816
4847
|
/**
|
|
4817
4848
|
* 获取微信配置状态
|
|
4818
4849
|
* @returns {string}
|
|
@@ -4833,8 +4864,8 @@ const oa = E(vt, { apiName: "shareMiniProgramCard" }), ca = E(Ei, { apiName: "sh
|
|
|
4833
4864
|
// WebView 对象(兼容旧版本)
|
|
4834
4865
|
webView: null,
|
|
4835
4866
|
// 图片相关常量
|
|
4836
|
-
ImageSourceTypes:
|
|
4837
|
-
ImageSizeTypes:
|
|
4867
|
+
ImageSourceTypes: Ce,
|
|
4868
|
+
ImageSizeTypes: _e,
|
|
4838
4869
|
/**
|
|
4839
4870
|
* 获取图片功能能力信息
|
|
4840
4871
|
* @returns {Object} 能力信息对象
|
|
@@ -4843,9 +4874,9 @@ const oa = E(vt, { apiName: "shareMiniProgramCard" }), ca = E(Ei, { apiName: "sh
|
|
|
4843
4874
|
* console.log('是否支持:', capabilities.supported)
|
|
4844
4875
|
* @since 2.0.0
|
|
4845
4876
|
*/
|
|
4846
|
-
getImageCapabilities:
|
|
4877
|
+
getImageCapabilities: Sn,
|
|
4847
4878
|
// 扫码相关常量
|
|
4848
|
-
ScanTypes:
|
|
4879
|
+
ScanTypes: X,
|
|
4849
4880
|
/**
|
|
4850
4881
|
* 获取扫码功能能力信息
|
|
4851
4882
|
* @returns {Object} 能力信息对象
|
|
@@ -4856,7 +4887,7 @@ const oa = E(vt, { apiName: "shareMiniProgramCard" }), ca = E(Ei, { apiName: "sh
|
|
|
4856
4887
|
*/
|
|
4857
4888
|
getScanCapabilities: Ln,
|
|
4858
4889
|
// 位置相关常量
|
|
4859
|
-
CoordinateTypes:
|
|
4890
|
+
CoordinateTypes: ae,
|
|
4860
4891
|
/**
|
|
4861
4892
|
* 获取位置功能能力信息
|
|
4862
4893
|
* @returns {Object} 能力信息对象
|
|
@@ -4917,7 +4948,7 @@ const oa = E(vt, { apiName: "shareMiniProgramCard" }), ca = E(Ei, { apiName: "sh
|
|
|
4917
4948
|
getPrintCapabilities: xi,
|
|
4918
4949
|
// 人脸识别 API(仅支持微信小程序环境)
|
|
4919
4950
|
faceVerify: Hi,
|
|
4920
|
-
getFaceCapabilities:
|
|
4951
|
+
getFaceCapabilities: Bi,
|
|
4921
4952
|
// 插件系统
|
|
4922
4953
|
plugins: {
|
|
4923
4954
|
/**
|
|
@@ -4939,7 +4970,7 @@ const oa = E(vt, { apiName: "shareMiniProgramCard" }), ca = E(Ei, { apiName: "sh
|
|
|
4939
4970
|
* @example
|
|
4940
4971
|
* await qsh.plugins.install('image')
|
|
4941
4972
|
*/
|
|
4942
|
-
install: (t) => fe.install(t,
|
|
4973
|
+
install: (t) => fe.install(t, se),
|
|
4943
4974
|
/**
|
|
4944
4975
|
* 获取插件列表
|
|
4945
4976
|
* @returns {Array} 插件列表
|
|
@@ -4953,7 +4984,7 @@ const oa = E(vt, { apiName: "shareMiniProgramCard" }), ca = E(Ei, { apiName: "sh
|
|
|
4953
4984
|
/**
|
|
4954
4985
|
* 拦截器链
|
|
4955
4986
|
*/
|
|
4956
|
-
chain:
|
|
4987
|
+
chain: z,
|
|
4957
4988
|
/**
|
|
4958
4989
|
* 注册请求拦截器
|
|
4959
4990
|
* @param {Function} interceptor - 拦截器函数
|
|
@@ -4965,7 +4996,7 @@ const oa = E(vt, { apiName: "shareMiniProgramCard" }), ca = E(Ei, { apiName: "sh
|
|
|
4965
4996
|
* return ctx
|
|
4966
4997
|
* })
|
|
4967
4998
|
*/
|
|
4968
|
-
useRequest: (t, e) =>
|
|
4999
|
+
useRequest: (t, e) => z.useRequest(t, e),
|
|
4969
5000
|
/**
|
|
4970
5001
|
* 注册响应拦截器
|
|
4971
5002
|
* @param {Function} interceptor - 拦截器函数
|
|
@@ -4977,7 +5008,7 @@ const oa = E(vt, { apiName: "shareMiniProgramCard" }), ca = E(Ei, { apiName: "sh
|
|
|
4977
5008
|
* return result
|
|
4978
5009
|
* })
|
|
4979
5010
|
*/
|
|
4980
|
-
useResponse: (t, e) =>
|
|
5011
|
+
useResponse: (t, e) => z.useResponse(t, e),
|
|
4981
5012
|
/**
|
|
4982
5013
|
* 内置拦截器
|
|
4983
5014
|
*/
|
|
@@ -5039,7 +5070,7 @@ const oa = E(vt, { apiName: "shareMiniProgramCard" }), ca = E(Ei, { apiName: "sh
|
|
|
5039
5070
|
* @example
|
|
5040
5071
|
* if (qsh.errors.isStandard(error)) { ... }
|
|
5041
5072
|
*/
|
|
5042
|
-
isStandard:
|
|
5073
|
+
isStandard: Sr
|
|
5043
5074
|
},
|
|
5044
5075
|
// 状态管理
|
|
5045
5076
|
store: {
|
|
@@ -5087,25 +5118,25 @@ const oa = E(vt, { apiName: "shareMiniProgramCard" }), ca = E(Ei, { apiName: "sh
|
|
|
5087
5118
|
/**
|
|
5088
5119
|
* 日志记录器
|
|
5089
5120
|
*/
|
|
5090
|
-
logger:
|
|
5121
|
+
logger: L,
|
|
5091
5122
|
/**
|
|
5092
5123
|
* 设置外部日志 reporter,便于对接埋点/观测
|
|
5093
5124
|
*/
|
|
5094
|
-
setLogReporter: (t) =>
|
|
5125
|
+
setLogReporter: (t) => L.setReporter(t),
|
|
5095
5126
|
/**
|
|
5096
5127
|
* 错误处理器
|
|
5097
5128
|
*/
|
|
5098
|
-
errorHandler:
|
|
5129
|
+
errorHandler: d,
|
|
5099
5130
|
/**
|
|
5100
5131
|
* 状态管理器
|
|
5101
5132
|
*/
|
|
5102
|
-
stateManager:
|
|
5133
|
+
stateManager: Y,
|
|
5103
5134
|
/**
|
|
5104
5135
|
* 启用调试模式
|
|
5105
5136
|
* @example
|
|
5106
5137
|
* qsh.debug.enableDevMode()
|
|
5107
5138
|
*/
|
|
5108
|
-
enableDevMode: () =>
|
|
5139
|
+
enableDevMode: () => L.enableDevMode(),
|
|
5109
5140
|
/**
|
|
5110
5141
|
* 获取日志历史
|
|
5111
5142
|
* @param {number} [count] - 获取条数
|
|
@@ -5113,7 +5144,7 @@ const oa = E(vt, { apiName: "shareMiniProgramCard" }), ca = E(Ei, { apiName: "sh
|
|
|
5113
5144
|
* @example
|
|
5114
5145
|
* console.log(qsh.debug.getLogs(10))
|
|
5115
5146
|
*/
|
|
5116
|
-
getLogs: (t) =>
|
|
5147
|
+
getLogs: (t) => L.getHistory(t),
|
|
5117
5148
|
/**
|
|
5118
5149
|
* 获取 SDK 统计信息
|
|
5119
5150
|
* @returns {Object} 统计信息
|
|
@@ -5121,11 +5152,11 @@ const oa = E(vt, { apiName: "shareMiniProgramCard" }), ca = E(Ei, { apiName: "sh
|
|
|
5121
5152
|
* console.log(qsh.debug.getStats())
|
|
5122
5153
|
*/
|
|
5123
5154
|
getStats: () => ({
|
|
5124
|
-
logger:
|
|
5125
|
-
state:
|
|
5155
|
+
logger: L.getStats(),
|
|
5156
|
+
state: Y.getStats(),
|
|
5126
5157
|
weixinConfig: ve().getStats(),
|
|
5127
5158
|
plugins: fe.getStats(),
|
|
5128
|
-
interceptors:
|
|
5159
|
+
interceptors: z.getStats(),
|
|
5129
5160
|
store: G.getStats()
|
|
5130
5161
|
}),
|
|
5131
5162
|
/**
|
|
@@ -5141,20 +5172,20 @@ const oa = E(vt, { apiName: "shareMiniProgramCard" }), ca = E(Ei, { apiName: "sh
|
|
|
5141
5172
|
* @example
|
|
5142
5173
|
* console.log(qsh.debug.exportDebugInfo())
|
|
5143
5174
|
*/
|
|
5144
|
-
exportDebugInfo: () =>
|
|
5175
|
+
exportDebugInfo: () => L.exportToJSON()
|
|
5145
5176
|
}
|
|
5146
5177
|
};
|
|
5147
|
-
Ut.isWeixinMiniProgram ?
|
|
5178
|
+
Ut.isWeixinMiniProgram ? se.webView = window.wx && window.wx.miniProgram : se.webView = {
|
|
5148
5179
|
navigateTo: Wt,
|
|
5149
5180
|
navigateBack: $t,
|
|
5150
5181
|
switchTab: Ft,
|
|
5151
|
-
reLaunch:
|
|
5152
|
-
redirectTo:
|
|
5182
|
+
reLaunch: kt,
|
|
5183
|
+
redirectTo: Bt,
|
|
5153
5184
|
postMessage: Gt,
|
|
5154
5185
|
getEnv: Kt,
|
|
5155
5186
|
getCode: Fe,
|
|
5156
|
-
navigateToMiniProgram:
|
|
5157
|
-
chooseImage:
|
|
5187
|
+
navigateToMiniProgram: ke,
|
|
5188
|
+
chooseImage: Be,
|
|
5158
5189
|
scanCode: Ge,
|
|
5159
5190
|
getLocation: Ke,
|
|
5160
5191
|
openLocation: Ve,
|
|
@@ -5162,10 +5193,10 @@ Ut.isWeixinMiniProgram ? oe.webView = window.wx && window.wx.miniProgram : oe.we
|
|
|
5162
5193
|
};
|
|
5163
5194
|
const et = typeof window.uni != "undefined" ? window.uni : {};
|
|
5164
5195
|
Object.keys(et).forEach((t) => {
|
|
5165
|
-
|
|
5196
|
+
se.hasOwnProperty(t) || (se[t] = et[t]);
|
|
5166
5197
|
});
|
|
5167
|
-
typeof window != "undefined" && (window.qsh =
|
|
5198
|
+
typeof window != "undefined" && (window.qsh = se);
|
|
5168
5199
|
export {
|
|
5169
|
-
|
|
5200
|
+
se as default
|
|
5170
5201
|
};
|
|
5171
5202
|
//# sourceMappingURL=qsh-webview-sdk.es.js.map
|