qsh-webview-sdk 2.0.6 → 2.0.8
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 +32 -9
- package/dist/index.d.ts +86 -17
- package/dist/qsh-webview-sdk.es.js +1152 -892
- 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 +47 -47
|
@@ -1,93 +1,93 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
1
|
+
var St = Object.defineProperty, Pt = Object.defineProperties;
|
|
2
|
+
var Tt = Object.getOwnPropertyDescriptors;
|
|
3
|
+
var be = Object.getOwnPropertySymbols;
|
|
4
|
+
var Lt = Object.prototype.hasOwnProperty, Mt = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var ye = (t, e, r) => e in t ? St(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r, p = (t, e) => {
|
|
6
6
|
for (var r in e || (e = {}))
|
|
7
|
-
|
|
8
|
-
if (
|
|
9
|
-
for (var r of
|
|
10
|
-
|
|
7
|
+
Lt.call(e, r) && ye(t, r, e[r]);
|
|
8
|
+
if (be)
|
|
9
|
+
for (var r of be(e))
|
|
10
|
+
Mt.call(e, r) && ye(t, r, e[r]);
|
|
11
11
|
return t;
|
|
12
|
-
}, A = (t, e) =>
|
|
13
|
-
var
|
|
12
|
+
}, A = (t, e) => Pt(t, Tt(e));
|
|
13
|
+
var v = (t, e, r) => ye(t, typeof e != "symbol" ? e + "" : e, r);
|
|
14
14
|
var m = (t, e, r) => new Promise((n, i) => {
|
|
15
|
-
var
|
|
15
|
+
var a = (l) => {
|
|
16
16
|
try {
|
|
17
|
-
|
|
18
|
-
} catch (
|
|
19
|
-
i(
|
|
17
|
+
d(r.next(l));
|
|
18
|
+
} catch (h) {
|
|
19
|
+
i(h);
|
|
20
20
|
}
|
|
21
|
-
},
|
|
21
|
+
}, g = (l) => {
|
|
22
22
|
try {
|
|
23
|
-
|
|
24
|
-
} catch (
|
|
25
|
-
i(
|
|
23
|
+
d(r.throw(l));
|
|
24
|
+
} catch (h) {
|
|
25
|
+
i(h);
|
|
26
26
|
}
|
|
27
|
-
},
|
|
28
|
-
|
|
27
|
+
}, d = (l) => l.done ? n(l.value) : Promise.resolve(l.value).then(a, g);
|
|
28
|
+
d((r = r.apply(t, e)).next());
|
|
29
29
|
});
|
|
30
|
-
function
|
|
30
|
+
function de() {
|
|
31
31
|
return typeof window != "undefined" ? window : void 0;
|
|
32
32
|
}
|
|
33
|
-
function
|
|
33
|
+
function _e() {
|
|
34
34
|
return typeof navigator == "undefined" ? "" : navigator.userAgent || "";
|
|
35
35
|
}
|
|
36
|
-
function
|
|
37
|
-
const t =
|
|
36
|
+
function E() {
|
|
37
|
+
const t = de();
|
|
38
38
|
if (!t) return !1;
|
|
39
39
|
if (t.__wxjs_environment === "miniprogram" || t.wx && t.wx.miniProgram)
|
|
40
40
|
return !0;
|
|
41
|
-
const e =
|
|
41
|
+
const e = _e();
|
|
42
42
|
return !!(e && /micromessenger/i.test(e) && /miniProgram/i.test(e));
|
|
43
43
|
}
|
|
44
|
-
function
|
|
45
|
-
const t =
|
|
44
|
+
function ge() {
|
|
45
|
+
const t = de();
|
|
46
46
|
return !!(t && t.plus);
|
|
47
47
|
}
|
|
48
|
-
function
|
|
49
|
-
const t =
|
|
48
|
+
function pe() {
|
|
49
|
+
const t = de();
|
|
50
50
|
return !!(t && (t.__dcloud_weex_postMessage || t.__dcloud_weex_));
|
|
51
51
|
}
|
|
52
|
-
function
|
|
53
|
-
const t =
|
|
52
|
+
function he() {
|
|
53
|
+
const t = de();
|
|
54
54
|
return !!(t && (t.__uniapp_x_postMessage || t.__uniapp_x_));
|
|
55
55
|
}
|
|
56
|
-
function
|
|
57
|
-
const t =
|
|
56
|
+
function me() {
|
|
57
|
+
const t = _e();
|
|
58
58
|
return /uni-app/i.test(t);
|
|
59
59
|
}
|
|
60
|
-
function
|
|
61
|
-
const t =
|
|
60
|
+
function Ce() {
|
|
61
|
+
const t = _e();
|
|
62
62
|
return /Html5Plus/i.test(t);
|
|
63
63
|
}
|
|
64
|
-
function
|
|
65
|
-
return
|
|
66
|
-
}
|
|
67
|
-
function
|
|
68
|
-
return
|
|
69
|
-
}
|
|
70
|
-
let
|
|
71
|
-
function
|
|
72
|
-
return
|
|
73
|
-
isWeixinMiniProgram:
|
|
74
|
-
isAppPlus:
|
|
75
|
-
isNvue:
|
|
76
|
-
isUvue:
|
|
77
|
-
isUniApp:
|
|
78
|
-
isHtml5Plus:
|
|
79
|
-
isUniAppWebView:
|
|
80
|
-
type:
|
|
81
|
-
}),
|
|
82
|
-
}
|
|
83
|
-
const
|
|
64
|
+
function Be() {
|
|
65
|
+
return me() || Ce();
|
|
66
|
+
}
|
|
67
|
+
function bt() {
|
|
68
|
+
return he() ? "uvue" : pe() ? "nvue" : E() ? "weixin" : ge() ? "plus" : Be() ? "webview" : me() ? "UniApp" : "h5";
|
|
69
|
+
}
|
|
70
|
+
let ae = null;
|
|
71
|
+
function Ne(t = !1) {
|
|
72
|
+
return ae && !t || (ae = {
|
|
73
|
+
isWeixinMiniProgram: E(),
|
|
74
|
+
isAppPlus: ge(),
|
|
75
|
+
isNvue: pe(),
|
|
76
|
+
isUvue: he(),
|
|
77
|
+
isUniApp: me(),
|
|
78
|
+
isHtml5Plus: Ce(),
|
|
79
|
+
isUniAppWebView: Be(),
|
|
80
|
+
type: bt()
|
|
81
|
+
}), ae;
|
|
82
|
+
}
|
|
83
|
+
const c = Ne(), U = {
|
|
84
84
|
PLATFORM_NOT_SUPPORTED: "PLATFORM_NOT_SUPPORTED",
|
|
85
85
|
API_CALL_FAILED: "API_CALL_FAILED",
|
|
86
86
|
BRIDGE_NOT_READY: "BRIDGE_NOT_READY",
|
|
87
87
|
INVALID_PARAMETERS: "INVALID_PARAMETERS",
|
|
88
88
|
NETWORK_ERROR: "NETWORK_ERROR"
|
|
89
89
|
};
|
|
90
|
-
class
|
|
90
|
+
class L extends Error {
|
|
91
91
|
/**
|
|
92
92
|
* 构造函数
|
|
93
93
|
* @param {string} type - 错误类型
|
|
@@ -96,7 +96,7 @@ class C extends Error {
|
|
|
96
96
|
* @param {Error} [originalError] - 原始错误对象
|
|
97
97
|
*/
|
|
98
98
|
constructor(e, r, n = {}, i = null) {
|
|
99
|
-
super(r), this.name = "QshError", this.type = e, this.context = n, this.originalError = i, this.timestamp = (/* @__PURE__ */ new Date()).toISOString(), Error.captureStackTrace && Error.captureStackTrace(this,
|
|
99
|
+
super(r), this.name = "QshError", this.type = e, this.context = n, this.originalError = i, this.timestamp = (/* @__PURE__ */ new Date()).toISOString(), Error.captureStackTrace && Error.captureStackTrace(this, L);
|
|
100
100
|
}
|
|
101
101
|
/**
|
|
102
102
|
* 转换为 JSON 格式
|
|
@@ -113,28 +113,28 @@ class C extends Error {
|
|
|
113
113
|
};
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
|
-
const
|
|
116
|
+
const O = class O {
|
|
117
117
|
/**
|
|
118
118
|
* 设置调试模式
|
|
119
119
|
* @param {boolean} enabled - 是否启用调试模式
|
|
120
120
|
*/
|
|
121
121
|
static setDebugMode(e) {
|
|
122
|
-
|
|
122
|
+
O.isDebugMode = e;
|
|
123
123
|
}
|
|
124
124
|
/**
|
|
125
125
|
* 添加错误回调
|
|
126
126
|
* @param {Function} callback - 错误处理回调函数
|
|
127
127
|
*/
|
|
128
128
|
static addErrorCallback(e) {
|
|
129
|
-
typeof e == "function" &&
|
|
129
|
+
typeof e == "function" && O.errorCallbacks.push(e);
|
|
130
130
|
}
|
|
131
131
|
/**
|
|
132
132
|
* 移除错误回调
|
|
133
133
|
* @param {Function} callback - 要移除的回调函数
|
|
134
134
|
*/
|
|
135
135
|
static removeErrorCallback(e) {
|
|
136
|
-
const r =
|
|
137
|
-
r > -1 &&
|
|
136
|
+
const r = O.errorCallbacks.indexOf(e);
|
|
137
|
+
r > -1 && O.errorCallbacks.splice(r, 1);
|
|
138
138
|
}
|
|
139
139
|
/**
|
|
140
140
|
* 处理 API 调用错误
|
|
@@ -144,16 +144,16 @@ const y = class y {
|
|
|
144
144
|
*/
|
|
145
145
|
static handleApiError(e, r = {}) {
|
|
146
146
|
let n;
|
|
147
|
-
return e instanceof
|
|
147
|
+
return e instanceof L ? n = e : e instanceof Error ? n = new L(
|
|
148
148
|
U.API_CALL_FAILED,
|
|
149
149
|
e.message,
|
|
150
150
|
r,
|
|
151
151
|
e
|
|
152
|
-
) : n = new
|
|
152
|
+
) : n = new L(
|
|
153
153
|
U.API_CALL_FAILED,
|
|
154
154
|
String(e),
|
|
155
155
|
r
|
|
156
|
-
),
|
|
156
|
+
), O.logError(n), O.notifyCallbacks(n), n;
|
|
157
157
|
}
|
|
158
158
|
/**
|
|
159
159
|
* 处理平台不支持错误
|
|
@@ -162,12 +162,12 @@ const y = class y {
|
|
|
162
162
|
* @returns {QshError} 错误对象
|
|
163
163
|
*/
|
|
164
164
|
static handlePlatformNotSupported(e, r) {
|
|
165
|
-
const n = new
|
|
165
|
+
const n = new L(
|
|
166
166
|
U.PLATFORM_NOT_SUPPORTED,
|
|
167
167
|
`API "${r}" is not supported on platform "${e}"`,
|
|
168
168
|
{ platformType: e, apiName: r }
|
|
169
169
|
);
|
|
170
|
-
return
|
|
170
|
+
return O.logError(n), O.notifyCallbacks(n), n;
|
|
171
171
|
}
|
|
172
172
|
/**
|
|
173
173
|
* 处理桥接未就绪错误
|
|
@@ -175,12 +175,12 @@ const y = class y {
|
|
|
175
175
|
* @returns {QshError} 错误对象
|
|
176
176
|
*/
|
|
177
177
|
static handleBridgeNotReady(e) {
|
|
178
|
-
const r = new
|
|
178
|
+
const r = new L(
|
|
179
179
|
U.BRIDGE_NOT_READY,
|
|
180
180
|
`Bridge is not ready when calling "${e}"`,
|
|
181
181
|
{ apiName: e }
|
|
182
182
|
);
|
|
183
|
-
return
|
|
183
|
+
return O.logError(r), O.notifyCallbacks(r), r;
|
|
184
184
|
}
|
|
185
185
|
/**
|
|
186
186
|
* 处理参数验证错误
|
|
@@ -191,12 +191,12 @@ const y = class y {
|
|
|
191
191
|
* @returns {QshError} 错误对象
|
|
192
192
|
*/
|
|
193
193
|
static handleInvalidParameters(e, r, n, i) {
|
|
194
|
-
const
|
|
194
|
+
const a = new L(
|
|
195
195
|
U.INVALID_PARAMETERS,
|
|
196
196
|
`Invalid parameter "${r}" in "${e}": expected ${n}, got ${typeof i}`,
|
|
197
197
|
{ apiName: e, paramName: r, expectedType: n, actualValue: i }
|
|
198
198
|
);
|
|
199
|
-
return
|
|
199
|
+
return O.logError(a), O.notifyCallbacks(a), a;
|
|
200
200
|
}
|
|
201
201
|
/**
|
|
202
202
|
* 安全地包装函数执行,捕获并处理错误
|
|
@@ -208,7 +208,7 @@ const y = class y {
|
|
|
208
208
|
try {
|
|
209
209
|
return e();
|
|
210
210
|
} catch (n) {
|
|
211
|
-
return
|
|
211
|
+
return O.handleApiError(n, r);
|
|
212
212
|
}
|
|
213
213
|
}
|
|
214
214
|
/**
|
|
@@ -222,7 +222,7 @@ const y = class y {
|
|
|
222
222
|
try {
|
|
223
223
|
return yield e();
|
|
224
224
|
} catch (i) {
|
|
225
|
-
return
|
|
225
|
+
return O.handleApiError(i, r);
|
|
226
226
|
}
|
|
227
227
|
});
|
|
228
228
|
}
|
|
@@ -234,7 +234,7 @@ const y = class y {
|
|
|
234
234
|
static logError(e) {
|
|
235
235
|
if (typeof console != "undefined") {
|
|
236
236
|
const r = `[QSH-SDK Error] ${e.type}: ${e.message}`;
|
|
237
|
-
|
|
237
|
+
O.isDebugMode ? console.error(r, {
|
|
238
238
|
context: e.context,
|
|
239
239
|
originalError: e.originalError,
|
|
240
240
|
stack: e.stack,
|
|
@@ -248,7 +248,7 @@ const y = class y {
|
|
|
248
248
|
* @private
|
|
249
249
|
*/
|
|
250
250
|
static notifyCallbacks(e) {
|
|
251
|
-
|
|
251
|
+
O.errorCallbacks.forEach((r) => {
|
|
252
252
|
try {
|
|
253
253
|
r(e);
|
|
254
254
|
} catch (n) {
|
|
@@ -263,24 +263,24 @@ const y = class y {
|
|
|
263
263
|
*/
|
|
264
264
|
static createErrorDecorator(e = {}) {
|
|
265
265
|
return function(r, n, i) {
|
|
266
|
-
const
|
|
267
|
-
return i.value = function(...
|
|
268
|
-
return
|
|
266
|
+
const a = i.value;
|
|
267
|
+
return i.value = function(...g) {
|
|
268
|
+
return O.safeExecute(() => a.apply(this, g), A(p({}, e), { method: n, target: r.constructor.name }));
|
|
269
269
|
}, i;
|
|
270
270
|
};
|
|
271
271
|
}
|
|
272
272
|
};
|
|
273
|
-
|
|
274
|
-
let
|
|
275
|
-
const
|
|
273
|
+
v(O, "isDebugMode", !1), v(O, "errorCallbacks", []);
|
|
274
|
+
let u = O;
|
|
275
|
+
const P = {
|
|
276
276
|
UNINITIALIZED: "uninitialized",
|
|
277
277
|
INITIALIZING: "initializing",
|
|
278
278
|
READY: "ready",
|
|
279
279
|
ERROR: "error"
|
|
280
280
|
};
|
|
281
|
-
class
|
|
281
|
+
class vt {
|
|
282
282
|
constructor() {
|
|
283
|
-
this.state =
|
|
283
|
+
this.state = P.UNINITIALIZED, this.readyPromise = null, this.readyCallbacks = [], this.errorCallbacks = [], this.initializationError = null, this.handleBridgeReady = this.handleBridgeReady.bind(this), this.handleInitializationError = this.handleInitializationError.bind(this);
|
|
284
284
|
}
|
|
285
285
|
/**
|
|
286
286
|
* 获取当前状态
|
|
@@ -294,21 +294,21 @@ class Rt {
|
|
|
294
294
|
* @returns {boolean} 是否就绪
|
|
295
295
|
*/
|
|
296
296
|
isReady() {
|
|
297
|
-
return this.state ===
|
|
297
|
+
return this.state === P.READY;
|
|
298
298
|
}
|
|
299
299
|
/**
|
|
300
300
|
* 检查是否正在初始化
|
|
301
301
|
* @returns {boolean} 是否正在初始化
|
|
302
302
|
*/
|
|
303
303
|
isInitializing() {
|
|
304
|
-
return this.state ===
|
|
304
|
+
return this.state === P.INITIALIZING;
|
|
305
305
|
}
|
|
306
306
|
/**
|
|
307
307
|
* 检查是否出错
|
|
308
308
|
* @returns {boolean} 是否出错
|
|
309
309
|
*/
|
|
310
310
|
hasError() {
|
|
311
|
-
return this.state ===
|
|
311
|
+
return this.state === P.ERROR;
|
|
312
312
|
}
|
|
313
313
|
/**
|
|
314
314
|
* 获取初始化错误
|
|
@@ -333,9 +333,9 @@ class Rt {
|
|
|
333
333
|
*/
|
|
334
334
|
startInitialization(e) {
|
|
335
335
|
return m(this, null, function* () {
|
|
336
|
-
if (this.state !==
|
|
336
|
+
if (this.state !== P.UNINITIALIZED)
|
|
337
337
|
return this.waitForReady();
|
|
338
|
-
this.state =
|
|
338
|
+
this.state = P.INITIALIZING;
|
|
339
339
|
try {
|
|
340
340
|
yield e(), this.handleBridgeReady();
|
|
341
341
|
} catch (r) {
|
|
@@ -349,11 +349,11 @@ class Rt {
|
|
|
349
349
|
* @private
|
|
350
350
|
*/
|
|
351
351
|
handleBridgeReady() {
|
|
352
|
-
this.state ===
|
|
352
|
+
this.state === P.INITIALIZING && (this.state = P.READY, this.readyCallbacks.forEach((e) => {
|
|
353
353
|
try {
|
|
354
354
|
e();
|
|
355
355
|
} catch (r) {
|
|
356
|
-
|
|
356
|
+
u.handleApiError(r, { context: "StateManager.handleBridgeReady" });
|
|
357
357
|
}
|
|
358
358
|
}), this.readyCallbacks = [], this.errorCallbacks = []);
|
|
359
359
|
}
|
|
@@ -363,11 +363,11 @@ class Rt {
|
|
|
363
363
|
* @private
|
|
364
364
|
*/
|
|
365
365
|
handleInitializationError(e) {
|
|
366
|
-
this.state =
|
|
366
|
+
this.state = P.ERROR, this.initializationError = e, this.errorCallbacks.forEach((r) => {
|
|
367
367
|
try {
|
|
368
368
|
r(e);
|
|
369
369
|
} catch (n) {
|
|
370
|
-
|
|
370
|
+
u.handleApiError(n, { context: "StateManager.handleInitializationError" });
|
|
371
371
|
}
|
|
372
372
|
}), this.readyCallbacks = [], this.errorCallbacks = [];
|
|
373
373
|
}
|
|
@@ -375,7 +375,7 @@ class Rt {
|
|
|
375
375
|
* 重置状态管理器(用于测试或重新初始化)
|
|
376
376
|
*/
|
|
377
377
|
reset() {
|
|
378
|
-
this.state =
|
|
378
|
+
this.state = P.UNINITIALIZED, this.readyPromise = null, this.readyCallbacks = [], this.errorCallbacks = [], this.initializationError = null;
|
|
379
379
|
}
|
|
380
380
|
/**
|
|
381
381
|
* 添加状态变化监听器
|
|
@@ -390,11 +390,11 @@ class Rt {
|
|
|
390
390
|
const n = () => {
|
|
391
391
|
this.state === e && r(this.state);
|
|
392
392
|
};
|
|
393
|
-
return e ===
|
|
393
|
+
return e === P.READY ? this.readyCallbacks.push(n) : e === P.ERROR && this.errorCallbacks.push(n), () => {
|
|
394
394
|
const i = this.readyCallbacks.indexOf(n);
|
|
395
395
|
i > -1 && this.readyCallbacks.splice(i, 1);
|
|
396
|
-
const
|
|
397
|
-
|
|
396
|
+
const a = this.errorCallbacks.indexOf(n);
|
|
397
|
+
a > -1 && this.errorCallbacks.splice(a, 1);
|
|
398
398
|
};
|
|
399
399
|
}
|
|
400
400
|
/**
|
|
@@ -411,52 +411,52 @@ class Rt {
|
|
|
411
411
|
};
|
|
412
412
|
}
|
|
413
413
|
}
|
|
414
|
-
const
|
|
414
|
+
const G = new vt(), Fe = () => G.waitForReady(), xt = () => G.isReady(), Dt = () => G.getState(), w = {
|
|
415
415
|
ERROR: 0,
|
|
416
416
|
WARN: 1,
|
|
417
417
|
INFO: 2,
|
|
418
418
|
DEBUG: 3,
|
|
419
419
|
TRACE: 4
|
|
420
|
-
},
|
|
420
|
+
}, ee = {
|
|
421
421
|
[w.ERROR]: "ERROR",
|
|
422
422
|
[w.WARN]: "WARN",
|
|
423
423
|
[w.INFO]: "INFO",
|
|
424
424
|
[w.DEBUG]: "DEBUG",
|
|
425
425
|
[w.TRACE]: "TRACE"
|
|
426
|
-
},
|
|
426
|
+
}, f = class f {
|
|
427
427
|
// 可注入的外部 reporter
|
|
428
428
|
/**
|
|
429
429
|
* 设置日志级别
|
|
430
430
|
* @param {number} level - 日志级别
|
|
431
431
|
*/
|
|
432
432
|
static setLevel(e) {
|
|
433
|
-
e >= w.ERROR && e <= w.TRACE && (
|
|
433
|
+
e >= w.ERROR && e <= w.TRACE && (f.currentLevel = e, f.log(w.INFO, "Logger", `日志级别设置为: ${ee[e]}`));
|
|
434
434
|
}
|
|
435
435
|
/**
|
|
436
436
|
* 启用开发模式(显示所有日志)
|
|
437
437
|
*/
|
|
438
438
|
static enableDevMode() {
|
|
439
|
-
|
|
439
|
+
f.setLevel(w.DEBUG), f.log(w.INFO, "Logger", "开发模式已启用");
|
|
440
440
|
}
|
|
441
441
|
/**
|
|
442
442
|
* 启用生产模式(只显示错误和警告)
|
|
443
443
|
*/
|
|
444
444
|
static enableProdMode() {
|
|
445
|
-
|
|
445
|
+
f.setLevel(w.WARN), f.log(w.INFO, "Logger", "生产模式已启用");
|
|
446
446
|
}
|
|
447
447
|
/**
|
|
448
448
|
* 启用特定模块的日志
|
|
449
449
|
* @param {string} module - 模块名称
|
|
450
450
|
*/
|
|
451
451
|
static enableModule(e) {
|
|
452
|
-
|
|
452
|
+
f.enabledModules.add(e), f.log(w.INFO, "Logger", `模块日志已启用: ${e}`);
|
|
453
453
|
}
|
|
454
454
|
/**
|
|
455
455
|
* 禁用特定模块的日志
|
|
456
456
|
* @param {string} module - 模块名称
|
|
457
457
|
*/
|
|
458
458
|
static disableModule(e) {
|
|
459
|
-
|
|
459
|
+
f.enabledModules.delete(e), f.log(w.INFO, "Logger", `模块日志已禁用: ${e}`);
|
|
460
460
|
}
|
|
461
461
|
/**
|
|
462
462
|
* 检查是否应该记录日志
|
|
@@ -466,7 +466,7 @@ const K = new Rt(), Ue = () => K.waitForReady(), St = () => K.isReady(), Tt = ()
|
|
|
466
466
|
* @private
|
|
467
467
|
*/
|
|
468
468
|
static shouldLog(e, r) {
|
|
469
|
-
return e >
|
|
469
|
+
return e > f.currentLevel ? !1 : r && f.enabledModules.size > 0 ? f.enabledModules.has(r) : !0;
|
|
470
470
|
}
|
|
471
471
|
/**
|
|
472
472
|
* 核心日志记录方法
|
|
@@ -477,22 +477,22 @@ const K = new Rt(), Ue = () => K.waitForReady(), St = () => K.isReady(), Tt = ()
|
|
|
477
477
|
* @private
|
|
478
478
|
*/
|
|
479
479
|
static log(e, r, n, ...i) {
|
|
480
|
-
if (!
|
|
480
|
+
if (!f.shouldLog(e, r))
|
|
481
481
|
return;
|
|
482
|
-
const
|
|
483
|
-
timestamp:
|
|
482
|
+
const a = (/* @__PURE__ */ new Date()).toISOString(), g = ee[e], d = r ? `[${r}]` : "", l = `${f.prefix} ${d} ${n}`, h = {
|
|
483
|
+
timestamp: a,
|
|
484
484
|
level: e,
|
|
485
|
-
levelName:
|
|
485
|
+
levelName: g,
|
|
486
486
|
module: r,
|
|
487
487
|
message: n,
|
|
488
488
|
args: i
|
|
489
489
|
};
|
|
490
|
-
if (
|
|
490
|
+
if (f.addToHistory(h), typeof f.reporter == "function")
|
|
491
491
|
try {
|
|
492
|
-
|
|
493
|
-
} catch (
|
|
492
|
+
f.reporter(h);
|
|
493
|
+
} catch (T) {
|
|
494
494
|
}
|
|
495
|
-
|
|
495
|
+
f.outputToConsole(e, l, ...i);
|
|
496
496
|
}
|
|
497
497
|
/**
|
|
498
498
|
* 添加日志到历史记录
|
|
@@ -500,7 +500,7 @@ const K = new Rt(), Ue = () => K.waitForReady(), St = () => K.isReady(), Tt = ()
|
|
|
500
500
|
* @private
|
|
501
501
|
*/
|
|
502
502
|
static addToHistory(e) {
|
|
503
|
-
|
|
503
|
+
f.logHistory.push(e), f.logHistory.length > f.maxHistorySize && f.logHistory.shift();
|
|
504
504
|
}
|
|
505
505
|
/**
|
|
506
506
|
* 输出到控制台
|
|
@@ -536,7 +536,7 @@ const K = new Rt(), Ue = () => K.waitForReady(), St = () => K.isReady(), Tt = ()
|
|
|
536
536
|
* @param {any[]} args - 额外参数
|
|
537
537
|
*/
|
|
538
538
|
static error(e, r, ...n) {
|
|
539
|
-
|
|
539
|
+
f.log(w.ERROR, e, r, ...n);
|
|
540
540
|
}
|
|
541
541
|
/**
|
|
542
542
|
* 警告级别日志
|
|
@@ -545,7 +545,7 @@ const K = new Rt(), Ue = () => K.waitForReady(), St = () => K.isReady(), Tt = ()
|
|
|
545
545
|
* @param {any[]} args - 额外参数
|
|
546
546
|
*/
|
|
547
547
|
static warn(e, r, ...n) {
|
|
548
|
-
|
|
548
|
+
f.log(w.WARN, e, r, ...n);
|
|
549
549
|
}
|
|
550
550
|
/**
|
|
551
551
|
* 信息级别日志
|
|
@@ -554,7 +554,7 @@ const K = new Rt(), Ue = () => K.waitForReady(), St = () => K.isReady(), Tt = ()
|
|
|
554
554
|
* @param {any[]} args - 额外参数
|
|
555
555
|
*/
|
|
556
556
|
static info(e, r, ...n) {
|
|
557
|
-
|
|
557
|
+
f.log(w.INFO, e, r, ...n);
|
|
558
558
|
}
|
|
559
559
|
/**
|
|
560
560
|
* 调试级别日志
|
|
@@ -563,7 +563,7 @@ const K = new Rt(), Ue = () => K.waitForReady(), St = () => K.isReady(), Tt = ()
|
|
|
563
563
|
* @param {any[]} args - 额外参数
|
|
564
564
|
*/
|
|
565
565
|
static debug(e, r, ...n) {
|
|
566
|
-
|
|
566
|
+
f.log(w.DEBUG, e, r, ...n);
|
|
567
567
|
}
|
|
568
568
|
/**
|
|
569
569
|
* 跟踪级别日志
|
|
@@ -572,7 +572,7 @@ const K = new Rt(), Ue = () => K.waitForReady(), St = () => K.isReady(), Tt = ()
|
|
|
572
572
|
* @param {any[]} args - 额外参数
|
|
573
573
|
*/
|
|
574
574
|
static trace(e, r, ...n) {
|
|
575
|
-
|
|
575
|
+
f.log(w.TRACE, e, r, ...n);
|
|
576
576
|
}
|
|
577
577
|
/**
|
|
578
578
|
* 获取日志历史
|
|
@@ -580,13 +580,13 @@ const K = new Rt(), Ue = () => K.waitForReady(), St = () => K.isReady(), Tt = ()
|
|
|
580
580
|
* @returns {Array} 日志条目数组
|
|
581
581
|
*/
|
|
582
582
|
static getHistory(e) {
|
|
583
|
-
return e && e > 0 ?
|
|
583
|
+
return e && e > 0 ? f.logHistory.slice(-e) : [...f.logHistory];
|
|
584
584
|
}
|
|
585
585
|
/**
|
|
586
586
|
* 清空日志历史
|
|
587
587
|
*/
|
|
588
588
|
static clearHistory() {
|
|
589
|
-
|
|
589
|
+
f.logHistory = [], f.log(w.INFO, "Logger", "日志历史已清空");
|
|
590
590
|
}
|
|
591
591
|
/**
|
|
592
592
|
* 获取日志统计信息
|
|
@@ -594,15 +594,15 @@ const K = new Rt(), Ue = () => K.waitForReady(), St = () => K.isReady(), Tt = ()
|
|
|
594
594
|
*/
|
|
595
595
|
static getStats() {
|
|
596
596
|
const e = {
|
|
597
|
-
currentLevel:
|
|
598
|
-
currentLevelName:
|
|
599
|
-
enabledModules: Array.from(
|
|
600
|
-
historySize:
|
|
601
|
-
maxHistorySize:
|
|
597
|
+
currentLevel: f.currentLevel,
|
|
598
|
+
currentLevelName: ee[f.currentLevel],
|
|
599
|
+
enabledModules: Array.from(f.enabledModules),
|
|
600
|
+
historySize: f.logHistory.length,
|
|
601
|
+
maxHistorySize: f.maxHistorySize
|
|
602
602
|
}, r = {};
|
|
603
|
-
for (const n of Object.keys(
|
|
604
|
-
r[
|
|
605
|
-
return
|
|
603
|
+
for (const n of Object.keys(ee))
|
|
604
|
+
r[ee[n]] = 0;
|
|
605
|
+
return f.logHistory.forEach((n) => {
|
|
606
606
|
r[n.levelName]++;
|
|
607
607
|
}), e.levelCounts = r, e;
|
|
608
608
|
}
|
|
@@ -612,7 +612,7 @@ const K = new Rt(), Ue = () => K.waitForReady(), St = () => K.isReady(), Tt = ()
|
|
|
612
612
|
* @returns {string} JSON 字符串
|
|
613
613
|
*/
|
|
614
614
|
static exportToJSON(e) {
|
|
615
|
-
const r =
|
|
615
|
+
const r = f.getHistory(e), n = f.getStats();
|
|
616
616
|
return JSON.stringify({
|
|
617
617
|
exportTime: (/* @__PURE__ */ new Date()).toISOString(),
|
|
618
618
|
stats: n,
|
|
@@ -626,11 +626,11 @@ const K = new Rt(), Ue = () => K.waitForReady(), St = () => K.isReady(), Tt = ()
|
|
|
626
626
|
*/
|
|
627
627
|
static createModuleLogger(e) {
|
|
628
628
|
return {
|
|
629
|
-
error: (r, ...n) =>
|
|
630
|
-
warn: (r, ...n) =>
|
|
631
|
-
info: (r, ...n) =>
|
|
632
|
-
debug: (r, ...n) =>
|
|
633
|
-
trace: (r, ...n) =>
|
|
629
|
+
error: (r, ...n) => f.error(e, r, ...n),
|
|
630
|
+
warn: (r, ...n) => f.warn(e, r, ...n),
|
|
631
|
+
info: (r, ...n) => f.info(e, r, ...n),
|
|
632
|
+
debug: (r, ...n) => f.debug(e, r, ...n),
|
|
633
|
+
trace: (r, ...n) => f.trace(e, r, ...n)
|
|
634
634
|
};
|
|
635
635
|
}
|
|
636
636
|
/**
|
|
@@ -638,14 +638,14 @@ const K = new Rt(), Ue = () => K.waitForReady(), St = () => K.isReady(), Tt = ()
|
|
|
638
638
|
* @param {(entry: any) => void|null} reporter
|
|
639
639
|
*/
|
|
640
640
|
static setReporter(e) {
|
|
641
|
-
|
|
641
|
+
f.reporter = typeof e == "function" ? e : null;
|
|
642
642
|
}
|
|
643
643
|
};
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
let S =
|
|
644
|
+
v(f, "currentLevel", w.ERROR), // 生产环境默认只显示错误
|
|
645
|
+
v(f, "enabledModules", /* @__PURE__ */ new Set()), // 启用日志的模块
|
|
646
|
+
v(f, "logHistory", []), // 日志历史(最多保留1000条)
|
|
647
|
+
v(f, "maxHistorySize", 1e3), v(f, "prefix", "[QSH-SDK]"), v(f, "reporter", null);
|
|
648
|
+
let S = f;
|
|
649
649
|
if (typeof window != "undefined") {
|
|
650
650
|
const t = window.location && (window.location.hostname === "localhost" || window.location.hostname === "127.0.0.1" || window.location.hostname.includes("192.168.")), e = window.location && (window.location.search.includes("debug=true") || window.location.search.includes("qsh_debug=1"));
|
|
651
651
|
let r = !1;
|
|
@@ -655,32 +655,32 @@ if (typeof window != "undefined") {
|
|
|
655
655
|
}
|
|
656
656
|
(t || e || r) && S.enableDevMode();
|
|
657
657
|
}
|
|
658
|
-
const
|
|
659
|
-
function
|
|
660
|
-
return
|
|
658
|
+
const y = S.createModuleLogger("Bridge"), _ = S.createModuleLogger("Platform"), s = S.createModuleLogger("API"), M = S.createModuleLogger("State"), ke = /complete|loaded|interactive/;
|
|
659
|
+
function Ut(t) {
|
|
660
|
+
return me() || Ce() ? (y.debug("检测到 APP 环境,开始初始化"), window.__uniapp_x_postMessage || window.__uniapp_x_ || window.__dcloud_weex_postMessage || window.__dcloud_weex_ ? (y.debug("NVUE/UVUE 环境,等待 DOMContentLoaded"), document.addEventListener("DOMContentLoaded", t)) : window.plus && ke.test(document.readyState) ? (y.debug("Plus 环境已就绪,立即初始化"), setTimeout(t, 0)) : (y.debug("Plus 环境,等待 plusready 事件"), document.addEventListener("plusready", t)), !0) : !1;
|
|
661
661
|
}
|
|
662
|
-
function
|
|
663
|
-
return window.wx && window.wx.miniProgram ? (
|
|
662
|
+
function Wt(t) {
|
|
663
|
+
return window.wx && window.wx.miniProgram ? (y.debug("检测到微信小程序环境,开始初始化"), window.WeixinJSBridge && window.WeixinJSBridge.invoke ? (y.debug("微信 JSBridge 已就绪,立即初始化"), setTimeout(t, 0)) : (y.debug("微信 JSBridge 未就绪,等待 WeixinJSBridgeReady 事件"), document.addEventListener("WeixinJSBridgeReady", t)), !0) : !1;
|
|
664
664
|
}
|
|
665
|
-
function
|
|
666
|
-
return
|
|
665
|
+
function $t(t) {
|
|
666
|
+
return y.info("开始初始化 JSBridge"), Ut(t) ? (y.info("使用 APP 环境初始化"), !0) : Wt(t) ? (y.info("使用微信小程序环境初始化"), !0) : (y.debug("使用默认 H5 环境初始化"), ke.test(document.readyState) ? (y.debug("DOM 已就绪,立即初始化"), setTimeout(t, 0)) : (y.debug("DOM 未就绪,等待 DOMContentLoaded"), document.addEventListener("DOMContentLoaded", t)), !0);
|
|
667
667
|
}
|
|
668
|
-
function
|
|
669
|
-
return
|
|
668
|
+
function Bt() {
|
|
669
|
+
return G.waitForReady();
|
|
670
670
|
}
|
|
671
|
-
function
|
|
672
|
-
return
|
|
671
|
+
function ze() {
|
|
672
|
+
return G.startInitialization(() => m(null, null, function* () {
|
|
673
673
|
return new Promise((t, e) => {
|
|
674
674
|
const r = () => {
|
|
675
675
|
t();
|
|
676
676
|
}, n = (i) => {
|
|
677
|
-
const
|
|
677
|
+
const a = u.handleApiError(i, {
|
|
678
678
|
context: "bridge initialization"
|
|
679
679
|
});
|
|
680
|
-
e(
|
|
680
|
+
e(a);
|
|
681
681
|
};
|
|
682
682
|
try {
|
|
683
|
-
|
|
683
|
+
$t(() => {
|
|
684
684
|
r();
|
|
685
685
|
});
|
|
686
686
|
} catch (i) {
|
|
@@ -695,7 +695,7 @@ const R = {
|
|
|
695
695
|
CONFIGURED: "configured",
|
|
696
696
|
ERROR: "error"
|
|
697
697
|
};
|
|
698
|
-
class
|
|
698
|
+
class Ft {
|
|
699
699
|
constructor() {
|
|
700
700
|
this.state = R.UNINITIALIZED, this.configPromise = null, this.readyCallbacks = [], this.errorCallbacks = [], this.lastError = null, this.CONFIG_API_URL = this.getConfigApiUrl(), this.CLIENT_ID = "bmfw-client", 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);
|
|
701
701
|
}
|
|
@@ -727,24 +727,24 @@ class vt {
|
|
|
727
727
|
return m(this, null, function* () {
|
|
728
728
|
const e = this.getCurrentPageUrl();
|
|
729
729
|
if (this.isTestMode())
|
|
730
|
-
return
|
|
730
|
+
return _.info("使用测试模式,返回模拟配置"), this.getMockConfig();
|
|
731
731
|
const r = `${this.CONFIG_API_URL}?clientId=${this.CLIENT_ID}&url=${encodeURIComponent(e)}`;
|
|
732
|
-
|
|
732
|
+
_.debug("请求微信配置", { url: r });
|
|
733
733
|
try {
|
|
734
734
|
const n = yield fetch(r);
|
|
735
735
|
if (!n.ok)
|
|
736
736
|
throw new Error(`HTTP ${n.status}: ${n.statusText}`);
|
|
737
737
|
const i = yield n.json();
|
|
738
|
-
if (
|
|
738
|
+
if (_.debug("微信配置响应", i), !i.success || i.code !== 200)
|
|
739
739
|
throw new Error(`配置获取失败: ${i.message || "未知错误"}`);
|
|
740
|
-
const { data:
|
|
741
|
-
if (!
|
|
740
|
+
const { data: a } = i;
|
|
741
|
+
if (!a || !a.appId || !a.timestamp || !a.nonceStr || !a.signature)
|
|
742
742
|
throw new Error("配置数据格式不正确,缺少必需字段");
|
|
743
|
-
return
|
|
743
|
+
return a;
|
|
744
744
|
} catch (n) {
|
|
745
|
-
if (
|
|
746
|
-
return
|
|
747
|
-
throw new
|
|
745
|
+
if (_.error("获取微信配置失败", n), this.shouldUseTestMode(n))
|
|
746
|
+
return _.warn("网络请求失败,降级到测试模式"), this.getMockConfig();
|
|
747
|
+
throw new L(
|
|
748
748
|
U.NETWORK_ERROR,
|
|
749
749
|
`获取微信配置失败: ${n.message}`,
|
|
750
750
|
{ url: r, originalError: n }
|
|
@@ -796,7 +796,7 @@ class vt {
|
|
|
796
796
|
*/
|
|
797
797
|
executeWeixinConfig(e) {
|
|
798
798
|
if (this.isTestMode() || e.appId === "wx_test_app_id") {
|
|
799
|
-
|
|
799
|
+
_.info("测试模式:模拟微信配置成功"), setTimeout(() => {
|
|
800
800
|
this.handleConfigSuccess();
|
|
801
801
|
}, 100);
|
|
802
802
|
return;
|
|
@@ -812,18 +812,18 @@ class vt {
|
|
|
812
812
|
signature: e.signature,
|
|
813
813
|
jsApiList: this.DEFAULT_JS_API_LIST
|
|
814
814
|
};
|
|
815
|
-
|
|
815
|
+
_.info("执行微信配置", r), window.wx.ready(this.handleConfigSuccess), window.wx.error(this.handleConfigError), window.wx.config(r);
|
|
816
816
|
}
|
|
817
817
|
/**
|
|
818
818
|
* 处理配置成功
|
|
819
819
|
* @private
|
|
820
820
|
*/
|
|
821
821
|
handleConfigSuccess() {
|
|
822
|
-
|
|
822
|
+
_.info("微信配置成功"), this.state = R.CONFIGURED, this.readyCallbacks.forEach((e) => {
|
|
823
823
|
try {
|
|
824
824
|
e();
|
|
825
825
|
} catch (r) {
|
|
826
|
-
|
|
826
|
+
u.handleApiError(r, { context: "WeixinConfigManager.handleConfigSuccess" });
|
|
827
827
|
}
|
|
828
828
|
}), this.readyCallbacks = [], this.errorCallbacks = [];
|
|
829
829
|
}
|
|
@@ -834,7 +834,7 @@ class vt {
|
|
|
834
834
|
*/
|
|
835
835
|
handleConfigError(e) {
|
|
836
836
|
const r = `微信配置验证失败: ${JSON.stringify(e)}`;
|
|
837
|
-
|
|
837
|
+
_.error(r, e), this.state = R.ERROR, this.lastError = new L(
|
|
838
838
|
U.API_CALL_FAILED,
|
|
839
839
|
r,
|
|
840
840
|
{ weixinErrorResponse: e }
|
|
@@ -842,7 +842,7 @@ class vt {
|
|
|
842
842
|
try {
|
|
843
843
|
n(this.lastError);
|
|
844
844
|
} catch (i) {
|
|
845
|
-
|
|
845
|
+
u.handleApiError(i, { context: "WeixinConfigManager.handleConfigError" });
|
|
846
846
|
}
|
|
847
847
|
}), this.readyCallbacks = [], this.errorCallbacks = [];
|
|
848
848
|
}
|
|
@@ -862,7 +862,7 @@ class vt {
|
|
|
862
862
|
*/
|
|
863
863
|
performAutoConfig() {
|
|
864
864
|
return m(this, null, function* () {
|
|
865
|
-
return
|
|
865
|
+
return u.safeExecuteAsync(() => m(this, null, function* () {
|
|
866
866
|
if (typeof window == "undefined")
|
|
867
867
|
throw new Error("非浏览器环境无法执行微信配置");
|
|
868
868
|
if (!window.wx)
|
|
@@ -916,7 +916,7 @@ class vt {
|
|
|
916
916
|
* 重置配置管理器(用于重试或测试)
|
|
917
917
|
*/
|
|
918
918
|
reset() {
|
|
919
|
-
this.state = R.UNINITIALIZED, this.configPromise = null, this.readyCallbacks = [], this.errorCallbacks = [], this.lastError = null,
|
|
919
|
+
this.state = R.UNINITIALIZED, this.configPromise = null, this.readyCallbacks = [], this.errorCallbacks = [], this.lastError = null, _.debug("微信配置管理器已重置");
|
|
920
920
|
}
|
|
921
921
|
/**
|
|
922
922
|
* 获取配置统计信息
|
|
@@ -935,68 +935,68 @@ class vt {
|
|
|
935
935
|
};
|
|
936
936
|
}
|
|
937
937
|
}
|
|
938
|
-
const
|
|
939
|
-
let
|
|
940
|
-
function
|
|
941
|
-
if (typeof window == "undefined" ||
|
|
938
|
+
const F = new Ft();
|
|
939
|
+
let H = !1, Ie = !1, ue = !1;
|
|
940
|
+
function kt() {
|
|
941
|
+
if (typeof window == "undefined" || Ie || H || window.wx && window.wx.miniProgram) return !1;
|
|
942
942
|
const t = navigator.userAgent || "", e = /micromessenger/i.test(t), r = /miniProgram/i.test(t), n = typeof window.__wxjs_environment != "undefined" && window.__wxjs_environment === "miniprogram";
|
|
943
943
|
return e && (r || n);
|
|
944
944
|
}
|
|
945
|
-
function
|
|
945
|
+
function Ae() {
|
|
946
946
|
return m(this, null, function* () {
|
|
947
|
-
if (
|
|
948
|
-
return
|
|
949
|
-
|
|
947
|
+
if (ue)
|
|
948
|
+
return F.waitForReady();
|
|
949
|
+
ue = !0, _.info("开始自动配置微信JS-SDK");
|
|
950
950
|
try {
|
|
951
|
-
yield
|
|
951
|
+
yield F.autoConfig(), _.info("微信JS-SDK自动配置完成");
|
|
952
952
|
} catch (t) {
|
|
953
|
-
|
|
953
|
+
_.error("微信JS-SDK自动配置失败", t);
|
|
954
954
|
}
|
|
955
955
|
});
|
|
956
956
|
}
|
|
957
|
-
function
|
|
958
|
-
return
|
|
959
|
-
|
|
957
|
+
function zt() {
|
|
958
|
+
return kt() ? document.getElementById("weixin-jssdk") ? (H = !1, Ie = !0, ue ? F.waitForReady() : Ae()) : new Promise((t) => {
|
|
959
|
+
H = !0;
|
|
960
960
|
try {
|
|
961
961
|
const e = document.createElement("script");
|
|
962
962
|
e.id = "weixin-jssdk", e.type = "text/javascript", e.async = !0, e.src = "https://res.wx.qq.com/open/js/jweixin-1.6.2.js", e.onload = function() {
|
|
963
963
|
return m(this, null, function* () {
|
|
964
|
-
|
|
964
|
+
Ie = !0, H = !1, _.info("微信 JS-SDK 已自动加载");
|
|
965
965
|
try {
|
|
966
|
-
yield
|
|
966
|
+
yield Ae();
|
|
967
967
|
} catch (n) {
|
|
968
|
-
|
|
968
|
+
_.error("微信配置失败,将使用消息桥作为后备", n);
|
|
969
969
|
}
|
|
970
970
|
t();
|
|
971
971
|
});
|
|
972
972
|
}, e.onerror = function() {
|
|
973
|
-
|
|
973
|
+
H = !1, _.warn("微信 JS-SDK 加载失败,SDK 将使用消息桥作为后备"), t();
|
|
974
974
|
}, (document.getElementsByTagName("head")[0] || document.documentElement).appendChild(e);
|
|
975
975
|
} catch (e) {
|
|
976
|
-
|
|
976
|
+
H = !1, _.error("注入微信 JS-SDK 失败", e), t();
|
|
977
977
|
}
|
|
978
978
|
}) : Promise.resolve();
|
|
979
979
|
}
|
|
980
980
|
function k() {
|
|
981
|
-
return
|
|
981
|
+
return F.waitForReady();
|
|
982
982
|
}
|
|
983
|
-
function
|
|
984
|
-
return
|
|
983
|
+
function z() {
|
|
984
|
+
return F.isReady();
|
|
985
985
|
}
|
|
986
|
-
function
|
|
987
|
-
return
|
|
986
|
+
function Kt() {
|
|
987
|
+
return F.getState();
|
|
988
988
|
}
|
|
989
|
-
function
|
|
990
|
-
return
|
|
989
|
+
function ve() {
|
|
990
|
+
return F;
|
|
991
991
|
}
|
|
992
|
-
function
|
|
992
|
+
function Gt() {
|
|
993
993
|
return m(this, null, function* () {
|
|
994
|
-
return
|
|
994
|
+
return _.info("手动重试微信配置"), F.reset(), ue = !1, Ae();
|
|
995
995
|
});
|
|
996
996
|
}
|
|
997
|
-
class
|
|
997
|
+
class Vt {
|
|
998
998
|
constructor() {
|
|
999
|
-
this.plugins = /* @__PURE__ */ new Map(), this.installed = /* @__PURE__ */ new Set(), this.installOrder = [],
|
|
999
|
+
this.plugins = /* @__PURE__ */ new Map(), this.installed = /* @__PURE__ */ new Set(), this.installOrder = [], s.debug("插件管理器已初始化");
|
|
1000
1000
|
}
|
|
1001
1001
|
/**
|
|
1002
1002
|
* 注册插件
|
|
@@ -1006,14 +1006,14 @@ class Wt {
|
|
|
1006
1006
|
* pluginManager.register(imagePlugin)
|
|
1007
1007
|
*/
|
|
1008
1008
|
register(e) {
|
|
1009
|
-
return
|
|
1009
|
+
return u.safeExecute(() => {
|
|
1010
1010
|
this.validatePlugin(e);
|
|
1011
1011
|
const { name: r, version: n } = e;
|
|
1012
1012
|
if (this.plugins.has(r)) {
|
|
1013
1013
|
const i = this.plugins.get(r);
|
|
1014
|
-
|
|
1014
|
+
s.warn(`插件 ${r} 已注册(版本 ${i.version}),将被覆盖为版本 ${n}`);
|
|
1015
1015
|
}
|
|
1016
|
-
return this.plugins.set(r, e),
|
|
1016
|
+
return this.plugins.set(r, e), s.info(`插件已注册: ${r}@${n}`), this;
|
|
1017
1017
|
}, {
|
|
1018
1018
|
context: "PluginManager.register",
|
|
1019
1019
|
pluginName: e == null ? void 0 : e.name
|
|
@@ -1047,20 +1047,20 @@ class Wt {
|
|
|
1047
1047
|
*/
|
|
1048
1048
|
install(e, r) {
|
|
1049
1049
|
return m(this, null, function* () {
|
|
1050
|
-
return
|
|
1050
|
+
return u.safeExecute(() => m(this, null, function* () {
|
|
1051
1051
|
if (!this.plugins.has(e))
|
|
1052
1052
|
throw new Error(`插件 ${e} 未注册`);
|
|
1053
1053
|
if (this.installed.has(e)) {
|
|
1054
|
-
|
|
1054
|
+
s.debug(`插件 ${e} 已安装,跳过`);
|
|
1055
1055
|
return;
|
|
1056
1056
|
}
|
|
1057
1057
|
const n = this.plugins.get(e);
|
|
1058
1058
|
if (n.dependencies && n.dependencies.length > 0) {
|
|
1059
|
-
|
|
1059
|
+
s.debug(`安装插件 ${e} 的依赖:`, n.dependencies);
|
|
1060
1060
|
for (const i of n.dependencies)
|
|
1061
1061
|
yield this.install(i, r);
|
|
1062
1062
|
}
|
|
1063
|
-
|
|
1063
|
+
s.info(`开始安装插件: ${e}@${n.version}`), yield n.install(r), this.installed.add(e), this.installOrder.push(e), s.info(`插件安装成功: ${e}@${n.version}`);
|
|
1064
1064
|
}), {
|
|
1065
1065
|
context: "PluginManager.install",
|
|
1066
1066
|
pluginName: e
|
|
@@ -1077,15 +1077,15 @@ class Wt {
|
|
|
1077
1077
|
*/
|
|
1078
1078
|
uninstall(e, r) {
|
|
1079
1079
|
return m(this, null, function* () {
|
|
1080
|
-
return
|
|
1080
|
+
return u.safeExecute(() => m(this, null, function* () {
|
|
1081
1081
|
if (!this.installed.has(e)) {
|
|
1082
|
-
|
|
1082
|
+
s.debug(`插件 ${e} 未安装,跳过卸载`);
|
|
1083
1083
|
return;
|
|
1084
1084
|
}
|
|
1085
1085
|
const n = this.plugins.get(e);
|
|
1086
|
-
n.uninstall && typeof n.uninstall == "function" && (
|
|
1086
|
+
n.uninstall && typeof n.uninstall == "function" && (s.info(`开始卸载插件: ${e}`), yield n.uninstall(r)), this.installed.delete(e);
|
|
1087
1087
|
const i = this.installOrder.indexOf(e);
|
|
1088
|
-
i > -1 && this.installOrder.splice(i, 1),
|
|
1088
|
+
i > -1 && this.installOrder.splice(i, 1), s.info(`插件已卸载: ${e}`);
|
|
1089
1089
|
}), {
|
|
1090
1090
|
context: "PluginManager.uninstall",
|
|
1091
1091
|
pluginName: e
|
|
@@ -1187,10 +1187,10 @@ class Wt {
|
|
|
1187
1187
|
this.plugins.clear(), this.installed.clear(), this.installOrder = [];
|
|
1188
1188
|
}
|
|
1189
1189
|
}
|
|
1190
|
-
const
|
|
1191
|
-
class
|
|
1190
|
+
const te = new Vt();
|
|
1191
|
+
class jt {
|
|
1192
1192
|
constructor() {
|
|
1193
|
-
this.requestInterceptors = [], this.responseInterceptors = [],
|
|
1193
|
+
this.requestInterceptors = [], this.responseInterceptors = [], s.debug("拦截器链已初始化");
|
|
1194
1194
|
}
|
|
1195
1195
|
/**
|
|
1196
1196
|
* 注册请求拦截器
|
|
@@ -1211,9 +1211,9 @@ class $t {
|
|
|
1211
1211
|
return this.requestInterceptors.push({
|
|
1212
1212
|
fn: e,
|
|
1213
1213
|
priority: n
|
|
1214
|
-
}), this.requestInterceptors.sort((i,
|
|
1215
|
-
const i = this.requestInterceptors.findIndex((
|
|
1216
|
-
i > -1 && (this.requestInterceptors.splice(i, 1),
|
|
1214
|
+
}), this.requestInterceptors.sort((i, a) => a.priority - i.priority), s.debug("请求拦截器已注册", { priority: n }), () => {
|
|
1215
|
+
const i = this.requestInterceptors.findIndex((a) => a.fn === e);
|
|
1216
|
+
i > -1 && (this.requestInterceptors.splice(i, 1), s.debug("请求拦截器已移除"));
|
|
1217
1217
|
};
|
|
1218
1218
|
}
|
|
1219
1219
|
/**
|
|
@@ -1235,9 +1235,9 @@ class $t {
|
|
|
1235
1235
|
return this.responseInterceptors.push({
|
|
1236
1236
|
fn: e,
|
|
1237
1237
|
priority: n
|
|
1238
|
-
}), this.responseInterceptors.sort((i,
|
|
1239
|
-
const i = this.responseInterceptors.findIndex((
|
|
1240
|
-
i > -1 && (this.responseInterceptors.splice(i, 1),
|
|
1238
|
+
}), this.responseInterceptors.sort((i, a) => a.priority - i.priority), s.debug("响应拦截器已注册", { priority: n }), () => {
|
|
1239
|
+
const i = this.responseInterceptors.findIndex((a) => a.fn === e);
|
|
1240
|
+
i > -1 && (this.responseInterceptors.splice(i, 1), s.debug("响应拦截器已移除"));
|
|
1241
1241
|
};
|
|
1242
1242
|
}
|
|
1243
1243
|
/**
|
|
@@ -1248,17 +1248,17 @@ class $t {
|
|
|
1248
1248
|
*/
|
|
1249
1249
|
runRequest(e) {
|
|
1250
1250
|
return m(this, null, function* () {
|
|
1251
|
-
let r =
|
|
1251
|
+
let r = p({}, e);
|
|
1252
1252
|
for (const { fn: n } of this.requestInterceptors) {
|
|
1253
1253
|
if (r.abort) {
|
|
1254
|
-
|
|
1254
|
+
s.debug("请求被中止", { apiName: r.apiName });
|
|
1255
1255
|
break;
|
|
1256
1256
|
}
|
|
1257
1257
|
try {
|
|
1258
1258
|
const i = yield n(r);
|
|
1259
1259
|
i && (r = i);
|
|
1260
1260
|
} catch (i) {
|
|
1261
|
-
|
|
1261
|
+
s.error("请求拦截器执行失败", i), r.abort = !0, r.error = i;
|
|
1262
1262
|
break;
|
|
1263
1263
|
}
|
|
1264
1264
|
}
|
|
@@ -1277,10 +1277,10 @@ class $t {
|
|
|
1277
1277
|
let n = e;
|
|
1278
1278
|
for (const { fn: i } of this.responseInterceptors)
|
|
1279
1279
|
try {
|
|
1280
|
-
const
|
|
1281
|
-
|
|
1282
|
-
} catch (
|
|
1283
|
-
|
|
1280
|
+
const a = yield i(n, r);
|
|
1281
|
+
a !== void 0 && (n = a);
|
|
1282
|
+
} catch (a) {
|
|
1283
|
+
s.error("响应拦截器执行失败", a);
|
|
1284
1284
|
}
|
|
1285
1285
|
return n;
|
|
1286
1286
|
});
|
|
@@ -1289,7 +1289,7 @@ class $t {
|
|
|
1289
1289
|
* 清空所有拦截器
|
|
1290
1290
|
*/
|
|
1291
1291
|
clear() {
|
|
1292
|
-
this.requestInterceptors = [], this.responseInterceptors = [],
|
|
1292
|
+
this.requestInterceptors = [], this.responseInterceptors = [], s.debug("所有拦截器已清空");
|
|
1293
1293
|
}
|
|
1294
1294
|
/**
|
|
1295
1295
|
* 获取统计信息
|
|
@@ -1302,11 +1302,11 @@ class $t {
|
|
|
1302
1302
|
};
|
|
1303
1303
|
}
|
|
1304
1304
|
}
|
|
1305
|
-
const
|
|
1305
|
+
const K = new jt(), qt = {
|
|
1306
1306
|
/**
|
|
1307
1307
|
* 请求日志
|
|
1308
1308
|
*/
|
|
1309
|
-
request: (t) => (t.startTime = Date.now(),
|
|
1309
|
+
request: (t) => (t.startTime = Date.now(), s.debug(`[API 调用] ${t.apiName}`, {
|
|
1310
1310
|
params: t.params
|
|
1311
1311
|
}), t),
|
|
1312
1312
|
/**
|
|
@@ -1314,7 +1314,7 @@ const F = new $t(), kt = {
|
|
|
1314
1314
|
*/
|
|
1315
1315
|
response: (t, e) => {
|
|
1316
1316
|
const r = Date.now() - e.startTime;
|
|
1317
|
-
return
|
|
1317
|
+
return s.debug(`[API 完成] ${e.apiName}`, {
|
|
1318
1318
|
duration: `${r}ms`,
|
|
1319
1319
|
success: t == null ? void 0 : t.success
|
|
1320
1320
|
}), t;
|
|
@@ -1347,7 +1347,7 @@ const F = new $t(), kt = {
|
|
|
1347
1347
|
getReport: () => {
|
|
1348
1348
|
const t = {};
|
|
1349
1349
|
return W.metrics.forEach((e, r) => {
|
|
1350
|
-
t[r] =
|
|
1350
|
+
t[r] = p({}, e);
|
|
1351
1351
|
}), t;
|
|
1352
1352
|
},
|
|
1353
1353
|
/**
|
|
@@ -1357,31 +1357,31 @@ const F = new $t(), kt = {
|
|
|
1357
1357
|
W.metrics.clear();
|
|
1358
1358
|
}
|
|
1359
1359
|
};
|
|
1360
|
-
function
|
|
1360
|
+
function Jt(t = {}) {
|
|
1361
1361
|
const {
|
|
1362
1362
|
maxRetries: e = 3,
|
|
1363
1363
|
retryDelay: r = 1e3,
|
|
1364
1364
|
shouldRetry: n = (i) => !i.success
|
|
1365
1365
|
} = t;
|
|
1366
1366
|
return {
|
|
1367
|
-
response: (i,
|
|
1368
|
-
return
|
|
1367
|
+
response: (i, a) => m(null, null, function* () {
|
|
1368
|
+
return a.retryCount || (a.retryCount = 0), n(i) && a.retryCount < e && (a.retryCount++, s.warn(`API 调用失败,第 ${a.retryCount} 次重试: ${a.apiName}`), yield new Promise((g) => setTimeout(g, r)), i.shouldRetry = !0, i.retryContext = a), i;
|
|
1369
1369
|
})
|
|
1370
1370
|
};
|
|
1371
1371
|
}
|
|
1372
|
-
function
|
|
1372
|
+
function Ht(t = {}) {
|
|
1373
1373
|
return {
|
|
1374
1374
|
request: (e) => {
|
|
1375
1375
|
const r = t[e.apiName];
|
|
1376
1376
|
if (r && typeof r == "function") {
|
|
1377
1377
|
const n = r(e.params);
|
|
1378
|
-
n && (
|
|
1378
|
+
n && (s.error(`参数验证失败: ${e.apiName}`, n), e.abort = !0, e.validationError = n);
|
|
1379
1379
|
}
|
|
1380
1380
|
return e;
|
|
1381
1381
|
}
|
|
1382
1382
|
};
|
|
1383
1383
|
}
|
|
1384
|
-
class
|
|
1384
|
+
class Yt {
|
|
1385
1385
|
constructor() {
|
|
1386
1386
|
this.state = {
|
|
1387
1387
|
// SDK 状态
|
|
@@ -1393,11 +1393,11 @@ class Kt {
|
|
|
1393
1393
|
},
|
|
1394
1394
|
// 平台信息
|
|
1395
1395
|
platform: {
|
|
1396
|
-
type:
|
|
1397
|
-
isWeixinMiniProgram:
|
|
1398
|
-
isAppPlus:
|
|
1399
|
-
isNvue:
|
|
1400
|
-
isUvue:
|
|
1396
|
+
type: c.type,
|
|
1397
|
+
isWeixinMiniProgram: c.isWeixinMiniProgram,
|
|
1398
|
+
isAppPlus: c.isAppPlus,
|
|
1399
|
+
isNvue: c.isNvue,
|
|
1400
|
+
isUvue: c.isUvue,
|
|
1401
1401
|
features: {}
|
|
1402
1402
|
// 平台支持的特性
|
|
1403
1403
|
},
|
|
@@ -1447,8 +1447,8 @@ class Kt {
|
|
|
1447
1447
|
* store.set('network.online', false)
|
|
1448
1448
|
*/
|
|
1449
1449
|
set(e, r) {
|
|
1450
|
-
const n = e.split("."), i = n.pop(),
|
|
1451
|
-
|
|
1450
|
+
const n = e.split("."), i = n.pop(), a = n.reduce((d, l) => ((!d[l] || typeof d[l] != "object") && (d[l] = {}), d[l]), this.state), g = a[i];
|
|
1451
|
+
g !== r && (a[i] = r, M.debug(`状态已更新: ${e}`, { oldValue: g, newValue: r }), this.notify(e, r, g));
|
|
1452
1452
|
}
|
|
1453
1453
|
/**
|
|
1454
1454
|
* 批量更新状态
|
|
@@ -1493,8 +1493,8 @@ class Kt {
|
|
|
1493
1493
|
* @returns {Function} 取消订阅的函数
|
|
1494
1494
|
*/
|
|
1495
1495
|
subscribeOnce(e, r) {
|
|
1496
|
-
const n = this.subscribe(e, (i,
|
|
1497
|
-
r(i,
|
|
1496
|
+
const n = this.subscribe(e, (i, a, g) => {
|
|
1497
|
+
r(i, a, g), n();
|
|
1498
1498
|
});
|
|
1499
1499
|
return n;
|
|
1500
1500
|
}
|
|
@@ -1507,32 +1507,32 @@ class Kt {
|
|
|
1507
1507
|
*/
|
|
1508
1508
|
notify(e, r, n) {
|
|
1509
1509
|
const i = this.listeners.get(e);
|
|
1510
|
-
i && i.forEach((
|
|
1510
|
+
i && i.forEach((g) => {
|
|
1511
1511
|
try {
|
|
1512
|
-
|
|
1513
|
-
} catch (
|
|
1514
|
-
M.error("订阅者执行失败",
|
|
1512
|
+
g(r, n, e);
|
|
1513
|
+
} catch (d) {
|
|
1514
|
+
M.error("订阅者执行失败", d);
|
|
1515
1515
|
}
|
|
1516
1516
|
});
|
|
1517
|
-
const
|
|
1518
|
-
for (let
|
|
1519
|
-
const
|
|
1520
|
-
if (
|
|
1521
|
-
const
|
|
1522
|
-
|
|
1517
|
+
const a = e.split(".");
|
|
1518
|
+
for (let g = 1; g < a.length; g++) {
|
|
1519
|
+
const d = a.slice(0, g).join("."), l = this.listeners.get(d);
|
|
1520
|
+
if (l) {
|
|
1521
|
+
const h = this.get(d);
|
|
1522
|
+
l.forEach((T) => {
|
|
1523
1523
|
try {
|
|
1524
|
-
|
|
1524
|
+
T(h, void 0, d);
|
|
1525
1525
|
} catch (N) {
|
|
1526
1526
|
M.error("父路径订阅者执行失败", N);
|
|
1527
1527
|
}
|
|
1528
1528
|
});
|
|
1529
1529
|
}
|
|
1530
1530
|
}
|
|
1531
|
-
this.wildcardListeners.forEach((
|
|
1531
|
+
this.wildcardListeners.forEach((g) => {
|
|
1532
1532
|
try {
|
|
1533
|
-
|
|
1534
|
-
} catch (
|
|
1535
|
-
M.error("通配符订阅者执行失败",
|
|
1533
|
+
g(r, n, e);
|
|
1534
|
+
} catch (d) {
|
|
1535
|
+
M.error("通配符订阅者执行失败", d);
|
|
1536
1536
|
}
|
|
1537
1537
|
});
|
|
1538
1538
|
}
|
|
@@ -1558,7 +1558,7 @@ class Kt {
|
|
|
1558
1558
|
*/
|
|
1559
1559
|
setApiLoading(e, r = !0) {
|
|
1560
1560
|
const n = `api.${e}`, i = this.get(n) || {};
|
|
1561
|
-
this.set(n, A(
|
|
1561
|
+
this.set(n, A(p({}, i), {
|
|
1562
1562
|
loading: r,
|
|
1563
1563
|
lastCall: r ? Date.now() : i.lastCall
|
|
1564
1564
|
}));
|
|
@@ -1570,7 +1570,7 @@ class Kt {
|
|
|
1570
1570
|
*/
|
|
1571
1571
|
setApiResult(e, r) {
|
|
1572
1572
|
const n = `api.${e}`, i = this.get(n) || {};
|
|
1573
|
-
this.set(n, A(
|
|
1573
|
+
this.set(n, A(p({}, i), {
|
|
1574
1574
|
loading: !1,
|
|
1575
1575
|
lastResult: r,
|
|
1576
1576
|
lastCallEnd: Date.now()
|
|
@@ -1625,7 +1625,7 @@ class Kt {
|
|
|
1625
1625
|
};
|
|
1626
1626
|
}
|
|
1627
1627
|
}
|
|
1628
|
-
const
|
|
1628
|
+
const x = new Yt(), o = {
|
|
1629
1629
|
// SDK 核心错误 (E_SDK_xxx)
|
|
1630
1630
|
SDK_NOT_READY: "E_SDK_001",
|
|
1631
1631
|
SDK_INIT_FAILED: "E_SDK_002",
|
|
@@ -1676,7 +1676,7 @@ const D = new Kt(), o = {
|
|
|
1676
1676
|
API_TIMEOUT: "E_TIMEOUT_001",
|
|
1677
1677
|
// 通用错误
|
|
1678
1678
|
UNKNOWN_ERROR: "E_UNKNOWN_999"
|
|
1679
|
-
},
|
|
1679
|
+
}, Oe = {
|
|
1680
1680
|
// SDK 核心
|
|
1681
1681
|
[o.SDK_NOT_READY]: "SDK 未就绪",
|
|
1682
1682
|
[o.SDK_INIT_FAILED]: "SDK 初始化失败",
|
|
@@ -1732,7 +1732,7 @@ const D = new Kt(), o = {
|
|
|
1732
1732
|
// 配置问题
|
|
1733
1733
|
UNKNOWN: "unknown"
|
|
1734
1734
|
// 未知问题
|
|
1735
|
-
},
|
|
1735
|
+
}, Xt = {
|
|
1736
1736
|
// 图片相关
|
|
1737
1737
|
"IMAGE/USER_CANCEL": o.IMAGE_CANCELLED,
|
|
1738
1738
|
"IMAGE/PERMISSION_DENIED": o.IMAGE_NO_PERMISSION,
|
|
@@ -1740,7 +1740,7 @@ const D = new Kt(), o = {
|
|
|
1740
1740
|
"COMMON/UNKNOWN": o.UNKNOWN_ERROR,
|
|
1741
1741
|
"COMMON/CONFIG_NOT_READY": o.IMAGE_CONFIG_NOT_READY,
|
|
1742
1742
|
"COMMON/PLATFORM_NOT_SUPPORTED": o.PLATFORM_NOT_SUPPORTED
|
|
1743
|
-
},
|
|
1743
|
+
}, xe = {
|
|
1744
1744
|
// 微信平台错误模式
|
|
1745
1745
|
weixin: {
|
|
1746
1746
|
patterns: [
|
|
@@ -1763,7 +1763,7 @@ const D = new Kt(), o = {
|
|
|
1763
1763
|
],
|
|
1764
1764
|
default: o.UNKNOWN_ERROR
|
|
1765
1765
|
}
|
|
1766
|
-
},
|
|
1766
|
+
}, De = {
|
|
1767
1767
|
chooseImage: {
|
|
1768
1768
|
"fail cancel": o.IMAGE_CANCELLED,
|
|
1769
1769
|
"fail auth deny": o.IMAGE_NO_PERMISSION,
|
|
@@ -1777,19 +1777,19 @@ const D = new Kt(), o = {
|
|
|
1777
1777
|
NOT_IN_CONTAINER: o.PLATFORM_NOT_SUPPORTED
|
|
1778
1778
|
}
|
|
1779
1779
|
};
|
|
1780
|
-
function
|
|
1780
|
+
function Ke(t) {
|
|
1781
1781
|
return t ? t.includes("CANCEL") ? b.USER_CANCEL : t.includes("PERM") || t.includes("PERMISSION") ? b.PERMISSION : t.includes("NET") || t.includes("NETWORK") ? b.NETWORK : t.includes("PARAM") ? b.PARAM : t.includes("CONFIG") ? b.CONFIG : t.includes("SDK") || t.includes("PLATFORM") ? b.SYSTEM : b.UNKNOWN : b.UNKNOWN;
|
|
1782
1782
|
}
|
|
1783
|
-
function
|
|
1783
|
+
function Zt(t) {
|
|
1784
1784
|
return t.includes("NET_") || t.includes("TIMEOUT") || t === o.NETWORK_ERROR || t === o.NETWORK_TIMEOUT || t === o.API_TIMEOUT;
|
|
1785
1785
|
}
|
|
1786
|
-
function
|
|
1787
|
-
return t.includes("CANCEL") ||
|
|
1786
|
+
function Qt(t) {
|
|
1787
|
+
return t.includes("CANCEL") || Ke(t) === b.USER_CANCEL;
|
|
1788
1788
|
}
|
|
1789
|
-
function
|
|
1790
|
-
return
|
|
1789
|
+
function Y(t) {
|
|
1790
|
+
return Oe[t] || Oe[o.UNKNOWN_ERROR];
|
|
1791
1791
|
}
|
|
1792
|
-
class
|
|
1792
|
+
class D extends Error {
|
|
1793
1793
|
/**
|
|
1794
1794
|
* 构造函数
|
|
1795
1795
|
* @param {string} code - 错误码
|
|
@@ -1797,7 +1797,7 @@ class x extends Error {
|
|
|
1797
1797
|
* @param {Object} options - 选项
|
|
1798
1798
|
*/
|
|
1799
1799
|
constructor(e, r, n = {}) {
|
|
1800
|
-
super(r), this.name = "StandardError", this.code = e, this.message = r ||
|
|
1800
|
+
super(r), this.name = "StandardError", this.code = e, this.message = r || Y(e), this.platform = n.platform || c.type, this.apiName = n.apiName, this.category = n.category || Ke(e), this.retriable = n.retriable !== void 0 ? n.retriable : Zt(e), this.originalError = n.originalError, this.details = n.details || {}, this.timestamp = Date.now();
|
|
1801
1801
|
}
|
|
1802
1802
|
/**
|
|
1803
1803
|
* 是否可重试
|
|
@@ -1811,14 +1811,14 @@ class x extends Error {
|
|
|
1811
1811
|
* @returns {boolean}
|
|
1812
1812
|
*/
|
|
1813
1813
|
isUserAction() {
|
|
1814
|
-
return
|
|
1814
|
+
return Qt(this.code);
|
|
1815
1815
|
}
|
|
1816
1816
|
/**
|
|
1817
1817
|
* 转为普通对象
|
|
1818
1818
|
* @returns {Object}
|
|
1819
1819
|
*/
|
|
1820
1820
|
toJSON() {
|
|
1821
|
-
return
|
|
1821
|
+
return p({
|
|
1822
1822
|
code: this.code,
|
|
1823
1823
|
message: this.message,
|
|
1824
1824
|
platform: this.platform,
|
|
@@ -1832,15 +1832,15 @@ class x extends Error {
|
|
|
1832
1832
|
} : {});
|
|
1833
1833
|
}
|
|
1834
1834
|
}
|
|
1835
|
-
function
|
|
1836
|
-
if (t instanceof
|
|
1835
|
+
function Ge(t, e = {}) {
|
|
1836
|
+
if (t instanceof D)
|
|
1837
1837
|
return t;
|
|
1838
|
-
const { apiName: r, platform: n =
|
|
1839
|
-
return t && typeof t.code == "string" && t.code.includes("/") ?
|
|
1838
|
+
const { apiName: r, platform: n = c.type } = e;
|
|
1839
|
+
return t && typeof t.code == "string" && t.code.includes("/") ? er(t, { apiName: r, platform: n }) : t && (t.errMsg || t.message) ? tr(t, { apiName: r, platform: n }) : typeof t == "string" ? new D(
|
|
1840
1840
|
o.UNKNOWN_ERROR,
|
|
1841
1841
|
t,
|
|
1842
1842
|
{ apiName: r, platform: n, originalError: t }
|
|
1843
|
-
) : new
|
|
1843
|
+
) : new D(
|
|
1844
1844
|
o.UNKNOWN_ERROR,
|
|
1845
1845
|
"未知错误",
|
|
1846
1846
|
{
|
|
@@ -1851,49 +1851,49 @@ function Be(t, e = {}) {
|
|
|
1851
1851
|
}
|
|
1852
1852
|
);
|
|
1853
1853
|
}
|
|
1854
|
-
function
|
|
1855
|
-
const { apiName: r, platform: n } = e, i = t.code,
|
|
1856
|
-
return
|
|
1854
|
+
function er(t, e) {
|
|
1855
|
+
const { apiName: r, platform: n } = e, i = t.code, a = Xt[i] || o.UNKNOWN_ERROR;
|
|
1856
|
+
return s.debug("转换旧版错误码", {
|
|
1857
1857
|
legacy: i,
|
|
1858
|
-
new:
|
|
1859
|
-
}), new
|
|
1860
|
-
|
|
1861
|
-
t.message ||
|
|
1858
|
+
new: a
|
|
1859
|
+
}), new D(
|
|
1860
|
+
a,
|
|
1861
|
+
t.message || Y(a),
|
|
1862
1862
|
{
|
|
1863
1863
|
apiName: r,
|
|
1864
1864
|
platform: t.platform || n,
|
|
1865
1865
|
originalError: t,
|
|
1866
|
-
details:
|
|
1866
|
+
details: p({
|
|
1867
1867
|
legacyCode: i,
|
|
1868
1868
|
legacyVersion: t.version
|
|
1869
1869
|
}, t.details)
|
|
1870
1870
|
}
|
|
1871
1871
|
);
|
|
1872
1872
|
}
|
|
1873
|
-
function
|
|
1873
|
+
function tr(t, e) {
|
|
1874
1874
|
const { apiName: r, platform: n } = e, i = (t.errMsg || t.message || "").toLowerCase();
|
|
1875
|
-
if (r &&
|
|
1876
|
-
const
|
|
1877
|
-
for (const [
|
|
1878
|
-
if (i.includes(
|
|
1879
|
-
return new
|
|
1875
|
+
if (r && De[r]) {
|
|
1876
|
+
const d = De[r];
|
|
1877
|
+
for (const [l, h] of Object.entries(d))
|
|
1878
|
+
if (i.includes(l.toLowerCase()))
|
|
1879
|
+
return new D(h, Y(h), {
|
|
1880
1880
|
apiName: r,
|
|
1881
1881
|
platform: n,
|
|
1882
1882
|
originalError: t
|
|
1883
1883
|
});
|
|
1884
1884
|
}
|
|
1885
|
-
const
|
|
1886
|
-
for (const { pattern:
|
|
1887
|
-
if (
|
|
1888
|
-
return new
|
|
1885
|
+
const a = xe[n] || xe.uniapp;
|
|
1886
|
+
for (const { pattern: d, code: l } of a.patterns)
|
|
1887
|
+
if (d.test(i))
|
|
1888
|
+
return new D(l, Y(l), {
|
|
1889
1889
|
apiName: r,
|
|
1890
1890
|
platform: n,
|
|
1891
1891
|
originalError: t
|
|
1892
1892
|
});
|
|
1893
|
-
const
|
|
1894
|
-
return new
|
|
1895
|
-
|
|
1896
|
-
t.errMsg || t.message ||
|
|
1893
|
+
const g = a.default || o.UNKNOWN_ERROR;
|
|
1894
|
+
return new D(
|
|
1895
|
+
g,
|
|
1896
|
+
t.errMsg || t.message || Y(g),
|
|
1897
1897
|
{
|
|
1898
1898
|
apiName: r,
|
|
1899
1899
|
platform: n,
|
|
@@ -1901,7 +1901,7 @@ function qt(t, e) {
|
|
|
1901
1901
|
}
|
|
1902
1902
|
);
|
|
1903
1903
|
}
|
|
1904
|
-
const
|
|
1904
|
+
const Ve = {
|
|
1905
1905
|
/**
|
|
1906
1906
|
* 响应拦截器
|
|
1907
1907
|
* @param {Object} result - API 响应结果
|
|
@@ -1910,11 +1910,11 @@ const Fe = {
|
|
|
1910
1910
|
*/
|
|
1911
1911
|
response: (t, e) => {
|
|
1912
1912
|
if (!t.success && t.error) {
|
|
1913
|
-
const r =
|
|
1913
|
+
const r = Ge(t.error, {
|
|
1914
1914
|
apiName: e.apiName,
|
|
1915
|
-
platform:
|
|
1915
|
+
platform: c.type
|
|
1916
1916
|
});
|
|
1917
|
-
t.error = r.toJSON(), t.errorCode = r.code, t.errorCategory = r.category, t.retriable = r.isRetriable(),
|
|
1917
|
+
t.error = r.toJSON(), t.errorCode = r.code, t.errorCategory = r.category, t.retriable = r.isRetriable(), s.debug("错误已标准化", {
|
|
1918
1918
|
api: e.apiName,
|
|
1919
1919
|
code: r.code,
|
|
1920
1920
|
category: r.category
|
|
@@ -1923,35 +1923,35 @@ const Fe = {
|
|
|
1923
1923
|
return t;
|
|
1924
1924
|
}
|
|
1925
1925
|
};
|
|
1926
|
-
function
|
|
1927
|
-
return new
|
|
1926
|
+
function rr(t, e = {}) {
|
|
1927
|
+
return new D(t, Y(t), e);
|
|
1928
1928
|
}
|
|
1929
|
-
function
|
|
1930
|
-
return t instanceof
|
|
1929
|
+
function nr(t) {
|
|
1930
|
+
return t instanceof D;
|
|
1931
1931
|
}
|
|
1932
|
-
function
|
|
1932
|
+
function ir(t, e, r) {
|
|
1933
1933
|
return e ? Promise.race([
|
|
1934
1934
|
t(),
|
|
1935
1935
|
new Promise((n, i) => setTimeout(() => i(new Error(`Init task timeout: ${r}`)), e))
|
|
1936
1936
|
]) : t();
|
|
1937
1937
|
}
|
|
1938
|
-
function
|
|
1938
|
+
function sr() {
|
|
1939
1939
|
return m(this, arguments, function* (t = [], e = {}) {
|
|
1940
1940
|
for (const r of t) {
|
|
1941
1941
|
const n = (r == null ? void 0 : r.name) || "anonymous-task", i = (r == null ? void 0 : r.run) || r;
|
|
1942
1942
|
if (typeof i == "function")
|
|
1943
1943
|
try {
|
|
1944
|
-
yield
|
|
1945
|
-
} catch (
|
|
1946
|
-
if (typeof r.onError == "function" && r.onError(
|
|
1947
|
-
e.onError(
|
|
1944
|
+
yield ir(() => Promise.resolve().then(() => i()), r.timeoutMs, n), typeof r.onSuccess == "function" && r.onSuccess();
|
|
1945
|
+
} catch (a) {
|
|
1946
|
+
if (typeof r.onError == "function" && r.onError(a), typeof e.onError == "function")
|
|
1947
|
+
e.onError(a, r);
|
|
1948
1948
|
else
|
|
1949
|
-
throw
|
|
1949
|
+
throw a;
|
|
1950
1950
|
}
|
|
1951
1951
|
}
|
|
1952
1952
|
});
|
|
1953
1953
|
}
|
|
1954
|
-
class
|
|
1954
|
+
class je {
|
|
1955
1955
|
/**
|
|
1956
1956
|
* 构造函数
|
|
1957
1957
|
* @param {string} name - 平台名称
|
|
@@ -1965,10 +1965,10 @@ class Ke {
|
|
|
1965
1965
|
* @returns {Object} 处理后的选项
|
|
1966
1966
|
*/
|
|
1967
1967
|
processNavigationOptions(e = {}) {
|
|
1968
|
-
const { url: r, delta: n = 1 } = e, i = r && encodeURI(r),
|
|
1969
|
-
return A(
|
|
1968
|
+
const { url: r, delta: n = 1 } = e, i = r && encodeURI(r), a = parseInt(n) || 1;
|
|
1969
|
+
return A(p({}, e), {
|
|
1970
1970
|
url: i,
|
|
1971
|
-
delta:
|
|
1971
|
+
delta: a
|
|
1972
1972
|
});
|
|
1973
1973
|
}
|
|
1974
1974
|
/**
|
|
@@ -2077,18 +2077,18 @@ class Ke {
|
|
|
2077
2077
|
throw new Error(`${this.name} platform must implement performGetEnv method`);
|
|
2078
2078
|
}
|
|
2079
2079
|
}
|
|
2080
|
-
let
|
|
2081
|
-
function
|
|
2082
|
-
if (
|
|
2080
|
+
let re = [];
|
|
2081
|
+
function ar() {
|
|
2082
|
+
if (re.length === 0 && window.plus) {
|
|
2083
2083
|
const t = plus.webview.currentWebview();
|
|
2084
2084
|
if (!t)
|
|
2085
2085
|
throw new Error("plus.webview.currentWebview() is undefined");
|
|
2086
2086
|
const e = t.parent(), r = e ? e.id : t.id;
|
|
2087
|
-
|
|
2087
|
+
re.push(r);
|
|
2088
2088
|
}
|
|
2089
|
-
return
|
|
2089
|
+
return re;
|
|
2090
2090
|
}
|
|
2091
|
-
function
|
|
2091
|
+
function or(t, e) {
|
|
2092
2092
|
const r = {
|
|
2093
2093
|
options: {
|
|
2094
2094
|
timestamp: +/* @__PURE__ */ new Date()
|
|
@@ -2104,12 +2104,12 @@ function Qt(t, e) {
|
|
|
2104
2104
|
type: "WEB_INVOKE_APPSERVICE",
|
|
2105
2105
|
args: {
|
|
2106
2106
|
data: r,
|
|
2107
|
-
webviewIds:
|
|
2107
|
+
webviewIds: re
|
|
2108
2108
|
}
|
|
2109
2109
|
};
|
|
2110
2110
|
window.__uniapp_x_postMessage ? window.__uniapp_x_postMessageToService(n) : window.__uniapp_x_.postMessageToService(JSON.stringify(n));
|
|
2111
2111
|
}
|
|
2112
|
-
function
|
|
2112
|
+
function cr(t, e) {
|
|
2113
2113
|
const r = {
|
|
2114
2114
|
options: {
|
|
2115
2115
|
timestamp: +/* @__PURE__ */ new Date()
|
|
@@ -2125,19 +2125,19 @@ function er(t, e) {
|
|
|
2125
2125
|
type: "WEB_INVOKE_APPSERVICE",
|
|
2126
2126
|
args: {
|
|
2127
2127
|
data: r,
|
|
2128
|
-
webviewIds:
|
|
2128
|
+
webviewIds: re
|
|
2129
2129
|
}
|
|
2130
2130
|
};
|
|
2131
2131
|
window.__dcloud_weex_postMessage ? window.__dcloud_weex_postMessageToService(n) : window.__dcloud_weex_.postMessageToService(JSON.stringify(n));
|
|
2132
2132
|
}
|
|
2133
|
-
function
|
|
2133
|
+
function ur(t, e) {
|
|
2134
2134
|
const r = {
|
|
2135
2135
|
options: {
|
|
2136
2136
|
timestamp: +/* @__PURE__ */ new Date()
|
|
2137
2137
|
},
|
|
2138
2138
|
name: t,
|
|
2139
2139
|
arg: e
|
|
2140
|
-
}, n =
|
|
2140
|
+
}, n = ar();
|
|
2141
2141
|
if (plus.webview.getWebviewById("__uniapp__service"))
|
|
2142
2142
|
plus.webview.postMessageToUniNView({
|
|
2143
2143
|
type: "WEB_INVOKE_APPSERVICE",
|
|
@@ -2147,13 +2147,13 @@ function tr(t, e) {
|
|
|
2147
2147
|
}
|
|
2148
2148
|
}, "__uniapp__service");
|
|
2149
2149
|
else {
|
|
2150
|
-
const i = JSON.stringify(r),
|
|
2150
|
+
const i = JSON.stringify(r), a = JSON.stringify(n);
|
|
2151
2151
|
plus.webview.getLaunchWebview().evalJS(
|
|
2152
|
-
`UniPlusBridge.subscribeHandler("WEB_INVOKE_APPSERVICE",${i},${
|
|
2152
|
+
`UniPlusBridge.subscribeHandler("WEB_INVOKE_APPSERVICE",${i},${a});`
|
|
2153
2153
|
);
|
|
2154
2154
|
}
|
|
2155
2155
|
}
|
|
2156
|
-
function
|
|
2156
|
+
function lr(t, e) {
|
|
2157
2157
|
const r = {
|
|
2158
2158
|
options: {
|
|
2159
2159
|
timestamp: +/* @__PURE__ */ new Date()
|
|
@@ -2167,10 +2167,10 @@ function rr(t, e) {
|
|
|
2167
2167
|
pageId: ""
|
|
2168
2168
|
}, "*");
|
|
2169
2169
|
}
|
|
2170
|
-
function
|
|
2171
|
-
|
|
2170
|
+
function ne(t, e) {
|
|
2171
|
+
he() ? or(t, e) : pe() ? cr(t, e) : ge() ? ur(t, e) : lr(t, e);
|
|
2172
2172
|
}
|
|
2173
|
-
class
|
|
2173
|
+
class qe extends je {
|
|
2174
2174
|
constructor() {
|
|
2175
2175
|
super("weixin");
|
|
2176
2176
|
}
|
|
@@ -2189,17 +2189,17 @@ class ze extends Ke {
|
|
|
2189
2189
|
* @returns {void}
|
|
2190
2190
|
*/
|
|
2191
2191
|
performNavigation(e, r) {
|
|
2192
|
-
return
|
|
2192
|
+
return u.safeExecute(() => {
|
|
2193
2193
|
const { url: n, delta: i } = r;
|
|
2194
|
-
if (
|
|
2195
|
-
const
|
|
2196
|
-
if (typeof
|
|
2197
|
-
|
|
2198
|
-
const
|
|
2199
|
-
return
|
|
2194
|
+
if (_.debug(`微信平台执行导航操作: ${e}`, r), this.isWeixinApiAvailable()) {
|
|
2195
|
+
const g = window.wx.miniProgram[e];
|
|
2196
|
+
if (typeof g == "function") {
|
|
2197
|
+
_.debug(`使用微信原生 API: wx.miniProgram.${e}`);
|
|
2198
|
+
const d = e === "navigateBack" ? { delta: i } : { url: n };
|
|
2199
|
+
return g.call(window.wx.miniProgram, d);
|
|
2200
2200
|
}
|
|
2201
2201
|
}
|
|
2202
|
-
|
|
2202
|
+
_.debug(`使用消息桥接执行: ${e}`), ne(e, e === "navigateBack" ? { delta: i } : { url: n });
|
|
2203
2203
|
}, {
|
|
2204
2204
|
platform: this.name,
|
|
2205
2205
|
method: "performNavigation",
|
|
@@ -2213,11 +2213,11 @@ class ze extends Ke {
|
|
|
2213
2213
|
* @returns {void}
|
|
2214
2214
|
*/
|
|
2215
2215
|
performPostMessage(e) {
|
|
2216
|
-
return
|
|
2216
|
+
return u.safeExecute(() => {
|
|
2217
2217
|
const { data: r } = e;
|
|
2218
2218
|
if (this.isWeixinApiAvailable())
|
|
2219
2219
|
return window.wx.miniProgram.postMessage({ data: r });
|
|
2220
|
-
|
|
2220
|
+
ne("postMessage", r);
|
|
2221
2221
|
}, {
|
|
2222
2222
|
platform: this.name,
|
|
2223
2223
|
method: "performPostMessage",
|
|
@@ -2230,7 +2230,7 @@ class ze extends Ke {
|
|
|
2230
2230
|
* @returns {void}
|
|
2231
2231
|
*/
|
|
2232
2232
|
performGetEnv(e) {
|
|
2233
|
-
return
|
|
2233
|
+
return u.safeExecute(() => {
|
|
2234
2234
|
if (!e || typeof e != "function")
|
|
2235
2235
|
throw new Error("Callback function is required for getEnv");
|
|
2236
2236
|
if (this.isWeixinApiAvailable() && window.wx.miniProgram.getEnv)
|
|
@@ -2245,19 +2245,19 @@ class ze extends Ke {
|
|
|
2245
2245
|
});
|
|
2246
2246
|
}
|
|
2247
2247
|
}
|
|
2248
|
-
const
|
|
2249
|
-
var
|
|
2248
|
+
const j = new qe(), fr = (t) => j.navigateTo(t), dr = (t) => j.navigateBack(t), gr = (t) => j.switchTab(t), pr = (t) => j.reLaunch(t), hr = (t) => j.redirectTo(t), mr = (t) => j.postMessage(t), wr = (t) => j.getEnv(t);
|
|
2249
|
+
var Je = /* @__PURE__ */ Object.freeze({
|
|
2250
2250
|
__proto__: null,
|
|
2251
|
-
WeixinPlatform:
|
|
2252
|
-
getEnv:
|
|
2253
|
-
navigateBack:
|
|
2254
|
-
navigateTo:
|
|
2255
|
-
postMessage:
|
|
2256
|
-
reLaunch:
|
|
2257
|
-
redirectTo:
|
|
2258
|
-
switchTab:
|
|
2251
|
+
WeixinPlatform: qe,
|
|
2252
|
+
getEnv: wr,
|
|
2253
|
+
navigateBack: dr,
|
|
2254
|
+
navigateTo: fr,
|
|
2255
|
+
postMessage: mr,
|
|
2256
|
+
reLaunch: pr,
|
|
2257
|
+
redirectTo: hr,
|
|
2258
|
+
switchTab: gr
|
|
2259
2259
|
});
|
|
2260
|
-
class
|
|
2260
|
+
class He extends je {
|
|
2261
2261
|
constructor() {
|
|
2262
2262
|
super("app");
|
|
2263
2263
|
}
|
|
@@ -2268,9 +2268,9 @@ class Ve extends Ke {
|
|
|
2268
2268
|
* @returns {void}
|
|
2269
2269
|
*/
|
|
2270
2270
|
performNavigation(e, r) {
|
|
2271
|
-
return
|
|
2271
|
+
return u.safeExecute(() => {
|
|
2272
2272
|
const { url: n, delta: i } = r;
|
|
2273
|
-
|
|
2273
|
+
ne(e, e === "navigateBack" ? { delta: i } : { url: n });
|
|
2274
2274
|
}, {
|
|
2275
2275
|
platform: this.name,
|
|
2276
2276
|
method: "performNavigation",
|
|
@@ -2284,9 +2284,9 @@ class Ve extends Ke {
|
|
|
2284
2284
|
* @returns {void}
|
|
2285
2285
|
*/
|
|
2286
2286
|
performPostMessage(e) {
|
|
2287
|
-
return
|
|
2287
|
+
return u.safeExecute(() => {
|
|
2288
2288
|
const { data: r } = e;
|
|
2289
|
-
|
|
2289
|
+
ne("postMessage", r);
|
|
2290
2290
|
}, {
|
|
2291
2291
|
platform: this.name,
|
|
2292
2292
|
method: "performPostMessage",
|
|
@@ -2299,66 +2299,66 @@ class Ve extends Ke {
|
|
|
2299
2299
|
* @returns {void}
|
|
2300
2300
|
*/
|
|
2301
2301
|
performGetEnv(e) {
|
|
2302
|
-
return
|
|
2302
|
+
return u.safeExecute(() => {
|
|
2303
2303
|
if (!e || typeof e != "function")
|
|
2304
2304
|
throw new Error("Callback function is required for getEnv");
|
|
2305
2305
|
const r = {};
|
|
2306
2306
|
let n = !1;
|
|
2307
|
-
|
|
2307
|
+
he() ? (r.uvue = !0, n = !0) : pe() ? (r.nvue = !0, n = !0) : ge() && (r.plus = !0, n = !0), n ? r.app = !0 : r.h5 = !0, e(r);
|
|
2308
2308
|
}, {
|
|
2309
2309
|
platform: this.name,
|
|
2310
2310
|
method: "performGetEnv"
|
|
2311
2311
|
});
|
|
2312
2312
|
}
|
|
2313
2313
|
}
|
|
2314
|
-
const
|
|
2315
|
-
var
|
|
2314
|
+
const q = new He(), Er = (t) => q.navigateTo(t), yr = (t) => q.navigateBack(t), Ir = (t) => q.switchTab(t), Ar = (t) => q.reLaunch(t), Or = (t) => q.redirectTo(t), _r = (t) => q.postMessage(t), Cr = (t) => q.getEnv(t);
|
|
2315
|
+
var Ye = /* @__PURE__ */ Object.freeze({
|
|
2316
2316
|
__proto__: null,
|
|
2317
|
-
AppPlatform:
|
|
2318
|
-
getEnv:
|
|
2319
|
-
navigateBack:
|
|
2320
|
-
navigateTo:
|
|
2321
|
-
postMessage:
|
|
2322
|
-
reLaunch:
|
|
2323
|
-
redirectTo:
|
|
2324
|
-
switchTab:
|
|
2317
|
+
AppPlatform: He,
|
|
2318
|
+
getEnv: Cr,
|
|
2319
|
+
navigateBack: yr,
|
|
2320
|
+
navigateTo: Er,
|
|
2321
|
+
postMessage: _r,
|
|
2322
|
+
reLaunch: Ar,
|
|
2323
|
+
redirectTo: Or,
|
|
2324
|
+
switchTab: Ir
|
|
2325
2325
|
});
|
|
2326
|
-
function
|
|
2327
|
-
return
|
|
2326
|
+
function ie() {
|
|
2327
|
+
return E() ? Je : Ye;
|
|
2328
2328
|
}
|
|
2329
|
-
function
|
|
2330
|
-
return
|
|
2329
|
+
function Nr(t) {
|
|
2330
|
+
return ie().navigateTo(t);
|
|
2331
2331
|
}
|
|
2332
|
-
function
|
|
2333
|
-
return
|
|
2332
|
+
function Rr(t) {
|
|
2333
|
+
return ie().navigateBack(t);
|
|
2334
2334
|
}
|
|
2335
|
-
function
|
|
2336
|
-
return
|
|
2335
|
+
function Sr(t) {
|
|
2336
|
+
return ie().switchTab(t);
|
|
2337
2337
|
}
|
|
2338
|
-
function
|
|
2339
|
-
return
|
|
2338
|
+
function Pr(t) {
|
|
2339
|
+
return ie().reLaunch(t);
|
|
2340
2340
|
}
|
|
2341
|
-
function
|
|
2342
|
-
return
|
|
2341
|
+
function Tr(t) {
|
|
2342
|
+
return ie().redirectTo(t);
|
|
2343
2343
|
}
|
|
2344
|
-
function
|
|
2345
|
-
return
|
|
2344
|
+
function Xe() {
|
|
2345
|
+
return E() ? Je : Ye;
|
|
2346
2346
|
}
|
|
2347
|
-
function
|
|
2348
|
-
return
|
|
2347
|
+
function Lr(t = {}) {
|
|
2348
|
+
return Xe().postMessage(t);
|
|
2349
2349
|
}
|
|
2350
|
-
function
|
|
2351
|
-
return
|
|
2350
|
+
function Mr(t) {
|
|
2351
|
+
return Xe().getEnv(t);
|
|
2352
2352
|
}
|
|
2353
|
-
function
|
|
2353
|
+
function br(t) {
|
|
2354
2354
|
return t && typeof t == "object" && t.__v_raw ? t.__v_raw : t;
|
|
2355
2355
|
}
|
|
2356
|
-
function
|
|
2356
|
+
function vr() {
|
|
2357
2357
|
return "qsh_callback_" + Date.now() + "_" + Math.random().toString(36).substring(2, 9);
|
|
2358
2358
|
}
|
|
2359
|
-
class
|
|
2359
|
+
class xr {
|
|
2360
2360
|
constructor() {
|
|
2361
|
-
this.callbacks = /* @__PURE__ */ new Map(), this.timeouts = /* @__PURE__ */ new Map(), this.defaultTimeout = 3e4, typeof window != "undefined" && (window.qshWebviewCallbacks || (window.qshWebviewCallbacks = {})),
|
|
2361
|
+
this.callbacks = /* @__PURE__ */ new Map(), this.timeouts = /* @__PURE__ */ new Map(), this.persistentCallbacksByApi = /* @__PURE__ */ new Map(), this.defaultTimeout = 3e4, typeof window != "undefined" && (window.qshWebviewCallbacks || (window.qshWebviewCallbacks = {})), y.debug("WebView 桥接器已初始化");
|
|
2362
2362
|
}
|
|
2363
2363
|
/**
|
|
2364
2364
|
* 向主应用发送 API 调用消息
|
|
@@ -2369,17 +2369,17 @@ class Sr {
|
|
|
2369
2369
|
*/
|
|
2370
2370
|
callApi(i) {
|
|
2371
2371
|
return m(this, arguments, function* (e, r = {}, n = {}) {
|
|
2372
|
-
return
|
|
2373
|
-
var
|
|
2372
|
+
return u.safeExecute(() => m(this, null, function* () {
|
|
2373
|
+
var h;
|
|
2374
2374
|
if (typeof window != "undefined" && window === window.parent && !window.plus && !window.__uniapp_x_postMessage && !window.__uniapp_x_ && !window.__dcloud_weex_postMessage && !window.__dcloud_weex_) {
|
|
2375
|
-
const
|
|
2375
|
+
const T = new L(
|
|
2376
2376
|
U.PLATFORM_NOT_SUPPORTED,
|
|
2377
2377
|
"当前不在宿主 WebView 容器中,无法发送消息"
|
|
2378
2378
|
);
|
|
2379
|
-
n && typeof n.fail == "function" && n.fail({ errMsg:
|
|
2379
|
+
n && typeof n.fail == "function" && n.fail({ errMsg: T.message, code: "NOT_IN_CONTAINER" }), n && typeof n.complete == "function" && n.complete({ success: !1, error: { errMsg: T.message } });
|
|
2380
2380
|
return;
|
|
2381
2381
|
}
|
|
2382
|
-
const
|
|
2382
|
+
const g = {
|
|
2383
2383
|
apiName: e,
|
|
2384
2384
|
params: r,
|
|
2385
2385
|
callbacks: n,
|
|
@@ -2387,50 +2387,50 @@ class Sr {
|
|
|
2387
2387
|
abort: !1,
|
|
2388
2388
|
metadata: {}
|
|
2389
2389
|
};
|
|
2390
|
-
|
|
2391
|
-
const
|
|
2392
|
-
if (
|
|
2393
|
-
|
|
2394
|
-
errMsg: ((
|
|
2390
|
+
x.setApiLoading(e, !0);
|
|
2391
|
+
const d = yield K.runRequest(g);
|
|
2392
|
+
if (d.abort) {
|
|
2393
|
+
y.warn("API 调用被拦截器中止", { api: e }), x.setApiLoading(e, !1), n.fail && n.fail({
|
|
2394
|
+
errMsg: ((h = d.error) == null ? void 0 : h.message) || "API 调用被中止",
|
|
2395
2395
|
code: "INTERCEPTED"
|
|
2396
2396
|
}), n.complete && n.complete({ success: !1 });
|
|
2397
2397
|
return;
|
|
2398
2398
|
}
|
|
2399
|
-
const
|
|
2399
|
+
const l = vr();
|
|
2400
2400
|
if (n.success || n.fail || n.complete) {
|
|
2401
|
-
if (this.callbacks.set(
|
|
2402
|
-
context:
|
|
2401
|
+
if (this.callbacks.set(l, A(p({}, n), {
|
|
2402
|
+
context: d
|
|
2403
2403
|
// 保存上下文用于响应拦截
|
|
2404
|
-
})), window.qshWebviewCallbacks[
|
|
2405
|
-
this.handleCallback(
|
|
2406
|
-
}, r.isPersistent || r.disableTimeout)
|
|
2407
|
-
|
|
2408
|
-
callbackId:
|
|
2404
|
+
})), window.qshWebviewCallbacks[l] = (Ee) => {
|
|
2405
|
+
this.handleCallback(l, Ee);
|
|
2406
|
+
}, r.isPersistent && (this.persistentCallbacksByApi.has(e) || this.persistentCallbacksByApi.set(e, /* @__PURE__ */ new Set()), this.persistentCallbacksByApi.get(e).add(l)), r.isPersistent || r.disableTimeout)
|
|
2407
|
+
y.info(`API ${e} 禁用超时清理,将等待回调返回后清理`, {
|
|
2408
|
+
callbackId: l,
|
|
2409
2409
|
isPersistent: r.isPersistent,
|
|
2410
2410
|
disableTimeout: r.disableTimeout
|
|
2411
2411
|
});
|
|
2412
2412
|
else {
|
|
2413
|
-
const
|
|
2414
|
-
|
|
2413
|
+
const Ee = setTimeout(() => {
|
|
2414
|
+
y.warn("API 调用超时,自动清理回调", { api: e, callbackId: l }), n.fail && n.fail({
|
|
2415
2415
|
errMsg: `API ${e} 调用超时`,
|
|
2416
2416
|
code: "TIMEOUT"
|
|
2417
|
-
}), this.cleanupCallback(
|
|
2417
|
+
}), this.cleanupCallback(l);
|
|
2418
2418
|
}, r.timeout || this.defaultTimeout);
|
|
2419
|
-
this.timeouts.set(
|
|
2419
|
+
this.timeouts.set(l, Ee);
|
|
2420
2420
|
}
|
|
2421
2421
|
const N = {
|
|
2422
2422
|
type: "qsh_api_call",
|
|
2423
2423
|
api: e,
|
|
2424
|
-
params:
|
|
2425
|
-
callbackId:
|
|
2424
|
+
params: d.params,
|
|
2425
|
+
callbackId: l,
|
|
2426
2426
|
timestamp: Date.now()
|
|
2427
2427
|
};
|
|
2428
|
-
|
|
2428
|
+
y.info("发送 API 调用消息", {
|
|
2429
2429
|
api: e,
|
|
2430
|
-
callbackId:
|
|
2430
|
+
callbackId: l,
|
|
2431
2431
|
hasSuccess: !!n.success,
|
|
2432
2432
|
hasFail: !!n.fail
|
|
2433
|
-
}), console.log("message:", JSON.stringify(
|
|
2433
|
+
}), console.log("message:", JSON.stringify(br(N), null, 2)), ne("postMessage", N);
|
|
2434
2434
|
}
|
|
2435
2435
|
}), {
|
|
2436
2436
|
context: "WebViewBridge.callApi",
|
|
@@ -2446,17 +2446,17 @@ class Sr {
|
|
|
2446
2446
|
*/
|
|
2447
2447
|
handleCallback(e, r) {
|
|
2448
2448
|
return m(this, null, function* () {
|
|
2449
|
-
return
|
|
2450
|
-
var
|
|
2449
|
+
return u.safeExecute(() => m(this, null, function* () {
|
|
2450
|
+
var T, N;
|
|
2451
2451
|
const n = this.callbacks.get(e);
|
|
2452
2452
|
if (!n) {
|
|
2453
|
-
|
|
2453
|
+
y.warn("未找到回调函数", { callbackId: e });
|
|
2454
2454
|
return;
|
|
2455
2455
|
}
|
|
2456
|
-
const { success: i, fail:
|
|
2457
|
-
|
|
2458
|
-
const
|
|
2459
|
-
|
|
2456
|
+
const { success: i, fail: a, complete: g, context: d } = n;
|
|
2457
|
+
y.debug("处理回调", { callbackId: e, result: r });
|
|
2458
|
+
const l = yield K.runResponse(r, d);
|
|
2459
|
+
d && x.setApiResult(d.apiName, l), l.success && i ? i(l.data) : !l.success && a && a(l.error || { errMsg: "操作失败" }), g && g(l), ((N = (T = n.context) == null ? void 0 : T.params) == null ? void 0 : N.isPersistent) ? y.debug("持久监听API:保留回调", { callbackId: e }) : (this.cleanupCallback(e), y.debug("回调执行完成,已清理", { callbackId: e }));
|
|
2460
2460
|
}), {
|
|
2461
2461
|
context: "WebViewBridge.handleCallback",
|
|
2462
2462
|
callbackId: e
|
|
@@ -2470,16 +2470,33 @@ class Sr {
|
|
|
2470
2470
|
*/
|
|
2471
2471
|
cleanupCallback(e) {
|
|
2472
2472
|
const r = this.timeouts.get(e);
|
|
2473
|
-
r && (clearTimeout(r), this.timeouts.delete(e)), this.callbacks.delete(e), typeof window != "undefined" && window.qshWebviewCallbacks && delete window.qshWebviewCallbacks[e]
|
|
2473
|
+
if (r && (clearTimeout(r), this.timeouts.delete(e)), this.callbacks.delete(e), typeof window != "undefined" && window.qshWebviewCallbacks && delete window.qshWebviewCallbacks[e], this.persistentCallbacksByApi && this.persistentCallbacksByApi.size > 0) {
|
|
2474
|
+
const n = [];
|
|
2475
|
+
this.persistentCallbacksByApi.forEach((i, a) => {
|
|
2476
|
+
i.has(e) && (i.delete(e), i.size === 0 && n.push(a));
|
|
2477
|
+
}), n.forEach((i) => this.persistentCallbacksByApi.delete(i));
|
|
2478
|
+
}
|
|
2474
2479
|
}
|
|
2475
2480
|
/**
|
|
2476
2481
|
* 清理所有待处理的回调
|
|
2477
2482
|
*/
|
|
2478
2483
|
clearCallbacks() {
|
|
2479
|
-
|
|
2484
|
+
y.debug("清理所有回调", { count: this.callbacks.size }), this.timeouts.forEach((e) => clearTimeout(e)), this.timeouts.clear(), this.callbacks.clear(), this.persistentCallbacksByApi && this.persistentCallbacksByApi.clear(), typeof window != "undefined" && window.qshWebviewCallbacks && Object.keys(window.qshWebviewCallbacks).forEach((e) => {
|
|
2480
2485
|
e.startsWith("qsh_callback_") && delete window.qshWebviewCallbacks[e];
|
|
2481
2486
|
});
|
|
2482
2487
|
}
|
|
2488
|
+
/**
|
|
2489
|
+
* 清理指定 API 的持久回调
|
|
2490
|
+
* @param {string} apiName - API 名称
|
|
2491
|
+
* @returns {number} 清理数量
|
|
2492
|
+
*/
|
|
2493
|
+
cleanupPersistentCallbacksByApi(e) {
|
|
2494
|
+
const r = this.persistentCallbacksByApi.get(e);
|
|
2495
|
+
if (!r || r.size === 0)
|
|
2496
|
+
return 0;
|
|
2497
|
+
const n = Array.from(r);
|
|
2498
|
+
return n.forEach((i) => this.cleanupCallback(i)), this.persistentCallbacksByApi.delete(e), y.info("已清理持久回调", { api: e, count: n.length }), n.length;
|
|
2499
|
+
}
|
|
2483
2500
|
/**
|
|
2484
2501
|
* 获取桥接器状态信息
|
|
2485
2502
|
* @returns {Object} 状态信息
|
|
@@ -2492,30 +2509,30 @@ class Sr {
|
|
|
2492
2509
|
};
|
|
2493
2510
|
}
|
|
2494
2511
|
}
|
|
2495
|
-
const
|
|
2512
|
+
const Ze = new xr(), C = (t, e, r) => Ze.callApi(t, e, r), X = (t) => Ze.cleanupPersistentCallbacksByApi(t), le = {
|
|
2496
2513
|
ALBUM: "album",
|
|
2497
2514
|
// 相册
|
|
2498
2515
|
CAMERA: "camera"
|
|
2499
2516
|
// 相机
|
|
2500
|
-
},
|
|
2517
|
+
}, fe = {
|
|
2501
2518
|
ORIGINAL: "original",
|
|
2502
2519
|
// 原图
|
|
2503
2520
|
COMPRESSED: "compressed"
|
|
2504
2521
|
// 压缩图
|
|
2505
|
-
},
|
|
2522
|
+
}, Dr = {
|
|
2506
2523
|
count: 9,
|
|
2507
|
-
sizeType: [
|
|
2508
|
-
sourceType: [
|
|
2524
|
+
sizeType: [fe.ORIGINAL, fe.COMPRESSED],
|
|
2525
|
+
sourceType: [le.ALBUM, le.CAMERA]
|
|
2509
2526
|
};
|
|
2510
|
-
function
|
|
2511
|
-
const e =
|
|
2512
|
-
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 = [
|
|
2527
|
+
function Ur(t = {}) {
|
|
2528
|
+
const e = p(p({}, Dr), t);
|
|
2529
|
+
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 = [fe.COMPRESSED]), e.sourceType.length === 0 && (e.sourceType = [le.ALBUM]), e;
|
|
2513
2530
|
}
|
|
2514
|
-
function
|
|
2515
|
-
return ["weixin", "webview", "UniApp", "plus", "nvue", "uvue"].includes(
|
|
2531
|
+
function Qe() {
|
|
2532
|
+
return ["weixin", "webview", "UniApp", "plus", "nvue", "uvue"].includes(c.type);
|
|
2516
2533
|
}
|
|
2517
|
-
function
|
|
2518
|
-
return
|
|
2534
|
+
function et(t) {
|
|
2535
|
+
return u.safeExecute(() => {
|
|
2519
2536
|
var e;
|
|
2520
2537
|
if (!window.wx) {
|
|
2521
2538
|
const r = {
|
|
@@ -2525,24 +2542,24 @@ function He(t) {
|
|
|
2525
2542
|
(e = t.fail) == null || e.call(t, r);
|
|
2526
2543
|
return;
|
|
2527
2544
|
}
|
|
2528
|
-
if (!
|
|
2529
|
-
|
|
2545
|
+
if (!z()) {
|
|
2546
|
+
s.info("等待微信配置完成"), k().then(() => et(t)).catch((r) => {
|
|
2530
2547
|
var n;
|
|
2531
|
-
|
|
2548
|
+
s.error("微信配置失败", r), (n = t.fail) == null || n.call(t, { errMsg: `微信配置失败: ${r.message}` });
|
|
2532
2549
|
});
|
|
2533
2550
|
return;
|
|
2534
2551
|
}
|
|
2535
|
-
|
|
2552
|
+
s.debug("调用微信图片选择", t), window.wx.chooseImage({
|
|
2536
2553
|
count: t.count,
|
|
2537
2554
|
sizeType: t.sizeType,
|
|
2538
2555
|
sourceType: t.sourceType,
|
|
2539
2556
|
success: (r) => {
|
|
2540
2557
|
var n, i;
|
|
2541
|
-
|
|
2558
|
+
s.info("微信图片选择成功", { count: ((n = r.localIds) == null ? void 0 : n.length) || 0 }), (i = t.success) == null || i.call(t, r);
|
|
2542
2559
|
},
|
|
2543
2560
|
fail: (r) => {
|
|
2544
2561
|
var n;
|
|
2545
|
-
|
|
2562
|
+
s.error("微信图片选择失败", r), (n = t.fail) == null || n.call(t, r);
|
|
2546
2563
|
},
|
|
2547
2564
|
complete: t.complete
|
|
2548
2565
|
});
|
|
@@ -2551,18 +2568,18 @@ function He(t) {
|
|
|
2551
2568
|
platform: "weixin"
|
|
2552
2569
|
});
|
|
2553
2570
|
}
|
|
2554
|
-
function
|
|
2555
|
-
return
|
|
2556
|
-
|
|
2571
|
+
function Wr(t) {
|
|
2572
|
+
return u.safeExecute(() => {
|
|
2573
|
+
s.debug("通过 WebView 桥接调用图片选择", t), C("chooseImage", A(p({}, t), { disableTimeout: !0 }), {
|
|
2557
2574
|
success: (e) => {
|
|
2558
2575
|
var r, n;
|
|
2559
|
-
|
|
2576
|
+
s.info("UniApp 图片选择成功", {
|
|
2560
2577
|
count: ((r = e == null ? void 0 : e.tempFilePaths) == null ? void 0 : r.length) || 0
|
|
2561
2578
|
}), (n = t.success) == null || n.call(t, e);
|
|
2562
2579
|
},
|
|
2563
2580
|
fail: (e) => {
|
|
2564
2581
|
var r;
|
|
2565
|
-
|
|
2582
|
+
s.error("UniApp 图片选择失败", e), (r = t.fail) == null || r.call(t, e);
|
|
2566
2583
|
},
|
|
2567
2584
|
complete: t.complete
|
|
2568
2585
|
});
|
|
@@ -2571,34 +2588,34 @@ function Mr(t) {
|
|
|
2571
2588
|
platform: "uniapp"
|
|
2572
2589
|
});
|
|
2573
2590
|
}
|
|
2574
|
-
function
|
|
2575
|
-
return
|
|
2591
|
+
function $r(t = {}) {
|
|
2592
|
+
return u.safeExecute(() => {
|
|
2576
2593
|
var r;
|
|
2577
|
-
if (!
|
|
2594
|
+
if (!Qe()) {
|
|
2578
2595
|
const n = {
|
|
2579
|
-
errMsg: `当前环境 (${
|
|
2596
|
+
errMsg: `当前环境 (${c.type}) 不支持图片选择功能`,
|
|
2580
2597
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
2581
2598
|
};
|
|
2582
|
-
|
|
2599
|
+
s.error("平台不支持图片选择", { platform: c.type }), (r = t.fail) == null || r.call(t, n);
|
|
2583
2600
|
return;
|
|
2584
2601
|
}
|
|
2585
|
-
const e =
|
|
2586
|
-
|
|
2587
|
-
platform:
|
|
2602
|
+
const e = Ur(t);
|
|
2603
|
+
s.info("开始选择图片", {
|
|
2604
|
+
platform: c.type,
|
|
2588
2605
|
count: e.count,
|
|
2589
2606
|
sizeType: e.sizeType,
|
|
2590
2607
|
sourceType: e.sourceType
|
|
2591
|
-
}),
|
|
2608
|
+
}), E() ? et(e) : Wr(e);
|
|
2592
2609
|
}, {
|
|
2593
2610
|
context: "chooseImage",
|
|
2594
2611
|
options: t
|
|
2595
2612
|
});
|
|
2596
2613
|
}
|
|
2597
|
-
function
|
|
2614
|
+
function Br() {
|
|
2598
2615
|
return {
|
|
2599
|
-
supported:
|
|
2600
|
-
environment:
|
|
2601
|
-
implementation:
|
|
2616
|
+
supported: Qe(),
|
|
2617
|
+
environment: c.type,
|
|
2618
|
+
implementation: E() ? "weixin" : "webview",
|
|
2602
2619
|
features: {
|
|
2603
2620
|
multipleSelection: !0,
|
|
2604
2621
|
// 支持多选
|
|
@@ -2611,7 +2628,7 @@ function vr() {
|
|
|
2611
2628
|
}
|
|
2612
2629
|
};
|
|
2613
2630
|
}
|
|
2614
|
-
const
|
|
2631
|
+
const V = {
|
|
2615
2632
|
QR_CODE: "qrCode",
|
|
2616
2633
|
// 二维码
|
|
2617
2634
|
BAR_CODE: "barCode",
|
|
@@ -2620,21 +2637,21 @@ const z = {
|
|
|
2620
2637
|
// Data Matrix 码
|
|
2621
2638
|
PDF417: "pdf417"
|
|
2622
2639
|
// PDF417 条码
|
|
2623
|
-
},
|
|
2640
|
+
}, Fr = {
|
|
2624
2641
|
onlyFromCamera: !0,
|
|
2625
2642
|
// 只从相机扫码
|
|
2626
|
-
scanType: [
|
|
2643
|
+
scanType: [V.QR_CODE, V.BAR_CODE]
|
|
2627
2644
|
// 支持二维码和一维码
|
|
2628
2645
|
};
|
|
2629
|
-
function
|
|
2630
|
-
const e =
|
|
2631
|
-
return Array.isArray(e.scanType) || (e.scanType = [e.scanType].filter(Boolean)), e.scanType.length === 0 && (e.scanType = [
|
|
2646
|
+
function kr(t = {}) {
|
|
2647
|
+
const e = p(p({}, Fr), t);
|
|
2648
|
+
return Array.isArray(e.scanType) || (e.scanType = [e.scanType].filter(Boolean)), e.scanType.length === 0 && (e.scanType = [V.QR_CODE, V.BAR_CODE]), e.onlyFromCamera = !!e.onlyFromCamera, e;
|
|
2632
2649
|
}
|
|
2633
|
-
function
|
|
2634
|
-
return ["weixin", "webview", "UniApp", "plus", "nvue", "uvue"].includes(
|
|
2650
|
+
function tt() {
|
|
2651
|
+
return ["weixin", "webview", "UniApp", "plus", "nvue", "uvue"].includes(c.type);
|
|
2635
2652
|
}
|
|
2636
|
-
function
|
|
2637
|
-
return
|
|
2653
|
+
function rt(t) {
|
|
2654
|
+
return u.safeExecute(() => {
|
|
2638
2655
|
var e;
|
|
2639
2656
|
if (!window.wx) {
|
|
2640
2657
|
const r = {
|
|
@@ -2644,24 +2661,24 @@ function Xe(t) {
|
|
|
2644
2661
|
(e = t.fail) == null || e.call(t, r);
|
|
2645
2662
|
return;
|
|
2646
2663
|
}
|
|
2647
|
-
if (!
|
|
2648
|
-
|
|
2664
|
+
if (!z()) {
|
|
2665
|
+
s.info("等待微信配置完成"), k().then(() => rt(t)).catch((r) => {
|
|
2649
2666
|
var n;
|
|
2650
|
-
|
|
2667
|
+
s.error("微信配置失败", r), (n = t.fail) == null || n.call(t, { errMsg: `微信配置失败: ${r.message}` });
|
|
2651
2668
|
});
|
|
2652
2669
|
return;
|
|
2653
2670
|
}
|
|
2654
|
-
|
|
2671
|
+
s.debug("调用微信扫码", t), window.wx.scanQRCode({
|
|
2655
2672
|
needResult: 1,
|
|
2656
2673
|
// 直接返回扫码结果
|
|
2657
2674
|
scanType: t.scanType,
|
|
2658
2675
|
success: (r) => {
|
|
2659
2676
|
var i;
|
|
2660
|
-
|
|
2677
|
+
s.info("微信扫码成功", { result: r.resultStr });
|
|
2661
2678
|
const n = {
|
|
2662
2679
|
result: r.resultStr,
|
|
2663
2680
|
// 扫码内容
|
|
2664
|
-
scanType:
|
|
2681
|
+
scanType: zr(r.resultStr),
|
|
2665
2682
|
// 推测扫码类型
|
|
2666
2683
|
charSet: "utf-8",
|
|
2667
2684
|
// 微信默认 UTF-8
|
|
@@ -2671,7 +2688,7 @@ function Xe(t) {
|
|
|
2671
2688
|
},
|
|
2672
2689
|
fail: (r) => {
|
|
2673
2690
|
var n;
|
|
2674
|
-
|
|
2691
|
+
s.error("微信扫码失败", r), (n = t.fail) == null || n.call(t, r);
|
|
2675
2692
|
},
|
|
2676
2693
|
complete: t.complete
|
|
2677
2694
|
});
|
|
@@ -2680,22 +2697,22 @@ function Xe(t) {
|
|
|
2680
2697
|
platform: "weixin"
|
|
2681
2698
|
});
|
|
2682
2699
|
}
|
|
2683
|
-
function
|
|
2684
|
-
return t ? t.length > 50 || /[^\d]/.test(t) ?
|
|
2700
|
+
function zr(t) {
|
|
2701
|
+
return t ? t.length > 50 || /[^\d]/.test(t) ? V.QR_CODE : V.BAR_CODE : "unknown";
|
|
2685
2702
|
}
|
|
2686
|
-
function
|
|
2687
|
-
return
|
|
2688
|
-
|
|
2703
|
+
function Kr(t) {
|
|
2704
|
+
return u.safeExecute(() => {
|
|
2705
|
+
s.debug("通过 WebView 桥接调用扫码", t), C("scanCode", A(p({}, t), { disableTimeout: !0 }), {
|
|
2689
2706
|
success: (e) => {
|
|
2690
2707
|
var r;
|
|
2691
|
-
|
|
2708
|
+
s.info("UniApp 扫码成功", {
|
|
2692
2709
|
result: e == null ? void 0 : e.result,
|
|
2693
2710
|
scanType: e == null ? void 0 : e.scanType
|
|
2694
2711
|
}), (r = t.success) == null || r.call(t, e);
|
|
2695
2712
|
},
|
|
2696
2713
|
fail: (e) => {
|
|
2697
2714
|
var r;
|
|
2698
|
-
|
|
2715
|
+
s.error("UniApp 扫码失败", e), (r = t.fail) == null || r.call(t, e);
|
|
2699
2716
|
},
|
|
2700
2717
|
complete: t.complete
|
|
2701
2718
|
});
|
|
@@ -2704,33 +2721,33 @@ function Ur(t) {
|
|
|
2704
2721
|
platform: "uniapp"
|
|
2705
2722
|
});
|
|
2706
2723
|
}
|
|
2707
|
-
function
|
|
2708
|
-
return
|
|
2724
|
+
function Gr(t = {}) {
|
|
2725
|
+
return u.safeExecute(() => {
|
|
2709
2726
|
var r;
|
|
2710
|
-
if (!
|
|
2727
|
+
if (!tt()) {
|
|
2711
2728
|
const n = {
|
|
2712
|
-
errMsg: `当前环境 (${
|
|
2729
|
+
errMsg: `当前环境 (${c.type}) 不支持扫码功能`,
|
|
2713
2730
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
2714
2731
|
};
|
|
2715
|
-
|
|
2732
|
+
s.error("平台不支持扫码", { platform: c.type }), (r = t.fail) == null || r.call(t, n);
|
|
2716
2733
|
return;
|
|
2717
2734
|
}
|
|
2718
|
-
const e =
|
|
2719
|
-
|
|
2720
|
-
platform:
|
|
2735
|
+
const e = kr(t);
|
|
2736
|
+
s.info("开始扫码", {
|
|
2737
|
+
platform: c.type,
|
|
2721
2738
|
onlyFromCamera: e.onlyFromCamera,
|
|
2722
2739
|
scanType: e.scanType
|
|
2723
|
-
}),
|
|
2740
|
+
}), E() ? rt(e) : Kr(e);
|
|
2724
2741
|
}, {
|
|
2725
2742
|
context: "scanCode",
|
|
2726
2743
|
options: t
|
|
2727
2744
|
});
|
|
2728
2745
|
}
|
|
2729
|
-
function
|
|
2746
|
+
function Vr() {
|
|
2730
2747
|
return {
|
|
2731
|
-
supported:
|
|
2732
|
-
environment:
|
|
2733
|
-
implementation:
|
|
2748
|
+
supported: tt(),
|
|
2749
|
+
environment: c.type,
|
|
2750
|
+
implementation: E() ? "weixin" : "webview",
|
|
2734
2751
|
features: {
|
|
2735
2752
|
onlyFromCamera: !0,
|
|
2736
2753
|
// 支持只从相机扫码
|
|
@@ -2743,26 +2760,30 @@ function $r() {
|
|
|
2743
2760
|
}
|
|
2744
2761
|
};
|
|
2745
2762
|
}
|
|
2746
|
-
const
|
|
2763
|
+
const Z = {
|
|
2747
2764
|
WGS84: "wgs84",
|
|
2748
2765
|
// GPS 坐标
|
|
2749
2766
|
GCJ02: "gcj02",
|
|
2750
2767
|
// 国测局坐标(火星坐标)
|
|
2751
2768
|
BD09: "bd09"
|
|
2752
2769
|
// 百度坐标
|
|
2753
|
-
},
|
|
2754
|
-
type:
|
|
2770
|
+
}, jr = {
|
|
2771
|
+
type: Z.WGS84,
|
|
2755
2772
|
altitude: !1
|
|
2756
|
-
},
|
|
2773
|
+
}, qr = {
|
|
2757
2774
|
scale: 18
|
|
2758
2775
|
// 地图缩放级别 1-28
|
|
2759
2776
|
};
|
|
2760
|
-
function
|
|
2761
|
-
const e =
|
|
2762
|
-
return Object.values(
|
|
2777
|
+
function Jr(t = {}) {
|
|
2778
|
+
const e = p(p({}, jr), t);
|
|
2779
|
+
return Object.values(Z).includes(e.type) || (e.type = Z.WGS84), e.altitude = !!e.altitude, e;
|
|
2780
|
+
}
|
|
2781
|
+
function Hr(t = {}) {
|
|
2782
|
+
const e = p({}, t);
|
|
2783
|
+
return Object.values(Z).includes(e.type) || (e.type = Z.WGS84), e.needFullAccuracy = !!e.needFullAccuracy, e;
|
|
2763
2784
|
}
|
|
2764
|
-
function
|
|
2765
|
-
const e =
|
|
2785
|
+
function Yr(t = {}) {
|
|
2786
|
+
const e = p(p({}, qr), t);
|
|
2766
2787
|
if (e.latitude === void 0 || e.latitude === null)
|
|
2767
2788
|
throw {
|
|
2768
2789
|
errMsg: "缺少必需参数:latitude(纬度)",
|
|
@@ -2817,15 +2838,15 @@ function Kr(t = {}) {
|
|
|
2817
2838
|
};
|
|
2818
2839
|
if (e.scale !== void 0 && e.scale !== null) {
|
|
2819
2840
|
const r = Number(e.scale);
|
|
2820
|
-
isNaN(r) ? (
|
|
2841
|
+
isNaN(r) ? (s.warn("scale 参数无效,使用默认值 18", { scale: e.scale }), e.scale = 18) : e.scale = Math.max(1, Math.min(28, Math.floor(r)));
|
|
2821
2842
|
}
|
|
2822
2843
|
return e;
|
|
2823
2844
|
}
|
|
2824
|
-
function
|
|
2825
|
-
return ["weixin", "webview", "UniApp", "plus", "nvue", "uvue"].includes(
|
|
2845
|
+
function Re() {
|
|
2846
|
+
return ["weixin", "webview", "UniApp", "plus", "nvue", "uvue"].includes(c.type);
|
|
2826
2847
|
}
|
|
2827
|
-
function
|
|
2828
|
-
return
|
|
2848
|
+
function nt(t) {
|
|
2849
|
+
return u.safeExecute(() => {
|
|
2829
2850
|
var e;
|
|
2830
2851
|
if (!window.wx) {
|
|
2831
2852
|
const r = {
|
|
@@ -2835,25 +2856,25 @@ function Ze(t) {
|
|
|
2835
2856
|
(e = t.fail) == null || e.call(t, r);
|
|
2836
2857
|
return;
|
|
2837
2858
|
}
|
|
2838
|
-
if (!
|
|
2839
|
-
|
|
2859
|
+
if (!z()) {
|
|
2860
|
+
s.info("等待微信配置完成"), k().then(() => nt(t)).catch((r) => {
|
|
2840
2861
|
var n;
|
|
2841
|
-
|
|
2862
|
+
s.error("微信配置失败", r), (n = t.fail) == null || n.call(t, { errMsg: `微信配置失败: ${r.message}` });
|
|
2842
2863
|
});
|
|
2843
2864
|
return;
|
|
2844
2865
|
}
|
|
2845
|
-
|
|
2866
|
+
s.debug("调用微信定位", t), window.wx.getLocation({
|
|
2846
2867
|
type: t.type,
|
|
2847
2868
|
success: (r) => {
|
|
2848
2869
|
var n;
|
|
2849
|
-
|
|
2870
|
+
s.info("微信定位成功", {
|
|
2850
2871
|
latitude: r.latitude,
|
|
2851
2872
|
longitude: r.longitude
|
|
2852
2873
|
}), (n = t.success) == null || n.call(t, r);
|
|
2853
2874
|
},
|
|
2854
2875
|
fail: (r) => {
|
|
2855
2876
|
var n;
|
|
2856
|
-
|
|
2877
|
+
s.error("微信定位失败", r), (n = t.fail) == null || n.call(t, r);
|
|
2857
2878
|
},
|
|
2858
2879
|
complete: t.complete
|
|
2859
2880
|
});
|
|
@@ -2862,8 +2883,8 @@ function Ze(t) {
|
|
|
2862
2883
|
platform: "weixin"
|
|
2863
2884
|
});
|
|
2864
2885
|
}
|
|
2865
|
-
function
|
|
2866
|
-
return
|
|
2886
|
+
function it(t) {
|
|
2887
|
+
return u.safeExecute(() => {
|
|
2867
2888
|
var e;
|
|
2868
2889
|
if (!window.wx) {
|
|
2869
2890
|
const r = {
|
|
@@ -2873,14 +2894,14 @@ function Qe(t) {
|
|
|
2873
2894
|
(e = t.fail) == null || e.call(t, r);
|
|
2874
2895
|
return;
|
|
2875
2896
|
}
|
|
2876
|
-
if (!
|
|
2877
|
-
|
|
2897
|
+
if (!z()) {
|
|
2898
|
+
s.info("等待微信配置完成"), k().then(() => it(t)).catch((r) => {
|
|
2878
2899
|
var n;
|
|
2879
|
-
|
|
2900
|
+
s.error("微信配置失败", r), (n = t.fail) == null || n.call(t, { errMsg: `微信配置失败: ${r.message}` });
|
|
2880
2901
|
});
|
|
2881
2902
|
return;
|
|
2882
2903
|
}
|
|
2883
|
-
|
|
2904
|
+
s.debug("调用微信查看位置", t), window.wx.openLocation({
|
|
2884
2905
|
latitude: t.latitude,
|
|
2885
2906
|
longitude: t.longitude,
|
|
2886
2907
|
name: t.name || "",
|
|
@@ -2889,11 +2910,11 @@ function Qe(t) {
|
|
|
2889
2910
|
infoUrl: t.infoUrl || "",
|
|
2890
2911
|
success: (r) => {
|
|
2891
2912
|
var n;
|
|
2892
|
-
|
|
2913
|
+
s.info("微信查看位置成功"), (n = t.success) == null || n.call(t, r);
|
|
2893
2914
|
},
|
|
2894
2915
|
fail: (r) => {
|
|
2895
2916
|
var n;
|
|
2896
|
-
|
|
2917
|
+
s.error("微信查看位置失败", r), (n = t.fail) == null || n.call(t, r);
|
|
2897
2918
|
},
|
|
2898
2919
|
complete: t.complete
|
|
2899
2920
|
});
|
|
@@ -2902,19 +2923,19 @@ function Qe(t) {
|
|
|
2902
2923
|
platform: "weixin"
|
|
2903
2924
|
});
|
|
2904
2925
|
}
|
|
2905
|
-
function
|
|
2906
|
-
return
|
|
2907
|
-
|
|
2926
|
+
function Xr(t) {
|
|
2927
|
+
return u.safeExecute(() => {
|
|
2928
|
+
s.debug("通过 WebView 桥接调用获取位置", t), C("getLocation", t, {
|
|
2908
2929
|
success: (e) => {
|
|
2909
2930
|
var r;
|
|
2910
|
-
|
|
2931
|
+
s.info("UniApp 获取位置成功", {
|
|
2911
2932
|
latitude: e == null ? void 0 : e.latitude,
|
|
2912
2933
|
longitude: e == null ? void 0 : e.longitude
|
|
2913
2934
|
}), (r = t.success) == null || r.call(t, e);
|
|
2914
2935
|
},
|
|
2915
2936
|
fail: (e) => {
|
|
2916
2937
|
var r;
|
|
2917
|
-
|
|
2938
|
+
s.error("UniApp 获取位置失败", e), (r = t.fail) == null || r.call(t, e);
|
|
2918
2939
|
},
|
|
2919
2940
|
complete: t.complete
|
|
2920
2941
|
});
|
|
@@ -2923,16 +2944,16 @@ function zr(t) {
|
|
|
2923
2944
|
platform: "uniapp"
|
|
2924
2945
|
});
|
|
2925
2946
|
}
|
|
2926
|
-
function
|
|
2927
|
-
return
|
|
2928
|
-
|
|
2947
|
+
function Zr(t) {
|
|
2948
|
+
return u.safeExecute(() => {
|
|
2949
|
+
s.debug("通过 WebView 桥接调用查看位置", t), C("openLocation", t, {
|
|
2929
2950
|
success: (e) => {
|
|
2930
2951
|
var r;
|
|
2931
|
-
|
|
2952
|
+
s.info("UniApp 查看位置成功"), (r = t.success) == null || r.call(t, e);
|
|
2932
2953
|
},
|
|
2933
2954
|
fail: (e) => {
|
|
2934
2955
|
var r;
|
|
2935
|
-
|
|
2956
|
+
s.error("UniApp 查看位置失败", e), (r = t.fail) == null || r.call(t, e);
|
|
2936
2957
|
},
|
|
2937
2958
|
complete: t.complete
|
|
2938
2959
|
});
|
|
@@ -2941,62 +2962,63 @@ function Gr(t) {
|
|
|
2941
2962
|
platform: "uniapp"
|
|
2942
2963
|
});
|
|
2943
2964
|
}
|
|
2944
|
-
function
|
|
2945
|
-
return
|
|
2965
|
+
function Qr(t = {}) {
|
|
2966
|
+
return u.safeExecute(() => {
|
|
2946
2967
|
var r;
|
|
2947
|
-
if (!
|
|
2968
|
+
if (!Re()) {
|
|
2948
2969
|
const n = {
|
|
2949
|
-
errMsg: `当前环境 (${
|
|
2970
|
+
errMsg: `当前环境 (${c.type}) 不支持定位功能`,
|
|
2950
2971
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
2951
2972
|
};
|
|
2952
|
-
|
|
2973
|
+
s.error("平台不支持定位", { platform: c.type }), (r = t.fail) == null || r.call(t, n);
|
|
2953
2974
|
return;
|
|
2954
2975
|
}
|
|
2955
|
-
const e =
|
|
2956
|
-
|
|
2957
|
-
platform:
|
|
2976
|
+
const e = Jr(t);
|
|
2977
|
+
s.info("开始获取位置", {
|
|
2978
|
+
platform: c.type,
|
|
2958
2979
|
type: e.type,
|
|
2959
2980
|
altitude: e.altitude
|
|
2960
|
-
}),
|
|
2981
|
+
}), E() ? nt(e) : Xr(e);
|
|
2961
2982
|
}, {
|
|
2962
2983
|
context: "getLocation",
|
|
2963
2984
|
options: t
|
|
2964
2985
|
});
|
|
2965
2986
|
}
|
|
2966
|
-
function
|
|
2967
|
-
return
|
|
2987
|
+
function en(t = {}) {
|
|
2988
|
+
return u.safeExecute(() => {
|
|
2968
2989
|
var r, n, i;
|
|
2969
|
-
if (!
|
|
2970
|
-
const
|
|
2971
|
-
errMsg: `当前环境 (${
|
|
2990
|
+
if (!Re()) {
|
|
2991
|
+
const a = {
|
|
2992
|
+
errMsg: `当前环境 (${c.type}) 不支持查看位置功能`,
|
|
2972
2993
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
2973
2994
|
};
|
|
2974
|
-
|
|
2995
|
+
s.error("平台不支持查看位置", { platform: c.type }), (r = t.fail) == null || r.call(t, a);
|
|
2975
2996
|
return;
|
|
2976
2997
|
}
|
|
2977
2998
|
let e;
|
|
2978
2999
|
try {
|
|
2979
|
-
e =
|
|
2980
|
-
} catch (
|
|
2981
|
-
|
|
3000
|
+
e = Yr(t);
|
|
3001
|
+
} catch (a) {
|
|
3002
|
+
s.error("参数验证失败", a), (n = t.fail) == null || n.call(t, a), (i = t.complete) == null || i.call(t);
|
|
2982
3003
|
return;
|
|
2983
3004
|
}
|
|
2984
|
-
|
|
2985
|
-
platform:
|
|
3005
|
+
s.info("开始查看位置", {
|
|
3006
|
+
platform: c.type,
|
|
2986
3007
|
latitude: e.latitude,
|
|
2987
3008
|
longitude: e.longitude,
|
|
2988
3009
|
name: e.name
|
|
2989
|
-
}),
|
|
3010
|
+
}), E() ? it(e) : Zr(e);
|
|
2990
3011
|
}, {
|
|
2991
3012
|
context: "openLocation",
|
|
2992
3013
|
options: t
|
|
2993
3014
|
});
|
|
2994
3015
|
}
|
|
2995
|
-
function
|
|
3016
|
+
function tn() {
|
|
3017
|
+
const t = E();
|
|
2996
3018
|
return {
|
|
2997
|
-
supported:
|
|
2998
|
-
environment:
|
|
2999
|
-
implementation:
|
|
3019
|
+
supported: Re(),
|
|
3020
|
+
environment: c.type,
|
|
3021
|
+
implementation: t ? "weixin" : "webview",
|
|
3000
3022
|
features: {
|
|
3001
3023
|
getLocation: !0,
|
|
3002
3024
|
// 获取位置
|
|
@@ -3006,34 +3028,184 @@ function qr() {
|
|
|
3006
3028
|
// 支持坐标类型选择
|
|
3007
3029
|
altitudeSupport: !0,
|
|
3008
3030
|
// 支持高度信息
|
|
3009
|
-
asyncSupport: !0
|
|
3031
|
+
asyncSupport: !0,
|
|
3010
3032
|
// 支持 Promise
|
|
3033
|
+
onLocationChange: !t
|
|
3034
|
+
// 支持位置监听(微信环境不支持)
|
|
3011
3035
|
}
|
|
3012
3036
|
};
|
|
3013
3037
|
}
|
|
3014
|
-
const
|
|
3038
|
+
const $ = /* @__PURE__ */ new Set(), B = /* @__PURE__ */ new Set();
|
|
3039
|
+
function st(t, e, r) {
|
|
3040
|
+
t.forEach((n) => {
|
|
3041
|
+
if (typeof n == "function") {
|
|
3042
|
+
u.safeExecute(() => n(e), { context: r });
|
|
3043
|
+
return;
|
|
3044
|
+
}
|
|
3045
|
+
s.warn("监听回调不是函数,已跳过", { type: typeof n });
|
|
3046
|
+
});
|
|
3047
|
+
}
|
|
3048
|
+
function rn(t = {}) {
|
|
3049
|
+
return u.safeExecute(() => {
|
|
3050
|
+
var r, n;
|
|
3051
|
+
if (E()) {
|
|
3052
|
+
const i = {
|
|
3053
|
+
errMsg: `当前环境 (${c.type}) 不支持该接口`,
|
|
3054
|
+
code: "PLATFORM_NOT_SUPPORTED"
|
|
3055
|
+
};
|
|
3056
|
+
s.error("当前环境不支持此接口", { platform: c.type }), (r = t.fail) == null || r.call(t, i), (n = t.complete) == null || n.call(t, i);
|
|
3057
|
+
return;
|
|
3058
|
+
}
|
|
3059
|
+
const e = Hr(t);
|
|
3060
|
+
s.info("正在开启定位监听"), C("startLocationUpdate", {
|
|
3061
|
+
type: e.type,
|
|
3062
|
+
needFullAccuracy: e.needFullAccuracy
|
|
3063
|
+
}, {
|
|
3064
|
+
success: (i) => {
|
|
3065
|
+
var a;
|
|
3066
|
+
s.info("定位监听已启动"), (a = t.success) == null || a.call(t, i);
|
|
3067
|
+
},
|
|
3068
|
+
fail: (i) => {
|
|
3069
|
+
var a;
|
|
3070
|
+
return (a = t.fail) == null ? void 0 : a.call(t, i);
|
|
3071
|
+
},
|
|
3072
|
+
complete: t.complete
|
|
3073
|
+
});
|
|
3074
|
+
}, { context: "startLocationUpdate" });
|
|
3075
|
+
}
|
|
3076
|
+
function nn(t = {}) {
|
|
3077
|
+
return u.safeExecute(() => {
|
|
3078
|
+
var e, r;
|
|
3079
|
+
if (E()) {
|
|
3080
|
+
const n = {
|
|
3081
|
+
errMsg: `当前环境 (${c.type}) 不支持该接口`,
|
|
3082
|
+
code: "PLATFORM_NOT_SUPPORTED"
|
|
3083
|
+
};
|
|
3084
|
+
s.error("当前环境不支持此接口", { platform: c.type }), (e = t.fail) == null || e.call(t, n), (r = t.complete) == null || r.call(t, n);
|
|
3085
|
+
return;
|
|
3086
|
+
}
|
|
3087
|
+
s.info("正在停止定位监听"), C("stopLocationUpdate", t, {
|
|
3088
|
+
success: (n) => {
|
|
3089
|
+
var i;
|
|
3090
|
+
s.info("定位监听已停止"), (i = t.success) == null || i.call(t, n);
|
|
3091
|
+
},
|
|
3092
|
+
fail: (n) => {
|
|
3093
|
+
var i;
|
|
3094
|
+
return (i = t.fail) == null ? void 0 : i.call(t, n);
|
|
3095
|
+
},
|
|
3096
|
+
complete: t.complete
|
|
3097
|
+
});
|
|
3098
|
+
}, { context: "stopLocationUpdate" });
|
|
3099
|
+
}
|
|
3100
|
+
function sn(t) {
|
|
3101
|
+
return u.safeExecute(() => {
|
|
3102
|
+
if (E()) {
|
|
3103
|
+
s.warn("当前环境不支持此接口", { platform: c.type });
|
|
3104
|
+
return;
|
|
3105
|
+
}
|
|
3106
|
+
if (typeof t != "function")
|
|
3107
|
+
throw s.error("onLocationChange 回调不是函数", { type: typeof t }), {
|
|
3108
|
+
errMsg: "onLocationChange 回调必须是函数",
|
|
3109
|
+
code: "INVALID_CALLBACK"
|
|
3110
|
+
};
|
|
3111
|
+
const e = $.size > 0;
|
|
3112
|
+
$.add(t), e || (s.debug("注册实时位置变化监听器"), C("onLocationChange", { isPersistent: !0 }, {
|
|
3113
|
+
success: (r) => {
|
|
3114
|
+
s.debug("收到实时位置推送", r), st($, r, "onLocationChange");
|
|
3115
|
+
},
|
|
3116
|
+
fail: (r) => {
|
|
3117
|
+
s.warn("位置变化监听出错,请通过 onLocationChangeError 监听错误", r), $.delete(t), $.size === 0 && X("onLocationChange");
|
|
3118
|
+
}
|
|
3119
|
+
}));
|
|
3120
|
+
}, { context: "onLocationChange" });
|
|
3121
|
+
}
|
|
3122
|
+
function an(t) {
|
|
3123
|
+
return u.safeExecute(() => {
|
|
3124
|
+
if (E()) {
|
|
3125
|
+
s.warn("当前环境不支持此接口", { platform: c.type });
|
|
3126
|
+
return;
|
|
3127
|
+
}
|
|
3128
|
+
if (t && typeof t != "function")
|
|
3129
|
+
throw s.error("offLocationChange 回调不是函数", { type: typeof t }), {
|
|
3130
|
+
errMsg: "offLocationChange 回调必须是函数",
|
|
3131
|
+
code: "INVALID_CALLBACK"
|
|
3132
|
+
};
|
|
3133
|
+
t ? $.delete(t) : $.clear(), !($.size > 0) && (s.info("移除位置变化监听器"), C("offLocationChange", {}, {
|
|
3134
|
+
success: () => {
|
|
3135
|
+
s.info("位置变化监听已移除"), X("onLocationChange");
|
|
3136
|
+
},
|
|
3137
|
+
fail: (e) => {
|
|
3138
|
+
s.error("移除位置变化监听失败", e), X("onLocationChange");
|
|
3139
|
+
}
|
|
3140
|
+
}));
|
|
3141
|
+
}, { context: "offLocationChange" });
|
|
3142
|
+
}
|
|
3143
|
+
function on(t) {
|
|
3144
|
+
return u.safeExecute(() => {
|
|
3145
|
+
if (E()) {
|
|
3146
|
+
s.warn("当前环境不支持此接口", { platform: c.type });
|
|
3147
|
+
return;
|
|
3148
|
+
}
|
|
3149
|
+
if (typeof t != "function")
|
|
3150
|
+
throw s.error("onLocationChangeError 回调不是函数", { type: typeof t }), {
|
|
3151
|
+
errMsg: "onLocationChangeError 回调必须是函数",
|
|
3152
|
+
code: "INVALID_CALLBACK"
|
|
3153
|
+
};
|
|
3154
|
+
const e = B.size > 0;
|
|
3155
|
+
B.add(t), e || (s.debug("注册位置更新错误监听器"), C("onLocationChangeError", { isPersistent: !0 }, {
|
|
3156
|
+
success: (r) => {
|
|
3157
|
+
s.warn("持续定位发生异常", r), st(B, r, "onLocationChangeError");
|
|
3158
|
+
},
|
|
3159
|
+
fail: (r) => {
|
|
3160
|
+
s.warn("位置更新错误监听注册失败", r), B.delete(t), B.size === 0 && X("onLocationChangeError");
|
|
3161
|
+
}
|
|
3162
|
+
}));
|
|
3163
|
+
}, { context: "onLocationChangeError" });
|
|
3164
|
+
}
|
|
3165
|
+
function cn(t) {
|
|
3166
|
+
return u.safeExecute(() => {
|
|
3167
|
+
if (E()) {
|
|
3168
|
+
s.warn("当前环境不支持此接口", { platform: c.type });
|
|
3169
|
+
return;
|
|
3170
|
+
}
|
|
3171
|
+
if (t && typeof t != "function")
|
|
3172
|
+
throw s.error("offLocationChangeError 回调不是函数", { type: typeof t }), {
|
|
3173
|
+
errMsg: "offLocationChangeError 回调必须是函数",
|
|
3174
|
+
code: "INVALID_CALLBACK"
|
|
3175
|
+
};
|
|
3176
|
+
t ? B.delete(t) : B.clear(), !(B.size > 0) && (s.info("移除定位错误监听器"), C("offLocationChangeError", {}, {
|
|
3177
|
+
success: () => {
|
|
3178
|
+
s.info("定位错误监听已移除"), X("onLocationChangeError");
|
|
3179
|
+
},
|
|
3180
|
+
fail: (e) => {
|
|
3181
|
+
s.error("移除定位错误监听失败", e), X("onLocationChangeError");
|
|
3182
|
+
}
|
|
3183
|
+
}));
|
|
3184
|
+
}, { context: "offLocationChangeError" });
|
|
3185
|
+
}
|
|
3186
|
+
const un = {
|
|
3015
3187
|
latitude: null,
|
|
3016
3188
|
// 目标地纬度
|
|
3017
3189
|
longitude: null
|
|
3018
3190
|
// 目标地经度
|
|
3019
3191
|
};
|
|
3020
|
-
function
|
|
3021
|
-
const e =
|
|
3022
|
-
return e.latitude !== null && e.latitude !== void 0 && (typeof e.latitude != "number" ? (
|
|
3192
|
+
function ln(t = {}) {
|
|
3193
|
+
const e = p(p({}, un), t);
|
|
3194
|
+
return e.latitude !== null && e.latitude !== void 0 && (typeof e.latitude != "number" ? (s.warn("latitude 参数类型错误,已忽略", {
|
|
3023
3195
|
latitude: e.latitude
|
|
3024
|
-
}), e.latitude = null) : (e.latitude < -90 || e.latitude > 90) && (
|
|
3196
|
+
}), e.latitude = null) : (e.latitude < -90 || e.latitude > 90) && (s.warn("latitude 超出范围,已忽略", {
|
|
3025
3197
|
latitude: e.latitude
|
|
3026
|
-
}), e.latitude = null)), e.longitude !== null && e.longitude !== void 0 && (typeof e.longitude != "number" ? (
|
|
3198
|
+
}), e.latitude = null)), e.longitude !== null && e.longitude !== void 0 && (typeof e.longitude != "number" ? (s.warn("longitude 参数类型错误,已忽略", {
|
|
3027
3199
|
longitude: e.longitude
|
|
3028
|
-
}), e.longitude = null) : (e.longitude < -180 || e.longitude > 180) && (
|
|
3200
|
+
}), e.longitude = null) : (e.longitude < -180 || e.longitude > 180) && (s.warn("longitude 超出范围,已忽略", {
|
|
3029
3201
|
longitude: e.longitude
|
|
3030
3202
|
}), e.longitude = null)), e;
|
|
3031
3203
|
}
|
|
3032
|
-
function
|
|
3033
|
-
return ["weixin", "webview", "UniApp", "plus", "nvue", "uvue"].includes(
|
|
3204
|
+
function at() {
|
|
3205
|
+
return ["weixin", "webview", "UniApp", "plus", "nvue", "uvue"].includes(c.type);
|
|
3034
3206
|
}
|
|
3035
|
-
function
|
|
3036
|
-
return
|
|
3207
|
+
function ot(t) {
|
|
3208
|
+
return u.safeExecute(() => {
|
|
3037
3209
|
var n;
|
|
3038
3210
|
if (!window.wx) {
|
|
3039
3211
|
const i = {
|
|
@@ -3043,24 +3215,24 @@ function tt(t) {
|
|
|
3043
3215
|
(n = t.fail) == null || n.call(t, i);
|
|
3044
3216
|
return;
|
|
3045
3217
|
}
|
|
3046
|
-
if (!
|
|
3047
|
-
|
|
3048
|
-
var
|
|
3049
|
-
|
|
3218
|
+
if (!z()) {
|
|
3219
|
+
s.info("等待微信配置完成"), k().then(() => ot(t)).catch((i) => {
|
|
3220
|
+
var a;
|
|
3221
|
+
s.error("微信配置失败", i), (a = t.fail) == null || a.call(t, { errMsg: `微信配置失败: ${i.message}` });
|
|
3050
3222
|
});
|
|
3051
3223
|
return;
|
|
3052
3224
|
}
|
|
3053
|
-
|
|
3225
|
+
s.debug("调用微信位置选择", t);
|
|
3054
3226
|
const e = {
|
|
3055
3227
|
success: (i) => {
|
|
3056
|
-
var
|
|
3057
|
-
|
|
3228
|
+
var g;
|
|
3229
|
+
s.info("微信位置选择成功", {
|
|
3058
3230
|
name: i.name,
|
|
3059
3231
|
address: i.address,
|
|
3060
3232
|
latitude: i.latitude,
|
|
3061
3233
|
longitude: i.longitude
|
|
3062
3234
|
});
|
|
3063
|
-
const
|
|
3235
|
+
const a = {
|
|
3064
3236
|
name: i.name,
|
|
3065
3237
|
// 位置名称
|
|
3066
3238
|
address: i.address,
|
|
@@ -3071,15 +3243,15 @@ function tt(t) {
|
|
|
3071
3243
|
// 经度
|
|
3072
3244
|
errMsg: "chooseLocation:ok"
|
|
3073
3245
|
};
|
|
3074
|
-
(
|
|
3246
|
+
(g = t.success) == null || g.call(t, a);
|
|
3075
3247
|
},
|
|
3076
3248
|
fail: (i) => {
|
|
3077
|
-
var
|
|
3078
|
-
|
|
3249
|
+
var a;
|
|
3250
|
+
s.error("微信位置选择失败", i), (a = t.fail) == null || a.call(t, i);
|
|
3079
3251
|
},
|
|
3080
3252
|
complete: t.complete
|
|
3081
3253
|
}, r = {};
|
|
3082
|
-
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(A(
|
|
3254
|
+
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(A(p({}, r), {
|
|
3083
3255
|
success: e.success,
|
|
3084
3256
|
fail: e.fail,
|
|
3085
3257
|
complete: e.complete
|
|
@@ -3089,15 +3261,15 @@ function tt(t) {
|
|
|
3089
3261
|
platform: "weixin"
|
|
3090
3262
|
});
|
|
3091
3263
|
}
|
|
3092
|
-
function
|
|
3093
|
-
return
|
|
3094
|
-
|
|
3264
|
+
function fn(t) {
|
|
3265
|
+
return u.safeExecute(() => {
|
|
3266
|
+
s.debug("通过 WebView 桥接调用位置选择", t);
|
|
3095
3267
|
const e = {
|
|
3096
3268
|
// 禁用超时清理,等待用户操作完成后才清理
|
|
3097
3269
|
disableTimeout: !0,
|
|
3098
3270
|
success: (r) => {
|
|
3099
3271
|
var n;
|
|
3100
|
-
|
|
3272
|
+
s.info("UniApp 位置选择成功", {
|
|
3101
3273
|
name: r == null ? void 0 : r.name,
|
|
3102
3274
|
address: r == null ? void 0 : r.address,
|
|
3103
3275
|
latitude: r == null ? void 0 : r.latitude,
|
|
@@ -3106,11 +3278,11 @@ function Yr(t) {
|
|
|
3106
3278
|
},
|
|
3107
3279
|
fail: (r) => {
|
|
3108
3280
|
var n;
|
|
3109
|
-
|
|
3281
|
+
s.error("UniApp 位置选择失败", r), (n = t.fail) == null || n.call(t, r);
|
|
3110
3282
|
},
|
|
3111
3283
|
complete: t.complete
|
|
3112
3284
|
};
|
|
3113
|
-
t.latitude !== null && t.latitude !== void 0 && (e.latitude = t.latitude), t.longitude !== null && t.longitude !== void 0 && (e.longitude = t.longitude),
|
|
3285
|
+
t.latitude !== null && t.latitude !== void 0 && (e.latitude = t.latitude), t.longitude !== null && t.longitude !== void 0 && (e.longitude = t.longitude), C("chooseLocation", e, {
|
|
3114
3286
|
success: (r) => {
|
|
3115
3287
|
e.success(r);
|
|
3116
3288
|
},
|
|
@@ -3124,33 +3296,33 @@ function Yr(t) {
|
|
|
3124
3296
|
platform: "uniapp"
|
|
3125
3297
|
});
|
|
3126
3298
|
}
|
|
3127
|
-
function
|
|
3128
|
-
return
|
|
3299
|
+
function dn(t = {}) {
|
|
3300
|
+
return u.safeExecute(() => {
|
|
3129
3301
|
var r;
|
|
3130
|
-
if (!
|
|
3302
|
+
if (!at()) {
|
|
3131
3303
|
const n = {
|
|
3132
|
-
errMsg: `当前环境 (${
|
|
3304
|
+
errMsg: `当前环境 (${c.type}) 不支持位置选择功能`,
|
|
3133
3305
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
3134
3306
|
};
|
|
3135
|
-
|
|
3307
|
+
s.error("平台不支持位置选择", { platform: c.type }), (r = t.fail) == null || r.call(t, n);
|
|
3136
3308
|
return;
|
|
3137
3309
|
}
|
|
3138
|
-
const e =
|
|
3139
|
-
|
|
3140
|
-
platform:
|
|
3310
|
+
const e = ln(t);
|
|
3311
|
+
s.info("开始选择位置", {
|
|
3312
|
+
platform: c.type,
|
|
3141
3313
|
latitude: e.latitude,
|
|
3142
3314
|
longitude: e.longitude
|
|
3143
|
-
}),
|
|
3315
|
+
}), E() ? ot(e) : fn(e);
|
|
3144
3316
|
}, {
|
|
3145
3317
|
context: "chooseLocation",
|
|
3146
3318
|
options: t
|
|
3147
3319
|
});
|
|
3148
3320
|
}
|
|
3149
|
-
function
|
|
3321
|
+
function gn() {
|
|
3150
3322
|
return {
|
|
3151
|
-
supported:
|
|
3152
|
-
environment:
|
|
3153
|
-
implementation:
|
|
3323
|
+
supported: at(),
|
|
3324
|
+
environment: c.type,
|
|
3325
|
+
implementation: E() ? "weixin" : "webview",
|
|
3154
3326
|
features: {
|
|
3155
3327
|
chooseLocation: !0,
|
|
3156
3328
|
// 支持位置选择
|
|
@@ -3161,21 +3333,21 @@ function Zr() {
|
|
|
3161
3333
|
}
|
|
3162
3334
|
};
|
|
3163
3335
|
}
|
|
3164
|
-
const
|
|
3165
|
-
function
|
|
3166
|
-
|
|
3336
|
+
const ct = /* @__PURE__ */ new Map();
|
|
3337
|
+
function pn(t, e = {}) {
|
|
3338
|
+
ct.set(t, e);
|
|
3167
3339
|
}
|
|
3168
|
-
function
|
|
3169
|
-
const r =
|
|
3340
|
+
function hn(t, e) {
|
|
3341
|
+
const r = ct.get(t);
|
|
3170
3342
|
if (r)
|
|
3171
3343
|
return r[e] || r.default;
|
|
3172
3344
|
}
|
|
3173
|
-
const
|
|
3345
|
+
const mn = {
|
|
3174
3346
|
0: "WXSceneSession",
|
|
3175
3347
|
// 聊天界面
|
|
3176
3348
|
1: "WXSceneTimeline"
|
|
3177
3349
|
// 朋友圈
|
|
3178
|
-
},
|
|
3350
|
+
}, wn = {
|
|
3179
3351
|
0: "图文/网页",
|
|
3180
3352
|
1: "纯文字",
|
|
3181
3353
|
2: "纯图片",
|
|
@@ -3183,33 +3355,33 @@ const tn = {
|
|
|
3183
3355
|
4: "视频",
|
|
3184
3356
|
5: "小程序"
|
|
3185
3357
|
};
|
|
3186
|
-
function
|
|
3187
|
-
return
|
|
3358
|
+
function ut(t = {}) {
|
|
3359
|
+
return u.safeExecute(
|
|
3188
3360
|
() => {
|
|
3189
3361
|
var n, i;
|
|
3190
3362
|
if (typeof window == "undefined" || !window.wx) {
|
|
3191
|
-
const
|
|
3192
|
-
return (n = t.fail) == null || n.call(t,
|
|
3363
|
+
const a = { errMsg: "微信JS-SDK未加载", code: "WEIXIN_SDK_NOT_LOADED" };
|
|
3364
|
+
return (n = t.fail) == null || n.call(t, a), Promise.reject(a);
|
|
3193
3365
|
}
|
|
3194
|
-
if (!
|
|
3195
|
-
return
|
|
3196
|
-
const e =
|
|
3366
|
+
if (!z())
|
|
3367
|
+
return s.info("等待微信配置完成"), k().then(() => ut(t));
|
|
3368
|
+
const e = lt(t);
|
|
3197
3369
|
if (!e.success) {
|
|
3198
|
-
const
|
|
3199
|
-
return (i = t.fail) == null || i.call(t,
|
|
3370
|
+
const a = { errMsg: e.message || "参数校验失败", code: "INVALID_PARAMS" };
|
|
3371
|
+
return (i = t.fail) == null || i.call(t, a), Promise.reject(a);
|
|
3200
3372
|
}
|
|
3201
3373
|
const r = e.params;
|
|
3202
|
-
return
|
|
3203
|
-
window.wx[r.scene](A(
|
|
3374
|
+
return s.debug("调用微信分享", r), new Promise((a, g) => {
|
|
3375
|
+
window.wx[r.scene](A(p({}, r), {
|
|
3204
3376
|
success: () => {
|
|
3205
|
-
var
|
|
3206
|
-
const
|
|
3207
|
-
(
|
|
3377
|
+
var l;
|
|
3378
|
+
const d = { errMsg: "weixinShare:ok" };
|
|
3379
|
+
(l = t.success) == null || l.call(t, d), a(d);
|
|
3208
3380
|
},
|
|
3209
|
-
fail: (
|
|
3210
|
-
var
|
|
3211
|
-
const
|
|
3212
|
-
|
|
3381
|
+
fail: (d) => {
|
|
3382
|
+
var h;
|
|
3383
|
+
const l = { errMsg: (d == null ? void 0 : d.errMsg) || "weixinShare:fail", details: d };
|
|
3384
|
+
s.error("微信分享失败", l), (h = t.fail) == null || h.call(t, l), g(l);
|
|
3213
3385
|
},
|
|
3214
3386
|
complete: t.complete
|
|
3215
3387
|
}));
|
|
@@ -3221,23 +3393,23 @@ function nt(t = {}) {
|
|
|
3221
3393
|
}
|
|
3222
3394
|
);
|
|
3223
3395
|
}
|
|
3224
|
-
function
|
|
3225
|
-
const e =
|
|
3396
|
+
function lt(t = {}) {
|
|
3397
|
+
const e = p({}, t), r = {
|
|
3226
3398
|
scene: e.scene === 1 ? "updateTimelineShareData" : "updateAppMessageShareData"
|
|
3227
3399
|
};
|
|
3228
|
-
return
|
|
3400
|
+
return s.info("格式化微信参数", e), Object.prototype.hasOwnProperty.call(e, "title") ? Object.prototype.hasOwnProperty.call(e, "imageUrl") ? Object.prototype.hasOwnProperty.call(e, "path") ? Object.prototype.hasOwnProperty.call(e, "summary") ? (r.title = e.title, r.imgUrl = e.imageUrl, r.link = e.path, r.desc = e.summary, { params: r, success: !0 }) : { message: "参数字段summary值缺少!", success: !1 } : { message: "参数字段path值缺少!", success: !1 } : { message: "参数字段imageUrl值缺少!", success: !1 } : { message: "参数字段title值缺少!", success: !1 };
|
|
3229
3401
|
}
|
|
3230
|
-
function
|
|
3231
|
-
return
|
|
3232
|
-
() => (
|
|
3233
|
-
|
|
3402
|
+
function J(t = {}) {
|
|
3403
|
+
return u.safeExecute(
|
|
3404
|
+
() => (s.debug("通过 WebView 桥接调用微信分享", t), new Promise((e, r) => {
|
|
3405
|
+
C("toShareData", t, {
|
|
3234
3406
|
success: (n) => {
|
|
3235
3407
|
var i;
|
|
3236
3408
|
(i = t.success) == null || i.call(t, n), e(n);
|
|
3237
3409
|
},
|
|
3238
3410
|
fail: (n) => {
|
|
3239
3411
|
var i;
|
|
3240
|
-
|
|
3412
|
+
s.error("UniApp 微信分享失败", n), (i = t.fail) == null || i.call(t, n), r(n);
|
|
3241
3413
|
},
|
|
3242
3414
|
complete: t.complete
|
|
3243
3415
|
});
|
|
@@ -3248,14 +3420,14 @@ function j(t = {}) {
|
|
|
3248
3420
|
}
|
|
3249
3421
|
);
|
|
3250
3422
|
}
|
|
3251
|
-
function
|
|
3252
|
-
const e =
|
|
3423
|
+
function En(t = {}) {
|
|
3424
|
+
const e = p({}, t), r = {
|
|
3253
3425
|
provider: "weixin",
|
|
3254
3426
|
scene: "WXSceneSession"
|
|
3255
3427
|
};
|
|
3256
|
-
if (
|
|
3428
|
+
if (s.info("格式化 UniApp 参数", e), [0, 1].some((n) => parseInt(n) === parseInt(e.scene)) ? r.scene = mn[e.scene] : r.scene = "WXSceneSession", Object.prototype.hasOwnProperty.call(e, "type")) {
|
|
3257
3429
|
const n = Number(e.type);
|
|
3258
|
-
if (Object.keys(
|
|
3430
|
+
if (Object.keys(wn).some((a) => parseInt(a) === n)) {
|
|
3259
3431
|
if (r.type = n, [0].includes(n))
|
|
3260
3432
|
if (Object.prototype.hasOwnProperty.call(e, "path"))
|
|
3261
3433
|
r.href = e.path;
|
|
@@ -3271,43 +3443,43 @@ function nn(t = {}) {
|
|
|
3271
3443
|
r.imageUrl = e.imageUrl;
|
|
3272
3444
|
else
|
|
3273
3445
|
return { message: "参数字段imageUrl值缺少!", success: !1 };
|
|
3274
|
-
[5].includes(n) && Object.prototype.hasOwnProperty.call(e, "miniProgram") &&
|
|
3446
|
+
[5].includes(n) && Object.prototype.hasOwnProperty.call(e, "miniProgram") && p({}, e.miniProgram), Object.prototype.hasOwnProperty.call(e, "title") && (r.title = e.title), Object.prototype.hasOwnProperty.call(e, "success") && (r.success = e.success), Object.prototype.hasOwnProperty.call(e, "fail") && (r.fail = e.fail), Object.prototype.hasOwnProperty.call(e, "complete") && (r.complete = e.complete);
|
|
3275
3447
|
} else
|
|
3276
3448
|
return { message: "参数字段type值有误!", success: !1 };
|
|
3277
3449
|
} else
|
|
3278
3450
|
return { message: "参数字段type缺少!", success: !1 };
|
|
3279
3451
|
return { params: r, success: !0 };
|
|
3280
3452
|
}
|
|
3281
|
-
const
|
|
3282
|
-
|
|
3283
|
-
weixin:
|
|
3284
|
-
webview:
|
|
3285
|
-
plus:
|
|
3286
|
-
nvue:
|
|
3287
|
-
uvue:
|
|
3288
|
-
UniApp:
|
|
3289
|
-
h5:
|
|
3453
|
+
const ft = "share.toShare";
|
|
3454
|
+
pn(ft, {
|
|
3455
|
+
weixin: ut,
|
|
3456
|
+
webview: J,
|
|
3457
|
+
plus: J,
|
|
3458
|
+
nvue: J,
|
|
3459
|
+
uvue: J,
|
|
3460
|
+
UniApp: J,
|
|
3461
|
+
h5: J,
|
|
3290
3462
|
default: void 0
|
|
3291
3463
|
});
|
|
3292
|
-
function
|
|
3293
|
-
return
|
|
3464
|
+
function yn(t = {}) {
|
|
3465
|
+
return u.safeExecute(
|
|
3294
3466
|
() => {
|
|
3295
|
-
var
|
|
3296
|
-
const e =
|
|
3467
|
+
var a, g;
|
|
3468
|
+
const e = Ne(), r = hn(ft, e.type);
|
|
3297
3469
|
if (typeof r != "function") {
|
|
3298
|
-
const
|
|
3470
|
+
const d = {
|
|
3299
3471
|
errMsg: `当前环境 (${e.type}) 不支持微信分享功能`,
|
|
3300
3472
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
3301
3473
|
};
|
|
3302
|
-
return
|
|
3474
|
+
return s.error("平台不支持微信分享", { platform: e.type }), (a = t.fail) == null || a.call(t, d), Promise.reject(d);
|
|
3303
3475
|
}
|
|
3304
|
-
const n =
|
|
3476
|
+
const n = E() ? lt(t) : En(t);
|
|
3305
3477
|
if (!n.success) {
|
|
3306
|
-
const
|
|
3307
|
-
return (
|
|
3478
|
+
const d = { errMsg: n.message || "参数校验失败", code: "INVALID_PARAMS" };
|
|
3479
|
+
return (g = t.fail) == null || g.call(t, d), Promise.reject(d);
|
|
3308
3480
|
}
|
|
3309
3481
|
const i = n.params;
|
|
3310
|
-
return
|
|
3482
|
+
return s.info("开始微信分享", { platform: e.type, type: i == null ? void 0 : i.type }), r(i);
|
|
3311
3483
|
},
|
|
3312
3484
|
{
|
|
3313
3485
|
context: "toShare",
|
|
@@ -3315,7 +3487,7 @@ function sn(t = {}) {
|
|
|
3315
3487
|
}
|
|
3316
3488
|
);
|
|
3317
3489
|
}
|
|
3318
|
-
const
|
|
3490
|
+
const In = {
|
|
3319
3491
|
OFF: "off",
|
|
3320
3492
|
// 蓝牙关闭
|
|
3321
3493
|
ON: "on",
|
|
@@ -3324,56 +3496,56 @@ const an = {
|
|
|
3324
3496
|
// 不支持蓝牙
|
|
3325
3497
|
UNAUTHORIZED: "unauthorized"
|
|
3326
3498
|
// 未授权
|
|
3327
|
-
},
|
|
3499
|
+
}, An = {
|
|
3328
3500
|
allowDuplicatesKey: !1,
|
|
3329
3501
|
// 是否允许重复上报同一设备
|
|
3330
3502
|
services: []
|
|
3331
3503
|
// 指定服务 UUID 列表
|
|
3332
3504
|
};
|
|
3333
|
-
function
|
|
3334
|
-
return
|
|
3505
|
+
function we(t = {}) {
|
|
3506
|
+
return p(p({}, An), t);
|
|
3335
3507
|
}
|
|
3336
|
-
function
|
|
3337
|
-
return ["weixin", "webview", "UniApp", "plus", "nvue", "uvue"].includes(
|
|
3508
|
+
function se() {
|
|
3509
|
+
return ["weixin", "webview", "UniApp", "plus", "nvue", "uvue"].includes(c.type);
|
|
3338
3510
|
}
|
|
3339
|
-
function
|
|
3340
|
-
return
|
|
3511
|
+
function On(t) {
|
|
3512
|
+
return u.safeExecute(() => m(null, null, function* () {
|
|
3341
3513
|
var e;
|
|
3342
3514
|
if (!window.wx) {
|
|
3343
3515
|
const r = { errMsg: "微信JS-SDK未加载", code: "WEIXIN_SDK_NOT_LOADED" };
|
|
3344
3516
|
(e = t.fail) == null || e.call(t, r);
|
|
3345
3517
|
return;
|
|
3346
3518
|
}
|
|
3347
|
-
|
|
3519
|
+
z() || (s.info("等待微信配置完成"), yield k()), wx.openBluetoothAdapter({
|
|
3348
3520
|
success: () => {
|
|
3349
|
-
|
|
3521
|
+
s.info("微信蓝牙适配器已打开"), dt(t);
|
|
3350
3522
|
},
|
|
3351
3523
|
fail: (r) => {
|
|
3352
3524
|
var n;
|
|
3353
|
-
|
|
3525
|
+
s.error("蓝牙适配器打开失败", r), (n = t.fail) == null || n.call(t, r);
|
|
3354
3526
|
}
|
|
3355
3527
|
});
|
|
3356
3528
|
}), { context: "openBluetoothAdapterInWeixin" });
|
|
3357
3529
|
}
|
|
3358
|
-
function
|
|
3359
|
-
return
|
|
3360
|
-
|
|
3530
|
+
function _n(t) {
|
|
3531
|
+
return u.safeExecute(() => {
|
|
3532
|
+
s.debug("通过 WebView 桥接调用蓝牙功能", t), C("bluetooth", t, {
|
|
3361
3533
|
success: (e) => {
|
|
3362
3534
|
var r;
|
|
3363
|
-
|
|
3535
|
+
s.info("UniApp 蓝牙调用成功", e), (r = t.success) == null || r.call(t, e);
|
|
3364
3536
|
},
|
|
3365
3537
|
fail: (e) => {
|
|
3366
3538
|
var r;
|
|
3367
|
-
|
|
3539
|
+
s.error("UniApp 蓝牙调用失败", e), (r = t.fail) == null || r.call(t, e);
|
|
3368
3540
|
},
|
|
3369
3541
|
complete: t.complete
|
|
3370
3542
|
});
|
|
3371
3543
|
}, { context: "bluetoothInUniApp" });
|
|
3372
3544
|
}
|
|
3373
|
-
function
|
|
3374
|
-
return
|
|
3545
|
+
function Cn(t) {
|
|
3546
|
+
return u.safeExecute(() => {
|
|
3375
3547
|
var e;
|
|
3376
|
-
|
|
3548
|
+
s.debug("通过 WebView 桥接调用蓝牙设备搜索功能", t), C("bluetoothDevicesDiscovery", {
|
|
3377
3549
|
action: "startBluetoothDevicesDiscovery",
|
|
3378
3550
|
params: {
|
|
3379
3551
|
services: t.services || [],
|
|
@@ -3382,21 +3554,21 @@ function ln(t) {
|
|
|
3382
3554
|
}, {
|
|
3383
3555
|
success: (r) => {
|
|
3384
3556
|
var n;
|
|
3385
|
-
console.log("[Bluetooth] 设备开启搜索成功:", r),
|
|
3557
|
+
console.log("[Bluetooth] 设备开启搜索成功:", r), s.info("UniApp 蓝牙设备开启搜索成功", r), (n = t.success) == null || n.call(t, r);
|
|
3386
3558
|
},
|
|
3387
3559
|
fail: (r) => {
|
|
3388
3560
|
var n;
|
|
3389
|
-
console.error("[Bluetooth] 设备开启搜索失败:", r),
|
|
3561
|
+
console.error("[Bluetooth] 设备开启搜索失败:", r), s.error("UniApp 蓝牙设备开启搜索失败", r), (n = t.fail) == null || n.call(t, r);
|
|
3390
3562
|
},
|
|
3391
3563
|
complete: t.complete
|
|
3392
3564
|
});
|
|
3393
3565
|
}, { context: "startBluetoothDevicesDiscoveryInUniApp" });
|
|
3394
3566
|
}
|
|
3395
|
-
const
|
|
3396
|
-
function
|
|
3397
|
-
return
|
|
3567
|
+
const oe = /* @__PURE__ */ new Set();
|
|
3568
|
+
function Nn(t, e = {}) {
|
|
3569
|
+
return u.safeExecute(() => {
|
|
3398
3570
|
var r;
|
|
3399
|
-
return
|
|
3571
|
+
return oe.add(t), oe.size === 1 && C("onBluetoothDeviceFound", {
|
|
3400
3572
|
action: "onBluetoothDeviceFound",
|
|
3401
3573
|
isPersistent: !0,
|
|
3402
3574
|
params: {
|
|
@@ -3405,8 +3577,8 @@ function dn(t, e = {}) {
|
|
|
3405
3577
|
}
|
|
3406
3578
|
}, {
|
|
3407
3579
|
success: (n) => {
|
|
3408
|
-
|
|
3409
|
-
typeof i == "function" ?
|
|
3580
|
+
oe.forEach((i) => {
|
|
3581
|
+
typeof i == "function" ? u.safeExecute(() => i(n), { context: "BluetoothDeviceCallback" }) : console.warn("[BluetoothDeviceCallback] 不是函数:", i);
|
|
3410
3582
|
});
|
|
3411
3583
|
},
|
|
3412
3584
|
fail: (n) => {
|
|
@@ -3414,13 +3586,13 @@ function dn(t, e = {}) {
|
|
|
3414
3586
|
console.error("[Bluetooth] 搜索失败:", n), (i = e.fail) == null || i.call(e, n);
|
|
3415
3587
|
},
|
|
3416
3588
|
complete: e.complete
|
|
3417
|
-
}), () =>
|
|
3589
|
+
}), () => oe.delete(t);
|
|
3418
3590
|
}, { context: "qsh_onBluetoothDeviceFound" });
|
|
3419
3591
|
}
|
|
3420
|
-
function
|
|
3421
|
-
return
|
|
3592
|
+
function Rn(t) {
|
|
3593
|
+
return u.safeExecute(() => {
|
|
3422
3594
|
var e;
|
|
3423
|
-
|
|
3595
|
+
s.debug("通过 WebView 桥接调用蓝牙连接功能", t), C("bluetoothConnection", {
|
|
3424
3596
|
action: "createBLEConnection",
|
|
3425
3597
|
params: {
|
|
3426
3598
|
deviceId: t.deviceId,
|
|
@@ -3430,100 +3602,100 @@ function fn(t) {
|
|
|
3430
3602
|
}, {
|
|
3431
3603
|
success: (r) => {
|
|
3432
3604
|
var n;
|
|
3433
|
-
console.log("[Bluetooth] 蓝牙连接成功:", r),
|
|
3605
|
+
console.log("[Bluetooth] 蓝牙连接成功:", r), s.info("UniApp 蓝牙连接成功", r), (n = t.success) == null || n.call(t, r);
|
|
3434
3606
|
},
|
|
3435
3607
|
fail: (r) => {
|
|
3436
3608
|
var n;
|
|
3437
|
-
console.error("[Bluetooth] 蓝牙连接失败:", r),
|
|
3609
|
+
console.error("[Bluetooth] 蓝牙连接失败:", r), s.error("UniApp 蓝牙连接失败", r), (n = t.fail) == null || n.call(t, r);
|
|
3438
3610
|
},
|
|
3439
3611
|
complete: t.complete
|
|
3440
3612
|
});
|
|
3441
3613
|
}, { context: "createBLEConnectionInUniApp" });
|
|
3442
3614
|
}
|
|
3443
|
-
function
|
|
3444
|
-
return
|
|
3615
|
+
function Sn(t = {}) {
|
|
3616
|
+
return u.safeExecute(() => {
|
|
3445
3617
|
var r;
|
|
3446
|
-
if (!
|
|
3618
|
+
if (!se()) {
|
|
3447
3619
|
const n = {
|
|
3448
|
-
errMsg: `当前环境 (${
|
|
3620
|
+
errMsg: `当前环境 (${c.type}) 不支持蓝牙功能`,
|
|
3449
3621
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
3450
3622
|
};
|
|
3451
|
-
|
|
3623
|
+
s.error("平台不支持蓝牙", { platform: c.type }), (r = t.fail) == null || r.call(t, n);
|
|
3452
3624
|
return;
|
|
3453
3625
|
}
|
|
3454
|
-
const e =
|
|
3455
|
-
|
|
3456
|
-
platform:
|
|
3626
|
+
const e = we(t);
|
|
3627
|
+
s.info("开始蓝牙操作", {
|
|
3628
|
+
platform: c.type,
|
|
3457
3629
|
services: e.services,
|
|
3458
3630
|
allowDuplicatesKey: e.allowDuplicatesKey
|
|
3459
|
-
}),
|
|
3631
|
+
}), E() ? On(e) : _n(e);
|
|
3460
3632
|
}, { context: "openBluetoothAdapter", options: t });
|
|
3461
3633
|
}
|
|
3462
|
-
function
|
|
3463
|
-
return
|
|
3634
|
+
function Pn(t = {}) {
|
|
3635
|
+
return u.safeExecute(() => {
|
|
3464
3636
|
var r, n;
|
|
3465
|
-
if (!
|
|
3637
|
+
if (!se()) {
|
|
3466
3638
|
const i = {
|
|
3467
|
-
errMsg: `当前环境 (${
|
|
3639
|
+
errMsg: `当前环境 (${c.type}) 不支持蓝牙功能`,
|
|
3468
3640
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
3469
3641
|
};
|
|
3470
|
-
|
|
3642
|
+
s.error("平台不支持蓝牙", { platform: c.type }), (r = t.fail) == null || r.call(t, i), (n = t.complete) == null || n.call(t, i);
|
|
3471
3643
|
return;
|
|
3472
3644
|
}
|
|
3473
|
-
const e =
|
|
3474
|
-
|
|
3475
|
-
platform:
|
|
3645
|
+
const e = we(t);
|
|
3646
|
+
s.info("开始搜索蓝牙设备", {
|
|
3647
|
+
platform: c.type,
|
|
3476
3648
|
services: e.services,
|
|
3477
3649
|
allowDuplicatesKey: e.allowDuplicatesKey
|
|
3478
|
-
}),
|
|
3650
|
+
}), E() ? startBluetoothDevicesDiscoveryInWeixin(e) : Cn(e);
|
|
3479
3651
|
}, { context: "startBluetoothDevicesDiscovery", options: t });
|
|
3480
3652
|
}
|
|
3481
|
-
function
|
|
3482
|
-
return
|
|
3653
|
+
function dt(t, e = {}) {
|
|
3654
|
+
return u.safeExecute(() => {
|
|
3483
3655
|
var n, i;
|
|
3484
|
-
if (!
|
|
3485
|
-
const
|
|
3486
|
-
errMsg: `当前环境 (${
|
|
3656
|
+
if (!se()) {
|
|
3657
|
+
const a = {
|
|
3658
|
+
errMsg: `当前环境 (${c.type}) 不支持蓝牙功能`,
|
|
3487
3659
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
3488
3660
|
};
|
|
3489
|
-
|
|
3661
|
+
s.error("平台不支持蓝牙", { platform: c.type }), (n = e.fail) == null || n.call(e, a), (i = e.complete) == null || i.call(e, a);
|
|
3490
3662
|
return;
|
|
3491
3663
|
}
|
|
3492
|
-
const r =
|
|
3493
|
-
|
|
3664
|
+
const r = we(e);
|
|
3665
|
+
s.info("注册蓝牙设备发现监听", { platform: c.type }), E() ? onBluetoothDeviceFoundInWeixin(r) : Nn(t, r);
|
|
3494
3666
|
}, { context: "onBluetoothDeviceFound", options: e });
|
|
3495
3667
|
}
|
|
3496
|
-
function
|
|
3497
|
-
return
|
|
3498
|
-
var
|
|
3499
|
-
if (!
|
|
3500
|
-
const
|
|
3501
|
-
errMsg: `当前环境 (${
|
|
3668
|
+
function Tn(t = {}) {
|
|
3669
|
+
return u.safeExecute(() => {
|
|
3670
|
+
var a, g, d, l;
|
|
3671
|
+
if (!se()) {
|
|
3672
|
+
const h = {
|
|
3673
|
+
errMsg: `当前环境 (${c.type}) 不支持蓝牙功能`,
|
|
3502
3674
|
code: "PLATFORM_NOT_SUPPORTED"
|
|
3503
3675
|
};
|
|
3504
|
-
|
|
3676
|
+
s.error("平台不支持蓝牙连接", { platform: c.type }), (a = t.fail) == null || a.call(t, h), (g = t.complete) == null || g.call(t, h);
|
|
3505
3677
|
return;
|
|
3506
3678
|
}
|
|
3507
|
-
const e =
|
|
3679
|
+
const e = we(t), { name: r, deviceId: n, autoConnect: i = !1 } = e;
|
|
3508
3680
|
if (!n) {
|
|
3509
|
-
const
|
|
3510
|
-
(
|
|
3681
|
+
const h = { errMsg: "缺少 deviceId 参数", code: "INVALID_PARAMS" };
|
|
3682
|
+
(d = t.fail) == null || d.call(t, h), (l = t.complete) == null || l.call(t, h);
|
|
3511
3683
|
return;
|
|
3512
3684
|
}
|
|
3513
|
-
|
|
3685
|
+
s.info("创建蓝牙连接", { deviceId: n, autoConnect: i, platform: c.type }), E() ? uni.createBLEConnection({
|
|
3514
3686
|
deviceId: n,
|
|
3515
3687
|
autoConnect: i,
|
|
3516
3688
|
success: t.success,
|
|
3517
3689
|
fail: t.fail,
|
|
3518
3690
|
complete: t.complete
|
|
3519
|
-
}) :
|
|
3691
|
+
}) : Rn(e);
|
|
3520
3692
|
}, { context: "createBLEConnection", options: t });
|
|
3521
3693
|
}
|
|
3522
|
-
function
|
|
3694
|
+
function Ln() {
|
|
3523
3695
|
return {
|
|
3524
|
-
supported:
|
|
3525
|
-
environment:
|
|
3526
|
-
implementation:
|
|
3696
|
+
supported: se(),
|
|
3697
|
+
environment: c.type,
|
|
3698
|
+
implementation: E() ? "weixin" : "webview",
|
|
3527
3699
|
features: {
|
|
3528
3700
|
discovery: !0,
|
|
3529
3701
|
connect: !0,
|
|
@@ -3533,151 +3705,228 @@ function mn() {
|
|
|
3533
3705
|
}
|
|
3534
3706
|
};
|
|
3535
3707
|
}
|
|
3536
|
-
const
|
|
3537
|
-
|
|
3538
|
-
|
|
3539
|
-
function
|
|
3540
|
-
|
|
3541
|
-
|
|
3542
|
-
|
|
3543
|
-
|
|
3708
|
+
const Mn = {
|
|
3709
|
+
// TODO: 添加更多默认配置
|
|
3710
|
+
};
|
|
3711
|
+
function bn(t = {}) {
|
|
3712
|
+
return p(p({}, Mn), t);
|
|
3713
|
+
}
|
|
3714
|
+
function gt() {
|
|
3715
|
+
return ["UniApp", "plus", "nvue", "uvue"].includes(c.type);
|
|
3716
|
+
}
|
|
3717
|
+
function vn(t) {
|
|
3718
|
+
return u.safeExecute(() => {
|
|
3719
|
+
s.debug("通过 WebView 桥接调用打印PDF", t), C("printPdf", A(p({}, t), {
|
|
3720
|
+
isPersistent: !0
|
|
3721
|
+
// 强制禁用超时自动清理
|
|
3722
|
+
}), {
|
|
3723
|
+
success: (e) => {
|
|
3724
|
+
var r;
|
|
3725
|
+
s.info("UniApp 打印PDF成功", e), (r = t.success) == null || r.call(t, e);
|
|
3726
|
+
},
|
|
3727
|
+
fail: (e) => {
|
|
3728
|
+
var r;
|
|
3729
|
+
s.error("UniApp 打印PDF失败", e), (r = t.fail) == null || r.call(t, e);
|
|
3730
|
+
},
|
|
3731
|
+
complete: t.complete
|
|
3732
|
+
});
|
|
3733
|
+
}, {
|
|
3734
|
+
context: "printPdfInUniApp",
|
|
3735
|
+
platform: "uniapp"
|
|
3736
|
+
});
|
|
3737
|
+
}
|
|
3738
|
+
function xn(t = {}) {
|
|
3739
|
+
return u.safeExecute(() => {
|
|
3740
|
+
var r;
|
|
3741
|
+
if (!gt()) {
|
|
3742
|
+
const n = {
|
|
3743
|
+
errMsg: `当前环境 (${c.type}) 不支持打印PDF功能`,
|
|
3744
|
+
code: "PLATFORM_NOT_SUPPORTED"
|
|
3745
|
+
};
|
|
3746
|
+
s.error("平台不支持打印PDF", { platform: c.type }), (r = t.fail) == null || r.call(t, n);
|
|
3747
|
+
return;
|
|
3748
|
+
}
|
|
3749
|
+
const e = bn(t);
|
|
3750
|
+
s.info("开始打印PDF", { platform: c.type }), vn(e);
|
|
3751
|
+
}, {
|
|
3752
|
+
context: "printPdf",
|
|
3753
|
+
options: t
|
|
3754
|
+
});
|
|
3755
|
+
}
|
|
3756
|
+
function Dn() {
|
|
3757
|
+
return {
|
|
3758
|
+
supported: gt(),
|
|
3759
|
+
environment: c.type,
|
|
3760
|
+
implementation: "uniapp",
|
|
3761
|
+
features: {
|
|
3762
|
+
asyncSupport: !0
|
|
3763
|
+
}
|
|
3764
|
+
};
|
|
3765
|
+
}
|
|
3766
|
+
const pt = Ne();
|
|
3767
|
+
K.useResponse(Ve.response, { priority: 1e3 });
|
|
3768
|
+
let Ue = !1;
|
|
3769
|
+
function We() {
|
|
3770
|
+
if (Ue) return;
|
|
3771
|
+
Ue = !0, sr([
|
|
3772
|
+
{ name: "load-weixin-sdk", run: zt, timeoutMs: 8e3 },
|
|
3773
|
+
{ name: "init-bridge", run: ze, timeoutMs: 8e3 }
|
|
3544
3774
|
], {
|
|
3545
3775
|
onError: (e, r) => {
|
|
3546
3776
|
console.error(`[QSH-SDK] 初始化失败(${(r == null ? void 0 : r.name) || "unknown"}):`, e);
|
|
3547
3777
|
}
|
|
3548
3778
|
});
|
|
3549
3779
|
}
|
|
3550
|
-
typeof window != "undefined" && (document.readyState === "complete" || document.readyState === "interactive" ? setTimeout(
|
|
3551
|
-
function
|
|
3780
|
+
typeof window != "undefined" && (document.readyState === "complete" || document.readyState === "interactive" ? setTimeout(We, 0) : document.addEventListener("DOMContentLoaded", We));
|
|
3781
|
+
function I(t, { apiName: e } = {}) {
|
|
3552
3782
|
return function(r = {}, ...n) {
|
|
3553
|
-
const i = r && typeof r == "object" && (typeof r.success == "function" || typeof r.fail == "function" || typeof r.complete == "function"),
|
|
3554
|
-
const
|
|
3783
|
+
const i = r && typeof r == "object" && (typeof r.success == "function" || typeof r.fail == "function" || typeof r.complete == "function"), a = r && typeof r == "object" ? r : {}, g = () => i ? t(a, ...n) : new Promise((l, h) => {
|
|
3784
|
+
const T = A(p({}, a), {
|
|
3555
3785
|
success: (N) => {
|
|
3556
|
-
typeof
|
|
3786
|
+
typeof a.success == "function" && a.success(N), l(N);
|
|
3557
3787
|
},
|
|
3558
3788
|
fail: (N) => {
|
|
3559
|
-
typeof
|
|
3789
|
+
typeof a.fail == "function" && a.fail(N), h(N);
|
|
3560
3790
|
},
|
|
3561
|
-
complete:
|
|
3791
|
+
complete: a.complete
|
|
3562
3792
|
});
|
|
3563
|
-
t(
|
|
3793
|
+
t(T, ...n);
|
|
3564
3794
|
});
|
|
3565
|
-
return (typeof window == "undefined" ? Promise.resolve() :
|
|
3566
|
-
throw console.error(`[QSH-SDK] ${e || "API"} call failed:`,
|
|
3795
|
+
return (typeof window == "undefined" ? Promise.resolve() : Fe()).then(() => g()).catch((l) => {
|
|
3796
|
+
throw console.error(`[QSH-SDK] ${e || "API"} call failed:`, l), l;
|
|
3567
3797
|
});
|
|
3568
3798
|
};
|
|
3569
3799
|
}
|
|
3570
|
-
|
|
3571
|
-
function
|
|
3572
|
-
|
|
3573
|
-
|
|
3800
|
+
function ce(t) {
|
|
3801
|
+
return typeof t == "function" ? { success: t } : t && typeof t == "object" ? t : {};
|
|
3802
|
+
}
|
|
3803
|
+
const ht = I(Nr), mt = I(Rr), wt = I(Sr), Et = I(Pr), yt = I(Tr), It = I(Lr);
|
|
3804
|
+
function At(t) {
|
|
3805
|
+
const e = () => Mr(t);
|
|
3806
|
+
return (typeof window == "undefined" ? Promise.resolve() : Fe()).then(() => e());
|
|
3574
3807
|
}
|
|
3575
|
-
const
|
|
3576
|
-
function
|
|
3808
|
+
const Se = I($r);
|
|
3809
|
+
function Un(t = {}) {
|
|
3577
3810
|
return new Promise((e, r) => {
|
|
3578
|
-
|
|
3811
|
+
Se(A(p({}, t), {
|
|
3579
3812
|
success: e,
|
|
3580
3813
|
fail: r
|
|
3581
3814
|
}));
|
|
3582
3815
|
});
|
|
3583
3816
|
}
|
|
3584
|
-
const
|
|
3585
|
-
function
|
|
3817
|
+
const Ot = I(xn);
|
|
3818
|
+
function Wn(t = {}) {
|
|
3586
3819
|
return new Promise((e, r) => {
|
|
3587
|
-
|
|
3820
|
+
Ot(A(p({}, t), {
|
|
3588
3821
|
success: e,
|
|
3589
3822
|
fail: r
|
|
3590
3823
|
}));
|
|
3591
3824
|
});
|
|
3592
3825
|
}
|
|
3593
|
-
const
|
|
3594
|
-
function
|
|
3826
|
+
const Pe = I(Gr);
|
|
3827
|
+
function $n(t = {}) {
|
|
3595
3828
|
return new Promise((e, r) => {
|
|
3596
|
-
|
|
3829
|
+
Pe(A(p({}, t), {
|
|
3597
3830
|
success: e,
|
|
3598
3831
|
fail: r
|
|
3599
3832
|
}));
|
|
3600
3833
|
});
|
|
3601
3834
|
}
|
|
3602
|
-
const
|
|
3603
|
-
function
|
|
3835
|
+
const Bn = I(yn), Te = I(Qr);
|
|
3836
|
+
function Fn(t = {}) {
|
|
3604
3837
|
return new Promise((e, r) => {
|
|
3605
|
-
|
|
3838
|
+
Te(A(p({}, t), {
|
|
3606
3839
|
success: e,
|
|
3607
3840
|
fail: r
|
|
3608
3841
|
}));
|
|
3609
3842
|
});
|
|
3610
3843
|
}
|
|
3611
|
-
const
|
|
3612
|
-
function
|
|
3844
|
+
const Le = I(en);
|
|
3845
|
+
function kn(t = {}) {
|
|
3613
3846
|
return new Promise((e, r) => {
|
|
3614
|
-
|
|
3847
|
+
Le(A(p({}, t), {
|
|
3615
3848
|
success: e,
|
|
3616
3849
|
fail: r
|
|
3617
3850
|
}));
|
|
3618
3851
|
});
|
|
3619
3852
|
}
|
|
3620
|
-
const
|
|
3621
|
-
function
|
|
3853
|
+
const Me = I(dn);
|
|
3854
|
+
function zn(t = {}) {
|
|
3622
3855
|
return new Promise((e, r) => {
|
|
3623
|
-
|
|
3856
|
+
Me(A(p({}, t), {
|
|
3624
3857
|
success: e,
|
|
3625
3858
|
fail: r
|
|
3626
3859
|
}));
|
|
3627
3860
|
});
|
|
3628
3861
|
}
|
|
3629
|
-
const
|
|
3630
|
-
function
|
|
3862
|
+
const _t = I(Sn);
|
|
3863
|
+
function Kn(t = {}) {
|
|
3631
3864
|
return new Promise((e, r) => {
|
|
3632
|
-
|
|
3865
|
+
_t(A(p({}, t), {
|
|
3633
3866
|
success: e,
|
|
3634
3867
|
fail: r
|
|
3635
3868
|
}));
|
|
3636
3869
|
});
|
|
3637
3870
|
}
|
|
3638
|
-
const
|
|
3639
|
-
function
|
|
3871
|
+
const Ct = I(Pn);
|
|
3872
|
+
function Gn(t = {}) {
|
|
3640
3873
|
return new Promise((e, r) => {
|
|
3641
|
-
|
|
3874
|
+
Ct(A(p({}, t), {
|
|
3642
3875
|
success: e,
|
|
3643
3876
|
fail: r
|
|
3644
3877
|
}));
|
|
3645
3878
|
});
|
|
3646
3879
|
}
|
|
3647
|
-
const
|
|
3648
|
-
function
|
|
3880
|
+
const Nt = I(dt);
|
|
3881
|
+
function Vn(t = {}) {
|
|
3882
|
+
return new Promise((e, r) => {
|
|
3883
|
+
Nt(A(p({}, t), {
|
|
3884
|
+
success: e,
|
|
3885
|
+
fail: r
|
|
3886
|
+
}));
|
|
3887
|
+
});
|
|
3888
|
+
}
|
|
3889
|
+
const Rt = I(Tn);
|
|
3890
|
+
function jn(t = {}) {
|
|
3649
3891
|
return new Promise((e, r) => {
|
|
3650
|
-
|
|
3892
|
+
Rt(A(p({}, t), {
|
|
3651
3893
|
success: e,
|
|
3652
3894
|
fail: r
|
|
3653
3895
|
}));
|
|
3654
3896
|
});
|
|
3655
3897
|
}
|
|
3656
|
-
const
|
|
3898
|
+
const Q = {
|
|
3657
3899
|
// 导航 API
|
|
3658
|
-
navigateTo:
|
|
3659
|
-
navigateBack:
|
|
3660
|
-
switchTab:
|
|
3661
|
-
reLaunch:
|
|
3662
|
-
redirectTo:
|
|
3900
|
+
navigateTo: ht,
|
|
3901
|
+
navigateBack: mt,
|
|
3902
|
+
switchTab: wt,
|
|
3903
|
+
reLaunch: Et,
|
|
3904
|
+
redirectTo: yt,
|
|
3663
3905
|
// 消息 API
|
|
3664
|
-
postMessage:
|
|
3665
|
-
getEnv:
|
|
3906
|
+
postMessage: It,
|
|
3907
|
+
getEnv: At,
|
|
3666
3908
|
// 图片 API
|
|
3667
|
-
chooseImage:
|
|
3668
|
-
chooseImageAsync:
|
|
3909
|
+
chooseImage: Se,
|
|
3910
|
+
chooseImageAsync: Un,
|
|
3669
3911
|
// 扫码 API
|
|
3670
|
-
scanCode:
|
|
3671
|
-
scanCodeAsync:
|
|
3912
|
+
scanCode: Pe,
|
|
3913
|
+
scanCodeAsync: $n,
|
|
3672
3914
|
// 位置 API
|
|
3673
|
-
getLocation:
|
|
3674
|
-
getLocationAsync:
|
|
3675
|
-
openLocation:
|
|
3676
|
-
openLocationAsync:
|
|
3677
|
-
chooseLocation:
|
|
3678
|
-
chooseLocationAsync:
|
|
3915
|
+
getLocation: Te,
|
|
3916
|
+
getLocationAsync: Fn,
|
|
3917
|
+
openLocation: Le,
|
|
3918
|
+
openLocationAsync: kn,
|
|
3919
|
+
chooseLocation: Me,
|
|
3920
|
+
chooseLocationAsync: zn,
|
|
3921
|
+
// 位置监听 API(保留回调签名)
|
|
3922
|
+
onLocationChange: (t) => I((e = {}) => sn(e.success), { apiName: "onLocationChange" })(ce(t)),
|
|
3923
|
+
offLocationChange: (t) => I((e = {}) => an(e.success), { apiName: "offLocationChange" })(ce(t)),
|
|
3924
|
+
onLocationChangeError: (t) => I((e = {}) => on(e.success), { apiName: "onLocationChangeError" })(ce(t)),
|
|
3925
|
+
offLocationChangeError: (t) => I((e = {}) => cn(e.success), { apiName: "offLocationChangeError" })(ce(t)),
|
|
3926
|
+
startLocationUpdate: I(rn, { apiName: "startLocationUpdate" }),
|
|
3927
|
+
stopLocationUpdate: I(nn, { apiName: "stopLocationUpdate" }),
|
|
3679
3928
|
// 环境信息
|
|
3680
|
-
environment:
|
|
3929
|
+
environment: pt,
|
|
3681
3930
|
/**
|
|
3682
3931
|
* 等待 JSBridge 就绪
|
|
3683
3932
|
* 返回一个 Promise,当桥接完成初始化后 resolve。
|
|
@@ -3686,7 +3935,7 @@ const H = {
|
|
|
3686
3935
|
* await qsh.ready()
|
|
3687
3936
|
* @since 2.0.0
|
|
3688
3937
|
*/
|
|
3689
|
-
ready:
|
|
3938
|
+
ready: Bt,
|
|
3690
3939
|
/**
|
|
3691
3940
|
* 手动初始化 JSBridge
|
|
3692
3941
|
* 默认会在 DOM 就绪时自动初始化;如需更早或手动控制,可调用本方法。
|
|
@@ -3695,7 +3944,7 @@ const H = {
|
|
|
3695
3944
|
* await qsh.init()
|
|
3696
3945
|
* @since 2.0.0
|
|
3697
3946
|
*/
|
|
3698
|
-
init:
|
|
3947
|
+
init: ze,
|
|
3699
3948
|
/**
|
|
3700
3949
|
* 检查 JSBridge 是否就绪
|
|
3701
3950
|
* @returns {boolean}
|
|
@@ -3703,7 +3952,7 @@ const H = {
|
|
|
3703
3952
|
* if (qsh.isReady()) { console.log('ready') }
|
|
3704
3953
|
* @since 2.0.0
|
|
3705
3954
|
*/
|
|
3706
|
-
isReady:
|
|
3955
|
+
isReady: xt,
|
|
3707
3956
|
/**
|
|
3708
3957
|
* 获取当前 SDK 状态
|
|
3709
3958
|
* @returns {string}
|
|
@@ -3711,7 +3960,7 @@ const H = {
|
|
|
3711
3960
|
* console.log(qsh.getState()) // 'ready'
|
|
3712
3961
|
* @since 2.0.0
|
|
3713
3962
|
*/
|
|
3714
|
-
getState:
|
|
3963
|
+
getState: Dt,
|
|
3715
3964
|
// 微信配置 API
|
|
3716
3965
|
weixin: {
|
|
3717
3966
|
/**
|
|
@@ -3729,7 +3978,7 @@ const H = {
|
|
|
3729
3978
|
* if (qsh.weixin.isConfigReady()) { wx.chooseImage({}) }
|
|
3730
3979
|
* @since 2.0.0
|
|
3731
3980
|
*/
|
|
3732
|
-
isConfigReady:
|
|
3981
|
+
isConfigReady: z,
|
|
3733
3982
|
/**
|
|
3734
3983
|
* 获取微信配置状态
|
|
3735
3984
|
* @returns {string}
|
|
@@ -3737,7 +3986,7 @@ const H = {
|
|
|
3737
3986
|
* console.log(qsh.weixin.getConfigState()) // 'configured'
|
|
3738
3987
|
* @since 2.0.0
|
|
3739
3988
|
*/
|
|
3740
|
-
getConfigState:
|
|
3989
|
+
getConfigState: Kt,
|
|
3741
3990
|
/**
|
|
3742
3991
|
* 手动重试微信配置
|
|
3743
3992
|
* @returns {Promise<void>}
|
|
@@ -3745,13 +3994,13 @@ const H = {
|
|
|
3745
3994
|
* await qsh.weixin.retryConfig()
|
|
3746
3995
|
* @since 2.0.0
|
|
3747
3996
|
*/
|
|
3748
|
-
retryConfig:
|
|
3997
|
+
retryConfig: Gt
|
|
3749
3998
|
},
|
|
3750
3999
|
// WebView 对象(兼容旧版本)
|
|
3751
4000
|
webView: null,
|
|
3752
4001
|
// 图片相关常量
|
|
3753
|
-
ImageSourceTypes:
|
|
3754
|
-
ImageSizeTypes:
|
|
4002
|
+
ImageSourceTypes: le,
|
|
4003
|
+
ImageSizeTypes: fe,
|
|
3755
4004
|
/**
|
|
3756
4005
|
* 获取图片功能能力信息
|
|
3757
4006
|
* @returns {Object} 能力信息对象
|
|
@@ -3760,9 +4009,9 @@ const H = {
|
|
|
3760
4009
|
* console.log('是否支持:', capabilities.supported)
|
|
3761
4010
|
* @since 2.0.0
|
|
3762
4011
|
*/
|
|
3763
|
-
getImageCapabilities:
|
|
4012
|
+
getImageCapabilities: Br,
|
|
3764
4013
|
// 扫码相关常量
|
|
3765
|
-
ScanTypes:
|
|
4014
|
+
ScanTypes: V,
|
|
3766
4015
|
/**
|
|
3767
4016
|
* 获取扫码功能能力信息
|
|
3768
4017
|
* @returns {Object} 能力信息对象
|
|
@@ -3771,9 +4020,9 @@ const H = {
|
|
|
3771
4020
|
* console.log('是否支持:', capabilities.supported)
|
|
3772
4021
|
* @since 2.1.0
|
|
3773
4022
|
*/
|
|
3774
|
-
getScanCapabilities:
|
|
4023
|
+
getScanCapabilities: Vr,
|
|
3775
4024
|
// 位置相关常量
|
|
3776
|
-
CoordinateTypes:
|
|
4025
|
+
CoordinateTypes: Z,
|
|
3777
4026
|
/**
|
|
3778
4027
|
* 获取位置功能能力信息
|
|
3779
4028
|
* @returns {Object} 能力信息对象
|
|
@@ -3782,7 +4031,7 @@ const H = {
|
|
|
3782
4031
|
* console.log('是否支持:', capabilities.supported)
|
|
3783
4032
|
* @since 2.1.0
|
|
3784
4033
|
*/
|
|
3785
|
-
getLocationCapabilities:
|
|
4034
|
+
getLocationCapabilities: tn,
|
|
3786
4035
|
/**
|
|
3787
4036
|
* 获取位置选择功能能力信息
|
|
3788
4037
|
* @returns {Object} 能力信息对象
|
|
@@ -3791,20 +4040,20 @@ const H = {
|
|
|
3791
4040
|
* console.log('是否支持:', capabilities.supported)
|
|
3792
4041
|
* @since 2.1.0
|
|
3793
4042
|
*/
|
|
3794
|
-
getChooseLocationCapabilities:
|
|
4043
|
+
getChooseLocationCapabilities: gn,
|
|
3795
4044
|
// 蓝牙 API
|
|
3796
|
-
openBluetoothAdapter:
|
|
3797
|
-
openBluetoothAdapterAsync:
|
|
3798
|
-
startBluetoothDevicesDiscovery:
|
|
3799
|
-
startBluetoothDevicesDiscoveryAsync:
|
|
3800
|
-
onBluetoothDeviceFound:
|
|
3801
|
-
onBluetoothDeviceFoundAsync:
|
|
3802
|
-
createBLEConnection:
|
|
3803
|
-
createBLEConnectionAsync:
|
|
4045
|
+
openBluetoothAdapter: _t,
|
|
4046
|
+
openBluetoothAdapterAsync: Kn,
|
|
4047
|
+
startBluetoothDevicesDiscovery: Ct,
|
|
4048
|
+
startBluetoothDevicesDiscoveryAsync: Gn,
|
|
4049
|
+
onBluetoothDeviceFound: Nt,
|
|
4050
|
+
onBluetoothDeviceFoundAsync: Vn,
|
|
4051
|
+
createBLEConnection: Rt,
|
|
4052
|
+
createBLEConnectionAsync: jn,
|
|
3804
4053
|
// 蓝牙相关常量
|
|
3805
|
-
BluetoothStates:
|
|
4054
|
+
BluetoothStates: In,
|
|
3806
4055
|
//微信分享
|
|
3807
|
-
toShare:
|
|
4056
|
+
toShare: Bn,
|
|
3808
4057
|
/**
|
|
3809
4058
|
* 获取蓝牙功能能力信息
|
|
3810
4059
|
* @returns {Object} 能力信息对象
|
|
@@ -3812,13 +4061,24 @@ const H = {
|
|
|
3812
4061
|
* const capabilities = qsh.getBluetoothCapabilities()
|
|
3813
4062
|
* console.log('是否支持:', capabilities.supported)
|
|
3814
4063
|
*/
|
|
3815
|
-
getBluetoothCapabilities:
|
|
4064
|
+
getBluetoothCapabilities: Ln,
|
|
4065
|
+
// 打印PDF API
|
|
4066
|
+
printPdf: Ot,
|
|
4067
|
+
printPdfAsync: Wn,
|
|
4068
|
+
/**
|
|
4069
|
+
* 获取打印PDF功能能力信息
|
|
4070
|
+
* @returns {Object} 能力信息对象
|
|
4071
|
+
* @example
|
|
4072
|
+
* const capabilities = qsh.getPrintCapabilities()
|
|
4073
|
+
* console.log('是否支持:', capabilities.supported)
|
|
4074
|
+
*/
|
|
4075
|
+
getPrintCapabilities: Dn,
|
|
3816
4076
|
// 插件系统
|
|
3817
4077
|
plugins: {
|
|
3818
4078
|
/**
|
|
3819
4079
|
* 插件管理器
|
|
3820
4080
|
*/
|
|
3821
|
-
manager:
|
|
4081
|
+
manager: te,
|
|
3822
4082
|
/**
|
|
3823
4083
|
* 注册插件
|
|
3824
4084
|
* @param {Object} plugin - 插件对象
|
|
@@ -3826,7 +4086,7 @@ const H = {
|
|
|
3826
4086
|
* @example
|
|
3827
4087
|
* qsh.plugins.register(myPlugin)
|
|
3828
4088
|
*/
|
|
3829
|
-
register: (t) =>
|
|
4089
|
+
register: (t) => te.register(t),
|
|
3830
4090
|
/**
|
|
3831
4091
|
* 安装插件
|
|
3832
4092
|
* @param {string} name - 插件名称
|
|
@@ -3834,21 +4094,21 @@ const H = {
|
|
|
3834
4094
|
* @example
|
|
3835
4095
|
* await qsh.plugins.install('image')
|
|
3836
4096
|
*/
|
|
3837
|
-
install: (t) =>
|
|
4097
|
+
install: (t) => te.install(t, Q),
|
|
3838
4098
|
/**
|
|
3839
4099
|
* 获取插件列表
|
|
3840
4100
|
* @returns {Array} 插件列表
|
|
3841
4101
|
* @example
|
|
3842
4102
|
* console.log(qsh.plugins.list())
|
|
3843
4103
|
*/
|
|
3844
|
-
list: () =>
|
|
4104
|
+
list: () => te.getPluginList()
|
|
3845
4105
|
},
|
|
3846
4106
|
// 拦截器系统
|
|
3847
4107
|
interceptors: {
|
|
3848
4108
|
/**
|
|
3849
4109
|
* 拦截器链
|
|
3850
4110
|
*/
|
|
3851
|
-
chain:
|
|
4111
|
+
chain: K,
|
|
3852
4112
|
/**
|
|
3853
4113
|
* 注册请求拦截器
|
|
3854
4114
|
* @param {Function} interceptor - 拦截器函数
|
|
@@ -3860,7 +4120,7 @@ const H = {
|
|
|
3860
4120
|
* return ctx
|
|
3861
4121
|
* })
|
|
3862
4122
|
*/
|
|
3863
|
-
useRequest: (t, e) =>
|
|
4123
|
+
useRequest: (t, e) => K.useRequest(t, e),
|
|
3864
4124
|
/**
|
|
3865
4125
|
* 注册响应拦截器
|
|
3866
4126
|
* @param {Function} interceptor - 拦截器函数
|
|
@@ -3872,16 +4132,16 @@ const H = {
|
|
|
3872
4132
|
* return result
|
|
3873
4133
|
* })
|
|
3874
4134
|
*/
|
|
3875
|
-
useResponse: (t, e) =>
|
|
4135
|
+
useResponse: (t, e) => K.useResponse(t, e),
|
|
3876
4136
|
/**
|
|
3877
4137
|
* 内置拦截器
|
|
3878
4138
|
*/
|
|
3879
4139
|
builtin: {
|
|
3880
|
-
logging:
|
|
4140
|
+
logging: qt,
|
|
3881
4141
|
performance: W,
|
|
3882
|
-
createRetry:
|
|
3883
|
-
createValidation:
|
|
3884
|
-
errorNormalizer:
|
|
4142
|
+
createRetry: Jt,
|
|
4143
|
+
createValidation: Ht,
|
|
4144
|
+
errorNormalizer: Ve
|
|
3885
4145
|
}
|
|
3886
4146
|
},
|
|
3887
4147
|
// 观测指标
|
|
@@ -3904,7 +4164,7 @@ const H = {
|
|
|
3904
4164
|
/**
|
|
3905
4165
|
* 错误消息
|
|
3906
4166
|
*/
|
|
3907
|
-
messages:
|
|
4167
|
+
messages: Oe,
|
|
3908
4168
|
/**
|
|
3909
4169
|
* 错误分类
|
|
3910
4170
|
*/
|
|
@@ -3917,7 +4177,7 @@ const H = {
|
|
|
3917
4177
|
* @example
|
|
3918
4178
|
* const standardError = qsh.errors.normalize(error, { apiName: 'chooseImage' })
|
|
3919
4179
|
*/
|
|
3920
|
-
normalize:
|
|
4180
|
+
normalize: Ge,
|
|
3921
4181
|
/**
|
|
3922
4182
|
* 创建标准错误
|
|
3923
4183
|
* @param {string} code - 错误码
|
|
@@ -3926,7 +4186,7 @@ const H = {
|
|
|
3926
4186
|
* @example
|
|
3927
4187
|
* const error = qsh.errors.create('E_IMG_001', { apiName: 'chooseImage' })
|
|
3928
4188
|
*/
|
|
3929
|
-
create:
|
|
4189
|
+
create: rr,
|
|
3930
4190
|
/**
|
|
3931
4191
|
* 判断是否为标准错误
|
|
3932
4192
|
* @param {any} error - 错误对象
|
|
@@ -3934,14 +4194,14 @@ const H = {
|
|
|
3934
4194
|
* @example
|
|
3935
4195
|
* if (qsh.errors.isStandard(error)) { ... }
|
|
3936
4196
|
*/
|
|
3937
|
-
isStandard:
|
|
4197
|
+
isStandard: nr
|
|
3938
4198
|
},
|
|
3939
4199
|
// 状态管理
|
|
3940
4200
|
store: {
|
|
3941
4201
|
/**
|
|
3942
4202
|
* 状态仓库实例
|
|
3943
4203
|
*/
|
|
3944
|
-
instance:
|
|
4204
|
+
instance: x,
|
|
3945
4205
|
/**
|
|
3946
4206
|
* 获取状态
|
|
3947
4207
|
* @param {string} path - 状态路径
|
|
@@ -3949,7 +4209,7 @@ const H = {
|
|
|
3949
4209
|
* @example
|
|
3950
4210
|
* const status = qsh.store.get('sdk.status')
|
|
3951
4211
|
*/
|
|
3952
|
-
get: (t) =>
|
|
4212
|
+
get: (t) => x.get(t),
|
|
3953
4213
|
/**
|
|
3954
4214
|
* 设置状态
|
|
3955
4215
|
* @param {string} path - 状态路径
|
|
@@ -3957,7 +4217,7 @@ const H = {
|
|
|
3957
4217
|
* @example
|
|
3958
4218
|
* qsh.store.set('sdk.status', 'ready')
|
|
3959
4219
|
*/
|
|
3960
|
-
set: (t, e) =>
|
|
4220
|
+
set: (t, e) => x.set(t, e),
|
|
3961
4221
|
/**
|
|
3962
4222
|
* 订阅状态变化
|
|
3963
4223
|
* @param {string} path - 状态路径
|
|
@@ -3968,14 +4228,14 @@ const H = {
|
|
|
3968
4228
|
* console.log('网络状态:', online)
|
|
3969
4229
|
* })
|
|
3970
4230
|
*/
|
|
3971
|
-
subscribe: (t, e) =>
|
|
4231
|
+
subscribe: (t, e) => x.subscribe(t, e),
|
|
3972
4232
|
/**
|
|
3973
4233
|
* 获取状态快照
|
|
3974
4234
|
* @returns {Object} 状态快照
|
|
3975
4235
|
* @example
|
|
3976
4236
|
* console.log(qsh.store.getSnapshot())
|
|
3977
4237
|
*/
|
|
3978
|
-
getSnapshot: () =>
|
|
4238
|
+
getSnapshot: () => x.getSnapshot()
|
|
3979
4239
|
},
|
|
3980
4240
|
// 调试工具(生产环境可能被优化掉)
|
|
3981
4241
|
debug: {
|
|
@@ -3990,11 +4250,11 @@ const H = {
|
|
|
3990
4250
|
/**
|
|
3991
4251
|
* 错误处理器
|
|
3992
4252
|
*/
|
|
3993
|
-
errorHandler:
|
|
4253
|
+
errorHandler: u,
|
|
3994
4254
|
/**
|
|
3995
4255
|
* 状态管理器
|
|
3996
4256
|
*/
|
|
3997
|
-
stateManager:
|
|
4257
|
+
stateManager: G,
|
|
3998
4258
|
/**
|
|
3999
4259
|
* 启用调试模式
|
|
4000
4260
|
* @example
|
|
@@ -4017,11 +4277,11 @@ const H = {
|
|
|
4017
4277
|
*/
|
|
4018
4278
|
getStats: () => ({
|
|
4019
4279
|
logger: S.getStats(),
|
|
4020
|
-
state:
|
|
4021
|
-
weixinConfig:
|
|
4022
|
-
plugins:
|
|
4023
|
-
interceptors:
|
|
4024
|
-
store:
|
|
4280
|
+
state: G.getStats(),
|
|
4281
|
+
weixinConfig: ve().getStats(),
|
|
4282
|
+
plugins: te.getStats(),
|
|
4283
|
+
interceptors: K.getStats(),
|
|
4284
|
+
store: x.getStats()
|
|
4025
4285
|
}),
|
|
4026
4286
|
/**
|
|
4027
4287
|
* 获取微信配置管理器
|
|
@@ -4029,7 +4289,7 @@ const H = {
|
|
|
4029
4289
|
* @example
|
|
4030
4290
|
* console.log(qsh.debug.getWeixinConfigManager().getStats())
|
|
4031
4291
|
*/
|
|
4032
|
-
getWeixinConfigManager:
|
|
4292
|
+
getWeixinConfigManager: ve,
|
|
4033
4293
|
/**
|
|
4034
4294
|
* 导出调试信息
|
|
4035
4295
|
* @returns {string} JSON 格式的调试信息
|
|
@@ -4039,26 +4299,26 @@ const H = {
|
|
|
4039
4299
|
exportDebugInfo: () => S.exportToJSON()
|
|
4040
4300
|
}
|
|
4041
4301
|
};
|
|
4042
|
-
|
|
4043
|
-
navigateTo:
|
|
4044
|
-
navigateBack:
|
|
4045
|
-
switchTab:
|
|
4046
|
-
reLaunch:
|
|
4047
|
-
redirectTo:
|
|
4048
|
-
postMessage:
|
|
4049
|
-
getEnv:
|
|
4050
|
-
chooseImage:
|
|
4051
|
-
scanCode:
|
|
4052
|
-
getLocation:
|
|
4053
|
-
openLocation:
|
|
4054
|
-
chooseLocation:
|
|
4302
|
+
pt.isWeixinMiniProgram ? Q.webView = window.wx && window.wx.miniProgram : Q.webView = {
|
|
4303
|
+
navigateTo: ht,
|
|
4304
|
+
navigateBack: mt,
|
|
4305
|
+
switchTab: wt,
|
|
4306
|
+
reLaunch: Et,
|
|
4307
|
+
redirectTo: yt,
|
|
4308
|
+
postMessage: It,
|
|
4309
|
+
getEnv: At,
|
|
4310
|
+
chooseImage: Se,
|
|
4311
|
+
scanCode: Pe,
|
|
4312
|
+
getLocation: Te,
|
|
4313
|
+
openLocation: Le,
|
|
4314
|
+
chooseLocation: Me
|
|
4055
4315
|
};
|
|
4056
|
-
const
|
|
4057
|
-
Object.keys(
|
|
4058
|
-
|
|
4316
|
+
const $e = typeof window.uni != "undefined" ? window.uni : {};
|
|
4317
|
+
Object.keys($e).forEach((t) => {
|
|
4318
|
+
Q.hasOwnProperty(t) || (Q[t] = $e[t]);
|
|
4059
4319
|
});
|
|
4060
|
-
typeof window != "undefined" && (window.qsh =
|
|
4320
|
+
typeof window != "undefined" && (window.qsh = Q);
|
|
4061
4321
|
export {
|
|
4062
|
-
|
|
4322
|
+
Q as default
|
|
4063
4323
|
};
|
|
4064
4324
|
//# sourceMappingURL=qsh-webview-sdk.es.js.map
|