@hlw-uni/mp-vue 1.2.28 → 2.0.2

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.
Files changed (70) hide show
  1. package/dist/app.d.ts +33 -0
  2. package/dist/composables/_internal/unwrap.d.ts +15 -0
  3. package/dist/composables/ad/index.d.ts +101 -0
  4. package/dist/composables/color/index.d.ts +8 -0
  5. package/dist/composables/contact/index.d.ts +32 -0
  6. package/dist/composables/device/index.d.ts +129 -0
  7. package/dist/composables/format/index.d.ts +9 -0
  8. package/dist/composables/http/adapters/alist.d.ts +3 -0
  9. package/dist/composables/http/adapters/base.d.ts +19 -0
  10. package/dist/composables/http/adapters/cos.d.ts +3 -0
  11. package/dist/composables/http/adapters/index.d.ts +15 -0
  12. package/dist/composables/http/adapters/oss.d.ts +3 -0
  13. package/dist/composables/http/adapters/qiniu.d.ts +3 -0
  14. package/dist/composables/http/client.d.ts +66 -0
  15. package/dist/composables/http/index.d.ts +8 -0
  16. package/dist/composables/http/types.d.ts +51 -0
  17. package/dist/composables/index.d.ts +26 -0
  18. package/dist/composables/loading/index.d.ts +7 -0
  19. package/dist/composables/msg/index.d.ts +36 -0
  20. package/dist/composables/navigator/index.d.ts +47 -0
  21. package/dist/composables/page-meta/index.d.ts +18 -0
  22. package/dist/composables/refs/index.d.ts +8 -0
  23. package/dist/composables/share/index.d.ts +71 -0
  24. package/dist/composables/storage/index.d.ts +16 -0
  25. package/dist/composables/theme/font.d.ts +1 -1
  26. package/dist/composables/theme/index.d.ts +15 -2
  27. package/dist/composables/utils/index.d.ts +39 -0
  28. package/dist/composables/validate/index.d.ts +12 -0
  29. package/dist/directives/copy.d.ts +3 -0
  30. package/dist/directives/index.d.ts +1 -0
  31. package/dist/hlw.d.ts +14 -0
  32. package/dist/index.d.ts +10 -7
  33. package/dist/index.js +1733 -63
  34. package/dist/index.mjs +1732 -62
  35. package/package.json +5 -3
  36. package/src/app.ts +173 -0
  37. package/src/components/hlw-ad/index.vue +74 -30
  38. package/src/composables/_internal/unwrap.ts +19 -0
  39. package/src/composables/ad/index.ts +395 -0
  40. package/src/composables/color/index.ts +44 -0
  41. package/src/composables/contact/index.ts +92 -0
  42. package/src/composables/device/index.ts +168 -0
  43. package/src/composables/format/index.ts +48 -0
  44. package/src/composables/http/adapters/alist.ts +19 -0
  45. package/src/composables/http/adapters/base.ts +21 -0
  46. package/src/composables/http/adapters/cos.ts +23 -0
  47. package/src/composables/http/adapters/index.ts +31 -0
  48. package/src/composables/http/adapters/oss.ts +22 -0
  49. package/src/composables/http/adapters/qiniu.ts +19 -0
  50. package/src/composables/http/client.ts +237 -0
  51. package/src/composables/http/index.ts +8 -0
  52. package/src/composables/http/types.ts +57 -0
  53. package/src/composables/http/useRequest.ts +107 -0
  54. package/src/composables/index.ts +82 -0
  55. package/src/composables/loading/index.ts +23 -0
  56. package/src/composables/msg/index.ts +132 -0
  57. package/src/composables/navigator/index.ts +104 -0
  58. package/src/composables/page-meta/index.ts +49 -0
  59. package/src/composables/refs/index.ts +30 -0
  60. package/src/composables/share/index.ts +189 -0
  61. package/src/composables/storage/index.ts +76 -0
  62. package/src/composables/theme/font.ts +26 -5
  63. package/src/composables/theme/index.ts +26 -11
  64. package/src/composables/theme/palette.ts +1 -1
  65. package/src/composables/utils/index.ts +160 -0
  66. package/src/composables/validate/index.ts +58 -0
  67. package/src/directives/copy.ts +50 -0
  68. package/src/directives/index.ts +1 -0
  69. package/src/hlw.ts +37 -0
  70. package/src/index.ts +21 -20
package/dist/index.mjs CHANGED
@@ -1,10 +1,1198 @@
1
- import { ref, onMounted, onUnmounted, computed } from "vue";
2
- import { useColor } from "@hlw-uni/mp-core";
3
- import { defineStore } from "pinia";
1
+ var __defProp = Object.defineProperty;
2
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
+ var __publicField = (obj, key, value) => {
4
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
+ return value;
6
+ };
7
+ import { ref, onBeforeUpdate, onUnmounted, computed, createSSRApp } from "vue";
8
+ import { defineStore, storeToRefs } from "pinia";
9
+ import { onShareAppMessage, onShareTimeline } from "@dcloudio/uni-app";
10
+ const cosAdapter = {
11
+ name: "cos",
12
+ /**
13
+ * 生成 COS 直传所需的表单字段。
14
+ */
15
+ buildFormData(ctx) {
16
+ const c = ctx.credentials ?? {};
17
+ return {
18
+ "q-ak": c["ak"] ?? "",
19
+ policy: c["policy"] ?? "",
20
+ "q-key-time": c["key-time"] ?? "",
21
+ "q-signature": c["signature"] ?? "",
22
+ "Content-Disposition": `inline;filename=${encodeURIComponent(ctx.fileName)}`,
23
+ success_action_status: 200,
24
+ ...ctx.extraData ?? {}
25
+ };
26
+ }
27
+ };
28
+ const ossAdapter = {
29
+ name: "oss",
30
+ /**
31
+ * 生成 OSS 直传所需的表单字段。
32
+ */
33
+ buildFormData(ctx) {
34
+ const c = ctx.credentials ?? {};
35
+ return {
36
+ policy: c["policy"] ?? "",
37
+ signature: c["signature"] ?? "",
38
+ OSSAccessKeyId: c["accessKeyId"] ?? "",
39
+ success_action_status: 200,
40
+ "Content-Disposition": `inline;filename=${encodeURIComponent(ctx.fileName)}`,
41
+ ...ctx.extraData ?? {}
42
+ };
43
+ }
44
+ };
45
+ const qiniuAdapter = {
46
+ name: "qiniu",
47
+ /**
48
+ * 生成七牛直传所需的表单字段。
49
+ */
50
+ buildFormData(ctx) {
51
+ const c = ctx.credentials ?? {};
52
+ return {
53
+ token: c["token"] ?? "",
54
+ key: c["key"] ?? ctx.fileName,
55
+ ...ctx.extraData ?? {}
56
+ };
57
+ }
58
+ };
59
+ const alistAdapter = {
60
+ name: "alist",
61
+ /**
62
+ * 生成 Alist 所需的表单字段。
63
+ */
64
+ buildFormData(ctx) {
65
+ const c = ctx.credentials ?? {};
66
+ return {
67
+ "file-path": c["file-path"] ?? ctx.fileName,
68
+ authorization: c["token"] ?? "",
69
+ ...ctx.extraData ?? {}
70
+ };
71
+ }
72
+ };
73
+ const adapters = {
74
+ cos: cosAdapter,
75
+ oss: ossAdapter,
76
+ qiniu: qiniuAdapter,
77
+ alist: alistAdapter
78
+ };
79
+ function getAdapter(name) {
80
+ const adapter2 = adapters[name];
81
+ if (!adapter2)
82
+ throw new Error(`[hlw] Unknown upload adapter: ${name}`);
83
+ return adapter2;
84
+ }
85
+ class HttpClient {
86
+ /**
87
+ * 创建 HttpClient 实例并初始化默认配置。
88
+ */
89
+ constructor(options = {}) {
90
+ __publicField(this, "_reqInterceptors", []);
91
+ __publicField(this, "_resInterceptors", []);
92
+ __publicField(this, "_errInterceptors", []);
93
+ __publicField(this, "_baseURL");
94
+ __publicField(this, "_defaultHeaders");
95
+ __publicField(this, "_noCache");
96
+ this._baseURL = options.baseURL ?? "";
97
+ this._noCache = options.noCache ?? true;
98
+ this._defaultHeaders = {
99
+ "Content-Type": "application/json",
100
+ ...options.headers
101
+ };
102
+ }
103
+ /** 运行时设置 baseURL。 */
104
+ setBaseURL(url) {
105
+ this._baseURL = url;
106
+ }
107
+ /** 注册请求拦截器,并返回注销函数。 */
108
+ onRequest(fn) {
109
+ this._reqInterceptors.push(fn);
110
+ return () => {
111
+ const idx = this._reqInterceptors.indexOf(fn);
112
+ if (idx > -1)
113
+ this._reqInterceptors.splice(idx, 1);
114
+ };
115
+ }
116
+ /** 注册响应拦截器,并返回注销函数。 */
117
+ onResponse(fn) {
118
+ this._resInterceptors.push(fn);
119
+ return () => {
120
+ const idx = this._resInterceptors.indexOf(fn);
121
+ if (idx > -1)
122
+ this._resInterceptors.splice(idx, 1);
123
+ };
124
+ }
125
+ /** 注册错误拦截器,并返回注销函数。 */
126
+ onError(fn) {
127
+ this._errInterceptors.push(fn);
128
+ return () => {
129
+ const idx = this._errInterceptors.indexOf(fn);
130
+ if (idx > -1)
131
+ this._errInterceptors.splice(idx, 1);
132
+ };
133
+ }
134
+ /**
135
+ * 执行一次全局请求,自动串联请求与响应拦截器。
136
+ */
137
+ async request(config2) {
138
+ let cfg = {
139
+ method: "GET",
140
+ ...config2,
141
+ headers: { ...this._defaultHeaders, ...config2.headers }
142
+ };
143
+ for (const fn of this._reqInterceptors) {
144
+ cfg = await fn(cfg);
145
+ }
146
+ try {
147
+ const fullUrl = this._buildUrl(cfg.url);
148
+ const res = await this._doRequest(fullUrl, cfg);
149
+ for (const fn of this._resInterceptors) {
150
+ const modified = await fn(res);
151
+ if (modified !== void 0)
152
+ return modified;
153
+ }
154
+ return res;
155
+ } catch (e) {
156
+ const err = e;
157
+ await this._applyErrorInterceptors(err);
158
+ throw err;
159
+ }
160
+ }
161
+ /**
162
+ * 创建组件内可复用的请求状态对象。
163
+ */
164
+ useRequest() {
165
+ const loading = ref(false);
166
+ const data = ref(null);
167
+ const error = ref(null);
168
+ const run = async (cfg) => {
169
+ loading.value = true;
170
+ error.value = null;
171
+ try {
172
+ const res = await this.request(cfg);
173
+ data.value = res.data;
174
+ return res;
175
+ } catch (e) {
176
+ error.value = e;
177
+ throw e;
178
+ } finally {
179
+ loading.value = false;
180
+ }
181
+ };
182
+ const get = (url, d) => run({ url, method: "GET", data: d });
183
+ const post = (url, d) => run({ url, method: "POST", data: d });
184
+ const put = (url, d) => run({ url, method: "PUT", data: d });
185
+ const del = (url, d) => run({ url, method: "DELETE", data: d });
186
+ return { loading, data, error, run, get, post, put, del };
187
+ }
188
+ /**
189
+ * 根据上传类型选择适配器并执行文件上传。
190
+ */
191
+ upload(config2) {
192
+ const fileName = config2.fileName ?? config2.filePath.split("/").pop() ?? "file";
193
+ let server = config2.server;
194
+ if (config2.type === "local" && config2.url)
195
+ server = config2.url;
196
+ const formData = config2.type === "local" ? config2.credentials ?? {} : getAdapter(config2.type).buildFormData({
197
+ filePath: config2.filePath,
198
+ fileName,
199
+ credentials: config2.credentials
200
+ });
201
+ return new Promise((resolve, reject) => {
202
+ uni.uploadFile({
203
+ url: server,
204
+ filePath: config2.filePath,
205
+ name: "file",
206
+ formData,
207
+ header: config2.header,
208
+ success: (res) => {
209
+ if (res.statusCode === 200) {
210
+ try {
211
+ const body = JSON.parse(res.data);
212
+ resolve({ code: body.code ?? 1, msg: body.message ?? "上传成功", data: body.data ?? "" });
213
+ } catch {
214
+ resolve({ code: 1, msg: "上传成功", data: res.data });
215
+ }
216
+ } else {
217
+ reject(new Error("上传失败"));
218
+ }
219
+ },
220
+ fail: (err) => reject(new Error(err.errMsg || "上传失败"))
221
+ });
222
+ });
223
+ }
224
+ /**
225
+ * 拼接 baseURL,并在开启防缓存时追加时间戳参数。
226
+ */
227
+ _buildUrl(url) {
228
+ if (/^https?:\/\//.test(url))
229
+ return url;
230
+ const full = `${this._baseURL}${url}`;
231
+ if (!this._noCache)
232
+ return full;
233
+ const sep = full.includes("?") ? "&" : "?";
234
+ return `${full}${sep}_t=${Date.now()}`;
235
+ }
236
+ /**
237
+ * 调用 uni.request 发起底层网络请求。
238
+ */
239
+ async _doRequest(url, cfg) {
240
+ return new Promise((resolve, reject) => {
241
+ uni.request({
242
+ url,
243
+ method: cfg.method,
244
+ data: cfg.data,
245
+ header: cfg.headers,
246
+ success: (res) => {
247
+ var _a;
248
+ if (res.statusCode >= 200 && res.statusCode < 300) {
249
+ resolve(res.data);
250
+ } else {
251
+ const msg2 = ((_a = res.data) == null ? void 0 : _a.info) ?? `请求失败: ${res.statusCode}`;
252
+ reject(new Error(String(msg2)));
253
+ }
254
+ },
255
+ fail: (err) => reject(new Error(err.errMsg || "网络请求失败"))
256
+ });
257
+ });
258
+ }
259
+ /**
260
+ * 顺序执行已注册的错误拦截器。
261
+ */
262
+ async _applyErrorInterceptors(err) {
263
+ for (const fn of this._errInterceptors) {
264
+ await fn(err);
265
+ }
266
+ }
267
+ }
268
+ const http = new HttpClient();
269
+ function useRequest(options = {}) {
270
+ const { initialData = null, manual = false, onSuccess, onError } = options;
271
+ const loading = ref(false);
272
+ const data = ref(initialData);
273
+ const error = ref(null);
274
+ async function run(config2) {
275
+ loading.value = true;
276
+ error.value = null;
277
+ try {
278
+ const res = await http.request(config2);
279
+ data.value = res.data;
280
+ onSuccess == null ? void 0 : onSuccess(res.data, res);
281
+ return res;
282
+ } catch (e) {
283
+ error.value = e;
284
+ onError == null ? void 0 : onError(e);
285
+ throw e;
286
+ } finally {
287
+ loading.value = false;
288
+ }
289
+ }
290
+ function get(url, data2) {
291
+ return run({ url, method: "GET", data: data2 });
292
+ }
293
+ function post(url, data2) {
294
+ return run({ url, method: "POST", data: data2 });
295
+ }
296
+ function put(url, data2) {
297
+ return run({ url, method: "PUT", data: data2 });
298
+ }
299
+ function del(url, data2) {
300
+ return run({ url, method: "DELETE", data: data2 });
301
+ }
302
+ return { loading, data, error, run, get, post, put, del };
303
+ }
304
+ function useUpload() {
305
+ const uploading = ref(false);
306
+ async function upload(options) {
307
+ uploading.value = true;
308
+ try {
309
+ return await http.upload(options);
310
+ } finally {
311
+ uploading.value = false;
312
+ }
313
+ }
314
+ return { uploading, upload };
315
+ }
316
+ function useLoading() {
317
+ function showLoading(message = "加载中...") {
318
+ uni.showLoading({ title: message, mask: true });
319
+ }
320
+ function hideLoading() {
321
+ uni.hideLoading();
322
+ }
323
+ return {
324
+ showLoading,
325
+ hideLoading
326
+ };
327
+ }
328
+ function useMsg() {
329
+ function toast(opts) {
330
+ const normalized = typeof opts === "string" ? { message: opts } : opts;
331
+ const { message, icon = "none", image, duration = 2e3, mask = false, position = "center" } = normalized;
332
+ uni.showToast({ title: message, icon, image, duration, mask, position });
333
+ }
334
+ function success(message) {
335
+ uni.showToast({ title: message, icon: "success", duration: 2e3 });
336
+ }
337
+ function error(message) {
338
+ uni.showToast({ title: message, icon: "fail", duration: 2e3 });
339
+ }
340
+ function showLoading(message = "加载中...") {
341
+ uni.showLoading({ title: message, mask: true });
342
+ }
343
+ function hideLoading() {
344
+ uni.hideLoading();
345
+ }
346
+ function confirm(opts) {
347
+ return new Promise((resolve) => {
348
+ const {
349
+ title = "提示",
350
+ content,
351
+ confirmText = "确定",
352
+ cancelText = "取消",
353
+ confirmColor = "#3b82f6",
354
+ cancelColor = "#999999"
355
+ } = opts;
356
+ uni.showModal({
357
+ title,
358
+ content,
359
+ confirmText,
360
+ cancelText,
361
+ confirmColor,
362
+ cancelColor,
363
+ success: (res) => resolve(res.confirm),
364
+ fail: () => resolve(false)
365
+ });
366
+ });
367
+ }
368
+ function modal(opts) {
369
+ return confirm(opts);
370
+ }
371
+ function setLoadingBar(progress) {
372
+ const clamped = Math.max(0, Math.min(100, progress));
373
+ uni.setNavigationBarTitle({
374
+ title: `${"■".repeat(Math.round(clamped / 2))}${"□".repeat(50 - Math.round(clamped / 2))} ${clamped}%`
375
+ });
376
+ }
377
+ return {
378
+ toast,
379
+ success,
380
+ error,
381
+ fail: error,
382
+ showLoading,
383
+ hideLoading,
384
+ confirm,
385
+ modal,
386
+ setLoadingBar
387
+ };
388
+ }
389
+ const _info = ref(null);
390
+ function tryCall(fn) {
391
+ try {
392
+ return (fn == null ? void 0 : fn()) ?? {};
393
+ } catch {
394
+ return {};
395
+ }
396
+ }
397
+ function collect() {
398
+ var _a;
399
+ let deviceInfo = tryCall(uni.getDeviceInfo);
400
+ let windowInfo = tryCall(uni.getWindowInfo);
401
+ let appBaseInfo = tryCall(uni.getAppBaseInfo);
402
+ if (!deviceInfo.brand && !deviceInfo.model) {
403
+ const sys = tryCall(() => uni.getSystemInfoSync());
404
+ deviceInfo = { ...sys };
405
+ windowInfo = { ...sys };
406
+ appBaseInfo = { ...sys };
407
+ }
408
+ let appid = "";
409
+ try {
410
+ const accountInfo = uni.getAccountInfoSync();
411
+ appid = ((_a = accountInfo == null ? void 0 : accountInfo.miniProgram) == null ? void 0 : _a.appId) || "";
412
+ } catch {
413
+ appid = deviceInfo.appId || "";
414
+ }
415
+ const system = deviceInfo.system || "";
416
+ return {
417
+ appid,
418
+ app_name: appBaseInfo.appName || "",
419
+ app_version: appBaseInfo.appVersion || "",
420
+ app_version_code: appBaseInfo.appVersionCode || "",
421
+ app_channel: appBaseInfo.appChannel || "",
422
+ device_brand: deviceInfo.brand || "",
423
+ device_model: deviceInfo.model || "",
424
+ device_id: deviceInfo.deviceId || "",
425
+ device_type: deviceInfo.deviceType || "",
426
+ device_orientation: windowInfo.deviceOrientation || "portrait",
427
+ brand: deviceInfo.brand || "",
428
+ model: deviceInfo.model || "",
429
+ system,
430
+ os: system.split(" ")[0] || "",
431
+ pixel_ratio: windowInfo.pixelRatio || 0,
432
+ screen_width: windowInfo.screenWidth || 0,
433
+ screen_height: windowInfo.screenHeight || 0,
434
+ window_width: windowInfo.windowWidth || 0,
435
+ window_height: windowInfo.windowHeight || 0,
436
+ status_bar_height: windowInfo.statusBarHeight || 0,
437
+ sdk_version: appBaseInfo.SDKVersion || "",
438
+ host_name: appBaseInfo.hostName || "",
439
+ host_version: appBaseInfo.hostVersion || "",
440
+ host_language: appBaseInfo.hostLanguage || "",
441
+ host_theme: appBaseInfo.hostTheme || "",
442
+ platform: deviceInfo.platform || "",
443
+ language: appBaseInfo.language || "",
444
+ version: appBaseInfo.version || ""
445
+ };
446
+ }
447
+ function ensure() {
448
+ if (!_info.value) {
449
+ _info.value = collect();
450
+ }
451
+ }
452
+ function useDevice() {
453
+ ensure();
454
+ return _info;
455
+ }
456
+ function deviceToQuery() {
457
+ ensure();
458
+ if (!_info.value)
459
+ return "";
460
+ return Object.entries(_info.value).filter(([, v]) => v !== "" && v !== 0).map(([k, v]) => `${k}=${encodeURIComponent(String(v))}`).join("&");
461
+ }
462
+ function clearDeviceCache() {
463
+ _info.value = null;
464
+ }
465
+ function useRefs() {
466
+ const refs = ref({});
467
+ onBeforeUpdate(() => {
468
+ refs.value = {};
469
+ });
470
+ onUnmounted(() => {
471
+ refs.value = {};
472
+ });
473
+ const setRefs = (key) => (el) => {
474
+ if (el)
475
+ refs.value[key] = el;
476
+ };
477
+ return { refs, setRefs };
478
+ }
479
+ function usePageMeta() {
480
+ function setTitle(title) {
481
+ uni.setNavigationBarTitle({ title });
482
+ }
483
+ function setOptions(options) {
484
+ if (options.title || options.navigationBarTitleText) {
485
+ setTitle(options.title || options.navigationBarTitleText);
486
+ }
487
+ if (options.navigationBarBackgroundColor || options.navigationBarTextStyle) {
488
+ uni.setNavigationBarColor({
489
+ frontColor: options.navigationBarTextStyle === "white" ? "#ffffff" : "#000000",
490
+ backgroundColor: options.navigationBarBackgroundColor ?? "#ffffff"
491
+ });
492
+ }
493
+ if (options.backgroundColor) {
494
+ uni.setBackgroundColor({ backgroundColor: options.backgroundColor });
495
+ }
496
+ if (options.enablePullDownRefresh !== void 0) {
497
+ uni.setBackgroundTextStyle({ textStyle: "dark" });
498
+ }
499
+ }
500
+ return {
501
+ setTitle,
502
+ setOptions
503
+ };
504
+ }
505
+ function useStorage() {
506
+ function get(key) {
507
+ try {
508
+ const value = uni.getStorageSync(key);
509
+ return value ?? null;
510
+ } catch {
511
+ return null;
512
+ }
513
+ }
514
+ function set(key, value) {
515
+ try {
516
+ uni.setStorageSync(key, value);
517
+ return true;
518
+ } catch {
519
+ return false;
520
+ }
521
+ }
522
+ function remove(key) {
523
+ try {
524
+ uni.removeStorageSync(key);
525
+ return true;
526
+ } catch {
527
+ return false;
528
+ }
529
+ }
530
+ function clear() {
531
+ try {
532
+ uni.clearStorageSync();
533
+ return true;
534
+ } catch {
535
+ return false;
536
+ }
537
+ }
538
+ function info() {
539
+ try {
540
+ return uni.getStorageInfoSync();
541
+ } catch {
542
+ return null;
543
+ }
544
+ }
545
+ return { get, set, remove, clear, info };
546
+ }
547
+ function useValidate() {
548
+ function phone(value) {
549
+ return /^1[3-9]\d{9}$/.test(value);
550
+ }
551
+ function email(value) {
552
+ return /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(value);
553
+ }
554
+ function url(value) {
555
+ try {
556
+ new URL(value);
557
+ return true;
558
+ } catch {
559
+ return false;
560
+ }
561
+ }
562
+ function idCard(value) {
563
+ return /^[1-9]\d{5}(18|19|20)\d{2}(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])\d{3}[\dXx]$/.test(value);
564
+ }
565
+ function carNumber(value) {
566
+ return /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领][A-Z][A-Z0-9]{5}$/.test(value);
567
+ }
568
+ function password(value) {
569
+ return /^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{8,}$/.test(value);
570
+ }
571
+ function empty(value) {
572
+ if (value == null)
573
+ return true;
574
+ if (typeof value === "string")
575
+ return value.trim() === "";
576
+ if (Array.isArray(value))
577
+ return value.length === 0;
578
+ if (typeof value === "object")
579
+ return Object.keys(value).length === 0;
580
+ return false;
581
+ }
582
+ return {
583
+ phone,
584
+ email,
585
+ url,
586
+ idCard,
587
+ carNumber,
588
+ password,
589
+ empty
590
+ };
591
+ }
592
+ function useFormat() {
593
+ function date(date2, format = "YYYY-MM-DD HH:mm:ss") {
594
+ const d = new Date(date2);
595
+ if (isNaN(d.getTime()))
596
+ return "";
597
+ const year = d.getFullYear();
598
+ const month = String(d.getMonth() + 1).padStart(2, "0");
599
+ const day = String(d.getDate()).padStart(2, "0");
600
+ const hours = String(d.getHours()).padStart(2, "0");
601
+ const minutes = String(d.getMinutes()).padStart(2, "0");
602
+ const seconds = String(d.getSeconds()).padStart(2, "0");
603
+ return format.replace("YYYY", String(year)).replace("MM", month).replace("DD", day).replace("HH", hours).replace("mm", minutes).replace("ss", seconds);
604
+ }
605
+ function fileSize(bytes) {
606
+ if (bytes === 0)
607
+ return "0 B";
608
+ const k = 1024;
609
+ const sizes = ["B", "KB", "MB", "GB", "TB"];
610
+ const i = Math.floor(Math.log(bytes) / Math.log(k));
611
+ return `${parseFloat((bytes / Math.pow(k, i)).toFixed(2))} ${sizes[i]}`;
612
+ }
613
+ function phone(value) {
614
+ return value.replace(/(\d{3})\d{4}(\d{4})/, "$1****$2");
615
+ }
616
+ function money(amount, decimals = 2, decPoint = ".", thousandsSep = ",") {
617
+ return amount.toFixed(decimals).replace(/\B(?=(\d{3})+(?!\d))/g, thousandsSep);
618
+ }
619
+ return { date, fileSize, phone, money };
620
+ }
621
+ function unwrapPayload(raw) {
622
+ if (raw == null)
623
+ return null;
624
+ if (typeof raw === "object" && "code" in raw && typeof raw.code === "number") {
625
+ const env = raw;
626
+ return env.code === 1 && env.data ? env.data : null;
627
+ }
628
+ return raw;
629
+ }
630
+ const EMPTY = {
631
+ banner_unit_id: "",
632
+ grid_unit_id: "",
633
+ custom_unit_id: "",
634
+ video_unit_id: "",
635
+ reward_unit_id: "",
636
+ popup_unit_id: ""
637
+ };
638
+ let adapter$1 = null;
639
+ function setConfigAd(a) {
640
+ adapter$1 = a;
641
+ }
642
+ const useAdStore = defineStore("hlw_ad", () => {
643
+ const config2 = ref({ ...EMPTY });
644
+ const loaded = ref(false);
645
+ return { config: config2, loaded };
646
+ });
647
+ let _msg$1 = null;
648
+ const msg = () => _msg$1 ?? (_msg$1 = useMsg());
649
+ const rewardedCache = /* @__PURE__ */ new Map();
650
+ const interstitialCache = /* @__PURE__ */ new Map();
651
+ function useAd() {
652
+ const store = useAdStore();
653
+ const { config: config2, loaded } = storeToRefs(store);
654
+ async function loadConfig2(force = false) {
655
+ if (loaded.value && !force)
656
+ return;
657
+ if (!(adapter$1 == null ? void 0 : adapter$1.getConfig)) {
658
+ console.warn("[useAd] adapter.getConfig 未注入;先调用 setConfigAd()");
659
+ return;
660
+ }
661
+ try {
662
+ const cfg = unwrapPayload(await adapter$1.getConfig());
663
+ if (cfg) {
664
+ store.config = cfg;
665
+ store.loaded = true;
666
+ }
667
+ } catch (e) {
668
+ console.warn("[useAd] load config failed", e);
669
+ }
670
+ }
671
+ function getUnitId(type) {
672
+ return store.config[`${type}_unit_id`] || "";
673
+ }
674
+ async function showReward(claim) {
675
+ const unitId = getUnitId("reward");
676
+ if (!unitId) {
677
+ msg().toast("激励广告未配置");
678
+ return false;
679
+ }
680
+ if ((adapter$1 == null ? void 0 : adapter$1.isAuth) && !adapter$1.isAuth()) {
681
+ msg().toast("请先登录");
682
+ return false;
683
+ }
684
+ while (true) {
685
+ const closeRes = await playRewardedOnce(unitId);
686
+ if (!claim) {
687
+ if (closeRes.isEnded)
688
+ return true;
689
+ const goon = await confirmReward();
690
+ if (!goon)
691
+ return false;
692
+ continue;
693
+ }
694
+ try {
695
+ const r = await claim(closeRes);
696
+ if (r.retry)
697
+ continue;
698
+ if (!r.ok) {
699
+ if (r.msg)
700
+ msg().error(r.msg);
701
+ return false;
702
+ }
703
+ if (r.reward && r.reward > 0)
704
+ msg().success(`+${r.reward} 积分`);
705
+ return true;
706
+ } catch (e) {
707
+ console.warn("[useAd] claim failed", e);
708
+ msg().error("领取失败,请稍后再试");
709
+ return false;
710
+ }
711
+ }
712
+ }
713
+ async function showPopup() {
714
+ const unitId = getUnitId("popup");
715
+ if (!unitId)
716
+ return false;
717
+ return await showInterstitialAd(unitId);
718
+ }
719
+ return {
720
+ // 状态
721
+ config: config2,
722
+ loaded,
723
+ // 方法
724
+ loadConfig: loadConfig2,
725
+ getUnitId,
726
+ showReward,
727
+ showPopup
728
+ };
729
+ }
730
+ async function playRewardedOnce(unitId) {
731
+ msg().showLoading("广告加载中");
732
+ let hidden = false;
733
+ const hide = () => {
734
+ if (hidden)
735
+ return;
736
+ hidden = true;
737
+ msg().hideLoading();
738
+ };
739
+ try {
740
+ const isEnded = await showRewardedAd(unitId, { onShown: hide });
741
+ return { isEnded };
742
+ } finally {
743
+ hide();
744
+ }
745
+ }
746
+ function confirmReward() {
747
+ return new Promise((resolve) => {
748
+ uni.showModal({
749
+ title: "提示",
750
+ content: "看完广告才可以领取奖励哦,要继续观看吗?",
751
+ confirmText: "继续观看",
752
+ cancelText: "放弃",
753
+ success: (r) => resolve(!!r.confirm),
754
+ fail: () => resolve(false)
755
+ });
756
+ });
757
+ }
758
+ function showRewardedAd(unitId, hooks) {
759
+ return new Promise((resolve) => {
760
+ var _a;
761
+ let entry = rewardedCache.get(unitId);
762
+ if (!entry) {
763
+ const ad2 = uni.createRewardedVideoAd({ adUnitId: unitId });
764
+ if (!ad2) {
765
+ resolve(false);
766
+ return;
767
+ }
768
+ (_a = ad2.onError) == null ? void 0 : _a.call(ad2, (err) => {
769
+ console.warn(`[useAd] reward onError (${unitId})`, err);
770
+ });
771
+ entry = { ad: ad2, loading: false };
772
+ rewardedCache.set(unitId, entry);
773
+ }
774
+ const { ad } = entry;
775
+ let closeHandler = null;
776
+ let errorHandler = null;
777
+ const cleanup = () => {
778
+ var _a2, _b;
779
+ if (closeHandler) {
780
+ (_a2 = ad.offClose) == null ? void 0 : _a2.call(ad, closeHandler);
781
+ closeHandler = null;
782
+ }
783
+ if (errorHandler) {
784
+ (_b = ad.offError) == null ? void 0 : _b.call(ad, errorHandler);
785
+ errorHandler = null;
786
+ }
787
+ };
788
+ closeHandler = (res) => {
789
+ cleanup();
790
+ resolve(!!(res && res.isEnded));
791
+ };
792
+ errorHandler = (err) => {
793
+ console.warn(`[useAd] reward show error (${unitId})`, err);
794
+ cleanup();
795
+ resolve(false);
796
+ };
797
+ ad.onClose(closeHandler);
798
+ ad.onError(errorHandler);
799
+ const doShow = () => ad.show().then(() => {
800
+ var _a2;
801
+ try {
802
+ (_a2 = hooks == null ? void 0 : hooks.onShown) == null ? void 0 : _a2.call(hooks);
803
+ } catch (e) {
804
+ console.warn("[useAd] onShown error", e);
805
+ }
806
+ }).catch(() => {
807
+ cleanup();
808
+ resolve(false);
809
+ });
810
+ if (entry.loading) {
811
+ Promise.resolve().then(doShow);
812
+ } else {
813
+ entry.loading = true;
814
+ ad.load().then(doShow).catch(doShow).finally(() => {
815
+ if (entry)
816
+ entry.loading = false;
817
+ });
818
+ }
819
+ });
820
+ }
821
+ function showInterstitialAd(unitId) {
822
+ return new Promise((resolve) => {
823
+ var _a;
824
+ let ad = interstitialCache.get(unitId);
825
+ if (!ad) {
826
+ ad = uni.createInterstitialAd({ adUnitId: unitId });
827
+ if (!ad) {
828
+ resolve(false);
829
+ return;
830
+ }
831
+ (_a = ad.onError) == null ? void 0 : _a.call(ad, (err) => {
832
+ console.warn(`[useAd] popup onError (${unitId})`, err);
833
+ });
834
+ interstitialCache.set(unitId, ad);
835
+ }
836
+ ad.show().then(() => resolve(true)).catch(() => {
837
+ if (typeof ad.load !== "function") {
838
+ resolve(false);
839
+ return;
840
+ }
841
+ ad.load().then(() => ad.show()).then(() => resolve(true)).catch(() => resolve(false));
842
+ });
843
+ });
844
+ }
845
+ function destroyAds() {
846
+ rewardedCache.forEach((e) => {
847
+ var _a, _b;
848
+ return (_b = (_a = e.ad) == null ? void 0 : _a.destroy) == null ? void 0 : _b.call(_a);
849
+ });
850
+ rewardedCache.clear();
851
+ interstitialCache.forEach((ad) => {
852
+ var _a;
853
+ return (_a = ad == null ? void 0 : ad.destroy) == null ? void 0 : _a.call(ad);
854
+ });
855
+ interstitialCache.clear();
856
+ }
857
+ function useShare(config2) {
858
+ const resolve = (from) => typeof config2 === "function" ? config2(from) : config2;
859
+ onShareAppMessage((options) => {
860
+ const resolved = resolve((options == null ? void 0 : options.from) ?? "menu");
861
+ const payload = {};
862
+ if (resolved.title !== void 0)
863
+ payload.title = resolved.title;
864
+ if (resolved.path !== void 0)
865
+ payload.path = resolved.path;
866
+ if (resolved.imageUrl !== void 0)
867
+ payload.imageUrl = resolved.imageUrl;
868
+ return payload;
869
+ });
870
+ onShareTimeline(() => {
871
+ const resolved = resolve("menu");
872
+ const timeline = resolved.timeline ?? {};
873
+ const payload = {};
874
+ const title = timeline.title ?? resolved.title;
875
+ const imageUrl = timeline.imageUrl ?? resolved.imageUrl;
876
+ if (title !== void 0)
877
+ payload.title = title;
878
+ if (timeline.query !== void 0)
879
+ payload.query = timeline.query;
880
+ if (imageUrl !== void 0)
881
+ payload.imageUrl = imageUrl;
882
+ return payload;
883
+ });
884
+ }
885
+ let shareAdapter = null;
886
+ const shareCache = ref(null);
887
+ let sharePending = null;
888
+ function setConfigShare(a) {
889
+ shareAdapter = a;
890
+ }
891
+ function loadShareConfig() {
892
+ if (shareCache.value)
893
+ return Promise.resolve();
894
+ if (sharePending)
895
+ return sharePending;
896
+ if (!(shareAdapter == null ? void 0 : shareAdapter.getConfig)) {
897
+ console.warn("[useShareConfig] adapter.getConfig 未注入;先调用 setConfigShare()");
898
+ return Promise.resolve();
899
+ }
900
+ sharePending = shareAdapter.getConfig().then((raw) => {
901
+ const cfg = unwrapPayload(raw);
902
+ if (cfg)
903
+ shareCache.value = cfg;
904
+ }).catch((e) => {
905
+ console.warn("[useShareConfig] load failed", e);
906
+ }).finally(() => {
907
+ sharePending = null;
908
+ });
909
+ return sharePending;
910
+ }
911
+ function useShareConfig(pageKey, fallback) {
912
+ void loadShareConfig();
913
+ return () => {
914
+ var _a;
915
+ const remote = (_a = shareCache.value) == null ? void 0 : _a[pageKey];
916
+ const title = (remote == null ? void 0 : remote.title) || fallback.title;
917
+ const image = (remote == null ? void 0 : remote.image) || fallback.image;
918
+ const payload = { title, path: fallback.path };
919
+ if (image)
920
+ payload.imageUrl = image;
921
+ return payload;
922
+ };
923
+ }
924
+ let adapter = null;
925
+ const config = ref(null);
926
+ let pending = null;
927
+ function setConfigContact(a) {
928
+ adapter = a;
929
+ }
930
+ function loadConfig() {
931
+ if (config.value)
932
+ return Promise.resolve();
933
+ if (pending)
934
+ return pending;
935
+ if (!(adapter == null ? void 0 : adapter.getConfig)) {
936
+ console.warn("[useContact] adapter.getConfig 未注入;先调用 setConfigContact()");
937
+ return Promise.resolve();
938
+ }
939
+ pending = adapter.getConfig().then((raw) => {
940
+ const cfg = unwrapPayload(raw);
941
+ if (cfg)
942
+ config.value = cfg;
943
+ }).catch((e) => {
944
+ console.warn("[useContact] load config failed", e);
945
+ }).finally(() => {
946
+ pending = null;
947
+ });
948
+ return pending;
949
+ }
950
+ function useContact() {
951
+ void loadConfig();
952
+ return computed(() => {
953
+ var _a, _b, _c, _d;
954
+ return {
955
+ sendMessageTitle: ((_a = config.value) == null ? void 0 : _a.send_message_title) || "",
956
+ sendMessagePath: ((_b = config.value) == null ? void 0 : _b.send_message_path) || "",
957
+ sendMessageImg: ((_c = config.value) == null ? void 0 : _c.send_message_img) || "",
958
+ showMessageCard: ((_d = config.value) == null ? void 0 : _d.show_message_card) ?? false
959
+ };
960
+ });
961
+ }
962
+ function useUtils() {
963
+ function copy(data, showToast = true) {
964
+ return new Promise((resolve) => {
965
+ uni.setClipboardData({
966
+ data,
967
+ showToast: false,
968
+ success: () => {
969
+ if (showToast) {
970
+ uni.showToast({ title: "复制成功", icon: "none", duration: 1500 });
971
+ }
972
+ resolve(true);
973
+ },
974
+ fail: () => resolve(false)
975
+ });
976
+ });
977
+ }
978
+ function copyFromEvent(event) {
979
+ var _a;
980
+ const dataset = (_a = event == null ? void 0 : event.currentTarget) == null ? void 0 : _a.dataset;
981
+ const text = dataset == null ? void 0 : dataset.copy;
982
+ if (text == null || text === "")
983
+ return;
984
+ const showToast = (dataset == null ? void 0 : dataset.copyToast) !== "false";
985
+ copy(String(text), showToast);
986
+ }
987
+ function paste() {
988
+ return new Promise((resolve) => {
989
+ uni.getClipboardData({
990
+ success: (res) => resolve(res.data),
991
+ fail: () => resolve("")
992
+ });
993
+ });
994
+ }
995
+ function saveImage(filePath) {
996
+ return new Promise((resolve) => {
997
+ uni.saveImageToPhotosAlbum({
998
+ filePath,
999
+ success: () => {
1000
+ uni.showToast({ title: "保存成功", icon: "success" });
1001
+ resolve(true);
1002
+ },
1003
+ fail: (err) => {
1004
+ if (err.errMsg.includes("auth deny") || err.errMsg.includes("authorize")) {
1005
+ uni.showModal({
1006
+ title: "提示",
1007
+ content: "需要授权相册权限",
1008
+ confirmText: "去设置",
1009
+ success: (res) => {
1010
+ if (res.confirm)
1011
+ uni.openSetting();
1012
+ }
1013
+ });
1014
+ } else {
1015
+ uni.showToast({ title: "保存失败", icon: "none" });
1016
+ }
1017
+ resolve(false);
1018
+ }
1019
+ });
1020
+ });
1021
+ }
1022
+ function downloadFile(options) {
1023
+ return new Promise((resolve) => {
1024
+ const task = uni.downloadFile({
1025
+ url: options.url,
1026
+ filePath: options.filePath,
1027
+ header: options.header,
1028
+ success: (res) => {
1029
+ if (res.statusCode === 200) {
1030
+ resolve({ success: true, tempFilePath: res.tempFilePath, statusCode: res.statusCode });
1031
+ } else {
1032
+ resolve({ success: false, statusCode: res.statusCode, errMsg: `下载失败,状态码:${res.statusCode}` });
1033
+ }
1034
+ },
1035
+ fail: (err) => resolve({ success: false, errMsg: err.errMsg })
1036
+ });
1037
+ if (options.onProgress) {
1038
+ task.onProgressUpdate((res) => {
1039
+ options.onProgress(res.progress, res.totalBytesWritten, res.totalBytesExpectedToWrite);
1040
+ });
1041
+ }
1042
+ });
1043
+ }
1044
+ async function downloadAndSaveImage(url, onProgress) {
1045
+ try {
1046
+ uni.showLoading({ title: "下载中...", mask: true });
1047
+ const result = await downloadFile({
1048
+ url,
1049
+ onProgress: onProgress ? (progress) => onProgress(progress) : void 0
1050
+ });
1051
+ uni.hideLoading();
1052
+ if (!result.success || !result.tempFilePath) {
1053
+ uni.showToast({ title: result.errMsg || "下载失败", icon: "none" });
1054
+ return false;
1055
+ }
1056
+ return await saveImage(result.tempFilePath);
1057
+ } catch {
1058
+ uni.hideLoading();
1059
+ uni.showToast({ title: "操作失败", icon: "none" });
1060
+ return false;
1061
+ }
1062
+ }
1063
+ return { copy, copyFromEvent, paste, saveImage, downloadFile, downloadAndSaveImage };
1064
+ }
1065
+ const HEX_RE = /^#[0-9a-fA-F]{6}$/;
1066
+ function parseHex(hex) {
1067
+ if (!HEX_RE.test(hex))
1068
+ throw new Error(`Invalid hex color: ${hex}`);
1069
+ return [
1070
+ parseInt(hex.slice(1, 3), 16),
1071
+ parseInt(hex.slice(3, 5), 16),
1072
+ parseInt(hex.slice(5, 7), 16)
1073
+ ];
1074
+ }
1075
+ function useColor() {
1076
+ function varsToStyle2(vars) {
1077
+ return Object.entries(vars).map(([k, v]) => `${k}:${v}`).join(";") + ";";
1078
+ }
1079
+ function hexToRgba2(hex, alpha) {
1080
+ const [r, g, b] = parseHex(hex);
1081
+ return `rgba(${r},${g},${b},${alpha})`;
1082
+ }
1083
+ function darkenHex2(hex, amount = 0.15) {
1084
+ const [r, g, b] = parseHex(hex);
1085
+ const d = (c) => Math.max(0, Math.round(c * (1 - amount)));
1086
+ return `#${d(r).toString(16).padStart(2, "0")}${d(g).toString(16).padStart(2, "0")}${d(b).toString(16).padStart(2, "0")}`;
1087
+ }
1088
+ return { varsToStyle: varsToStyle2, hexToRgba: hexToRgba2, darkenHex: darkenHex2 };
1089
+ }
1090
+ function doNavigate(type, value, options = {}) {
1091
+ var _a;
1092
+ const { onFail, silent = false } = options;
1093
+ if (!value) {
1094
+ if (!silent)
1095
+ uni.showToast({ title: "跳转目标未配置", icon: "none" });
1096
+ onFail == null ? void 0 : onFail("跳转目标未配置");
1097
+ return;
1098
+ }
1099
+ const fail = (err) => {
1100
+ const msg2 = (err == null ? void 0 : err.errMsg) || `无法跳转:${value}`;
1101
+ if (!silent)
1102
+ uni.showToast({ title: msg2, icon: "none" });
1103
+ onFail == null ? void 0 : onFail(msg2);
1104
+ };
1105
+ switch (type) {
1106
+ case "switchTab":
1107
+ uni.switchTab({ url: value, fail });
1108
+ break;
1109
+ case "redirectTo":
1110
+ uni.redirectTo({ url: value, fail });
1111
+ break;
1112
+ case "reLaunch":
1113
+ uni.reLaunch({ url: value, fail });
1114
+ break;
1115
+ case "webview":
1116
+ if (!silent)
1117
+ uni.showToast({ title: `H5:${value}`, icon: "none" });
1118
+ break;
1119
+ case "miniprogram": {
1120
+ (_a = uni.navigateToMiniProgram) == null ? void 0 : _a.call(uni, {
1121
+ appId: value,
1122
+ path: options.path || "",
1123
+ envVersion: options.envVersion,
1124
+ extraData: options.extraData,
1125
+ fail
1126
+ });
1127
+ break;
1128
+ }
1129
+ case "navigateTo":
1130
+ default:
1131
+ uni.navigateTo({ url: value, fail });
1132
+ break;
1133
+ }
1134
+ }
1135
+ function useRouter() {
1136
+ return {
1137
+ navigate: doNavigate
1138
+ };
1139
+ }
1140
+ const useThemeStore = defineStore(
1141
+ "theme",
1142
+ () => {
1143
+ const scale = ref("normal");
1144
+ function setScale(s) {
1145
+ scale.value = s;
1146
+ uni.setStorageSync(FONT_SCALE_KEY, s);
1147
+ uni.$emit(THEME_CHANGE_EVENT);
1148
+ }
1149
+ const fontOptions = Object.keys(FONT_PRESETS).map((key) => ({
1150
+ value: key,
1151
+ label: FONT_PRESETS[key].label
1152
+ }));
1153
+ const primaryColor = ref(DEFAULT_THEMES[0].value);
1154
+ const themes = DEFAULT_THEMES;
1155
+ const activeTheme = computed(
1156
+ () => themes.find((t) => t.value === primaryColor.value) ?? { label: "自定义", value: primaryColor.value }
1157
+ );
1158
+ function setTheme(color) {
1159
+ primaryColor.value = color;
1160
+ uni.setStorageSync(THEME_COLOR_KEY, color);
1161
+ uni.$emit(THEME_CHANGE_EVENT);
1162
+ }
1163
+ const appearance = ref("auto");
1164
+ const appearanceOptions = APPEARANCE_PRESETS;
1165
+ const appearanceMode = computed(() => resolveAppearance(appearance.value));
1166
+ const isDark = computed(() => appearanceMode.value === "dark");
1167
+ function setAppearance(a) {
1168
+ appearance.value = a;
1169
+ uni.setStorageSync(APPEARANCE_KEY, a);
1170
+ uni.$emit(THEME_CHANGE_EVENT);
1171
+ }
1172
+ return {
1173
+ // 字体
1174
+ scale,
1175
+ fontOptions,
1176
+ setScale,
1177
+ // 主题色
1178
+ primaryColor,
1179
+ themes,
1180
+ activeTheme,
1181
+ setTheme,
1182
+ // 外观模式
1183
+ appearance,
1184
+ appearanceOptions,
1185
+ appearanceMode,
1186
+ isDark,
1187
+ setAppearance
1188
+ };
1189
+ },
1190
+ { unistorage: true }
1191
+ );
4
1192
  const FONT_SCALE_KEY = "hlw_font_scale";
5
1193
  const FONT_PRESETS = {
6
1194
  small: {
7
- label: "小字体",
1195
+ label: "较小",
8
1196
  vars: {
9
1197
  "--font-xs": "16rpx",
10
1198
  "--font-sm": "20rpx",
@@ -14,6 +1202,17 @@ const FONT_PRESETS = {
14
1202
  "--font-xl": "36rpx"
15
1203
  }
16
1204
  },
1205
+ compact: {
1206
+ label: "略小",
1207
+ vars: {
1208
+ "--font-xs": "18rpx",
1209
+ "--font-sm": "22rpx",
1210
+ "--font-base": "26rpx",
1211
+ "--font-md": "30rpx",
1212
+ "--font-lg": "34rpx",
1213
+ "--font-xl": "38rpx"
1214
+ }
1215
+ },
17
1216
  normal: {
18
1217
  label: "标准",
19
1218
  vars: {
@@ -25,8 +1224,19 @@ const FONT_PRESETS = {
25
1224
  "--font-xl": "40rpx"
26
1225
  }
27
1226
  },
1227
+ medium: {
1228
+ label: "适中",
1229
+ vars: {
1230
+ "--font-xs": "22rpx",
1231
+ "--font-sm": "28rpx",
1232
+ "--font-base": "32rpx",
1233
+ "--font-md": "36rpx",
1234
+ "--font-lg": "42rpx",
1235
+ "--font-xl": "46rpx"
1236
+ }
1237
+ },
28
1238
  large: {
29
- label: "大字体",
1239
+ label: "较大",
30
1240
  vars: {
31
1241
  "--font-xs": "24rpx",
32
1242
  "--font-sm": "30rpx",
@@ -37,7 +1247,7 @@ const FONT_PRESETS = {
37
1247
  }
38
1248
  },
39
1249
  xlarge: {
40
- label: "超大字体",
1250
+ label: "超大",
41
1251
  vars: {
42
1252
  "--font-xs": "28rpx",
43
1253
  "--font-sm": "36rpx",
@@ -46,12 +1256,23 @@ const FONT_PRESETS = {
46
1256
  "--font-lg": "56rpx",
47
1257
  "--font-xl": "64rpx"
48
1258
  }
1259
+ },
1260
+ xxlarge: {
1261
+ label: "特大",
1262
+ vars: {
1263
+ "--font-xs": "32rpx",
1264
+ "--font-sm": "42rpx",
1265
+ "--font-base": "48rpx",
1266
+ "--font-md": "56rpx",
1267
+ "--font-lg": "64rpx",
1268
+ "--font-xl": "72rpx"
1269
+ }
49
1270
  }
50
1271
  };
51
1272
  function getCurrentFontScale() {
52
1273
  try {
53
1274
  const v = uni.getStorageSync(FONT_SCALE_KEY);
54
- if (v === "small" || v === "large" || v === "xlarge")
1275
+ if (v === "small" || v === "compact" || v === "medium" || v === "large" || v === "xlarge" || v === "xxlarge")
55
1276
  return v;
56
1277
  } catch {
57
1278
  }
@@ -189,6 +1410,54 @@ function getCurrentAppearanceMode() {
189
1410
  function getCurrentAppearanceVars() {
190
1411
  return APPEARANCE_VAR_MAP[getCurrentAppearanceMode()];
191
1412
  }
1413
+ const TYPOGRAPHY_ROLES = {
1414
+ "title-lg": {
1415
+ size: "var(--font-xl)",
1416
+ weight: "600",
1417
+ lineHeight: "1.2",
1418
+ color: "var(--text-primary)"
1419
+ },
1420
+ "title": {
1421
+ size: "var(--font-md)",
1422
+ weight: "500",
1423
+ lineHeight: "1.3",
1424
+ color: "var(--text-primary)"
1425
+ },
1426
+ "subtitle": {
1427
+ size: "var(--font-base)",
1428
+ weight: "500",
1429
+ lineHeight: "1.3",
1430
+ color: "var(--text-secondary)"
1431
+ },
1432
+ "body": {
1433
+ size: "var(--font-base)",
1434
+ weight: "400",
1435
+ lineHeight: "1.5",
1436
+ color: "var(--text-secondary)"
1437
+ },
1438
+ "desc": {
1439
+ size: "var(--font-sm)",
1440
+ weight: "400",
1441
+ lineHeight: "1.4",
1442
+ color: "var(--text-subtle)"
1443
+ },
1444
+ "caption": {
1445
+ size: "var(--font-xs)",
1446
+ weight: "500",
1447
+ lineHeight: "1.3",
1448
+ color: "var(--text-muted)"
1449
+ }
1450
+ };
1451
+ function getCurrentTypographyVars() {
1452
+ const vars = {};
1453
+ for (const [role, cfg] of Object.entries(TYPOGRAPHY_ROLES)) {
1454
+ vars[`--text-${role}-size`] = cfg.size;
1455
+ vars[`--text-${role}-weight`] = cfg.weight;
1456
+ vars[`--text-${role}-line-height`] = cfg.lineHeight;
1457
+ vars[`--text-${role}-color`] = cfg.color;
1458
+ }
1459
+ return vars;
1460
+ }
192
1461
  const { varsToStyle } = useColor();
193
1462
  const THEME_CHANGE_EVENT = "hlw:theme-change";
194
1463
  function buildThemeStyle() {
@@ -199,78 +1468,479 @@ function buildThemeStyle() {
199
1468
  });
200
1469
  }
201
1470
  function useThemePageStyle() {
202
- const themePageStyle = ref(buildThemeStyle());
203
- const onThemeChange = () => {
204
- themePageStyle.value = buildThemeStyle();
205
- };
206
- onMounted(() => uni.$on(THEME_CHANGE_EVENT, onThemeChange));
207
- onUnmounted(() => uni.$off(THEME_CHANGE_EVENT, onThemeChange));
1471
+ const store = useThemeStore();
1472
+ const themePageStyle = computed(() => {
1473
+ void store.scale;
1474
+ void store.primaryColor;
1475
+ void store.appearance;
1476
+ return buildThemeStyle();
1477
+ });
208
1478
  return { themePageStyle };
209
1479
  }
210
- const useThemeStore = defineStore(
211
- "theme",
212
- () => {
213
- const scale = ref("normal");
214
- function setScale(s) {
215
- scale.value = s;
216
- uni.setStorageSync(FONT_SCALE_KEY, s);
217
- uni.$emit(THEME_CHANGE_EVENT);
1480
+ let _msg = null;
1481
+ let _device = null;
1482
+ let _utils = null;
1483
+ let _color = null;
1484
+ const hlw = {
1485
+ /** 延迟创建消息提示实例。 */
1486
+ get $msg() {
1487
+ return _msg ?? (_msg = useMsg());
1488
+ },
1489
+ /** 延迟读取并缓存设备信息。 */
1490
+ get $device() {
1491
+ return (_device ?? (_device = useDevice())).value;
1492
+ },
1493
+ /** 复用全局 HTTP 实例。 */
1494
+ $http: http,
1495
+ /** 延迟创建通用工具实例。 */
1496
+ get $utils() {
1497
+ return _utils ?? (_utils = useUtils());
1498
+ },
1499
+ /** 延迟创建颜色工具实例。 */
1500
+ get $color() {
1501
+ return _color ?? (_color = useColor());
1502
+ }
1503
+ };
1504
+ function getDefaultExportFromCjs(x) {
1505
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
1506
+ }
1507
+ var md5$1 = { exports: {} };
1508
+ var crypt = { exports: {} };
1509
+ (function() {
1510
+ var base64map = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", crypt$1 = {
1511
+ // Bit-wise rotation left
1512
+ rotl: function(n, b) {
1513
+ return n << b | n >>> 32 - b;
1514
+ },
1515
+ // Bit-wise rotation right
1516
+ rotr: function(n, b) {
1517
+ return n << 32 - b | n >>> b;
1518
+ },
1519
+ // Swap big-endian to little-endian and vice versa
1520
+ endian: function(n) {
1521
+ if (n.constructor == Number) {
1522
+ return crypt$1.rotl(n, 8) & 16711935 | crypt$1.rotl(n, 24) & 4278255360;
1523
+ }
1524
+ for (var i = 0; i < n.length; i++)
1525
+ n[i] = crypt$1.endian(n[i]);
1526
+ return n;
1527
+ },
1528
+ // Generate an array of any length of random bytes
1529
+ randomBytes: function(n) {
1530
+ for (var bytes = []; n > 0; n--)
1531
+ bytes.push(Math.floor(Math.random() * 256));
1532
+ return bytes;
1533
+ },
1534
+ // Convert a byte array to big-endian 32-bit words
1535
+ bytesToWords: function(bytes) {
1536
+ for (var words = [], i = 0, b = 0; i < bytes.length; i++, b += 8)
1537
+ words[b >>> 5] |= bytes[i] << 24 - b % 32;
1538
+ return words;
1539
+ },
1540
+ // Convert big-endian 32-bit words to a byte array
1541
+ wordsToBytes: function(words) {
1542
+ for (var bytes = [], b = 0; b < words.length * 32; b += 8)
1543
+ bytes.push(words[b >>> 5] >>> 24 - b % 32 & 255);
1544
+ return bytes;
1545
+ },
1546
+ // Convert a byte array to a hex string
1547
+ bytesToHex: function(bytes) {
1548
+ for (var hex = [], i = 0; i < bytes.length; i++) {
1549
+ hex.push((bytes[i] >>> 4).toString(16));
1550
+ hex.push((bytes[i] & 15).toString(16));
1551
+ }
1552
+ return hex.join("");
1553
+ },
1554
+ // Convert a hex string to a byte array
1555
+ hexToBytes: function(hex) {
1556
+ for (var bytes = [], c = 0; c < hex.length; c += 2)
1557
+ bytes.push(parseInt(hex.substr(c, 2), 16));
1558
+ return bytes;
1559
+ },
1560
+ // Convert a byte array to a base-64 string
1561
+ bytesToBase64: function(bytes) {
1562
+ for (var base64 = [], i = 0; i < bytes.length; i += 3) {
1563
+ var triplet = bytes[i] << 16 | bytes[i + 1] << 8 | bytes[i + 2];
1564
+ for (var j = 0; j < 4; j++)
1565
+ if (i * 8 + j * 6 <= bytes.length * 8)
1566
+ base64.push(base64map.charAt(triplet >>> 6 * (3 - j) & 63));
1567
+ else
1568
+ base64.push("=");
1569
+ }
1570
+ return base64.join("");
1571
+ },
1572
+ // Convert a base-64 string to a byte array
1573
+ base64ToBytes: function(base64) {
1574
+ base64 = base64.replace(/[^A-Z0-9+\/]/ig, "");
1575
+ for (var bytes = [], i = 0, imod4 = 0; i < base64.length; imod4 = ++i % 4) {
1576
+ if (imod4 == 0)
1577
+ continue;
1578
+ bytes.push((base64map.indexOf(base64.charAt(i - 1)) & Math.pow(2, -2 * imod4 + 8) - 1) << imod4 * 2 | base64map.indexOf(base64.charAt(i)) >>> 6 - imod4 * 2);
1579
+ }
1580
+ return bytes;
218
1581
  }
219
- const fontOptions = Object.keys(FONT_PRESETS).map((key) => ({
220
- value: key,
221
- label: FONT_PRESETS[key].label
222
- }));
223
- const primaryColor = ref(DEFAULT_THEMES[0].value);
224
- const themes = DEFAULT_THEMES;
225
- const activeTheme = computed(
226
- () => themes.find((t) => t.value === primaryColor.value) ?? { label: "自定义", value: primaryColor.value }
227
- );
228
- function setTheme(color) {
229
- primaryColor.value = color;
230
- uni.setStorageSync(THEME_COLOR_KEY, color);
231
- uni.$emit(THEME_CHANGE_EVENT);
1582
+ };
1583
+ crypt.exports = crypt$1;
1584
+ })();
1585
+ var cryptExports = crypt.exports;
1586
+ var charenc = {
1587
+ // UTF-8 encoding
1588
+ utf8: {
1589
+ // Convert a string to a byte array
1590
+ stringToBytes: function(str) {
1591
+ return charenc.bin.stringToBytes(unescape(encodeURIComponent(str)));
1592
+ },
1593
+ // Convert a byte array to a string
1594
+ bytesToString: function(bytes) {
1595
+ return decodeURIComponent(escape(charenc.bin.bytesToString(bytes)));
232
1596
  }
233
- const appearance = ref("auto");
234
- const appearanceOptions = APPEARANCE_PRESETS;
235
- const appearanceMode = computed(() => resolveAppearance(appearance.value));
236
- const isDark = computed(() => appearanceMode.value === "dark");
237
- function setAppearance(a) {
238
- appearance.value = a;
239
- uni.setStorageSync(APPEARANCE_KEY, a);
240
- uni.$emit(THEME_CHANGE_EVENT);
1597
+ },
1598
+ // Binary encoding
1599
+ bin: {
1600
+ // Convert a string to a byte array
1601
+ stringToBytes: function(str) {
1602
+ for (var bytes = [], i = 0; i < str.length; i++)
1603
+ bytes.push(str.charCodeAt(i) & 255);
1604
+ return bytes;
1605
+ },
1606
+ // Convert a byte array to a string
1607
+ bytesToString: function(bytes) {
1608
+ for (var str = [], i = 0; i < bytes.length; i++)
1609
+ str.push(String.fromCharCode(bytes[i]));
1610
+ return str.join("");
241
1611
  }
242
- return {
243
- // 字体
244
- scale,
245
- fontOptions,
246
- setScale,
247
- // 主题色
248
- primaryColor,
249
- themes,
250
- activeTheme,
251
- setTheme,
252
- // 外观模式
253
- appearance,
254
- appearanceOptions,
255
- appearanceMode,
256
- isDark,
257
- setAppearance
258
- };
1612
+ }
1613
+ };
1614
+ var charenc_1 = charenc;
1615
+ /*!
1616
+ * Determine if an object is a Buffer
1617
+ *
1618
+ * @author Feross Aboukhadijeh <https://feross.org>
1619
+ * @license MIT
1620
+ */
1621
+ var isBuffer_1 = function(obj) {
1622
+ return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer);
1623
+ };
1624
+ function isBuffer(obj) {
1625
+ return !!obj.constructor && typeof obj.constructor.isBuffer === "function" && obj.constructor.isBuffer(obj);
1626
+ }
1627
+ function isSlowBuffer(obj) {
1628
+ return typeof obj.readFloatLE === "function" && typeof obj.slice === "function" && isBuffer(obj.slice(0, 0));
1629
+ }
1630
+ (function() {
1631
+ var crypt2 = cryptExports, utf8 = charenc_1.utf8, isBuffer2 = isBuffer_1, bin = charenc_1.bin, md52 = function(message, options) {
1632
+ if (message.constructor == String)
1633
+ if (options && options.encoding === "binary")
1634
+ message = bin.stringToBytes(message);
1635
+ else
1636
+ message = utf8.stringToBytes(message);
1637
+ else if (isBuffer2(message))
1638
+ message = Array.prototype.slice.call(message, 0);
1639
+ else if (!Array.isArray(message) && message.constructor !== Uint8Array)
1640
+ message = message.toString();
1641
+ var m = crypt2.bytesToWords(message), l = message.length * 8, a = 1732584193, b = -271733879, c = -1732584194, d = 271733878;
1642
+ for (var i = 0; i < m.length; i++) {
1643
+ m[i] = (m[i] << 8 | m[i] >>> 24) & 16711935 | (m[i] << 24 | m[i] >>> 8) & 4278255360;
1644
+ }
1645
+ m[l >>> 5] |= 128 << l % 32;
1646
+ m[(l + 64 >>> 9 << 4) + 14] = l;
1647
+ var FF = md52._ff, GG = md52._gg, HH = md52._hh, II = md52._ii;
1648
+ for (var i = 0; i < m.length; i += 16) {
1649
+ var aa = a, bb = b, cc = c, dd = d;
1650
+ a = FF(a, b, c, d, m[i + 0], 7, -680876936);
1651
+ d = FF(d, a, b, c, m[i + 1], 12, -389564586);
1652
+ c = FF(c, d, a, b, m[i + 2], 17, 606105819);
1653
+ b = FF(b, c, d, a, m[i + 3], 22, -1044525330);
1654
+ a = FF(a, b, c, d, m[i + 4], 7, -176418897);
1655
+ d = FF(d, a, b, c, m[i + 5], 12, 1200080426);
1656
+ c = FF(c, d, a, b, m[i + 6], 17, -1473231341);
1657
+ b = FF(b, c, d, a, m[i + 7], 22, -45705983);
1658
+ a = FF(a, b, c, d, m[i + 8], 7, 1770035416);
1659
+ d = FF(d, a, b, c, m[i + 9], 12, -1958414417);
1660
+ c = FF(c, d, a, b, m[i + 10], 17, -42063);
1661
+ b = FF(b, c, d, a, m[i + 11], 22, -1990404162);
1662
+ a = FF(a, b, c, d, m[i + 12], 7, 1804603682);
1663
+ d = FF(d, a, b, c, m[i + 13], 12, -40341101);
1664
+ c = FF(c, d, a, b, m[i + 14], 17, -1502002290);
1665
+ b = FF(b, c, d, a, m[i + 15], 22, 1236535329);
1666
+ a = GG(a, b, c, d, m[i + 1], 5, -165796510);
1667
+ d = GG(d, a, b, c, m[i + 6], 9, -1069501632);
1668
+ c = GG(c, d, a, b, m[i + 11], 14, 643717713);
1669
+ b = GG(b, c, d, a, m[i + 0], 20, -373897302);
1670
+ a = GG(a, b, c, d, m[i + 5], 5, -701558691);
1671
+ d = GG(d, a, b, c, m[i + 10], 9, 38016083);
1672
+ c = GG(c, d, a, b, m[i + 15], 14, -660478335);
1673
+ b = GG(b, c, d, a, m[i + 4], 20, -405537848);
1674
+ a = GG(a, b, c, d, m[i + 9], 5, 568446438);
1675
+ d = GG(d, a, b, c, m[i + 14], 9, -1019803690);
1676
+ c = GG(c, d, a, b, m[i + 3], 14, -187363961);
1677
+ b = GG(b, c, d, a, m[i + 8], 20, 1163531501);
1678
+ a = GG(a, b, c, d, m[i + 13], 5, -1444681467);
1679
+ d = GG(d, a, b, c, m[i + 2], 9, -51403784);
1680
+ c = GG(c, d, a, b, m[i + 7], 14, 1735328473);
1681
+ b = GG(b, c, d, a, m[i + 12], 20, -1926607734);
1682
+ a = HH(a, b, c, d, m[i + 5], 4, -378558);
1683
+ d = HH(d, a, b, c, m[i + 8], 11, -2022574463);
1684
+ c = HH(c, d, a, b, m[i + 11], 16, 1839030562);
1685
+ b = HH(b, c, d, a, m[i + 14], 23, -35309556);
1686
+ a = HH(a, b, c, d, m[i + 1], 4, -1530992060);
1687
+ d = HH(d, a, b, c, m[i + 4], 11, 1272893353);
1688
+ c = HH(c, d, a, b, m[i + 7], 16, -155497632);
1689
+ b = HH(b, c, d, a, m[i + 10], 23, -1094730640);
1690
+ a = HH(a, b, c, d, m[i + 13], 4, 681279174);
1691
+ d = HH(d, a, b, c, m[i + 0], 11, -358537222);
1692
+ c = HH(c, d, a, b, m[i + 3], 16, -722521979);
1693
+ b = HH(b, c, d, a, m[i + 6], 23, 76029189);
1694
+ a = HH(a, b, c, d, m[i + 9], 4, -640364487);
1695
+ d = HH(d, a, b, c, m[i + 12], 11, -421815835);
1696
+ c = HH(c, d, a, b, m[i + 15], 16, 530742520);
1697
+ b = HH(b, c, d, a, m[i + 2], 23, -995338651);
1698
+ a = II(a, b, c, d, m[i + 0], 6, -198630844);
1699
+ d = II(d, a, b, c, m[i + 7], 10, 1126891415);
1700
+ c = II(c, d, a, b, m[i + 14], 15, -1416354905);
1701
+ b = II(b, c, d, a, m[i + 5], 21, -57434055);
1702
+ a = II(a, b, c, d, m[i + 12], 6, 1700485571);
1703
+ d = II(d, a, b, c, m[i + 3], 10, -1894986606);
1704
+ c = II(c, d, a, b, m[i + 10], 15, -1051523);
1705
+ b = II(b, c, d, a, m[i + 1], 21, -2054922799);
1706
+ a = II(a, b, c, d, m[i + 8], 6, 1873313359);
1707
+ d = II(d, a, b, c, m[i + 15], 10, -30611744);
1708
+ c = II(c, d, a, b, m[i + 6], 15, -1560198380);
1709
+ b = II(b, c, d, a, m[i + 13], 21, 1309151649);
1710
+ a = II(a, b, c, d, m[i + 4], 6, -145523070);
1711
+ d = II(d, a, b, c, m[i + 11], 10, -1120210379);
1712
+ c = II(c, d, a, b, m[i + 2], 15, 718787259);
1713
+ b = II(b, c, d, a, m[i + 9], 21, -343485551);
1714
+ a = a + aa >>> 0;
1715
+ b = b + bb >>> 0;
1716
+ c = c + cc >>> 0;
1717
+ d = d + dd >>> 0;
1718
+ }
1719
+ return crypt2.endian([a, b, c, d]);
1720
+ };
1721
+ md52._ff = function(a, b, c, d, x, s, t) {
1722
+ var n = a + (b & c | ~b & d) + (x >>> 0) + t;
1723
+ return (n << s | n >>> 32 - s) + b;
1724
+ };
1725
+ md52._gg = function(a, b, c, d, x, s, t) {
1726
+ var n = a + (b & d | c & ~d) + (x >>> 0) + t;
1727
+ return (n << s | n >>> 32 - s) + b;
1728
+ };
1729
+ md52._hh = function(a, b, c, d, x, s, t) {
1730
+ var n = a + (b ^ c ^ d) + (x >>> 0) + t;
1731
+ return (n << s | n >>> 32 - s) + b;
1732
+ };
1733
+ md52._ii = function(a, b, c, d, x, s, t) {
1734
+ var n = a + (c ^ (b | ~d)) + (x >>> 0) + t;
1735
+ return (n << s | n >>> 32 - s) + b;
1736
+ };
1737
+ md52._blocksize = 16;
1738
+ md52._digestsize = 16;
1739
+ md5$1.exports = function(message, options) {
1740
+ if (message === void 0 || message === null)
1741
+ throw new Error("Illegal argument " + message);
1742
+ var digestbytes = crypt2.wordsToBytes(md52(message, options));
1743
+ return options && options.asBytes ? digestbytes : options && options.asString ? bin.bytesToString(digestbytes) : crypt2.bytesToHex(digestbytes);
1744
+ };
1745
+ })();
1746
+ var md5Exports = md5$1.exports;
1747
+ const md5 = /* @__PURE__ */ getDefaultExportFromCjs(md5Exports);
1748
+ let _installed = false;
1749
+ let _interceptorCleanup = [];
1750
+ const _defaultOpts = {
1751
+ tokenHeader: "x-token",
1752
+ autoToastError: true
1753
+ };
1754
+ function useApp() {
1755
+ const _plugins = [];
1756
+ function use(pluginOrInstaller) {
1757
+ _plugins.push((app) => app.use(pluginOrInstaller));
1758
+ }
1759
+ function install(AppComponent) {
1760
+ if (_installed) {
1761
+ console.warn("[hlw] useApp().install() 应只调用一次");
1762
+ }
1763
+ _installed = true;
1764
+ function createApp() {
1765
+ const app = createSSRApp(AppComponent);
1766
+ app.config.globalProperties["hlw"] = hlw;
1767
+ _plugins.forEach((fn) => fn(app));
1768
+ return { app };
1769
+ }
1770
+ return createApp;
1771
+ }
1772
+ return { install, use, hlw, http };
1773
+ }
1774
+ function buildSignString(url) {
1775
+ try {
1776
+ const [path, query] = url.split("?");
1777
+ if (!query)
1778
+ return path + "&";
1779
+ const params = query.split("&").filter(Boolean);
1780
+ params.sort();
1781
+ return params.join("&") + "&";
1782
+ } catch {
1783
+ return url;
1784
+ }
1785
+ }
1786
+ let _sigSecret = "";
1787
+ function setupInterceptors(options = {}) {
1788
+ const opts = { ..._defaultOpts, ...options };
1789
+ if (opts.sigSecret)
1790
+ _sigSecret = opts.sigSecret;
1791
+ if (opts.baseURL)
1792
+ http.setBaseURL(opts.baseURL);
1793
+ _interceptorCleanup.forEach((dispose) => dispose());
1794
+ _interceptorCleanup = [];
1795
+ const offRequest = http.onRequest((config2) => {
1796
+ const device = useDevice();
1797
+ if (device.value) {
1798
+ const d = device.value;
1799
+ const query = [
1800
+ ["appid", d.appid],
1801
+ ["device_brand", d.device_brand],
1802
+ ["device_model", d.device_model],
1803
+ ["device_id", d.device_id],
1804
+ ["device_type", d.device_type],
1805
+ ["device_orientation", d.device_orientation],
1806
+ ["platform", d.platform],
1807
+ ["system", d.system],
1808
+ ["os", d.os],
1809
+ ["version", d.version],
1810
+ ["sdk_version", d.sdk_version],
1811
+ ["host_name", d.host_name],
1812
+ ["host_version", d.host_version],
1813
+ ["host_language", d.host_language],
1814
+ ["language", d.language],
1815
+ ["app_version", d.app_version],
1816
+ ["app_version_code", d.app_version_code],
1817
+ ["screen_width", String(d.screen_width)],
1818
+ ["screen_height", String(d.screen_height)]
1819
+ ].map(([k, v]) => `${encodeURIComponent(k)}=${encodeURIComponent(v ?? "")}`).join("&");
1820
+ config2.url = config2.url + (config2.url.includes("?") ? "&" : "?") + query;
1821
+ config2.headers = { ...config2.headers, "X-Appid": d.appid };
1822
+ }
1823
+ if (_sigSecret) {
1824
+ const signStr = buildSignString(config2.url);
1825
+ const sig = md5(signStr + _sigSecret);
1826
+ config2.url = config2.url + "&sig=" + sig;
1827
+ }
1828
+ if (opts.getToken) {
1829
+ const token = opts.getToken();
1830
+ if (token) {
1831
+ config2.headers = {
1832
+ ...config2.headers,
1833
+ [opts.tokenHeader]: token
1834
+ };
1835
+ }
1836
+ }
1837
+ return config2;
1838
+ });
1839
+ const offResponse = http.onResponse((res) => {
1840
+ if (opts.autoToastError && res.code !== 1) {
1841
+ uni.showToast({ title: res.info || "请求失败", icon: "none" });
1842
+ }
1843
+ return res;
1844
+ });
1845
+ const offError = http.onError((err) => {
1846
+ var _a;
1847
+ if (err.message.includes("401")) {
1848
+ (_a = opts.onUnauthorized) == null ? void 0 : _a.call(opts);
1849
+ }
1850
+ });
1851
+ _interceptorCleanup = [offRequest, offResponse, offError];
1852
+ }
1853
+ function copyText(data) {
1854
+ uni.setClipboardData({
1855
+ data,
1856
+ showToast: false,
1857
+ success: () => uni.showToast({ title: "复制成功", icon: "none", duration: 1500 })
1858
+ });
1859
+ }
1860
+ function injectTap(vnode, binding) {
1861
+ if (!vnode.props)
1862
+ vnode.props = {};
1863
+ const props = vnode.props;
1864
+ const prev = props.onTap;
1865
+ props.onTap = (e) => {
1866
+ prev == null ? void 0 : prev(e);
1867
+ const value = binding.value;
1868
+ if (value == null || value === "")
1869
+ return;
1870
+ copyText(String(value));
1871
+ };
1872
+ }
1873
+ const vCopy = {
1874
+ /**
1875
+ * 在指令创建时注入点击事件。
1876
+ */
1877
+ created(el, binding, vnode) {
1878
+ injectTap(vnode, binding);
259
1879
  },
260
- { unistorage: true }
261
- );
1880
+ /**
1881
+ * 在绑定值更新前重新注入点击事件。
1882
+ */
1883
+ beforeUpdate(el, binding, vnode) {
1884
+ injectTap(vnode, binding);
1885
+ }
1886
+ };
262
1887
  export {
1888
+ APPEARANCE_KEY,
1889
+ APPEARANCE_PRESETS,
1890
+ APPEARANCE_VAR_MAP,
263
1891
  DEFAULT_THEMES,
264
1892
  FONT_PRESETS,
265
1893
  FONT_SCALE_KEY,
1894
+ HttpClient,
266
1895
  THEME_CHANGE_EVENT,
267
1896
  THEME_COLOR_KEY,
268
1897
  THEME_SEMANTIC_COLORS,
1898
+ TYPOGRAPHY_ROLES,
1899
+ adapters,
1900
+ alistAdapter,
269
1901
  buildThemeStyle,
1902
+ clearDeviceCache,
1903
+ confirmReward,
1904
+ cosAdapter,
1905
+ destroyAds,
1906
+ deviceToQuery,
1907
+ getAdapter,
1908
+ getCurrentAppearance,
1909
+ getCurrentAppearanceMode,
1910
+ getCurrentAppearanceVars,
270
1911
  getCurrentFontScale,
271
1912
  getCurrentFontVars,
272
1913
  getCurrentThemeColor,
273
1914
  getCurrentThemeVars,
1915
+ getCurrentTypographyVars,
1916
+ hlw,
1917
+ http,
1918
+ ossAdapter,
1919
+ qiniuAdapter,
1920
+ resolveAppearance,
1921
+ setConfigAd,
1922
+ setConfigContact,
1923
+ setConfigShare,
1924
+ setupInterceptors,
1925
+ useAd,
1926
+ useApp,
1927
+ useColor,
1928
+ useContact,
1929
+ useDevice,
1930
+ useFormat,
1931
+ useLoading,
1932
+ useMsg,
1933
+ usePageMeta,
1934
+ useRefs,
1935
+ useRequest,
1936
+ useRouter,
1937
+ useShare,
1938
+ useShareConfig,
1939
+ useStorage,
274
1940
  useThemePageStyle,
275
- useThemeStore
1941
+ useThemeStore,
1942
+ useUpload,
1943
+ useUtils,
1944
+ useValidate,
1945
+ vCopy
276
1946
  };