@hlw-uni/mp-vue 2.1.57 → 2.1.58
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app.d.ts +12 -1
- package/dist/composables/ad/index.d.ts +26 -0
- package/dist/composables/device/index.d.ts +14 -0
- package/dist/composables/index.d.ts +1 -1
- package/dist/composables/msg/index.d.ts +44 -3
- package/dist/composables/navigator/index.d.ts +37 -1
- package/dist/composables/refs/index.d.ts +15 -1
- package/dist/composables/request/client.d.ts +87 -0
- package/dist/composables/request/service.d.ts +64 -0
- package/dist/composables/request/types.d.ts +50 -13
- package/dist/composables/share/index.d.ts +38 -0
- package/dist/composables/theme/appearance.d.ts +30 -4
- package/dist/composables/theme/font.d.ts +23 -0
- package/dist/composables/theme/index.d.ts +19 -6
- package/dist/composables/theme/palette.d.ts +23 -0
- package/dist/composables/theme/typography.d.ts +9 -1
- package/dist/composables/utils/index.d.ts +120 -13
- package/dist/directives/copy.d.ts +5 -0
- package/dist/hlw.d.ts +10 -0
- package/dist/index.js +305 -199
- package/dist/index.mjs +306 -200
- package/dist/stores/theme.d.ts +3 -0
- package/package.json +1 -1
- package/src/app.ts +20 -3
- package/src/components/hlw-add-mini/README.md +10 -11
- package/src/components/hlw-add-mini/index.vue +93 -66
- package/src/components/hlw-button/index.vue +33 -18
- package/src/composables/ad/index.ts +136 -62
- package/src/composables/device/index.ts +32 -2
- package/src/composables/index.ts +18 -1
- package/src/composables/msg/index.ts +70 -16
- package/src/composables/navigator/index.ts +45 -1
- package/src/composables/refs/index.ts +27 -4
- package/src/composables/request/client.ts +149 -0
- package/src/composables/request/service.ts +64 -0
- package/src/composables/request/types.ts +53 -13
- package/src/composables/share/index.ts +48 -0
- package/src/composables/theme/appearance.ts +31 -4
- package/src/composables/theme/font.ts +23 -0
- package/src/composables/theme/index.ts +23 -7
- package/src/composables/theme/palette.ts +32 -0
- package/src/composables/theme/typography.ts +9 -1
- package/src/composables/utils/index.ts +227 -127
- package/src/directives/copy.ts +31 -19
- package/src/hlw.ts +11 -0
- package/src/stores/theme.ts +28 -5
package/dist/index.js
CHANGED
|
@@ -92,22 +92,37 @@ var __publicField = (obj, key, value) => {
|
|
|
92
92
|
__publicField(this, "baseURL", "");
|
|
93
93
|
__publicField(this, "defaultHeaders", { "Content-Type": "application/json" });
|
|
94
94
|
}
|
|
95
|
+
/**
|
|
96
|
+
* 设置全局基础请求 URL。
|
|
97
|
+
*/
|
|
95
98
|
setBaseURL(url) {
|
|
96
99
|
this.baseURL = url;
|
|
97
100
|
}
|
|
101
|
+
/**
|
|
102
|
+
* 注册一个请求拦截器。
|
|
103
|
+
*/
|
|
98
104
|
onRequest(fn) {
|
|
99
105
|
this.reqInterceptors.push(fn);
|
|
100
106
|
return () => this.remove(this.reqInterceptors, fn);
|
|
101
107
|
}
|
|
108
|
+
/**
|
|
109
|
+
* 注册一个响应拦截器。
|
|
110
|
+
*/
|
|
102
111
|
onResponse(fn) {
|
|
103
112
|
const item = fn;
|
|
104
113
|
this.resInterceptors.push(item);
|
|
105
114
|
return () => this.remove(this.resInterceptors, item);
|
|
106
115
|
}
|
|
116
|
+
/**
|
|
117
|
+
* 注册一个错误拦截器。
|
|
118
|
+
*/
|
|
107
119
|
onError(fn) {
|
|
108
120
|
this.errInterceptors.push(fn);
|
|
109
121
|
return () => this.remove(this.errInterceptors, fn);
|
|
110
122
|
}
|
|
123
|
+
/**
|
|
124
|
+
* 执行 HTTP 请求。
|
|
125
|
+
*/
|
|
111
126
|
async request(config) {
|
|
112
127
|
let cfg = {
|
|
113
128
|
method: "GET",
|
|
@@ -133,18 +148,33 @@ var __publicField = (obj, key, value) => {
|
|
|
133
148
|
throw err;
|
|
134
149
|
}
|
|
135
150
|
}
|
|
151
|
+
/**
|
|
152
|
+
* 发送 GET 请求。
|
|
153
|
+
*/
|
|
136
154
|
get(url, data) {
|
|
137
155
|
return this.request({ url, method: "GET", data });
|
|
138
156
|
}
|
|
157
|
+
/**
|
|
158
|
+
* 发送 POST 请求。
|
|
159
|
+
*/
|
|
139
160
|
post(url, data) {
|
|
140
161
|
return this.request({ url, method: "POST", data });
|
|
141
162
|
}
|
|
163
|
+
/**
|
|
164
|
+
* 发送 PUT 请求。
|
|
165
|
+
*/
|
|
142
166
|
put(url, data) {
|
|
143
167
|
return this.request({ url, method: "PUT", data });
|
|
144
168
|
}
|
|
169
|
+
/**
|
|
170
|
+
* 发送 DELETE 请求。
|
|
171
|
+
*/
|
|
145
172
|
del(url, data) {
|
|
146
173
|
return this.request({ url, method: "DELETE", data });
|
|
147
174
|
}
|
|
175
|
+
/**
|
|
176
|
+
* 上传本地文件,适配云存储(COS/OSS/七牛/Alist)或本地直传。
|
|
177
|
+
*/
|
|
148
178
|
upload(config) {
|
|
149
179
|
const fileName = config.fileName ?? config.filePath.split("/").pop() ?? "file";
|
|
150
180
|
const server = config.type === "local" && config.url ? config.url : config.server;
|
|
@@ -180,6 +210,9 @@ var __publicField = (obj, key, value) => {
|
|
|
180
210
|
});
|
|
181
211
|
});
|
|
182
212
|
}
|
|
213
|
+
/**
|
|
214
|
+
* 解析微服务风格的命名空间 URL。
|
|
215
|
+
*/
|
|
183
216
|
resolveServiceUrl(namespace, url, servicePrefix = "") {
|
|
184
217
|
if (isAbsolute(url))
|
|
185
218
|
return url;
|
|
@@ -189,11 +222,17 @@ var __publicField = (obj, key, value) => {
|
|
|
189
222
|
const prefix = [prefixValue, ns].filter(Boolean).join("/");
|
|
190
223
|
return prefix ? `/${prefix}${path}` : path;
|
|
191
224
|
}
|
|
225
|
+
/**
|
|
226
|
+
* 内部拼接基础 URL 与相对路径。
|
|
227
|
+
*/
|
|
192
228
|
resolveUrl(url) {
|
|
193
229
|
if (isAbsolute(url))
|
|
194
230
|
return url;
|
|
195
231
|
return `${this.baseURL}${url}`;
|
|
196
232
|
}
|
|
233
|
+
/**
|
|
234
|
+
* 内部基于 uni.request 发送网络请求的方法。
|
|
235
|
+
*/
|
|
197
236
|
send(url, cfg) {
|
|
198
237
|
return new Promise((resolve, reject) => {
|
|
199
238
|
uni.request({
|
|
@@ -214,6 +253,9 @@ var __publicField = (obj, key, value) => {
|
|
|
214
253
|
});
|
|
215
254
|
});
|
|
216
255
|
}
|
|
256
|
+
/**
|
|
257
|
+
* 从数组中安全移除某个拦截器实例。
|
|
258
|
+
*/
|
|
217
259
|
remove(items, item) {
|
|
218
260
|
const index = items.indexOf(item);
|
|
219
261
|
if (index > -1)
|
|
@@ -240,21 +282,46 @@ var __publicField = (obj, key, value) => {
|
|
|
240
282
|
return { uploading, upload };
|
|
241
283
|
}
|
|
242
284
|
class BaseService {
|
|
285
|
+
/**
|
|
286
|
+
* 发送服务请求。会自动拼接前缀与命名空间。
|
|
287
|
+
* @param options 请求配置项
|
|
288
|
+
* @returns 响应结果 Promise
|
|
289
|
+
*/
|
|
243
290
|
request(options) {
|
|
244
291
|
return useRequest().request({
|
|
245
292
|
...options,
|
|
246
293
|
url: useRequest().resolveServiceUrl(this.namespace ?? "", options.url, this.servicePrefix ?? "")
|
|
247
294
|
});
|
|
248
295
|
}
|
|
296
|
+
/**
|
|
297
|
+
* 快捷发送 GET 请求。
|
|
298
|
+
* @param url 请求相对路径
|
|
299
|
+
* @param data 请求参数
|
|
300
|
+
*/
|
|
249
301
|
get(url, data) {
|
|
250
302
|
return this.request({ url, method: "GET", data });
|
|
251
303
|
}
|
|
304
|
+
/**
|
|
305
|
+
* 快捷发送 POST 请求。
|
|
306
|
+
* @param url 请求相对路径
|
|
307
|
+
* @param data 请求携带的 body
|
|
308
|
+
*/
|
|
252
309
|
post(url, data) {
|
|
253
310
|
return this.request({ url, method: "POST", data });
|
|
254
311
|
}
|
|
312
|
+
/**
|
|
313
|
+
* 快捷发送 PUT 请求。
|
|
314
|
+
* @param url 请求相对路径
|
|
315
|
+
* @param data 请求携带的 body
|
|
316
|
+
*/
|
|
255
317
|
put(url, data) {
|
|
256
318
|
return this.request({ url, method: "PUT", data });
|
|
257
319
|
}
|
|
320
|
+
/**
|
|
321
|
+
* 快捷发送 DELETE 请求。
|
|
322
|
+
* @param url 请求相对路径
|
|
323
|
+
* @param data 请求参数
|
|
324
|
+
*/
|
|
258
325
|
del(url, data) {
|
|
259
326
|
return this.request({ url, method: "DELETE", data });
|
|
260
327
|
}
|
|
@@ -271,15 +338,29 @@ var __publicField = (obj, key, value) => {
|
|
|
271
338
|
}
|
|
272
339
|
function useMsg() {
|
|
273
340
|
function toast(opts) {
|
|
274
|
-
const
|
|
275
|
-
|
|
276
|
-
|
|
341
|
+
const {
|
|
342
|
+
message,
|
|
343
|
+
icon = "none",
|
|
344
|
+
image = void 0,
|
|
345
|
+
duration = 2e3,
|
|
346
|
+
mask = false,
|
|
347
|
+
position = "center"
|
|
348
|
+
} = typeof opts === "string" ? { message: opts } : opts;
|
|
349
|
+
const mappedIcon = icon === "fail" || icon === "exception" ? "error" : icon;
|
|
350
|
+
uni.showToast({
|
|
351
|
+
title: message,
|
|
352
|
+
icon: mappedIcon,
|
|
353
|
+
image,
|
|
354
|
+
duration,
|
|
355
|
+
mask,
|
|
356
|
+
position
|
|
357
|
+
});
|
|
277
358
|
}
|
|
278
359
|
function success(message) {
|
|
279
360
|
uni.showToast({ title: message, icon: "success", duration: 2e3 });
|
|
280
361
|
}
|
|
281
362
|
function error(message) {
|
|
282
|
-
uni.showToast({ title: message, icon: "
|
|
363
|
+
uni.showToast({ title: message, icon: "error", duration: 2e3 });
|
|
283
364
|
}
|
|
284
365
|
function showLoading(message = "加载中...") {
|
|
285
366
|
uni.showLoading({ title: message, mask: true });
|
|
@@ -311,13 +392,11 @@ var __publicField = (obj, key, value) => {
|
|
|
311
392
|
});
|
|
312
393
|
});
|
|
313
394
|
}
|
|
314
|
-
function modal(opts) {
|
|
315
|
-
return confirm(opts);
|
|
316
|
-
}
|
|
317
395
|
function setLoadingBar(progress) {
|
|
318
396
|
const clamped = Math.max(0, Math.min(100, progress));
|
|
397
|
+
const filled = Math.round(clamped / 2);
|
|
319
398
|
uni.setNavigationBarTitle({
|
|
320
|
-
title: `${"■".repeat(
|
|
399
|
+
title: `${"■".repeat(filled)}${"□".repeat(50 - filled)} ${clamped}%`
|
|
321
400
|
});
|
|
322
401
|
}
|
|
323
402
|
return {
|
|
@@ -328,7 +407,7 @@ var __publicField = (obj, key, value) => {
|
|
|
328
407
|
showLoading,
|
|
329
408
|
hideLoading,
|
|
330
409
|
confirm,
|
|
331
|
-
modal,
|
|
410
|
+
modal: confirm,
|
|
332
411
|
setLoadingBar
|
|
333
412
|
};
|
|
334
413
|
}
|
|
@@ -351,141 +430,141 @@ var __publicField = (obj, key, value) => {
|
|
|
351
430
|
function toBoolean(val, def) {
|
|
352
431
|
if (typeof val === "boolean")
|
|
353
432
|
return val;
|
|
354
|
-
if (val === 0 || val === "0")
|
|
433
|
+
if (val === 0 || val === "0" || val === "false")
|
|
355
434
|
return false;
|
|
356
|
-
if (val === 1 || val === "1")
|
|
435
|
+
if (val === 1 || val === "1" || val === "true")
|
|
357
436
|
return true;
|
|
358
437
|
return def;
|
|
359
438
|
}
|
|
360
|
-
function
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
fail: () => ok(false)
|
|
373
|
-
});
|
|
439
|
+
function copy(text, tip = true) {
|
|
440
|
+
return new Promise((resolve) => {
|
|
441
|
+
uni.setClipboardData({
|
|
442
|
+
data: text,
|
|
443
|
+
showToast: false,
|
|
444
|
+
success: () => {
|
|
445
|
+
if (tip) {
|
|
446
|
+
uni.showToast({ title: "复制成功", icon: "none", duration: 1500 });
|
|
447
|
+
}
|
|
448
|
+
resolve(true);
|
|
449
|
+
},
|
|
450
|
+
fail: () => resolve(false)
|
|
374
451
|
});
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
452
|
+
});
|
|
453
|
+
}
|
|
454
|
+
function paste() {
|
|
455
|
+
return new Promise((resolve) => {
|
|
456
|
+
uni.getClipboardData({
|
|
457
|
+
success: (res) => resolve(res.data),
|
|
458
|
+
fail: () => resolve("")
|
|
382
459
|
});
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
460
|
+
});
|
|
461
|
+
}
|
|
462
|
+
function auth() {
|
|
463
|
+
uni.showModal({
|
|
464
|
+
title: "提示",
|
|
465
|
+
content: "需要授权相册权限",
|
|
466
|
+
confirmText: "去设置",
|
|
467
|
+
success: (res) => {
|
|
468
|
+
if (res.confirm)
|
|
469
|
+
uni.openSetting();
|
|
470
|
+
}
|
|
471
|
+
});
|
|
472
|
+
}
|
|
473
|
+
function saveImage(path) {
|
|
474
|
+
return new Promise((resolve) => {
|
|
475
|
+
uni.saveImageToPhotosAlbum({
|
|
476
|
+
filePath: path,
|
|
477
|
+
success: () => {
|
|
478
|
+
uni.showToast({ title: "保存成功", icon: "success" });
|
|
479
|
+
resolve(true);
|
|
480
|
+
},
|
|
481
|
+
fail: (err) => {
|
|
482
|
+
const msg = String(err.errMsg || "");
|
|
483
|
+
if (msg.includes("auth deny") || msg.includes("authorize")) {
|
|
484
|
+
auth();
|
|
485
|
+
} else {
|
|
486
|
+
uni.showToast({ title: "保存失败", icon: "none" });
|
|
487
|
+
}
|
|
488
|
+
resolve(false);
|
|
392
489
|
}
|
|
393
490
|
});
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
}
|
|
410
|
-
ok(false);
|
|
491
|
+
});
|
|
492
|
+
}
|
|
493
|
+
function saveVideoFile(path) {
|
|
494
|
+
return new Promise((resolve) => {
|
|
495
|
+
uni.saveVideoToPhotosAlbum({
|
|
496
|
+
filePath: path,
|
|
497
|
+
success: () => {
|
|
498
|
+
uni.showToast({ title: "保存成功", icon: "success" });
|
|
499
|
+
resolve(true);
|
|
500
|
+
},
|
|
501
|
+
fail: (err) => {
|
|
502
|
+
const msg = String(err.errMsg || "");
|
|
503
|
+
if (msg.includes("auth deny") || msg.includes("authorize")) {
|
|
504
|
+
auth();
|
|
505
|
+
} else {
|
|
506
|
+
uni.showToast({ title: "保存失败", icon: "none" });
|
|
411
507
|
}
|
|
412
|
-
|
|
508
|
+
resolve(false);
|
|
509
|
+
}
|
|
413
510
|
});
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
} else {
|
|
428
|
-
uni.showToast({ title: "保存失败", icon: "none" });
|
|
429
|
-
}
|
|
430
|
-
ok(false);
|
|
511
|
+
});
|
|
512
|
+
}
|
|
513
|
+
function download(opt) {
|
|
514
|
+
return new Promise((resolve) => {
|
|
515
|
+
const task = uni.downloadFile({
|
|
516
|
+
url: opt.url,
|
|
517
|
+
filePath: opt.path,
|
|
518
|
+
header: opt.header,
|
|
519
|
+
success: (res) => {
|
|
520
|
+
if (res.statusCode === 200) {
|
|
521
|
+
resolve({ ok: true, path: res.tempFilePath, code: res.statusCode });
|
|
522
|
+
} else {
|
|
523
|
+
resolve({ ok: false, code: res.statusCode, msg: `下载失败,状态码:${res.statusCode}` });
|
|
431
524
|
}
|
|
432
|
-
}
|
|
525
|
+
},
|
|
526
|
+
fail: (err) => resolve({ ok: false, msg: err.errMsg })
|
|
433
527
|
});
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
const task = uni.downloadFile({
|
|
438
|
-
url: opt.url,
|
|
439
|
-
filePath: opt.path,
|
|
440
|
-
header: opt.header,
|
|
441
|
-
success: (res) => {
|
|
442
|
-
if (res.statusCode === 200) {
|
|
443
|
-
ok({ ok: true, path: res.tempFilePath, code: res.statusCode });
|
|
444
|
-
} else {
|
|
445
|
-
ok({ ok: false, code: res.statusCode, msg: `下载失败,状态码:${res.statusCode}` });
|
|
446
|
-
}
|
|
447
|
-
},
|
|
448
|
-
fail: (err) => ok({ ok: false, msg: err.errMsg })
|
|
528
|
+
if (opt.progress) {
|
|
529
|
+
task.onProgressUpdate((res) => {
|
|
530
|
+
opt.progress(res.progress, res.totalBytesWritten, res.totalBytesExpectedToWrite);
|
|
449
531
|
});
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
});
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
uni.
|
|
460
|
-
const res = await download({ url, progress: progress ? (value) => progress(value) : void 0 });
|
|
461
|
-
uni.hideLoading();
|
|
462
|
-
if (!res.ok || !res.path) {
|
|
463
|
-
uni.showToast({ title: res.msg || "下载失败", icon: "none" });
|
|
464
|
-
return false;
|
|
465
|
-
}
|
|
466
|
-
return await saveImage(res.path);
|
|
467
|
-
} catch {
|
|
468
|
-
uni.hideLoading();
|
|
469
|
-
uni.showToast({ title: "操作失败", icon: "none" });
|
|
532
|
+
}
|
|
533
|
+
});
|
|
534
|
+
}
|
|
535
|
+
async function saveImageUrl(url, progress) {
|
|
536
|
+
try {
|
|
537
|
+
uni.showLoading({ title: "下载中...", mask: true });
|
|
538
|
+
const res = await download({ url, progress: progress ? (value) => progress(value) : void 0 });
|
|
539
|
+
uni.hideLoading();
|
|
540
|
+
if (!res.ok || !res.path) {
|
|
541
|
+
uni.showToast({ title: res.msg || "下载失败", icon: "none" });
|
|
470
542
|
return false;
|
|
471
543
|
}
|
|
544
|
+
return await saveImage(res.path);
|
|
545
|
+
} catch {
|
|
546
|
+
uni.hideLoading();
|
|
547
|
+
uni.showToast({ title: "操作失败", icon: "none" });
|
|
548
|
+
return false;
|
|
472
549
|
}
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
}
|
|
482
|
-
return await saveVideo(res.path);
|
|
483
|
-
} catch {
|
|
484
|
-
uni.hideLoading();
|
|
485
|
-
uni.showToast({ title: "操作失败", icon: "none" });
|
|
550
|
+
}
|
|
551
|
+
async function saveVideoUrl(url, progress) {
|
|
552
|
+
try {
|
|
553
|
+
uni.showLoading({ title: "下载中...", mask: true });
|
|
554
|
+
const res = await download({ url, progress: progress ? (value) => progress(value) : void 0 });
|
|
555
|
+
uni.hideLoading();
|
|
556
|
+
if (!res.ok || !res.path) {
|
|
557
|
+
uni.showToast({ title: res.msg || "下载失败", icon: "none" });
|
|
486
558
|
return false;
|
|
487
559
|
}
|
|
560
|
+
return await saveVideoFile(res.path);
|
|
561
|
+
} catch {
|
|
562
|
+
uni.hideLoading();
|
|
563
|
+
uni.showToast({ title: "操作失败", icon: "none" });
|
|
564
|
+
return false;
|
|
488
565
|
}
|
|
566
|
+
}
|
|
567
|
+
function useUtils() {
|
|
489
568
|
return {
|
|
490
569
|
withQuery,
|
|
491
570
|
toQuery,
|
|
@@ -495,7 +574,7 @@ var __publicField = (obj, key, value) => {
|
|
|
495
574
|
copy,
|
|
496
575
|
paste,
|
|
497
576
|
saveImage,
|
|
498
|
-
|
|
577
|
+
saveVideoFile,
|
|
499
578
|
download,
|
|
500
579
|
saveImageUrl,
|
|
501
580
|
saveVideoUrl
|
|
@@ -589,10 +668,9 @@ var __publicField = (obj, key, value) => {
|
|
|
589
668
|
}
|
|
590
669
|
function useDevice() {
|
|
591
670
|
const info = getDevice();
|
|
592
|
-
const { toQuery: toQuery2 } = useUtils();
|
|
593
671
|
return {
|
|
594
672
|
info,
|
|
595
|
-
query:
|
|
673
|
+
query: toQuery(getQueryInfo(info))
|
|
596
674
|
};
|
|
597
675
|
}
|
|
598
676
|
function clearDeviceCache() {
|
|
@@ -631,8 +709,8 @@ var __publicField = (obj, key, value) => {
|
|
|
631
709
|
}
|
|
632
710
|
function showShareMenu() {
|
|
633
711
|
var _a;
|
|
634
|
-
const
|
|
635
|
-
(_a =
|
|
712
|
+
const api = typeof uni !== "undefined" ? uni : void 0;
|
|
713
|
+
(_a = api == null ? void 0 : api.showShareMenu) == null ? void 0 : _a.call(api, {
|
|
636
714
|
withShareTicket: true,
|
|
637
715
|
menus: ["shareAppMessage", "shareTimeline"],
|
|
638
716
|
fail: () => void 0
|
|
@@ -671,18 +749,20 @@ var __publicField = (obj, key, value) => {
|
|
|
671
749
|
showShareMenu
|
|
672
750
|
};
|
|
673
751
|
}
|
|
674
|
-
|
|
752
|
+
const popupCache = /* @__PURE__ */ new Map();
|
|
753
|
+
const rewardCache = /* @__PURE__ */ new Map();
|
|
754
|
+
let activePopupAdId = "";
|
|
675
755
|
let popupDone;
|
|
676
|
-
let
|
|
677
|
-
let popupError = null;
|
|
678
|
-
let rewardAd = null;
|
|
756
|
+
let activeRewardAdId = "";
|
|
679
757
|
let rewardDone;
|
|
680
758
|
let rewardPromise = null;
|
|
681
759
|
let rewardResolve = null;
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
760
|
+
function getAdApi() {
|
|
761
|
+
if (typeof uni !== "undefined")
|
|
762
|
+
return uni;
|
|
763
|
+
if (typeof wx !== "undefined")
|
|
764
|
+
return wx;
|
|
765
|
+
return null;
|
|
686
766
|
}
|
|
687
767
|
function finish(res) {
|
|
688
768
|
rewardDone == null ? void 0 : rewardDone(res);
|
|
@@ -690,53 +770,43 @@ var __publicField = (obj, key, value) => {
|
|
|
690
770
|
rewardResolve = null;
|
|
691
771
|
rewardPromise = null;
|
|
692
772
|
}
|
|
693
|
-
function clearReward() {
|
|
694
|
-
var _a, _b;
|
|
695
|
-
if (!rewardAd)
|
|
696
|
-
return;
|
|
697
|
-
if (rewardClose)
|
|
698
|
-
(_a = rewardAd.offClose) == null ? void 0 : _a.call(rewardAd, rewardClose);
|
|
699
|
-
if (rewardError)
|
|
700
|
-
(_b = rewardAd.offError) == null ? void 0 : _b.call(rewardAd, rewardError);
|
|
701
|
-
rewardClose = null;
|
|
702
|
-
rewardError = null;
|
|
703
|
-
}
|
|
704
773
|
function useHlwAd() {
|
|
705
|
-
function clearPopup() {
|
|
706
|
-
var _a, _b;
|
|
707
|
-
if (!popupAd)
|
|
708
|
-
return;
|
|
709
|
-
if (popupClose)
|
|
710
|
-
(_a = popupAd.offClose) == null ? void 0 : _a.call(popupAd, popupClose);
|
|
711
|
-
if (popupError)
|
|
712
|
-
(_b = popupAd.offError) == null ? void 0 : _b.call(popupAd, popupError);
|
|
713
|
-
popupClose = null;
|
|
714
|
-
popupError = null;
|
|
715
|
-
}
|
|
716
774
|
function setAdPopup(adId, done) {
|
|
717
775
|
var _a, _b, _c;
|
|
718
776
|
popupDone = done;
|
|
719
|
-
|
|
720
|
-
if (!adId || !(wxApi == null ? void 0 : wxApi.createInterstitialAd))
|
|
777
|
+
if (!adId)
|
|
721
778
|
return false;
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
779
|
+
const api = getAdApi();
|
|
780
|
+
if (!(api == null ? void 0 : api.createInterstitialAd))
|
|
781
|
+
return false;
|
|
782
|
+
activePopupAdId = adId;
|
|
783
|
+
if (!popupCache.has(adId)) {
|
|
784
|
+
try {
|
|
785
|
+
const ad = api.createInterstitialAd({ adUnitId: adId });
|
|
786
|
+
(_a = ad.onLoad) == null ? void 0 : _a.call(ad, () => console.log(`[HlwAd] Interstitial loaded: ${adId}`));
|
|
787
|
+
(_b = ad.onError) == null ? void 0 : _b.call(ad, (err) => {
|
|
788
|
+
console.error("[HlwAd] Interstitial load error:", err);
|
|
789
|
+
if (activePopupAdId === adId) {
|
|
790
|
+
popupDone == null ? void 0 : popupDone(false);
|
|
791
|
+
}
|
|
792
|
+
});
|
|
793
|
+
(_c = ad.onClose) == null ? void 0 : _c.call(ad, () => {
|
|
794
|
+
if (activePopupAdId === adId) {
|
|
795
|
+
popupDone == null ? void 0 : popupDone(true);
|
|
796
|
+
}
|
|
797
|
+
});
|
|
798
|
+
popupCache.set(adId, ad);
|
|
799
|
+
} catch (e) {
|
|
800
|
+
console.error("[HlwAd] Interstitial creation failed:", e);
|
|
801
|
+
return false;
|
|
802
|
+
}
|
|
803
|
+
}
|
|
735
804
|
return true;
|
|
736
805
|
}
|
|
737
806
|
function showAdPopup(delay = 3e3) {
|
|
738
807
|
return new Promise((resolve) => {
|
|
739
|
-
|
|
808
|
+
const ad = popupCache.get(activePopupAdId);
|
|
809
|
+
if (!ad) {
|
|
740
810
|
resolve(false);
|
|
741
811
|
return;
|
|
742
812
|
}
|
|
@@ -746,8 +816,8 @@ var __publicField = (obj, key, value) => {
|
|
|
746
816
|
resolve(ok);
|
|
747
817
|
};
|
|
748
818
|
setTimeout(() => {
|
|
749
|
-
|
|
750
|
-
console.error("
|
|
819
|
+
ad.show().catch((err) => {
|
|
820
|
+
console.error("[HlwAd] Interstitial show error:", err);
|
|
751
821
|
popupDone == null ? void 0 : popupDone(false);
|
|
752
822
|
});
|
|
753
823
|
}, Math.max(0, delay));
|
|
@@ -759,37 +829,52 @@ var __publicField = (obj, key, value) => {
|
|
|
759
829
|
rewardPromise = new Promise((resolve) => {
|
|
760
830
|
rewardResolve = resolve;
|
|
761
831
|
});
|
|
762
|
-
|
|
763
|
-
if (!adId || !(wxApi == null ? void 0 : wxApi.createRewardedVideoAd)) {
|
|
832
|
+
if (!adId) {
|
|
764
833
|
finish({ ok: false });
|
|
765
834
|
return rewardPromise;
|
|
766
835
|
}
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
836
|
+
const api = getAdApi();
|
|
837
|
+
if (!(api == null ? void 0 : api.createRewardedVideoAd)) {
|
|
838
|
+
finish({ ok: false });
|
|
839
|
+
return rewardPromise;
|
|
840
|
+
}
|
|
841
|
+
activeRewardAdId = adId;
|
|
842
|
+
if (!rewardCache.has(adId)) {
|
|
843
|
+
try {
|
|
844
|
+
const ad = api.createRewardedVideoAd({ adUnitId: adId });
|
|
845
|
+
(_a = ad.onLoad) == null ? void 0 : _a.call(ad, () => console.log(`[HlwAd] Rewarded video loaded: ${adId}`));
|
|
846
|
+
(_b = ad.onError) == null ? void 0 : _b.call(ad, (err) => {
|
|
847
|
+
console.error("[HlwAd] Rewarded video load error:", err);
|
|
848
|
+
if (activeRewardAdId === adId) {
|
|
849
|
+
finish({ ok: false, err });
|
|
850
|
+
}
|
|
851
|
+
});
|
|
852
|
+
(_c = ad.onClose) == null ? void 0 : _c.call(ad, (res) => {
|
|
853
|
+
if (activeRewardAdId === adId) {
|
|
854
|
+
const isEnded = !!(res == null ? void 0 : res.isEnded);
|
|
855
|
+
finish({ ok: isEnded, isEnded });
|
|
856
|
+
}
|
|
857
|
+
});
|
|
858
|
+
rewardCache.set(adId, ad);
|
|
859
|
+
} catch (e) {
|
|
860
|
+
console.error("[HlwAd] Rewarded video creation failed:", e);
|
|
861
|
+
finish({ ok: false, err: e });
|
|
862
|
+
}
|
|
863
|
+
}
|
|
780
864
|
return rewardPromise;
|
|
781
865
|
}
|
|
782
866
|
function showAdReward() {
|
|
783
|
-
|
|
867
|
+
const ad = rewardCache.get(activeRewardAdId);
|
|
868
|
+
if (!ad) {
|
|
784
869
|
return Promise.resolve({ ok: false });
|
|
785
870
|
}
|
|
786
871
|
const current = rewardPromise || new Promise((resolve) => {
|
|
787
872
|
rewardResolve = resolve;
|
|
788
873
|
});
|
|
789
874
|
rewardPromise = current;
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
console.error("
|
|
875
|
+
ad.show().catch(() => {
|
|
876
|
+
ad.load().then(() => ad.show()).catch((err) => {
|
|
877
|
+
console.error("[HlwAd] Rewarded video show error:", err);
|
|
793
878
|
finish({ ok: false, err });
|
|
794
879
|
});
|
|
795
880
|
});
|
|
@@ -859,12 +944,19 @@ var __publicField = (obj, key, value) => {
|
|
|
859
944
|
}
|
|
860
945
|
function useNavigate() {
|
|
861
946
|
return {
|
|
947
|
+
/** 核心底层路由分发函数 */
|
|
862
948
|
navigate,
|
|
949
|
+
/** 保留当前页面,跳转到应用内的某个页面 */
|
|
863
950
|
to: (url, options) => navigate("navigateTo", url, options),
|
|
951
|
+
/** 关闭当前页面,跳转到应用内的某个页面 */
|
|
864
952
|
redirect: (url, options) => navigate("redirectTo", url, options),
|
|
953
|
+
/** 跳转到 switchTab 页面,并关闭其他所有非 tabBar 页面 */
|
|
865
954
|
tab: (url, options) => navigate("switchTab", url, options),
|
|
955
|
+
/** 关闭所有页面,打开到应用内的某个页面 */
|
|
866
956
|
reLaunch: (url, options) => navigate("reLaunch", url, options),
|
|
957
|
+
/** 关闭当前页面,返回上一页面或多级页面 */
|
|
867
958
|
back: (delta = 1, options = {}) => navigate("navigateBack", "", { ...options, delta }),
|
|
959
|
+
/** 打开另一个小程序 */
|
|
868
960
|
miniProgram: (appId, options) => navigate("miniprogram", appId, options)
|
|
869
961
|
};
|
|
870
962
|
}
|
|
@@ -1269,6 +1361,7 @@ var __publicField = (obj, key, value) => {
|
|
|
1269
1361
|
uni.setClipboardData({
|
|
1270
1362
|
data,
|
|
1271
1363
|
showToast: false,
|
|
1364
|
+
// 禁用系统默认 Toast 提示,使用自定义的无图标 Toast
|
|
1272
1365
|
success: () => uni.showToast({ title: "复制成功", icon: "none", duration: 1500 })
|
|
1273
1366
|
});
|
|
1274
1367
|
}
|
|
@@ -1287,13 +1380,13 @@ var __publicField = (obj, key, value) => {
|
|
|
1287
1380
|
}
|
|
1288
1381
|
const vCopy = {
|
|
1289
1382
|
/**
|
|
1290
|
-
*
|
|
1383
|
+
* 在指令创建时注入点击事件拦截器。
|
|
1291
1384
|
*/
|
|
1292
1385
|
created(el, binding, vnode) {
|
|
1293
1386
|
injectTap(vnode, binding);
|
|
1294
1387
|
},
|
|
1295
1388
|
/**
|
|
1296
|
-
*
|
|
1389
|
+
* 在绑定值更新前重新注入点击事件拦截器,以获取最新的绑定值。
|
|
1297
1390
|
*/
|
|
1298
1391
|
beforeUpdate(el, binding, vnode) {
|
|
1299
1392
|
injectTap(vnode, binding);
|
|
@@ -1314,9 +1407,12 @@ var __publicField = (obj, key, value) => {
|
|
|
1314
1407
|
exports2.TYPOGRAPHY_ROLES = TYPOGRAPHY_ROLES;
|
|
1315
1408
|
exports2.adapters = adapters;
|
|
1316
1409
|
exports2.alistAdapter = alistAdapter;
|
|
1410
|
+
exports2.auth = auth;
|
|
1317
1411
|
exports2.buildThemeStyle = buildThemeStyle;
|
|
1318
1412
|
exports2.clearDeviceCache = clearDeviceCache;
|
|
1413
|
+
exports2.copy = copy;
|
|
1319
1414
|
exports2.cosAdapter = cosAdapter;
|
|
1415
|
+
exports2.download = download;
|
|
1320
1416
|
exports2.getAdapter = getAdapter;
|
|
1321
1417
|
exports2.getCurrentAppearance = getCurrentAppearance;
|
|
1322
1418
|
exports2.getCurrentAppearanceMode = getCurrentAppearanceMode;
|
|
@@ -1328,8 +1424,17 @@ var __publicField = (obj, key, value) => {
|
|
|
1328
1424
|
exports2.getCurrentTypographyVars = getCurrentTypographyVars;
|
|
1329
1425
|
exports2.hlw = hlw;
|
|
1330
1426
|
exports2.ossAdapter = ossAdapter;
|
|
1427
|
+
exports2.paste = paste;
|
|
1331
1428
|
exports2.qiniuAdapter = qiniuAdapter;
|
|
1332
1429
|
exports2.resolveAppearance = resolveAppearance;
|
|
1430
|
+
exports2.saveImage = saveImage;
|
|
1431
|
+
exports2.saveImageUrl = saveImageUrl;
|
|
1432
|
+
exports2.saveVideoFile = saveVideoFile;
|
|
1433
|
+
exports2.saveVideoUrl = saveVideoUrl;
|
|
1434
|
+
exports2.signText = signText;
|
|
1435
|
+
exports2.toBoolean = toBoolean;
|
|
1436
|
+
exports2.toNumber = toNumber;
|
|
1437
|
+
exports2.toQuery = toQuery;
|
|
1333
1438
|
exports2.useApp = useApp;
|
|
1334
1439
|
exports2.useDevice = useDevice;
|
|
1335
1440
|
exports2.useHlwAd = useHlwAd;
|
|
@@ -1343,5 +1448,6 @@ var __publicField = (obj, key, value) => {
|
|
|
1343
1448
|
exports2.useUpload = useUpload;
|
|
1344
1449
|
exports2.useUtils = useUtils;
|
|
1345
1450
|
exports2.vCopy = vCopy;
|
|
1451
|
+
exports2.withQuery = withQuery;
|
|
1346
1452
|
Object.defineProperty(exports2, Symbol.toStringTag, { value: "Module" });
|
|
1347
1453
|
});
|