@hlw-uni/mp-vue 2.1.57 → 2.1.59
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/index.d.ts +1 -1
- package/dist/composables/request/service.d.ts +73 -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 +310 -199
- package/dist/index.mjs +311 -200
- package/dist/stores/theme.d.ts +3 -0
- package/package.json +2 -2
- 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/components/hlw-custom/hlw-custom.vue +118 -0
- 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/index.ts +1 -1
- package/src/composables/request/service.ts +72 -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)
|
|
@@ -239,22 +281,48 @@ var __publicField = (obj, key, value) => {
|
|
|
239
281
|
}
|
|
240
282
|
return { uploading, upload };
|
|
241
283
|
}
|
|
284
|
+
var define_import_meta_env_default = {};
|
|
242
285
|
class BaseService {
|
|
286
|
+
/**
|
|
287
|
+
* 发送服务请求。会自动拼接前缀与命名空间。
|
|
288
|
+
* @param options 请求配置项
|
|
289
|
+
* @returns 响应结果 Promise
|
|
290
|
+
*/
|
|
243
291
|
request(options) {
|
|
244
292
|
return useRequest().request({
|
|
245
293
|
...options,
|
|
246
294
|
url: useRequest().resolveServiceUrl(this.namespace ?? "", options.url, this.servicePrefix ?? "")
|
|
247
295
|
});
|
|
248
296
|
}
|
|
297
|
+
/**
|
|
298
|
+
* 快捷发送 GET 请求。
|
|
299
|
+
* @param url 请求相对路径
|
|
300
|
+
* @param data 请求参数
|
|
301
|
+
*/
|
|
249
302
|
get(url, data) {
|
|
250
303
|
return this.request({ url, method: "GET", data });
|
|
251
304
|
}
|
|
305
|
+
/**
|
|
306
|
+
* 快捷发送 POST 请求。
|
|
307
|
+
* @param url 请求相对路径
|
|
308
|
+
* @param data 请求携带的 body
|
|
309
|
+
*/
|
|
252
310
|
post(url, data) {
|
|
253
311
|
return this.request({ url, method: "POST", data });
|
|
254
312
|
}
|
|
313
|
+
/**
|
|
314
|
+
* 快捷发送 PUT 请求。
|
|
315
|
+
* @param url 请求相对路径
|
|
316
|
+
* @param data 请求携带的 body
|
|
317
|
+
*/
|
|
255
318
|
put(url, data) {
|
|
256
319
|
return this.request({ url, method: "PUT", data });
|
|
257
320
|
}
|
|
321
|
+
/**
|
|
322
|
+
* 快捷发送 DELETE 请求。
|
|
323
|
+
* @param url 请求相对路径
|
|
324
|
+
* @param data 请求参数
|
|
325
|
+
*/
|
|
258
326
|
del(url, data) {
|
|
259
327
|
return this.request({ url, method: "DELETE", data });
|
|
260
328
|
}
|
|
@@ -269,17 +337,34 @@ var __publicField = (obj, key, value) => {
|
|
|
269
337
|
target.prototype.servicePrefix = typeof value === "string" ? value : value.prefix;
|
|
270
338
|
};
|
|
271
339
|
}
|
|
340
|
+
function PluginService(target) {
|
|
341
|
+
target.prototype.servicePrefix = define_import_meta_env_default.VITE_PLUGIN_NAME || "";
|
|
342
|
+
}
|
|
272
343
|
function useMsg() {
|
|
273
344
|
function toast(opts) {
|
|
274
|
-
const
|
|
275
|
-
|
|
276
|
-
|
|
345
|
+
const {
|
|
346
|
+
message,
|
|
347
|
+
icon = "none",
|
|
348
|
+
image = void 0,
|
|
349
|
+
duration = 2e3,
|
|
350
|
+
mask = false,
|
|
351
|
+
position = "center"
|
|
352
|
+
} = typeof opts === "string" ? { message: opts } : opts;
|
|
353
|
+
const mappedIcon = icon === "fail" || icon === "exception" ? "error" : icon;
|
|
354
|
+
uni.showToast({
|
|
355
|
+
title: message,
|
|
356
|
+
icon: mappedIcon,
|
|
357
|
+
image,
|
|
358
|
+
duration,
|
|
359
|
+
mask,
|
|
360
|
+
position
|
|
361
|
+
});
|
|
277
362
|
}
|
|
278
363
|
function success(message) {
|
|
279
364
|
uni.showToast({ title: message, icon: "success", duration: 2e3 });
|
|
280
365
|
}
|
|
281
366
|
function error(message) {
|
|
282
|
-
uni.showToast({ title: message, icon: "
|
|
367
|
+
uni.showToast({ title: message, icon: "error", duration: 2e3 });
|
|
283
368
|
}
|
|
284
369
|
function showLoading(message = "加载中...") {
|
|
285
370
|
uni.showLoading({ title: message, mask: true });
|
|
@@ -311,13 +396,11 @@ var __publicField = (obj, key, value) => {
|
|
|
311
396
|
});
|
|
312
397
|
});
|
|
313
398
|
}
|
|
314
|
-
function modal(opts) {
|
|
315
|
-
return confirm(opts);
|
|
316
|
-
}
|
|
317
399
|
function setLoadingBar(progress) {
|
|
318
400
|
const clamped = Math.max(0, Math.min(100, progress));
|
|
401
|
+
const filled = Math.round(clamped / 2);
|
|
319
402
|
uni.setNavigationBarTitle({
|
|
320
|
-
title: `${"■".repeat(
|
|
403
|
+
title: `${"■".repeat(filled)}${"□".repeat(50 - filled)} ${clamped}%`
|
|
321
404
|
});
|
|
322
405
|
}
|
|
323
406
|
return {
|
|
@@ -328,7 +411,7 @@ var __publicField = (obj, key, value) => {
|
|
|
328
411
|
showLoading,
|
|
329
412
|
hideLoading,
|
|
330
413
|
confirm,
|
|
331
|
-
modal,
|
|
414
|
+
modal: confirm,
|
|
332
415
|
setLoadingBar
|
|
333
416
|
};
|
|
334
417
|
}
|
|
@@ -351,141 +434,141 @@ var __publicField = (obj, key, value) => {
|
|
|
351
434
|
function toBoolean(val, def) {
|
|
352
435
|
if (typeof val === "boolean")
|
|
353
436
|
return val;
|
|
354
|
-
if (val === 0 || val === "0")
|
|
437
|
+
if (val === 0 || val === "0" || val === "false")
|
|
355
438
|
return false;
|
|
356
|
-
if (val === 1 || val === "1")
|
|
439
|
+
if (val === 1 || val === "1" || val === "true")
|
|
357
440
|
return true;
|
|
358
441
|
return def;
|
|
359
442
|
}
|
|
360
|
-
function
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
fail: () => ok(false)
|
|
373
|
-
});
|
|
443
|
+
function copy(text, tip = true) {
|
|
444
|
+
return new Promise((resolve) => {
|
|
445
|
+
uni.setClipboardData({
|
|
446
|
+
data: text,
|
|
447
|
+
showToast: false,
|
|
448
|
+
success: () => {
|
|
449
|
+
if (tip) {
|
|
450
|
+
uni.showToast({ title: "复制成功", icon: "none", duration: 1500 });
|
|
451
|
+
}
|
|
452
|
+
resolve(true);
|
|
453
|
+
},
|
|
454
|
+
fail: () => resolve(false)
|
|
374
455
|
});
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
456
|
+
});
|
|
457
|
+
}
|
|
458
|
+
function paste() {
|
|
459
|
+
return new Promise((resolve) => {
|
|
460
|
+
uni.getClipboardData({
|
|
461
|
+
success: (res) => resolve(res.data),
|
|
462
|
+
fail: () => resolve("")
|
|
382
463
|
});
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
464
|
+
});
|
|
465
|
+
}
|
|
466
|
+
function auth() {
|
|
467
|
+
uni.showModal({
|
|
468
|
+
title: "提示",
|
|
469
|
+
content: "需要授权相册权限",
|
|
470
|
+
confirmText: "去设置",
|
|
471
|
+
success: (res) => {
|
|
472
|
+
if (res.confirm)
|
|
473
|
+
uni.openSetting();
|
|
474
|
+
}
|
|
475
|
+
});
|
|
476
|
+
}
|
|
477
|
+
function saveImage(path) {
|
|
478
|
+
return new Promise((resolve) => {
|
|
479
|
+
uni.saveImageToPhotosAlbum({
|
|
480
|
+
filePath: path,
|
|
481
|
+
success: () => {
|
|
482
|
+
uni.showToast({ title: "保存成功", icon: "success" });
|
|
483
|
+
resolve(true);
|
|
484
|
+
},
|
|
485
|
+
fail: (err) => {
|
|
486
|
+
const msg = String(err.errMsg || "");
|
|
487
|
+
if (msg.includes("auth deny") || msg.includes("authorize")) {
|
|
488
|
+
auth();
|
|
489
|
+
} else {
|
|
490
|
+
uni.showToast({ title: "保存失败", icon: "none" });
|
|
491
|
+
}
|
|
492
|
+
resolve(false);
|
|
392
493
|
}
|
|
393
494
|
});
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
}
|
|
410
|
-
ok(false);
|
|
495
|
+
});
|
|
496
|
+
}
|
|
497
|
+
function saveVideoFile(path) {
|
|
498
|
+
return new Promise((resolve) => {
|
|
499
|
+
uni.saveVideoToPhotosAlbum({
|
|
500
|
+
filePath: path,
|
|
501
|
+
success: () => {
|
|
502
|
+
uni.showToast({ title: "保存成功", icon: "success" });
|
|
503
|
+
resolve(true);
|
|
504
|
+
},
|
|
505
|
+
fail: (err) => {
|
|
506
|
+
const msg = String(err.errMsg || "");
|
|
507
|
+
if (msg.includes("auth deny") || msg.includes("authorize")) {
|
|
508
|
+
auth();
|
|
509
|
+
} else {
|
|
510
|
+
uni.showToast({ title: "保存失败", icon: "none" });
|
|
411
511
|
}
|
|
412
|
-
|
|
512
|
+
resolve(false);
|
|
513
|
+
}
|
|
413
514
|
});
|
|
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);
|
|
515
|
+
});
|
|
516
|
+
}
|
|
517
|
+
function download(opt) {
|
|
518
|
+
return new Promise((resolve) => {
|
|
519
|
+
const task = uni.downloadFile({
|
|
520
|
+
url: opt.url,
|
|
521
|
+
filePath: opt.path,
|
|
522
|
+
header: opt.header,
|
|
523
|
+
success: (res) => {
|
|
524
|
+
if (res.statusCode === 200) {
|
|
525
|
+
resolve({ ok: true, path: res.tempFilePath, code: res.statusCode });
|
|
526
|
+
} else {
|
|
527
|
+
resolve({ ok: false, code: res.statusCode, msg: `下载失败,状态码:${res.statusCode}` });
|
|
431
528
|
}
|
|
432
|
-
}
|
|
529
|
+
},
|
|
530
|
+
fail: (err) => resolve({ ok: false, msg: err.errMsg })
|
|
433
531
|
});
|
|
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 })
|
|
532
|
+
if (opt.progress) {
|
|
533
|
+
task.onProgressUpdate((res) => {
|
|
534
|
+
opt.progress(res.progress, res.totalBytesWritten, res.totalBytesExpectedToWrite);
|
|
449
535
|
});
|
|
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" });
|
|
536
|
+
}
|
|
537
|
+
});
|
|
538
|
+
}
|
|
539
|
+
async function saveImageUrl(url, progress) {
|
|
540
|
+
try {
|
|
541
|
+
uni.showLoading({ title: "下载中...", mask: true });
|
|
542
|
+
const res = await download({ url, progress: progress ? (value) => progress(value) : void 0 });
|
|
543
|
+
uni.hideLoading();
|
|
544
|
+
if (!res.ok || !res.path) {
|
|
545
|
+
uni.showToast({ title: res.msg || "下载失败", icon: "none" });
|
|
470
546
|
return false;
|
|
471
547
|
}
|
|
548
|
+
return await saveImage(res.path);
|
|
549
|
+
} catch {
|
|
550
|
+
uni.hideLoading();
|
|
551
|
+
uni.showToast({ title: "操作失败", icon: "none" });
|
|
552
|
+
return false;
|
|
472
553
|
}
|
|
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" });
|
|
554
|
+
}
|
|
555
|
+
async function saveVideoUrl(url, progress) {
|
|
556
|
+
try {
|
|
557
|
+
uni.showLoading({ title: "下载中...", mask: true });
|
|
558
|
+
const res = await download({ url, progress: progress ? (value) => progress(value) : void 0 });
|
|
559
|
+
uni.hideLoading();
|
|
560
|
+
if (!res.ok || !res.path) {
|
|
561
|
+
uni.showToast({ title: res.msg || "下载失败", icon: "none" });
|
|
486
562
|
return false;
|
|
487
563
|
}
|
|
564
|
+
return await saveVideoFile(res.path);
|
|
565
|
+
} catch {
|
|
566
|
+
uni.hideLoading();
|
|
567
|
+
uni.showToast({ title: "操作失败", icon: "none" });
|
|
568
|
+
return false;
|
|
488
569
|
}
|
|
570
|
+
}
|
|
571
|
+
function useUtils() {
|
|
489
572
|
return {
|
|
490
573
|
withQuery,
|
|
491
574
|
toQuery,
|
|
@@ -495,7 +578,7 @@ var __publicField = (obj, key, value) => {
|
|
|
495
578
|
copy,
|
|
496
579
|
paste,
|
|
497
580
|
saveImage,
|
|
498
|
-
|
|
581
|
+
saveVideoFile,
|
|
499
582
|
download,
|
|
500
583
|
saveImageUrl,
|
|
501
584
|
saveVideoUrl
|
|
@@ -589,10 +672,9 @@ var __publicField = (obj, key, value) => {
|
|
|
589
672
|
}
|
|
590
673
|
function useDevice() {
|
|
591
674
|
const info = getDevice();
|
|
592
|
-
const { toQuery: toQuery2 } = useUtils();
|
|
593
675
|
return {
|
|
594
676
|
info,
|
|
595
|
-
query:
|
|
677
|
+
query: toQuery(getQueryInfo(info))
|
|
596
678
|
};
|
|
597
679
|
}
|
|
598
680
|
function clearDeviceCache() {
|
|
@@ -631,8 +713,8 @@ var __publicField = (obj, key, value) => {
|
|
|
631
713
|
}
|
|
632
714
|
function showShareMenu() {
|
|
633
715
|
var _a;
|
|
634
|
-
const
|
|
635
|
-
(_a =
|
|
716
|
+
const api = typeof uni !== "undefined" ? uni : void 0;
|
|
717
|
+
(_a = api == null ? void 0 : api.showShareMenu) == null ? void 0 : _a.call(api, {
|
|
636
718
|
withShareTicket: true,
|
|
637
719
|
menus: ["shareAppMessage", "shareTimeline"],
|
|
638
720
|
fail: () => void 0
|
|
@@ -671,18 +753,20 @@ var __publicField = (obj, key, value) => {
|
|
|
671
753
|
showShareMenu
|
|
672
754
|
};
|
|
673
755
|
}
|
|
674
|
-
|
|
756
|
+
const popupCache = /* @__PURE__ */ new Map();
|
|
757
|
+
const rewardCache = /* @__PURE__ */ new Map();
|
|
758
|
+
let activePopupAdId = "";
|
|
675
759
|
let popupDone;
|
|
676
|
-
let
|
|
677
|
-
let popupError = null;
|
|
678
|
-
let rewardAd = null;
|
|
760
|
+
let activeRewardAdId = "";
|
|
679
761
|
let rewardDone;
|
|
680
762
|
let rewardPromise = null;
|
|
681
763
|
let rewardResolve = null;
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
764
|
+
function getAdApi() {
|
|
765
|
+
if (typeof uni !== "undefined")
|
|
766
|
+
return uni;
|
|
767
|
+
if (typeof wx !== "undefined")
|
|
768
|
+
return wx;
|
|
769
|
+
return null;
|
|
686
770
|
}
|
|
687
771
|
function finish(res) {
|
|
688
772
|
rewardDone == null ? void 0 : rewardDone(res);
|
|
@@ -690,53 +774,43 @@ var __publicField = (obj, key, value) => {
|
|
|
690
774
|
rewardResolve = null;
|
|
691
775
|
rewardPromise = null;
|
|
692
776
|
}
|
|
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
777
|
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
778
|
function setAdPopup(adId, done) {
|
|
717
779
|
var _a, _b, _c;
|
|
718
780
|
popupDone = done;
|
|
719
|
-
|
|
720
|
-
if (!adId || !(wxApi == null ? void 0 : wxApi.createInterstitialAd))
|
|
781
|
+
if (!adId)
|
|
721
782
|
return false;
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
783
|
+
const api = getAdApi();
|
|
784
|
+
if (!(api == null ? void 0 : api.createInterstitialAd))
|
|
785
|
+
return false;
|
|
786
|
+
activePopupAdId = adId;
|
|
787
|
+
if (!popupCache.has(adId)) {
|
|
788
|
+
try {
|
|
789
|
+
const ad = api.createInterstitialAd({ adUnitId: adId });
|
|
790
|
+
(_a = ad.onLoad) == null ? void 0 : _a.call(ad, () => console.log(`[HlwAd] Interstitial loaded: ${adId}`));
|
|
791
|
+
(_b = ad.onError) == null ? void 0 : _b.call(ad, (err) => {
|
|
792
|
+
console.error("[HlwAd] Interstitial load error:", err);
|
|
793
|
+
if (activePopupAdId === adId) {
|
|
794
|
+
popupDone == null ? void 0 : popupDone(false);
|
|
795
|
+
}
|
|
796
|
+
});
|
|
797
|
+
(_c = ad.onClose) == null ? void 0 : _c.call(ad, () => {
|
|
798
|
+
if (activePopupAdId === adId) {
|
|
799
|
+
popupDone == null ? void 0 : popupDone(true);
|
|
800
|
+
}
|
|
801
|
+
});
|
|
802
|
+
popupCache.set(adId, ad);
|
|
803
|
+
} catch (e) {
|
|
804
|
+
console.error("[HlwAd] Interstitial creation failed:", e);
|
|
805
|
+
return false;
|
|
806
|
+
}
|
|
807
|
+
}
|
|
735
808
|
return true;
|
|
736
809
|
}
|
|
737
810
|
function showAdPopup(delay = 3e3) {
|
|
738
811
|
return new Promise((resolve) => {
|
|
739
|
-
|
|
812
|
+
const ad = popupCache.get(activePopupAdId);
|
|
813
|
+
if (!ad) {
|
|
740
814
|
resolve(false);
|
|
741
815
|
return;
|
|
742
816
|
}
|
|
@@ -746,8 +820,8 @@ var __publicField = (obj, key, value) => {
|
|
|
746
820
|
resolve(ok);
|
|
747
821
|
};
|
|
748
822
|
setTimeout(() => {
|
|
749
|
-
|
|
750
|
-
console.error("
|
|
823
|
+
ad.show().catch((err) => {
|
|
824
|
+
console.error("[HlwAd] Interstitial show error:", err);
|
|
751
825
|
popupDone == null ? void 0 : popupDone(false);
|
|
752
826
|
});
|
|
753
827
|
}, Math.max(0, delay));
|
|
@@ -759,37 +833,52 @@ var __publicField = (obj, key, value) => {
|
|
|
759
833
|
rewardPromise = new Promise((resolve) => {
|
|
760
834
|
rewardResolve = resolve;
|
|
761
835
|
});
|
|
762
|
-
|
|
763
|
-
if (!adId || !(wxApi == null ? void 0 : wxApi.createRewardedVideoAd)) {
|
|
836
|
+
if (!adId) {
|
|
764
837
|
finish({ ok: false });
|
|
765
838
|
return rewardPromise;
|
|
766
839
|
}
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
840
|
+
const api = getAdApi();
|
|
841
|
+
if (!(api == null ? void 0 : api.createRewardedVideoAd)) {
|
|
842
|
+
finish({ ok: false });
|
|
843
|
+
return rewardPromise;
|
|
844
|
+
}
|
|
845
|
+
activeRewardAdId = adId;
|
|
846
|
+
if (!rewardCache.has(adId)) {
|
|
847
|
+
try {
|
|
848
|
+
const ad = api.createRewardedVideoAd({ adUnitId: adId });
|
|
849
|
+
(_a = ad.onLoad) == null ? void 0 : _a.call(ad, () => console.log(`[HlwAd] Rewarded video loaded: ${adId}`));
|
|
850
|
+
(_b = ad.onError) == null ? void 0 : _b.call(ad, (err) => {
|
|
851
|
+
console.error("[HlwAd] Rewarded video load error:", err);
|
|
852
|
+
if (activeRewardAdId === adId) {
|
|
853
|
+
finish({ ok: false, err });
|
|
854
|
+
}
|
|
855
|
+
});
|
|
856
|
+
(_c = ad.onClose) == null ? void 0 : _c.call(ad, (res) => {
|
|
857
|
+
if (activeRewardAdId === adId) {
|
|
858
|
+
const isEnded = !!(res == null ? void 0 : res.isEnded);
|
|
859
|
+
finish({ ok: isEnded, isEnded });
|
|
860
|
+
}
|
|
861
|
+
});
|
|
862
|
+
rewardCache.set(adId, ad);
|
|
863
|
+
} catch (e) {
|
|
864
|
+
console.error("[HlwAd] Rewarded video creation failed:", e);
|
|
865
|
+
finish({ ok: false, err: e });
|
|
866
|
+
}
|
|
867
|
+
}
|
|
780
868
|
return rewardPromise;
|
|
781
869
|
}
|
|
782
870
|
function showAdReward() {
|
|
783
|
-
|
|
871
|
+
const ad = rewardCache.get(activeRewardAdId);
|
|
872
|
+
if (!ad) {
|
|
784
873
|
return Promise.resolve({ ok: false });
|
|
785
874
|
}
|
|
786
875
|
const current = rewardPromise || new Promise((resolve) => {
|
|
787
876
|
rewardResolve = resolve;
|
|
788
877
|
});
|
|
789
878
|
rewardPromise = current;
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
console.error("
|
|
879
|
+
ad.show().catch(() => {
|
|
880
|
+
ad.load().then(() => ad.show()).catch((err) => {
|
|
881
|
+
console.error("[HlwAd] Rewarded video show error:", err);
|
|
793
882
|
finish({ ok: false, err });
|
|
794
883
|
});
|
|
795
884
|
});
|
|
@@ -859,12 +948,19 @@ var __publicField = (obj, key, value) => {
|
|
|
859
948
|
}
|
|
860
949
|
function useNavigate() {
|
|
861
950
|
return {
|
|
951
|
+
/** 核心底层路由分发函数 */
|
|
862
952
|
navigate,
|
|
953
|
+
/** 保留当前页面,跳转到应用内的某个页面 */
|
|
863
954
|
to: (url, options) => navigate("navigateTo", url, options),
|
|
955
|
+
/** 关闭当前页面,跳转到应用内的某个页面 */
|
|
864
956
|
redirect: (url, options) => navigate("redirectTo", url, options),
|
|
957
|
+
/** 跳转到 switchTab 页面,并关闭其他所有非 tabBar 页面 */
|
|
865
958
|
tab: (url, options) => navigate("switchTab", url, options),
|
|
959
|
+
/** 关闭所有页面,打开到应用内的某个页面 */
|
|
866
960
|
reLaunch: (url, options) => navigate("reLaunch", url, options),
|
|
961
|
+
/** 关闭当前页面,返回上一页面或多级页面 */
|
|
867
962
|
back: (delta = 1, options = {}) => navigate("navigateBack", "", { ...options, delta }),
|
|
963
|
+
/** 打开另一个小程序 */
|
|
868
964
|
miniProgram: (appId, options) => navigate("miniprogram", appId, options)
|
|
869
965
|
};
|
|
870
966
|
}
|
|
@@ -1269,6 +1365,7 @@ var __publicField = (obj, key, value) => {
|
|
|
1269
1365
|
uni.setClipboardData({
|
|
1270
1366
|
data,
|
|
1271
1367
|
showToast: false,
|
|
1368
|
+
// 禁用系统默认 Toast 提示,使用自定义的无图标 Toast
|
|
1272
1369
|
success: () => uni.showToast({ title: "复制成功", icon: "none", duration: 1500 })
|
|
1273
1370
|
});
|
|
1274
1371
|
}
|
|
@@ -1287,13 +1384,13 @@ var __publicField = (obj, key, value) => {
|
|
|
1287
1384
|
}
|
|
1288
1385
|
const vCopy = {
|
|
1289
1386
|
/**
|
|
1290
|
-
*
|
|
1387
|
+
* 在指令创建时注入点击事件拦截器。
|
|
1291
1388
|
*/
|
|
1292
1389
|
created(el, binding, vnode) {
|
|
1293
1390
|
injectTap(vnode, binding);
|
|
1294
1391
|
},
|
|
1295
1392
|
/**
|
|
1296
|
-
*
|
|
1393
|
+
* 在绑定值更新前重新注入点击事件拦截器,以获取最新的绑定值。
|
|
1297
1394
|
*/
|
|
1298
1395
|
beforeUpdate(el, binding, vnode) {
|
|
1299
1396
|
injectTap(vnode, binding);
|
|
@@ -1306,6 +1403,7 @@ var __publicField = (obj, key, value) => {
|
|
|
1306
1403
|
exports2.DEFAULT_THEMES = DEFAULT_THEMES;
|
|
1307
1404
|
exports2.FONT_PRESETS = FONT_PRESETS;
|
|
1308
1405
|
exports2.FONT_SCALE_KEY = FONT_SCALE_KEY;
|
|
1406
|
+
exports2.PluginService = PluginService;
|
|
1309
1407
|
exports2.ServiceNamespace = ServiceNamespace;
|
|
1310
1408
|
exports2.ServicePrefix = ServicePrefix;
|
|
1311
1409
|
exports2.THEME_CHANGE_EVENT = THEME_CHANGE_EVENT;
|
|
@@ -1314,9 +1412,12 @@ var __publicField = (obj, key, value) => {
|
|
|
1314
1412
|
exports2.TYPOGRAPHY_ROLES = TYPOGRAPHY_ROLES;
|
|
1315
1413
|
exports2.adapters = adapters;
|
|
1316
1414
|
exports2.alistAdapter = alistAdapter;
|
|
1415
|
+
exports2.auth = auth;
|
|
1317
1416
|
exports2.buildThemeStyle = buildThemeStyle;
|
|
1318
1417
|
exports2.clearDeviceCache = clearDeviceCache;
|
|
1418
|
+
exports2.copy = copy;
|
|
1319
1419
|
exports2.cosAdapter = cosAdapter;
|
|
1420
|
+
exports2.download = download;
|
|
1320
1421
|
exports2.getAdapter = getAdapter;
|
|
1321
1422
|
exports2.getCurrentAppearance = getCurrentAppearance;
|
|
1322
1423
|
exports2.getCurrentAppearanceMode = getCurrentAppearanceMode;
|
|
@@ -1328,8 +1429,17 @@ var __publicField = (obj, key, value) => {
|
|
|
1328
1429
|
exports2.getCurrentTypographyVars = getCurrentTypographyVars;
|
|
1329
1430
|
exports2.hlw = hlw;
|
|
1330
1431
|
exports2.ossAdapter = ossAdapter;
|
|
1432
|
+
exports2.paste = paste;
|
|
1331
1433
|
exports2.qiniuAdapter = qiniuAdapter;
|
|
1332
1434
|
exports2.resolveAppearance = resolveAppearance;
|
|
1435
|
+
exports2.saveImage = saveImage;
|
|
1436
|
+
exports2.saveImageUrl = saveImageUrl;
|
|
1437
|
+
exports2.saveVideoFile = saveVideoFile;
|
|
1438
|
+
exports2.saveVideoUrl = saveVideoUrl;
|
|
1439
|
+
exports2.signText = signText;
|
|
1440
|
+
exports2.toBoolean = toBoolean;
|
|
1441
|
+
exports2.toNumber = toNumber;
|
|
1442
|
+
exports2.toQuery = toQuery;
|
|
1333
1443
|
exports2.useApp = useApp;
|
|
1334
1444
|
exports2.useDevice = useDevice;
|
|
1335
1445
|
exports2.useHlwAd = useHlwAd;
|
|
@@ -1343,5 +1453,6 @@ var __publicField = (obj, key, value) => {
|
|
|
1343
1453
|
exports2.useUpload = useUpload;
|
|
1344
1454
|
exports2.useUtils = useUtils;
|
|
1345
1455
|
exports2.vCopy = vCopy;
|
|
1456
|
+
exports2.withQuery = withQuery;
|
|
1346
1457
|
Object.defineProperty(exports2, Symbol.toStringTag, { value: "Module" });
|
|
1347
1458
|
});
|