@hlw-uni/mp-vue 2.1.52 → 2.1.55
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 +2 -20
- package/dist/composables/ad/index.d.ts +11 -73
- package/dist/composables/device/index.d.ts +5 -70
- package/dist/composables/index.d.ts +6 -14
- package/dist/composables/navigator/index.d.ts +15 -39
- package/dist/composables/request/client.d.ts +21 -0
- package/dist/composables/request/index.d.ts +6 -0
- package/dist/composables/request/service.d.ts +30 -0
- package/dist/composables/{http → request}/types.d.ts +0 -3
- package/dist/composables/share/index.d.ts +7 -66
- package/dist/composables/utils/index.d.ts +25 -32
- package/dist/hlw.d.ts +2 -4
- package/dist/index.d.ts +2 -3
- package/dist/index.js +614 -1253
- package/dist/index.mjs +613 -1252
- package/package.json +2 -1
- package/src/app.ts +3 -143
- package/src/components/hlw-ad/index.vue +6 -5
- package/src/components/hlw-page/index.vue +1 -1
- package/src/composables/ad/README.md +58 -0
- package/src/composables/ad/index.ts +117 -376
- package/src/composables/device/README.md +50 -0
- package/src/composables/device/index.ts +110 -83
- package/src/composables/index.ts +10 -39
- package/src/composables/msg/README.md +79 -0
- package/src/composables/navigator/README.md +71 -0
- package/src/composables/navigator/index.ts +77 -77
- package/src/composables/refs/README.md +40 -0
- package/src/composables/request/README.md +124 -0
- package/src/composables/{http → request}/adapters/oss.ts +1 -0
- package/src/composables/request/client.ts +204 -0
- package/src/composables/request/index.ts +15 -0
- package/src/composables/request/service.ts +54 -0
- package/src/composables/{http → request}/types.ts +0 -4
- package/src/composables/share/README.md +53 -0
- package/src/composables/share/index.ts +64 -168
- package/src/composables/theme/README.md +131 -0
- package/src/composables/theme/index.ts +4 -2
- package/src/composables/theme/palette.ts +22 -4
- package/src/composables/utils/README.md +81 -0
- package/src/composables/utils/index.ts +131 -95
- package/src/hlw.ts +6 -14
- package/src/index.ts +2 -3
- package/dist/composables/_internal/unwrap.d.ts +0 -15
- package/dist/composables/algo/index.d.ts +0 -7
- package/dist/composables/algo/uuid.d.ts +0 -17
- package/dist/composables/color/index.d.ts +0 -8
- package/dist/composables/contact/index.d.ts +0 -32
- package/dist/composables/format/index.d.ts +0 -9
- package/dist/composables/http/client.d.ts +0 -66
- package/dist/composables/http/index.d.ts +0 -8
- package/dist/composables/loading/index.d.ts +0 -7
- package/dist/composables/page-meta/index.d.ts +0 -18
- package/dist/composables/storage/index.d.ts +0 -16
- package/dist/composables/validate/index.d.ts +0 -12
- package/dist/error.d.ts +0 -1
- package/src/composables/_internal/unwrap.ts +0 -19
- package/src/composables/algo/index.ts +0 -7
- package/src/composables/algo/uuid.ts +0 -27
- package/src/composables/color/index.ts +0 -44
- package/src/composables/contact/index.ts +0 -92
- package/src/composables/format/index.ts +0 -48
- package/src/composables/http/client.ts +0 -237
- package/src/composables/http/index.ts +0 -8
- package/src/composables/http/useRequest.ts +0 -107
- package/src/composables/loading/index.ts +0 -23
- package/src/composables/page-meta/index.ts +0 -49
- package/src/composables/storage/index.ts +0 -76
- package/src/composables/validate/index.ts +0 -58
- package/src/error.ts +0 -5
- /package/dist/composables/{http → request}/adapters/alist.d.ts +0 -0
- /package/dist/composables/{http → request}/adapters/base.d.ts +0 -0
- /package/dist/composables/{http → request}/adapters/cos.d.ts +0 -0
- /package/dist/composables/{http → request}/adapters/index.d.ts +0 -0
- /package/dist/composables/{http → request}/adapters/oss.d.ts +0 -0
- /package/dist/composables/{http → request}/adapters/qiniu.d.ts +0 -0
- /package/src/composables/{http → request}/adapters/alist.ts +0 -0
- /package/src/composables/{http → request}/adapters/base.ts +0 -0
- /package/src/composables/{http → request}/adapters/cos.ts +0 -0
- /package/src/composables/{http → request}/adapters/index.ts +0 -0
- /package/src/composables/{http → request}/adapters/qiniu.ts +0 -0
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
(function(global, factory) {
|
|
2
|
-
typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("vue"), require("
|
|
3
|
-
})(this, function(exports2, vue,
|
|
2
|
+
typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("vue"), require("@dcloudio/uni-app"), require("pinia")) : typeof define === "function" && define.amd ? define(["exports", "vue", "@dcloudio/uni-app", "pinia"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.HlwUniVue = {}, global.vue, global.uniApp, global.pinia));
|
|
3
|
+
})(this, function(exports2, vue, uniApp, pinia) {
|
|
4
4
|
"use strict";var __defProp = Object.defineProperty;
|
|
5
5
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
6
|
var __publicField = (obj, key, value) => {
|
|
@@ -34,6 +34,7 @@ var __publicField = (obj, key, value) => {
|
|
|
34
34
|
buildFormData(ctx) {
|
|
35
35
|
const c = ctx.credentials ?? {};
|
|
36
36
|
return {
|
|
37
|
+
key: c["key"] ?? ctx.fileName,
|
|
37
38
|
policy: c["policy"] ?? "",
|
|
38
39
|
signature: c["signature"] ?? "",
|
|
39
40
|
OSSAccessKeyId: c["accessKeyId"] ?? "",
|
|
@@ -78,252 +79,194 @@ var __publicField = (obj, key, value) => {
|
|
|
78
79
|
alist: alistAdapter
|
|
79
80
|
};
|
|
80
81
|
function getAdapter(name) {
|
|
81
|
-
const
|
|
82
|
-
if (!
|
|
82
|
+
const adapter = adapters[name];
|
|
83
|
+
if (!adapter)
|
|
83
84
|
throw new Error(`[hlw] Unknown upload adapter: ${name}`);
|
|
84
|
-
return
|
|
85
|
+
return adapter;
|
|
85
86
|
}
|
|
86
|
-
class
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
__publicField(this, "
|
|
92
|
-
__publicField(this, "
|
|
93
|
-
__publicField(this, "_errInterceptors", []);
|
|
94
|
-
__publicField(this, "_baseURL");
|
|
95
|
-
__publicField(this, "_defaultHeaders");
|
|
96
|
-
__publicField(this, "_noCache");
|
|
97
|
-
this._baseURL = options.baseURL ?? "";
|
|
98
|
-
this._noCache = options.noCache ?? true;
|
|
99
|
-
this._defaultHeaders = {
|
|
100
|
-
"Content-Type": "application/json",
|
|
101
|
-
...options.headers
|
|
102
|
-
};
|
|
87
|
+
class UniRequestClient {
|
|
88
|
+
constructor() {
|
|
89
|
+
__publicField(this, "reqInterceptors", []);
|
|
90
|
+
__publicField(this, "resInterceptors", []);
|
|
91
|
+
__publicField(this, "errInterceptors", []);
|
|
92
|
+
__publicField(this, "baseURL", "");
|
|
93
|
+
__publicField(this, "defaultHeaders", { "Content-Type": "application/json" });
|
|
103
94
|
}
|
|
104
|
-
/** 运行时设置 baseURL。 */
|
|
105
95
|
setBaseURL(url) {
|
|
106
|
-
this.
|
|
96
|
+
this.baseURL = url;
|
|
107
97
|
}
|
|
108
|
-
/** 注册请求拦截器,并返回注销函数。 */
|
|
109
98
|
onRequest(fn) {
|
|
110
|
-
this.
|
|
111
|
-
return () =>
|
|
112
|
-
const idx = this._reqInterceptors.indexOf(fn);
|
|
113
|
-
if (idx > -1)
|
|
114
|
-
this._reqInterceptors.splice(idx, 1);
|
|
115
|
-
};
|
|
99
|
+
this.reqInterceptors.push(fn);
|
|
100
|
+
return () => this.remove(this.reqInterceptors, fn);
|
|
116
101
|
}
|
|
117
|
-
/** 注册响应拦截器,并返回注销函数。 */
|
|
118
102
|
onResponse(fn) {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
if (idx > -1)
|
|
123
|
-
this._resInterceptors.splice(idx, 1);
|
|
124
|
-
};
|
|
103
|
+
const item = fn;
|
|
104
|
+
this.resInterceptors.push(item);
|
|
105
|
+
return () => this.remove(this.resInterceptors, item);
|
|
125
106
|
}
|
|
126
|
-
/** 注册错误拦截器,并返回注销函数。 */
|
|
127
107
|
onError(fn) {
|
|
128
|
-
this.
|
|
129
|
-
return () =>
|
|
130
|
-
const idx = this._errInterceptors.indexOf(fn);
|
|
131
|
-
if (idx > -1)
|
|
132
|
-
this._errInterceptors.splice(idx, 1);
|
|
133
|
-
};
|
|
108
|
+
this.errInterceptors.push(fn);
|
|
109
|
+
return () => this.remove(this.errInterceptors, fn);
|
|
134
110
|
}
|
|
135
|
-
|
|
136
|
-
* 执行一次全局请求,自动串联请求与响应拦截器。
|
|
137
|
-
*/
|
|
138
|
-
async request(config2) {
|
|
111
|
+
async request(config) {
|
|
139
112
|
let cfg = {
|
|
140
113
|
method: "GET",
|
|
141
|
-
...
|
|
142
|
-
headers: { ...this.
|
|
114
|
+
...config,
|
|
115
|
+
headers: { ...this.defaultHeaders, ...config.headers }
|
|
143
116
|
};
|
|
144
|
-
for (const fn of this.
|
|
117
|
+
for (const fn of this.reqInterceptors) {
|
|
145
118
|
cfg = await fn(cfg);
|
|
146
119
|
}
|
|
147
120
|
try {
|
|
148
|
-
const
|
|
149
|
-
const
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
return modified;
|
|
121
|
+
const res = await this.send(this.resolveUrl(cfg.url), cfg);
|
|
122
|
+
for (const fn of this.resInterceptors) {
|
|
123
|
+
const next = await fn(res);
|
|
124
|
+
if (next !== void 0)
|
|
125
|
+
return next;
|
|
154
126
|
}
|
|
155
127
|
return res;
|
|
156
128
|
} catch (e) {
|
|
157
129
|
const err = e;
|
|
158
|
-
|
|
130
|
+
for (const fn of this.errInterceptors) {
|
|
131
|
+
await fn(err);
|
|
132
|
+
}
|
|
159
133
|
throw err;
|
|
160
134
|
}
|
|
161
135
|
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
*/
|
|
165
|
-
useRequest() {
|
|
166
|
-
const loading = vue.ref(false);
|
|
167
|
-
const data = vue.ref(null);
|
|
168
|
-
const error = vue.ref(null);
|
|
169
|
-
const run = async (cfg) => {
|
|
170
|
-
loading.value = true;
|
|
171
|
-
error.value = null;
|
|
172
|
-
try {
|
|
173
|
-
const res = await this.request(cfg);
|
|
174
|
-
data.value = res.data;
|
|
175
|
-
return res;
|
|
176
|
-
} catch (e) {
|
|
177
|
-
error.value = e;
|
|
178
|
-
throw e;
|
|
179
|
-
} finally {
|
|
180
|
-
loading.value = false;
|
|
181
|
-
}
|
|
182
|
-
};
|
|
183
|
-
const get = (url, d) => run({ url, method: "GET", data: d });
|
|
184
|
-
const post = (url, d) => run({ url, method: "POST", data: d });
|
|
185
|
-
const put = (url, d) => run({ url, method: "PUT", data: d });
|
|
186
|
-
const del = (url, d) => run({ url, method: "DELETE", data: d });
|
|
187
|
-
return { loading, data, error, run, get, post, put, del };
|
|
136
|
+
get(url, data) {
|
|
137
|
+
return this.request({ url, method: "GET", data });
|
|
188
138
|
}
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
139
|
+
post(url, data) {
|
|
140
|
+
return this.request({ url, method: "POST", data });
|
|
141
|
+
}
|
|
142
|
+
put(url, data) {
|
|
143
|
+
return this.request({ url, method: "PUT", data });
|
|
144
|
+
}
|
|
145
|
+
del(url, data) {
|
|
146
|
+
return this.request({ url, method: "DELETE", data });
|
|
147
|
+
}
|
|
148
|
+
upload(config) {
|
|
149
|
+
const fileName = config.fileName ?? config.filePath.split("/").pop() ?? "file";
|
|
150
|
+
const server = config.type === "local" && config.url ? config.url : config.server;
|
|
151
|
+
const formData = config.type === "local" ? config.credentials ?? {} : getAdapter(config.type).buildFormData({
|
|
152
|
+
filePath: config.filePath,
|
|
199
153
|
fileName,
|
|
200
|
-
credentials:
|
|
154
|
+
credentials: config.credentials
|
|
201
155
|
});
|
|
202
156
|
return new Promise((resolve, reject) => {
|
|
203
157
|
uni.uploadFile({
|
|
204
158
|
url: server,
|
|
205
|
-
filePath:
|
|
159
|
+
filePath: config.filePath,
|
|
206
160
|
name: "file",
|
|
207
161
|
formData,
|
|
208
|
-
header:
|
|
162
|
+
header: config.header,
|
|
209
163
|
success: (res) => {
|
|
210
|
-
if (res.statusCode
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
164
|
+
if (res.statusCode < 200 || res.statusCode >= 300) {
|
|
165
|
+
reject(new Error(`上传失败: ${res.statusCode}`));
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
try {
|
|
169
|
+
const body = JSON.parse(res.data);
|
|
170
|
+
resolve({
|
|
171
|
+
code: body.code ?? 1,
|
|
172
|
+
msg: body.msg ?? body.message ?? "上传成功",
|
|
173
|
+
data: body.data ?? ""
|
|
174
|
+
});
|
|
175
|
+
} catch {
|
|
176
|
+
resolve({ code: 1, msg: "上传成功", data: res.data });
|
|
219
177
|
}
|
|
220
178
|
},
|
|
221
179
|
fail: (err) => reject(new Error(err.errMsg || "上传失败"))
|
|
222
180
|
});
|
|
223
181
|
});
|
|
224
182
|
}
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
183
|
+
resolveServiceUrl(namespace, url, servicePrefix = "") {
|
|
184
|
+
if (isAbsolute(url))
|
|
185
|
+
return url;
|
|
186
|
+
const ns = namespace.replace(/^\/+|\/+$/g, "").replace(/\//g, ".");
|
|
187
|
+
const prefixValue = servicePrefix.replace(/^\/+|\/+$/g, "");
|
|
188
|
+
const path = url.startsWith("/") ? url : `/${url}`;
|
|
189
|
+
const prefix = [prefixValue, ns].filter(Boolean).join("/");
|
|
190
|
+
return prefix ? `/${prefix}${path}` : path;
|
|
191
|
+
}
|
|
192
|
+
resolveUrl(url) {
|
|
193
|
+
if (isAbsolute(url))
|
|
230
194
|
return url;
|
|
231
|
-
|
|
232
|
-
if (!this._noCache)
|
|
233
|
-
return full;
|
|
234
|
-
const sep = full.includes("?") ? "&" : "?";
|
|
235
|
-
return `${full}${sep}_t=${Date.now()}`;
|
|
195
|
+
return `${this.baseURL}${url}`;
|
|
236
196
|
}
|
|
237
|
-
|
|
238
|
-
* 调用 uni.request 发起底层网络请求。
|
|
239
|
-
*/
|
|
240
|
-
async _doRequest(url, cfg) {
|
|
197
|
+
send(url, cfg) {
|
|
241
198
|
return new Promise((resolve, reject) => {
|
|
242
199
|
uni.request({
|
|
243
200
|
url,
|
|
244
201
|
method: cfg.method,
|
|
245
202
|
data: cfg.data,
|
|
246
203
|
header: cfg.headers,
|
|
204
|
+
timeout: cfg.timeout,
|
|
247
205
|
success: (res) => {
|
|
248
|
-
var _a;
|
|
249
206
|
if (res.statusCode >= 200 && res.statusCode < 300) {
|
|
250
207
|
resolve(res.data);
|
|
251
|
-
|
|
252
|
-
const msg2 = ((_a = res.data) == null ? void 0 : _a.info) ?? `请求失败: ${res.statusCode}`;
|
|
253
|
-
reject(new Error(String(msg2)));
|
|
208
|
+
return;
|
|
254
209
|
}
|
|
210
|
+
const body = res.data;
|
|
211
|
+
reject(new Error(String((body == null ? void 0 : body.info) ?? (body == null ? void 0 : body.message) ?? `请求失败: ${res.statusCode}`)));
|
|
255
212
|
},
|
|
256
213
|
fail: (err) => reject(new Error(err.errMsg || "网络请求失败"))
|
|
257
214
|
});
|
|
258
215
|
});
|
|
259
216
|
}
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
for (const fn of this._errInterceptors) {
|
|
265
|
-
await fn(err);
|
|
266
|
-
}
|
|
217
|
+
remove(items, item) {
|
|
218
|
+
const index = items.indexOf(item);
|
|
219
|
+
if (index > -1)
|
|
220
|
+
items.splice(index, 1);
|
|
267
221
|
}
|
|
268
222
|
}
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
async function run(config2) {
|
|
276
|
-
loading.value = true;
|
|
277
|
-
error.value = null;
|
|
278
|
-
try {
|
|
279
|
-
const res = await http.request(config2);
|
|
280
|
-
data.value = res.data;
|
|
281
|
-
onSuccess == null ? void 0 : onSuccess(res.data, res);
|
|
282
|
-
return res;
|
|
283
|
-
} catch (e) {
|
|
284
|
-
error.value = e;
|
|
285
|
-
onError == null ? void 0 : onError(e);
|
|
286
|
-
throw e;
|
|
287
|
-
} finally {
|
|
288
|
-
loading.value = false;
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
function get(url, data2) {
|
|
292
|
-
return run({ url, method: "GET", data: data2 });
|
|
293
|
-
}
|
|
294
|
-
function post(url, data2) {
|
|
295
|
-
return run({ url, method: "POST", data: data2 });
|
|
296
|
-
}
|
|
297
|
-
function put(url, data2) {
|
|
298
|
-
return run({ url, method: "PUT", data: data2 });
|
|
299
|
-
}
|
|
300
|
-
function del(url, data2) {
|
|
301
|
-
return run({ url, method: "DELETE", data: data2 });
|
|
302
|
-
}
|
|
303
|
-
return { loading, data, error, run, get, post, put, del };
|
|
223
|
+
function isAbsolute(url) {
|
|
224
|
+
return /^(https?:)?\/\//.test(url) || url.startsWith("file://");
|
|
225
|
+
}
|
|
226
|
+
const requestClient = new UniRequestClient();
|
|
227
|
+
function useRequest() {
|
|
228
|
+
return requestClient;
|
|
304
229
|
}
|
|
305
230
|
function useUpload() {
|
|
306
231
|
const uploading = vue.ref(false);
|
|
307
232
|
async function upload(options) {
|
|
308
233
|
uploading.value = true;
|
|
309
234
|
try {
|
|
310
|
-
return await
|
|
235
|
+
return await requestClient.upload(options);
|
|
311
236
|
} finally {
|
|
312
237
|
uploading.value = false;
|
|
313
238
|
}
|
|
314
239
|
}
|
|
315
240
|
return { uploading, upload };
|
|
316
241
|
}
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
242
|
+
class BaseService {
|
|
243
|
+
request(options) {
|
|
244
|
+
return useRequest().request({
|
|
245
|
+
...options,
|
|
246
|
+
url: useRequest().resolveServiceUrl(this.namespace ?? "", options.url, this.servicePrefix ?? "")
|
|
247
|
+
});
|
|
320
248
|
}
|
|
321
|
-
|
|
322
|
-
|
|
249
|
+
get(url, data) {
|
|
250
|
+
return this.request({ url, method: "GET", data });
|
|
323
251
|
}
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
252
|
+
post(url, data) {
|
|
253
|
+
return this.request({ url, method: "POST", data });
|
|
254
|
+
}
|
|
255
|
+
put(url, data) {
|
|
256
|
+
return this.request({ url, method: "PUT", data });
|
|
257
|
+
}
|
|
258
|
+
del(url, data) {
|
|
259
|
+
return this.request({ url, method: "DELETE", data });
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
function ServiceNamespace(value) {
|
|
263
|
+
return function(target) {
|
|
264
|
+
target.prototype.namespace = typeof value === "string" ? value : value.namespace;
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
function ServicePrefix(value) {
|
|
268
|
+
return function(target) {
|
|
269
|
+
target.prototype.servicePrefix = typeof value === "string" ? value : value.prefix;
|
|
327
270
|
};
|
|
328
271
|
}
|
|
329
272
|
function useMsg() {
|
|
@@ -389,81 +332,271 @@ var __publicField = (obj, key, value) => {
|
|
|
389
332
|
setLoadingBar
|
|
390
333
|
};
|
|
391
334
|
}
|
|
392
|
-
|
|
393
|
-
|
|
335
|
+
function withQuery(url, qs) {
|
|
336
|
+
if (!qs)
|
|
337
|
+
return url;
|
|
338
|
+
return `${url}${url.includes("?") ? "&" : "?"}${qs}`;
|
|
339
|
+
}
|
|
340
|
+
function toQuery(data) {
|
|
341
|
+
return Object.entries(data).filter(([, val]) => val !== void 0 && val !== null).map(([key, val]) => `${encodeURIComponent(key)}=${encodeURIComponent(String(val))}`).join("&");
|
|
342
|
+
}
|
|
343
|
+
function signText(url) {
|
|
344
|
+
const [path, qs] = url.split("?");
|
|
345
|
+
return qs ? `${qs.split("&").filter(Boolean).sort().join("&")}&` : `${path}&`;
|
|
346
|
+
}
|
|
347
|
+
function toNumber(val, def) {
|
|
348
|
+
const next = Number(val);
|
|
349
|
+
return Number.isFinite(next) ? next : def;
|
|
350
|
+
}
|
|
351
|
+
function toBoolean(val, def) {
|
|
352
|
+
if (typeof val === "boolean")
|
|
353
|
+
return val;
|
|
354
|
+
if (val === 0 || val === "0")
|
|
355
|
+
return false;
|
|
356
|
+
if (val === 1 || val === "1")
|
|
357
|
+
return true;
|
|
358
|
+
return def;
|
|
359
|
+
}
|
|
360
|
+
function useUtils() {
|
|
361
|
+
function copy(text, tip = true) {
|
|
362
|
+
return new Promise((ok) => {
|
|
363
|
+
uni.setClipboardData({
|
|
364
|
+
data: text,
|
|
365
|
+
showToast: false,
|
|
366
|
+
success: () => {
|
|
367
|
+
if (tip) {
|
|
368
|
+
uni.showToast({ title: "复制成功", icon: "none", duration: 1500 });
|
|
369
|
+
}
|
|
370
|
+
ok(true);
|
|
371
|
+
},
|
|
372
|
+
fail: () => ok(false)
|
|
373
|
+
});
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
function paste() {
|
|
377
|
+
return new Promise((ok) => {
|
|
378
|
+
uni.getClipboardData({
|
|
379
|
+
success: (res) => ok(res.data),
|
|
380
|
+
fail: () => ok("")
|
|
381
|
+
});
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
function auth() {
|
|
385
|
+
uni.showModal({
|
|
386
|
+
title: "提示",
|
|
387
|
+
content: "需要授权相册权限",
|
|
388
|
+
confirmText: "去设置",
|
|
389
|
+
success: (res) => {
|
|
390
|
+
if (res.confirm)
|
|
391
|
+
uni.openSetting();
|
|
392
|
+
}
|
|
393
|
+
});
|
|
394
|
+
}
|
|
395
|
+
function saveImage(path) {
|
|
396
|
+
return new Promise((ok) => {
|
|
397
|
+
uni.saveImageToPhotosAlbum({
|
|
398
|
+
filePath: path,
|
|
399
|
+
success: () => {
|
|
400
|
+
uni.showToast({ title: "保存成功", icon: "success" });
|
|
401
|
+
ok(true);
|
|
402
|
+
},
|
|
403
|
+
fail: (err) => {
|
|
404
|
+
const msg = String(err.errMsg || "");
|
|
405
|
+
if (msg.includes("auth deny") || msg.includes("authorize")) {
|
|
406
|
+
auth();
|
|
407
|
+
} else {
|
|
408
|
+
uni.showToast({ title: "保存失败", icon: "none" });
|
|
409
|
+
}
|
|
410
|
+
ok(false);
|
|
411
|
+
}
|
|
412
|
+
});
|
|
413
|
+
});
|
|
414
|
+
}
|
|
415
|
+
function saveVideo(path) {
|
|
416
|
+
return new Promise((ok) => {
|
|
417
|
+
uni.saveVideoToPhotosAlbum({
|
|
418
|
+
filePath: path,
|
|
419
|
+
success: () => {
|
|
420
|
+
uni.showToast({ title: "保存成功", icon: "success" });
|
|
421
|
+
ok(true);
|
|
422
|
+
},
|
|
423
|
+
fail: (err) => {
|
|
424
|
+
const msg = String(err.errMsg || "");
|
|
425
|
+
if (msg.includes("auth deny") || msg.includes("authorize")) {
|
|
426
|
+
auth();
|
|
427
|
+
} else {
|
|
428
|
+
uni.showToast({ title: "保存失败", icon: "none" });
|
|
429
|
+
}
|
|
430
|
+
ok(false);
|
|
431
|
+
}
|
|
432
|
+
});
|
|
433
|
+
});
|
|
434
|
+
}
|
|
435
|
+
function download(opt) {
|
|
436
|
+
return new Promise((ok) => {
|
|
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 })
|
|
449
|
+
});
|
|
450
|
+
if (opt.progress) {
|
|
451
|
+
task.onProgressUpdate((res) => {
|
|
452
|
+
opt.progress(res.progress, res.totalBytesWritten, res.totalBytesExpectedToWrite);
|
|
453
|
+
});
|
|
454
|
+
}
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
async function saveImageUrl(url, progress) {
|
|
458
|
+
try {
|
|
459
|
+
uni.showLoading({ title: "下载中...", mask: true });
|
|
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" });
|
|
470
|
+
return false;
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
async function saveVideoUrl(url, progress) {
|
|
474
|
+
try {
|
|
475
|
+
uni.showLoading({ title: "下载中...", mask: true });
|
|
476
|
+
const res = await download({ url, progress: progress ? (value) => progress(value) : void 0 });
|
|
477
|
+
uni.hideLoading();
|
|
478
|
+
if (!res.ok || !res.path) {
|
|
479
|
+
uni.showToast({ title: res.msg || "下载失败", icon: "none" });
|
|
480
|
+
return false;
|
|
481
|
+
}
|
|
482
|
+
return await saveVideo(res.path);
|
|
483
|
+
} catch {
|
|
484
|
+
uni.hideLoading();
|
|
485
|
+
uni.showToast({ title: "操作失败", icon: "none" });
|
|
486
|
+
return false;
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
return {
|
|
490
|
+
withQuery,
|
|
491
|
+
toQuery,
|
|
492
|
+
signText,
|
|
493
|
+
toNumber,
|
|
494
|
+
toBoolean,
|
|
495
|
+
copy,
|
|
496
|
+
paste,
|
|
497
|
+
saveImage,
|
|
498
|
+
saveVideo,
|
|
499
|
+
download,
|
|
500
|
+
saveImageUrl,
|
|
501
|
+
saveVideoUrl
|
|
502
|
+
};
|
|
503
|
+
}
|
|
504
|
+
let deviceCache = null;
|
|
505
|
+
function readSafe(fn) {
|
|
394
506
|
try {
|
|
395
507
|
return (fn == null ? void 0 : fn()) ?? {};
|
|
396
508
|
} catch {
|
|
397
509
|
return {};
|
|
398
510
|
}
|
|
399
511
|
}
|
|
400
|
-
function
|
|
401
|
-
|
|
402
|
-
let
|
|
403
|
-
let
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
let appid = "";
|
|
412
|
-
try {
|
|
413
|
-
const accountInfo = uni.getAccountInfoSync();
|
|
414
|
-
appid = ((_a = accountInfo == null ? void 0 : accountInfo.miniProgram) == null ? void 0 : _a.appId) || "";
|
|
415
|
-
} catch {
|
|
416
|
-
appid = deviceInfo.appId || "";
|
|
417
|
-
}
|
|
418
|
-
const system = deviceInfo.system || "";
|
|
512
|
+
function collectDevice() {
|
|
513
|
+
let device = readSafe(uni.getDeviceInfo);
|
|
514
|
+
let window = readSafe(uni.getWindowInfo);
|
|
515
|
+
let app = readSafe(uni.getAppBaseInfo);
|
|
516
|
+
if (!device.brand && !device.model) {
|
|
517
|
+
const system2 = readSafe(() => uni.getSystemInfoSync());
|
|
518
|
+
device = { ...system2 };
|
|
519
|
+
window = { ...system2 };
|
|
520
|
+
app = { ...system2 };
|
|
521
|
+
}
|
|
522
|
+
const system = device.system || "";
|
|
419
523
|
return {
|
|
420
|
-
appid,
|
|
421
|
-
app_name:
|
|
422
|
-
app_version:
|
|
423
|
-
app_version_code:
|
|
424
|
-
app_channel:
|
|
425
|
-
device_brand:
|
|
426
|
-
device_model:
|
|
427
|
-
device_id:
|
|
428
|
-
device_type:
|
|
429
|
-
device_orientation:
|
|
430
|
-
brand:
|
|
431
|
-
model:
|
|
524
|
+
appid: getAppid(device),
|
|
525
|
+
app_name: app.appName || "",
|
|
526
|
+
app_version: app.appVersion || "",
|
|
527
|
+
app_version_code: app.appVersionCode || "",
|
|
528
|
+
app_channel: app.appChannel || "",
|
|
529
|
+
device_brand: device.brand || "",
|
|
530
|
+
device_model: device.model || "",
|
|
531
|
+
device_id: device.deviceId || "",
|
|
532
|
+
device_type: device.deviceType || "",
|
|
533
|
+
device_orientation: window.deviceOrientation || "portrait",
|
|
534
|
+
brand: device.brand || "",
|
|
535
|
+
model: device.model || "",
|
|
432
536
|
system,
|
|
433
537
|
os: system.split(" ")[0] || "",
|
|
434
|
-
pixel_ratio:
|
|
435
|
-
screen_width:
|
|
436
|
-
screen_height:
|
|
437
|
-
window_width:
|
|
438
|
-
window_height:
|
|
439
|
-
status_bar_height:
|
|
440
|
-
sdk_version:
|
|
441
|
-
host_name:
|
|
442
|
-
host_version:
|
|
443
|
-
host_language:
|
|
444
|
-
host_theme:
|
|
445
|
-
platform:
|
|
446
|
-
language:
|
|
447
|
-
version:
|
|
538
|
+
pixel_ratio: window.pixelRatio || 0,
|
|
539
|
+
screen_width: window.screenWidth || 0,
|
|
540
|
+
screen_height: window.screenHeight || 0,
|
|
541
|
+
window_width: window.windowWidth || 0,
|
|
542
|
+
window_height: window.windowHeight || 0,
|
|
543
|
+
status_bar_height: window.statusBarHeight || 0,
|
|
544
|
+
sdk_version: app.SDKVersion || "",
|
|
545
|
+
host_name: app.hostName || "",
|
|
546
|
+
host_version: app.hostVersion || "",
|
|
547
|
+
host_language: app.hostLanguage || "",
|
|
548
|
+
host_theme: app.hostTheme || "",
|
|
549
|
+
platform: device.platform || "",
|
|
550
|
+
language: app.language || "",
|
|
551
|
+
version: app.version || ""
|
|
448
552
|
};
|
|
449
553
|
}
|
|
450
|
-
function
|
|
451
|
-
|
|
452
|
-
|
|
554
|
+
function getAppid(device) {
|
|
555
|
+
var _a;
|
|
556
|
+
try {
|
|
557
|
+
const account = uni.getAccountInfoSync();
|
|
558
|
+
return ((_a = account == null ? void 0 : account.miniProgram) == null ? void 0 : _a.appId) || "";
|
|
559
|
+
} catch {
|
|
560
|
+
return device.appId || "";
|
|
453
561
|
}
|
|
454
562
|
}
|
|
455
|
-
function
|
|
456
|
-
|
|
457
|
-
return
|
|
563
|
+
function getDevice() {
|
|
564
|
+
deviceCache ?? (deviceCache = collectDevice());
|
|
565
|
+
return deviceCache;
|
|
458
566
|
}
|
|
459
|
-
function
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
567
|
+
function getQueryInfo(info) {
|
|
568
|
+
return {
|
|
569
|
+
appid: info.appid,
|
|
570
|
+
device_brand: info.device_brand,
|
|
571
|
+
device_model: info.device_model,
|
|
572
|
+
device_id: info.device_id,
|
|
573
|
+
device_type: info.device_type,
|
|
574
|
+
device_orientation: info.device_orientation,
|
|
575
|
+
platform: info.platform,
|
|
576
|
+
system: info.system,
|
|
577
|
+
os: info.os,
|
|
578
|
+
version: info.version,
|
|
579
|
+
sdk_version: info.sdk_version,
|
|
580
|
+
host_name: info.host_name,
|
|
581
|
+
host_version: info.host_version,
|
|
582
|
+
host_language: info.host_language,
|
|
583
|
+
language: info.language,
|
|
584
|
+
app_version: info.app_version,
|
|
585
|
+
app_version_code: info.app_version_code,
|
|
586
|
+
screen_width: info.screen_width,
|
|
587
|
+
screen_height: info.screen_height
|
|
588
|
+
};
|
|
589
|
+
}
|
|
590
|
+
function useDevice() {
|
|
591
|
+
const info = getDevice();
|
|
592
|
+
const { toQuery: toQuery2 } = useUtils();
|
|
593
|
+
return {
|
|
594
|
+
info,
|
|
595
|
+
query: toQuery2(getQueryInfo(info))
|
|
596
|
+
};
|
|
464
597
|
}
|
|
465
598
|
function clearDeviceCache() {
|
|
466
|
-
|
|
599
|
+
deviceCache = null;
|
|
467
600
|
}
|
|
468
601
|
function useRefs() {
|
|
469
602
|
const refs = vue.ref({});
|
|
@@ -479,690 +612,262 @@ var __publicField = (obj, key, value) => {
|
|
|
479
612
|
};
|
|
480
613
|
return { refs, setRefs };
|
|
481
614
|
}
|
|
482
|
-
function
|
|
483
|
-
function
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
}
|
|
490
|
-
if (options.navigationBarBackgroundColor || options.navigationBarTextStyle) {
|
|
491
|
-
uni.setNavigationBarColor({
|
|
492
|
-
frontColor: options.navigationBarTextStyle === "white" ? "#ffffff" : "#000000",
|
|
493
|
-
backgroundColor: options.navigationBarBackgroundColor ?? "#ffffff"
|
|
494
|
-
});
|
|
495
|
-
}
|
|
496
|
-
if (options.backgroundColor) {
|
|
497
|
-
uni.setBackgroundColor({ backgroundColor: options.backgroundColor });
|
|
498
|
-
}
|
|
499
|
-
if (options.enablePullDownRefresh !== void 0) {
|
|
500
|
-
uni.setBackgroundTextStyle({ textStyle: "dark" });
|
|
501
|
-
}
|
|
502
|
-
}
|
|
503
|
-
return {
|
|
504
|
-
setTitle,
|
|
505
|
-
setOptions
|
|
615
|
+
function resolveConfig(config) {
|
|
616
|
+
return typeof config === "function" ? config() : config ?? {};
|
|
617
|
+
}
|
|
618
|
+
function buildPayload(base, extra) {
|
|
619
|
+
const current = {
|
|
620
|
+
...resolveConfig(base),
|
|
621
|
+
...resolveConfig(extra)
|
|
506
622
|
};
|
|
623
|
+
const payload = {};
|
|
624
|
+
if (current.title)
|
|
625
|
+
payload.title = current.title;
|
|
626
|
+
if (current.path)
|
|
627
|
+
payload.path = current.path;
|
|
628
|
+
if (current.imageUrl)
|
|
629
|
+
payload.imageUrl = current.imageUrl;
|
|
630
|
+
return payload;
|
|
507
631
|
}
|
|
508
|
-
function
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
}
|
|
517
|
-
function set(key, value) {
|
|
518
|
-
try {
|
|
519
|
-
uni.setStorageSync(key, value);
|
|
520
|
-
return true;
|
|
521
|
-
} catch {
|
|
522
|
-
return false;
|
|
523
|
-
}
|
|
524
|
-
}
|
|
525
|
-
function remove(key) {
|
|
526
|
-
try {
|
|
527
|
-
uni.removeStorageSync(key);
|
|
528
|
-
return true;
|
|
529
|
-
} catch {
|
|
530
|
-
return false;
|
|
531
|
-
}
|
|
532
|
-
}
|
|
533
|
-
function clear() {
|
|
534
|
-
try {
|
|
535
|
-
uni.clearStorageSync();
|
|
536
|
-
return true;
|
|
537
|
-
} catch {
|
|
538
|
-
return false;
|
|
539
|
-
}
|
|
540
|
-
}
|
|
541
|
-
function info() {
|
|
542
|
-
try {
|
|
543
|
-
return uni.getStorageInfoSync();
|
|
544
|
-
} catch {
|
|
545
|
-
return null;
|
|
546
|
-
}
|
|
547
|
-
}
|
|
548
|
-
return { get, set, remove, clear, info };
|
|
632
|
+
function showShareMenu() {
|
|
633
|
+
var _a;
|
|
634
|
+
const api2 = typeof uni !== "undefined" ? uni : void 0;
|
|
635
|
+
(_a = api2 == null ? void 0 : api2.showShareMenu) == null ? void 0 : _a.call(api2, {
|
|
636
|
+
withShareTicket: true,
|
|
637
|
+
menus: ["shareAppMessage", "shareTimeline"],
|
|
638
|
+
fail: () => void 0
|
|
639
|
+
});
|
|
549
640
|
}
|
|
550
|
-
function
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
return
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
if (typeof value === "string")
|
|
578
|
-
return value.trim() === "";
|
|
579
|
-
if (Array.isArray(value))
|
|
580
|
-
return value.length === 0;
|
|
581
|
-
if (typeof value === "object")
|
|
582
|
-
return Object.keys(value).length === 0;
|
|
583
|
-
return false;
|
|
584
|
-
}
|
|
641
|
+
function useShare(config = {}) {
|
|
642
|
+
let appMessageRegistered = false;
|
|
643
|
+
let timelineRegistered = false;
|
|
644
|
+
const onShareAppMessage = (extra) => {
|
|
645
|
+
if (appMessageRegistered)
|
|
646
|
+
return;
|
|
647
|
+
appMessageRegistered = true;
|
|
648
|
+
showShareMenu();
|
|
649
|
+
uniApp.onShareAppMessage(() => buildPayload(config, extra));
|
|
650
|
+
};
|
|
651
|
+
const onShareTimeline = (extra) => {
|
|
652
|
+
if (timelineRegistered)
|
|
653
|
+
return;
|
|
654
|
+
timelineRegistered = true;
|
|
655
|
+
showShareMenu();
|
|
656
|
+
uniApp.onShareTimeline(() => {
|
|
657
|
+
var _a;
|
|
658
|
+
const payload = buildPayload(config, extra);
|
|
659
|
+
return {
|
|
660
|
+
title: payload.title,
|
|
661
|
+
query: (_a = payload.path) == null ? void 0 : _a.split("?")[1],
|
|
662
|
+
imageUrl: payload.imageUrl
|
|
663
|
+
};
|
|
664
|
+
});
|
|
665
|
+
};
|
|
666
|
+
onShareAppMessage();
|
|
667
|
+
onShareTimeline();
|
|
585
668
|
return {
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
idCard,
|
|
590
|
-
carNumber,
|
|
591
|
-
password,
|
|
592
|
-
empty
|
|
669
|
+
onShareAppMessage,
|
|
670
|
+
onShareTimeline,
|
|
671
|
+
showShareMenu
|
|
593
672
|
};
|
|
594
673
|
}
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
}
|
|
608
|
-
function fileSize(bytes) {
|
|
609
|
-
if (bytes === 0)
|
|
610
|
-
return "0 B";
|
|
611
|
-
const k = 1024;
|
|
612
|
-
const sizes = ["B", "KB", "MB", "GB", "TB"];
|
|
613
|
-
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
614
|
-
return `${parseFloat((bytes / Math.pow(k, i)).toFixed(2))} ${sizes[i]}`;
|
|
615
|
-
}
|
|
616
|
-
function phone(value) {
|
|
617
|
-
return value.replace(/(\d{3})\d{4}(\d{4})/, "$1****$2");
|
|
618
|
-
}
|
|
619
|
-
function money(amount, decimals = 2, decPoint = ".", thousandsSep = ",") {
|
|
620
|
-
return amount.toFixed(decimals).replace(/\B(?=(\d{3})+(?!\d))/g, thousandsSep);
|
|
621
|
-
}
|
|
622
|
-
return { date, fileSize, phone, money };
|
|
674
|
+
let popupAd = null;
|
|
675
|
+
let popupDone;
|
|
676
|
+
let popupClose = null;
|
|
677
|
+
let popupError = null;
|
|
678
|
+
let rewardAd = null;
|
|
679
|
+
let rewardDone;
|
|
680
|
+
let rewardPromise = null;
|
|
681
|
+
let rewardResolve = null;
|
|
682
|
+
let rewardClose = null;
|
|
683
|
+
let rewardError = null;
|
|
684
|
+
function api() {
|
|
685
|
+
return typeof wx === "undefined" ? null : wx;
|
|
623
686
|
}
|
|
624
|
-
function
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
return env.code === 1 && env.data ? env.data : null;
|
|
630
|
-
}
|
|
631
|
-
return raw;
|
|
687
|
+
function finish(res) {
|
|
688
|
+
rewardDone == null ? void 0 : rewardDone(res);
|
|
689
|
+
rewardResolve == null ? void 0 : rewardResolve(res);
|
|
690
|
+
rewardResolve = null;
|
|
691
|
+
rewardPromise = null;
|
|
632
692
|
}
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
let adapter$1 = null;
|
|
644
|
-
let pending$1 = null;
|
|
645
|
-
function setConfigAd(a) {
|
|
646
|
-
adapter$1 = a;
|
|
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;
|
|
647
703
|
}
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
const loaded = vue.ref(false);
|
|
651
|
-
return { config: config2, loaded };
|
|
652
|
-
});
|
|
653
|
-
let _msg$1 = null;
|
|
654
|
-
const msg = () => _msg$1 ?? (_msg$1 = useMsg());
|
|
655
|
-
const rewardedCache = /* @__PURE__ */ new Map();
|
|
656
|
-
const interstitialCache = /* @__PURE__ */ new Map();
|
|
657
|
-
function useAd() {
|
|
658
|
-
const store = useAdStore();
|
|
659
|
-
const { loaded } = pinia.storeToRefs(store);
|
|
660
|
-
const config2 = vue.computed(() => {
|
|
704
|
+
function useHlwAd() {
|
|
705
|
+
function clearPopup() {
|
|
661
706
|
var _a, _b;
|
|
662
|
-
|
|
663
|
-
const userForce = ((_a = adapter$1 == null ? void 0 : adapter$1.userNoAd) == null ? void 0 : _a.call(adapter$1)) === true;
|
|
664
|
-
const vipHide = raw.vip_no_ad === 1 && ((_b = adapter$1 == null ? void 0 : adapter$1.isVip) == null ? void 0 : _b.call(adapter$1)) === true;
|
|
665
|
-
if (userForce || vipHide) {
|
|
666
|
-
return { ...EMPTY, reward_unit_id: raw.reward_unit_id, vip_no_ad: 1 };
|
|
667
|
-
}
|
|
668
|
-
return raw;
|
|
669
|
-
});
|
|
670
|
-
async function loadConfig2(force = false) {
|
|
671
|
-
if (loaded.value && !force)
|
|
672
|
-
return;
|
|
673
|
-
if (pending$1 && !force)
|
|
674
|
-
return pending$1;
|
|
675
|
-
if (!(adapter$1 == null ? void 0 : adapter$1.getConfig)) {
|
|
676
|
-
console.warn("[useAd] adapter.getConfig 未注入;先调用 setConfigAd()");
|
|
707
|
+
if (!popupAd)
|
|
677
708
|
return;
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
}
|
|
706
|
-
if ((adapter$1 == null ? void 0 : adapter$1.isAuth) && !adapter$1.isAuth()) {
|
|
707
|
-
msg().toast("请先登录");
|
|
708
|
-
return;
|
|
709
|
-
}
|
|
710
|
-
const closeRes = await playRewardedOnce(unitId);
|
|
711
|
-
if (onClose)
|
|
712
|
-
await onClose(closeRes);
|
|
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
|
+
function setAdPopup(adId, done) {
|
|
717
|
+
var _a, _b, _c;
|
|
718
|
+
popupDone = done;
|
|
719
|
+
const wxApi = api();
|
|
720
|
+
if (!adId || !(wxApi == null ? void 0 : wxApi.createInterstitialAd))
|
|
721
|
+
return false;
|
|
722
|
+
clearPopup();
|
|
723
|
+
popupAd = wxApi.createInterstitialAd({ adUnitId: adId });
|
|
724
|
+
(_a = popupAd.onLoad) == null ? void 0 : _a.call(popupAd, () => {
|
|
725
|
+
});
|
|
726
|
+
popupError = (err) => {
|
|
727
|
+
console.error("插屏广告加载失败", err);
|
|
728
|
+
popupDone == null ? void 0 : popupDone(false);
|
|
729
|
+
};
|
|
730
|
+
popupClose = () => {
|
|
731
|
+
popupDone == null ? void 0 : popupDone(true);
|
|
732
|
+
};
|
|
733
|
+
(_b = popupAd.onError) == null ? void 0 : _b.call(popupAd, popupError);
|
|
734
|
+
(_c = popupAd.onClose) == null ? void 0 : _c.call(popupAd, popupClose);
|
|
735
|
+
return true;
|
|
713
736
|
}
|
|
714
|
-
function
|
|
737
|
+
function showAdPopup(delay = 3e3) {
|
|
715
738
|
return new Promise((resolve) => {
|
|
739
|
+
if (!popupAd) {
|
|
740
|
+
resolve(false);
|
|
741
|
+
return;
|
|
742
|
+
}
|
|
743
|
+
const done = popupDone;
|
|
744
|
+
popupDone = (ok) => {
|
|
745
|
+
done == null ? void 0 : done(ok);
|
|
746
|
+
resolve(ok);
|
|
747
|
+
};
|
|
716
748
|
setTimeout(() => {
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
resolve(false);
|
|
721
|
-
return;
|
|
722
|
-
}
|
|
723
|
-
showInterstitialAd(unitId).then(resolve);
|
|
749
|
+
popupAd.show().catch((err) => {
|
|
750
|
+
console.error("插屏广告显示失败", err);
|
|
751
|
+
popupDone == null ? void 0 : popupDone(false);
|
|
724
752
|
});
|
|
725
|
-
},
|
|
753
|
+
}, Math.max(0, delay));
|
|
726
754
|
});
|
|
727
755
|
}
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
loadConfig: loadConfig2,
|
|
734
|
-
getUnitId,
|
|
735
|
-
showReward,
|
|
736
|
-
showPopup,
|
|
737
|
-
confirm: confirmModal
|
|
738
|
-
};
|
|
739
|
-
}
|
|
740
|
-
async function playRewardedOnce(unitId) {
|
|
741
|
-
msg().showLoading("广告加载中");
|
|
742
|
-
let hidden = false;
|
|
743
|
-
const hide = () => {
|
|
744
|
-
if (hidden)
|
|
745
|
-
return;
|
|
746
|
-
hidden = true;
|
|
747
|
-
msg().hideLoading();
|
|
748
|
-
};
|
|
749
|
-
try {
|
|
750
|
-
const isEnded = await showRewardedAd(unitId, { onShown: hide });
|
|
751
|
-
return { isEnded };
|
|
752
|
-
} finally {
|
|
753
|
-
hide();
|
|
754
|
-
}
|
|
755
|
-
}
|
|
756
|
-
function confirmModal() {
|
|
757
|
-
return new Promise((resolve) => {
|
|
758
|
-
uni.showModal({
|
|
759
|
-
title: "提示",
|
|
760
|
-
content: "看完广告才可以领取奖励哦,要继续观看吗?",
|
|
761
|
-
confirmText: "继续观看",
|
|
762
|
-
cancelText: "放弃",
|
|
763
|
-
success: (r) => resolve(!!r.confirm),
|
|
764
|
-
fail: () => resolve(false)
|
|
756
|
+
function setAdReward(adId, done) {
|
|
757
|
+
var _a, _b, _c;
|
|
758
|
+
rewardDone = done;
|
|
759
|
+
rewardPromise = new Promise((resolve) => {
|
|
760
|
+
rewardResolve = resolve;
|
|
765
761
|
});
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
var _a;
|
|
771
|
-
let entry = rewardedCache.get(unitId);
|
|
772
|
-
if (!entry) {
|
|
773
|
-
const ad2 = uni.createRewardedVideoAd({ adUnitId: unitId });
|
|
774
|
-
if (!ad2) {
|
|
775
|
-
resolve(false);
|
|
776
|
-
return;
|
|
777
|
-
}
|
|
778
|
-
(_a = ad2.onError) == null ? void 0 : _a.call(ad2, (err) => {
|
|
779
|
-
console.warn(`[useAd] reward onError (${unitId})`, err);
|
|
780
|
-
});
|
|
781
|
-
entry = { ad: ad2, loading: false };
|
|
782
|
-
rewardedCache.set(unitId, entry);
|
|
762
|
+
const wxApi = api();
|
|
763
|
+
if (!adId || !(wxApi == null ? void 0 : wxApi.createRewardedVideoAd)) {
|
|
764
|
+
finish({ ok: false });
|
|
765
|
+
return rewardPromise;
|
|
783
766
|
}
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
(_a2 = ad.offClose) == null ? void 0 : _a2.call(ad, closeHandler);
|
|
791
|
-
closeHandler = null;
|
|
792
|
-
}
|
|
793
|
-
if (errorHandler) {
|
|
794
|
-
(_b = ad.offError) == null ? void 0 : _b.call(ad, errorHandler);
|
|
795
|
-
errorHandler = null;
|
|
796
|
-
}
|
|
797
|
-
};
|
|
798
|
-
closeHandler = (res) => {
|
|
799
|
-
cleanup();
|
|
800
|
-
resolve(!!(res && res.isEnded));
|
|
767
|
+
clearReward();
|
|
768
|
+
rewardAd = wxApi.createRewardedVideoAd({ adUnitId: adId });
|
|
769
|
+
(_a = rewardAd.onLoad) == null ? void 0 : _a.call(rewardAd, () => {
|
|
770
|
+
});
|
|
771
|
+
rewardClose = (res) => {
|
|
772
|
+
finish({ ok: !!(res == null ? void 0 : res.isEnded), isEnded: !!(res == null ? void 0 : res.isEnded) });
|
|
801
773
|
};
|
|
802
|
-
|
|
803
|
-
console.
|
|
804
|
-
|
|
805
|
-
resolve(false);
|
|
774
|
+
rewardError = (err) => {
|
|
775
|
+
console.error("激励视频广告加载失败", err);
|
|
776
|
+
finish({ ok: false, err });
|
|
806
777
|
};
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
console.warn("[useAd] onShown error", e);
|
|
815
|
-
}
|
|
816
|
-
}).catch(() => {
|
|
817
|
-
cleanup();
|
|
818
|
-
resolve(false);
|
|
819
|
-
});
|
|
820
|
-
if (entry.loading) {
|
|
821
|
-
Promise.resolve().then(doShow);
|
|
822
|
-
} else {
|
|
823
|
-
entry.loading = true;
|
|
824
|
-
ad.load().then(doShow).catch(doShow).finally(() => {
|
|
825
|
-
if (entry)
|
|
826
|
-
entry.loading = false;
|
|
827
|
-
});
|
|
778
|
+
(_b = rewardAd.onClose) == null ? void 0 : _b.call(rewardAd, rewardClose);
|
|
779
|
+
(_c = rewardAd.onError) == null ? void 0 : _c.call(rewardAd, rewardError);
|
|
780
|
+
return rewardPromise;
|
|
781
|
+
}
|
|
782
|
+
function showAdReward() {
|
|
783
|
+
if (!rewardAd) {
|
|
784
|
+
return Promise.resolve({ ok: false });
|
|
828
785
|
}
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
console.warn("[useAd] 当前基础库不支持插屏广告");
|
|
838
|
-
resolve(false);
|
|
839
|
-
return;
|
|
840
|
-
}
|
|
841
|
-
ad = uni.createInterstitialAd({ adUnitId: unitId });
|
|
842
|
-
if (!ad) {
|
|
843
|
-
resolve(false);
|
|
844
|
-
return;
|
|
845
|
-
}
|
|
846
|
-
(_a = ad.onError) == null ? void 0 : _a.call(ad, (err) => {
|
|
847
|
-
console.warn(`[useAd] popup onError (${unitId})`, err);
|
|
786
|
+
const current = rewardPromise || new Promise((resolve) => {
|
|
787
|
+
rewardResolve = resolve;
|
|
788
|
+
});
|
|
789
|
+
rewardPromise = current;
|
|
790
|
+
rewardAd.show().catch(() => {
|
|
791
|
+
rewardAd.load().then(() => rewardAd.show()).catch((err) => {
|
|
792
|
+
console.error("激励视频广告显示失败", err);
|
|
793
|
+
finish({ ok: false, err });
|
|
848
794
|
});
|
|
849
|
-
interstitialCache.set(unitId, ad);
|
|
850
|
-
}
|
|
851
|
-
ad.show().then(() => resolve(true)).catch((err) => {
|
|
852
|
-
console.warn(`[useAd] popup show error (${unitId})`, err);
|
|
853
|
-
resolve(false);
|
|
854
795
|
});
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
rewardedCache.clear();
|
|
863
|
-
interstitialCache.forEach((ad) => {
|
|
864
|
-
var _a;
|
|
865
|
-
return (_a = ad == null ? void 0 : ad.destroy) == null ? void 0 : _a.call(ad);
|
|
866
|
-
});
|
|
867
|
-
interstitialCache.clear();
|
|
868
|
-
}
|
|
869
|
-
function useShare(config2) {
|
|
870
|
-
const resolve = (from) => typeof config2 === "function" ? config2(from) : config2;
|
|
871
|
-
uniApp.onShareAppMessage((options) => {
|
|
872
|
-
const resolved = resolve((options == null ? void 0 : options.from) ?? "menu");
|
|
873
|
-
const payload = {};
|
|
874
|
-
if (resolved.title !== void 0)
|
|
875
|
-
payload.title = resolved.title;
|
|
876
|
-
if (resolved.path !== void 0)
|
|
877
|
-
payload.path = resolved.path;
|
|
878
|
-
if (resolved.imageUrl !== void 0)
|
|
879
|
-
payload.imageUrl = resolved.imageUrl;
|
|
880
|
-
return payload;
|
|
881
|
-
});
|
|
882
|
-
uniApp.onShareTimeline(() => {
|
|
883
|
-
const resolved = resolve("menu");
|
|
884
|
-
const timeline = resolved.timeline ?? {};
|
|
885
|
-
const payload = {};
|
|
886
|
-
const title = timeline.title ?? resolved.title;
|
|
887
|
-
const imageUrl = timeline.imageUrl ?? resolved.imageUrl;
|
|
888
|
-
if (title !== void 0)
|
|
889
|
-
payload.title = title;
|
|
890
|
-
if (timeline.query !== void 0)
|
|
891
|
-
payload.query = timeline.query;
|
|
892
|
-
if (imageUrl !== void 0)
|
|
893
|
-
payload.imageUrl = imageUrl;
|
|
894
|
-
return payload;
|
|
895
|
-
});
|
|
896
|
-
}
|
|
897
|
-
let shareAdapter = null;
|
|
898
|
-
const shareCache = vue.ref(null);
|
|
899
|
-
let sharePending = null;
|
|
900
|
-
function setConfigShare(a) {
|
|
901
|
-
shareAdapter = a;
|
|
902
|
-
}
|
|
903
|
-
function loadShareConfig() {
|
|
904
|
-
if (shareCache.value)
|
|
905
|
-
return Promise.resolve();
|
|
906
|
-
if (sharePending)
|
|
907
|
-
return sharePending;
|
|
908
|
-
if (!(shareAdapter == null ? void 0 : shareAdapter.getConfig)) {
|
|
909
|
-
console.warn("[useShareConfig] adapter.getConfig 未注入;先调用 setConfigShare()");
|
|
910
|
-
return Promise.resolve();
|
|
911
|
-
}
|
|
912
|
-
sharePending = shareAdapter.getConfig().then((raw) => {
|
|
913
|
-
const cfg = unwrapPayload(raw);
|
|
914
|
-
if (cfg)
|
|
915
|
-
shareCache.value = cfg;
|
|
916
|
-
}).catch((e) => {
|
|
917
|
-
console.warn("[useShareConfig] load failed", e);
|
|
918
|
-
}).finally(() => {
|
|
919
|
-
sharePending = null;
|
|
920
|
-
});
|
|
921
|
-
return sharePending;
|
|
922
|
-
}
|
|
923
|
-
function useShareConfig(pageKey, fallback) {
|
|
924
|
-
void loadShareConfig();
|
|
925
|
-
return () => {
|
|
926
|
-
var _a;
|
|
927
|
-
const remote = (_a = shareCache.value) == null ? void 0 : _a[pageKey];
|
|
928
|
-
const title = (remote == null ? void 0 : remote.title) || fallback.title;
|
|
929
|
-
const image = (remote == null ? void 0 : remote.image) || fallback.image;
|
|
930
|
-
const payload = { title, path: fallback.path };
|
|
931
|
-
if (image)
|
|
932
|
-
payload.imageUrl = image;
|
|
933
|
-
return payload;
|
|
796
|
+
return current;
|
|
797
|
+
}
|
|
798
|
+
return {
|
|
799
|
+
setAdPopup,
|
|
800
|
+
showAdPopup,
|
|
801
|
+
setAdReward,
|
|
802
|
+
showAdReward
|
|
934
803
|
};
|
|
935
804
|
}
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
function loadConfig() {
|
|
943
|
-
if (config.value)
|
|
944
|
-
return Promise.resolve();
|
|
945
|
-
if (pending)
|
|
946
|
-
return pending;
|
|
947
|
-
if (!(adapter == null ? void 0 : adapter.getConfig)) {
|
|
948
|
-
console.warn("[useContact] adapter.getConfig 未注入;先调用 setConfigContact()");
|
|
949
|
-
return Promise.resolve();
|
|
950
|
-
}
|
|
951
|
-
pending = adapter.getConfig().then((raw) => {
|
|
952
|
-
const cfg = unwrapPayload(raw);
|
|
953
|
-
if (cfg)
|
|
954
|
-
config.value = cfg;
|
|
955
|
-
}).catch((e) => {
|
|
956
|
-
console.warn("[useContact] load config failed", e);
|
|
957
|
-
}).finally(() => {
|
|
958
|
-
pending = null;
|
|
959
|
-
});
|
|
960
|
-
return pending;
|
|
805
|
+
function fail(message, options = {}) {
|
|
806
|
+
var _a;
|
|
807
|
+
if (!options.silent) {
|
|
808
|
+
uni.showToast({ title: message, icon: "none" });
|
|
809
|
+
}
|
|
810
|
+
(_a = options.onFail) == null ? void 0 : _a.call(options, message);
|
|
961
811
|
}
|
|
962
|
-
function
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
return {
|
|
967
|
-
sendMessageTitle: ((_a = config.value) == null ? void 0 : _a.send_message_title) || "",
|
|
968
|
-
sendMessagePath: ((_b = config.value) == null ? void 0 : _b.send_message_path) || "",
|
|
969
|
-
sendMessageImg: ((_c = config.value) == null ? void 0 : _c.send_message_img) || "",
|
|
970
|
-
showMessageCard: ((_d = config.value) == null ? void 0 : _d.show_message_card) ?? false
|
|
971
|
-
};
|
|
972
|
-
});
|
|
812
|
+
function failHandler(target, options = {}) {
|
|
813
|
+
return (error) => {
|
|
814
|
+
fail((error == null ? void 0 : error.errMsg) || `无法跳转:${target}`, options);
|
|
815
|
+
};
|
|
973
816
|
}
|
|
974
|
-
function
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
const dataset = ((_a = data == null ? void 0 : data.currentTarget) == null ? void 0 : _a.dataset) || ((_b = data == null ? void 0 : data.target) == null ? void 0 : _b.dataset);
|
|
979
|
-
const text = dataset == null ? void 0 : dataset.copy;
|
|
980
|
-
if (text == null || text === "")
|
|
981
|
-
return Promise.resolve(false);
|
|
982
|
-
return copy(String(text), (dataset == null ? void 0 : dataset.copyToast) !== "false");
|
|
983
|
-
}
|
|
984
|
-
return new Promise((resolve) => {
|
|
985
|
-
uni.setClipboardData({
|
|
986
|
-
data,
|
|
987
|
-
showToast: false,
|
|
988
|
-
success: () => {
|
|
989
|
-
if (showToast) {
|
|
990
|
-
uni.showToast({ title: "复制成功", icon: "none", duration: 1500 });
|
|
991
|
-
}
|
|
992
|
-
resolve(true);
|
|
993
|
-
},
|
|
994
|
-
fail: () => resolve(false)
|
|
995
|
-
});
|
|
996
|
-
});
|
|
817
|
+
function navigate(type = "navigateTo", url = "", options = {}) {
|
|
818
|
+
if (type === "navigateBack") {
|
|
819
|
+
uni.navigateBack({ delta: options.delta || 1, fail: failHandler("返回上一页", options) });
|
|
820
|
+
return;
|
|
997
821
|
}
|
|
998
|
-
|
|
999
|
-
|
|
822
|
+
if (!url) {
|
|
823
|
+
fail("跳转目标未配置", options);
|
|
824
|
+
return;
|
|
1000
825
|
}
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
fail: () => resolve("")
|
|
1006
|
-
});
|
|
1007
|
-
});
|
|
826
|
+
const onFail = failHandler(url, options);
|
|
827
|
+
if (type === "redirectTo") {
|
|
828
|
+
uni.redirectTo({ url, fail: onFail });
|
|
829
|
+
return;
|
|
1008
830
|
}
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
filePath,
|
|
1013
|
-
success: () => {
|
|
1014
|
-
uni.showToast({ title: "保存成功", icon: "success" });
|
|
1015
|
-
resolve(true);
|
|
1016
|
-
},
|
|
1017
|
-
fail: (err) => {
|
|
1018
|
-
if (err.errMsg.includes("auth deny") || err.errMsg.includes("authorize")) {
|
|
1019
|
-
uni.showModal({
|
|
1020
|
-
title: "提示",
|
|
1021
|
-
content: "需要授权相册权限",
|
|
1022
|
-
confirmText: "去设置",
|
|
1023
|
-
success: (res) => {
|
|
1024
|
-
if (res.confirm)
|
|
1025
|
-
uni.openSetting();
|
|
1026
|
-
}
|
|
1027
|
-
});
|
|
1028
|
-
} else {
|
|
1029
|
-
uni.showToast({ title: "保存失败", icon: "none" });
|
|
1030
|
-
}
|
|
1031
|
-
resolve(false);
|
|
1032
|
-
}
|
|
1033
|
-
});
|
|
1034
|
-
});
|
|
831
|
+
if (type === "switchTab") {
|
|
832
|
+
uni.switchTab({ url, fail: onFail });
|
|
833
|
+
return;
|
|
1035
834
|
}
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
url: options.url,
|
|
1040
|
-
filePath: options.filePath,
|
|
1041
|
-
header: options.header,
|
|
1042
|
-
success: (res) => {
|
|
1043
|
-
if (res.statusCode === 200) {
|
|
1044
|
-
resolve({ success: true, tempFilePath: res.tempFilePath, statusCode: res.statusCode });
|
|
1045
|
-
} else {
|
|
1046
|
-
resolve({ success: false, statusCode: res.statusCode, errMsg: `下载失败,状态码:${res.statusCode}` });
|
|
1047
|
-
}
|
|
1048
|
-
},
|
|
1049
|
-
fail: (err) => resolve({ success: false, errMsg: err.errMsg })
|
|
1050
|
-
});
|
|
1051
|
-
if (options.onProgress) {
|
|
1052
|
-
task.onProgressUpdate((res) => {
|
|
1053
|
-
options.onProgress(res.progress, res.totalBytesWritten, res.totalBytesExpectedToWrite);
|
|
1054
|
-
});
|
|
1055
|
-
}
|
|
1056
|
-
});
|
|
835
|
+
if (type === "reLaunch") {
|
|
836
|
+
uni.reLaunch({ url, fail: onFail });
|
|
837
|
+
return;
|
|
1057
838
|
}
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
onProgress: onProgress ? (progress) => onProgress(progress) : void 0
|
|
1064
|
-
});
|
|
1065
|
-
uni.hideLoading();
|
|
1066
|
-
if (!result.success || !result.tempFilePath) {
|
|
1067
|
-
uni.showToast({ title: result.errMsg || "下载失败", icon: "none" });
|
|
1068
|
-
return false;
|
|
1069
|
-
}
|
|
1070
|
-
return await saveImage(result.tempFilePath);
|
|
1071
|
-
} catch {
|
|
1072
|
-
uni.hideLoading();
|
|
1073
|
-
uni.showToast({ title: "操作失败", icon: "none" });
|
|
1074
|
-
return false;
|
|
839
|
+
if (type === "miniprogram") {
|
|
840
|
+
const openMiniProgram = uni.navigateToMiniProgram;
|
|
841
|
+
if (!openMiniProgram) {
|
|
842
|
+
fail("当前平台不支持打开小程序", options);
|
|
843
|
+
return;
|
|
1075
844
|
}
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
return [
|
|
1084
|
-
parseInt(hex.slice(1, 3), 16),
|
|
1085
|
-
parseInt(hex.slice(3, 5), 16),
|
|
1086
|
-
parseInt(hex.slice(5, 7), 16)
|
|
1087
|
-
];
|
|
1088
|
-
}
|
|
1089
|
-
function useColor() {
|
|
1090
|
-
function varsToStyle2(vars) {
|
|
1091
|
-
return Object.entries(vars).map(([k, v]) => `${k}:${v}`).join(";") + ";";
|
|
1092
|
-
}
|
|
1093
|
-
function hexToRgba2(hex, alpha) {
|
|
1094
|
-
const [r, g, b] = parseHex(hex);
|
|
1095
|
-
return `rgba(${r},${g},${b},${alpha})`;
|
|
1096
|
-
}
|
|
1097
|
-
function darkenHex2(hex, amount = 0.15) {
|
|
1098
|
-
const [r, g, b] = parseHex(hex);
|
|
1099
|
-
const d = (c) => Math.max(0, Math.round(c * (1 - amount)));
|
|
1100
|
-
return `#${d(r).toString(16).padStart(2, "0")}${d(g).toString(16).padStart(2, "0")}${d(b).toString(16).padStart(2, "0")}`;
|
|
1101
|
-
}
|
|
1102
|
-
return { varsToStyle: varsToStyle2, hexToRgba: hexToRgba2, darkenHex: darkenHex2 };
|
|
1103
|
-
}
|
|
1104
|
-
function doNavigate(type, value, options = {}) {
|
|
1105
|
-
var _a;
|
|
1106
|
-
const { onFail, silent = false } = options;
|
|
1107
|
-
if (!value) {
|
|
1108
|
-
if (!silent)
|
|
1109
|
-
uni.showToast({ title: "跳转目标未配置", icon: "none" });
|
|
1110
|
-
onFail == null ? void 0 : onFail("跳转目标未配置");
|
|
845
|
+
openMiniProgram({
|
|
846
|
+
appId: url,
|
|
847
|
+
path: options.path || "",
|
|
848
|
+
envVersion: options.envVersion || "release",
|
|
849
|
+
extraData: options.extraData,
|
|
850
|
+
fail: onFail
|
|
851
|
+
});
|
|
1111
852
|
return;
|
|
1112
853
|
}
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
uni.showToast({ title: msg2, icon: "none" });
|
|
1117
|
-
onFail == null ? void 0 : onFail(msg2);
|
|
1118
|
-
};
|
|
1119
|
-
switch (type) {
|
|
1120
|
-
case "switchTab":
|
|
1121
|
-
uni.switchTab({ url: value, fail });
|
|
1122
|
-
break;
|
|
1123
|
-
case "redirectTo":
|
|
1124
|
-
uni.redirectTo({ url: value, fail });
|
|
1125
|
-
break;
|
|
1126
|
-
case "reLaunch":
|
|
1127
|
-
uni.reLaunch({ url: value, fail });
|
|
1128
|
-
break;
|
|
1129
|
-
case "webview":
|
|
1130
|
-
if (!silent)
|
|
1131
|
-
uni.showToast({ title: `H5:${value}`, icon: "none" });
|
|
1132
|
-
break;
|
|
1133
|
-
case "miniprogram": {
|
|
1134
|
-
(_a = uni.navigateToMiniProgram) == null ? void 0 : _a.call(uni, {
|
|
1135
|
-
appId: value,
|
|
1136
|
-
path: options.path || "",
|
|
1137
|
-
envVersion: options.envVersion,
|
|
1138
|
-
extraData: options.extraData ?? void 0,
|
|
1139
|
-
fail
|
|
1140
|
-
});
|
|
1141
|
-
break;
|
|
1142
|
-
}
|
|
1143
|
-
case "navigateTo":
|
|
1144
|
-
default:
|
|
1145
|
-
uni.navigateTo({ url: value, fail });
|
|
1146
|
-
break;
|
|
854
|
+
if (type === "webview") {
|
|
855
|
+
fail(`H5:${url}`, options);
|
|
856
|
+
return;
|
|
1147
857
|
}
|
|
858
|
+
uni.navigateTo({ url, fail: onFail });
|
|
1148
859
|
}
|
|
1149
|
-
function
|
|
860
|
+
function useNavigate() {
|
|
1150
861
|
return {
|
|
1151
|
-
navigate
|
|
862
|
+
navigate,
|
|
863
|
+
to: (url, options) => navigate("navigateTo", url, options),
|
|
864
|
+
redirect: (url, options) => navigate("redirectTo", url, options),
|
|
865
|
+
tab: (url, options) => navigate("switchTab", url, options),
|
|
866
|
+
reLaunch: (url, options) => navigate("reLaunch", url, options),
|
|
867
|
+
back: (delta = 1, options = {}) => navigate("navigateBack", "", { ...options, delta }),
|
|
868
|
+
miniProgram: (appId, options) => navigate("miniprogram", appId, options)
|
|
1152
869
|
};
|
|
1153
870
|
}
|
|
1154
|
-
function useUuid() {
|
|
1155
|
-
function v4() {
|
|
1156
|
-
const bytes = [];
|
|
1157
|
-
for (let i = 0; i < 16; i++) {
|
|
1158
|
-
bytes.push(Math.floor(Math.random() * 256));
|
|
1159
|
-
}
|
|
1160
|
-
bytes[6] = bytes[6] & 15 | 64;
|
|
1161
|
-
bytes[8] = bytes[8] & 63 | 128;
|
|
1162
|
-
return bytes.map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
1163
|
-
}
|
|
1164
|
-
return { v4 };
|
|
1165
|
-
}
|
|
1166
871
|
const useThemeStore = pinia.defineStore(
|
|
1167
872
|
"theme",
|
|
1168
873
|
() => {
|
|
@@ -1307,7 +1012,6 @@ var __publicField = (obj, key, value) => {
|
|
|
1307
1012
|
function getCurrentFontVars() {
|
|
1308
1013
|
return FONT_PRESETS[getCurrentFontScale()].vars;
|
|
1309
1014
|
}
|
|
1310
|
-
const { hexToRgba, darkenHex } = useColor();
|
|
1311
1015
|
const THEME_COLOR_KEY = "hlw_theme_color";
|
|
1312
1016
|
const THEME_SEMANTIC_COLORS = {
|
|
1313
1017
|
success: "#10b981",
|
|
@@ -1364,6 +1068,25 @@ var __publicField = (obj, key, value) => {
|
|
|
1364
1068
|
"--info-dark": darkenHex(THEME_SEMANTIC_COLORS.info)
|
|
1365
1069
|
};
|
|
1366
1070
|
}
|
|
1071
|
+
const HEX_RE = /^#[0-9a-fA-F]{6}$/;
|
|
1072
|
+
function parseHex(hex) {
|
|
1073
|
+
if (!HEX_RE.test(hex))
|
|
1074
|
+
throw new Error(`Invalid hex color: ${hex}`);
|
|
1075
|
+
return [
|
|
1076
|
+
parseInt(hex.slice(1, 3), 16),
|
|
1077
|
+
parseInt(hex.slice(3, 5), 16),
|
|
1078
|
+
parseInt(hex.slice(5, 7), 16)
|
|
1079
|
+
];
|
|
1080
|
+
}
|
|
1081
|
+
function hexToRgba(hex, alpha) {
|
|
1082
|
+
const [r, g, b] = parseHex(hex);
|
|
1083
|
+
return `rgba(${r},${g},${b},${alpha})`;
|
|
1084
|
+
}
|
|
1085
|
+
function darkenHex(hex, amount = 0.15) {
|
|
1086
|
+
const [r, g, b] = parseHex(hex);
|
|
1087
|
+
const darken = (value) => Math.max(0, Math.round(value * (1 - amount)));
|
|
1088
|
+
return `#${darken(r).toString(16).padStart(2, "0")}${darken(g).toString(16).padStart(2, "0")}${darken(b).toString(16).padStart(2, "0")}`;
|
|
1089
|
+
}
|
|
1367
1090
|
const APPEARANCE_KEY = "hlw_appearance";
|
|
1368
1091
|
const APPEARANCE_PRESETS = [
|
|
1369
1092
|
{ value: "light", label: "浅色模式" },
|
|
@@ -1484,7 +1207,6 @@ var __publicField = (obj, key, value) => {
|
|
|
1484
1207
|
}
|
|
1485
1208
|
return vars;
|
|
1486
1209
|
}
|
|
1487
|
-
const { varsToStyle } = useColor();
|
|
1488
1210
|
const THEME_CHANGE_EVENT = "hlw:theme-change";
|
|
1489
1211
|
function buildThemeStyle() {
|
|
1490
1212
|
return varsToStyle({
|
|
@@ -1492,6 +1214,9 @@ var __publicField = (obj, key, value) => {
|
|
|
1492
1214
|
...getCurrentThemeVars()
|
|
1493
1215
|
});
|
|
1494
1216
|
}
|
|
1217
|
+
function varsToStyle(vars) {
|
|
1218
|
+
return Object.entries(vars).map(([key, value]) => `${key}:${value}`).join(";") + ";";
|
|
1219
|
+
}
|
|
1495
1220
|
function useThemePageStyle() {
|
|
1496
1221
|
const store = useThemeStore();
|
|
1497
1222
|
const themePageStyle = vue.computed(() => {
|
|
@@ -1501,17 +1226,8 @@ var __publicField = (obj, key, value) => {
|
|
|
1501
1226
|
});
|
|
1502
1227
|
return { themePageStyle };
|
|
1503
1228
|
}
|
|
1504
|
-
function getErrorMessage(error) {
|
|
1505
|
-
if (error instanceof Error && error.message)
|
|
1506
|
-
return error.message;
|
|
1507
|
-
if (typeof error === "string" && error)
|
|
1508
|
-
return error;
|
|
1509
|
-
return "查询失败,请稍后重试";
|
|
1510
|
-
}
|
|
1511
1229
|
let _msg = null;
|
|
1512
|
-
let _device = null;
|
|
1513
1230
|
let _utils = null;
|
|
1514
|
-
let _color = null;
|
|
1515
1231
|
const hlw = {
|
|
1516
1232
|
/** 延迟创建消息提示实例。 */
|
|
1517
1233
|
get $msg() {
|
|
@@ -1519,269 +1235,16 @@ var __publicField = (obj, key, value) => {
|
|
|
1519
1235
|
},
|
|
1520
1236
|
/** 延迟读取并缓存设备信息。 */
|
|
1521
1237
|
get $device() {
|
|
1522
|
-
return
|
|
1238
|
+
return useDevice().info;
|
|
1523
1239
|
},
|
|
1524
|
-
/**
|
|
1525
|
-
$
|
|
1240
|
+
/** 复用全局请求实例。 */
|
|
1241
|
+
$request: useRequest(),
|
|
1526
1242
|
/** 延迟创建通用工具实例。 */
|
|
1527
1243
|
get $utils() {
|
|
1528
1244
|
return _utils ?? (_utils = useUtils());
|
|
1529
|
-
},
|
|
1530
|
-
/** 延迟创建颜色工具实例。 */
|
|
1531
|
-
get $color() {
|
|
1532
|
-
return _color ?? (_color = useColor());
|
|
1533
1245
|
}
|
|
1534
1246
|
};
|
|
1535
|
-
function getDefaultExportFromCjs(x) {
|
|
1536
|
-
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
1537
|
-
}
|
|
1538
|
-
var md5$1 = { exports: {} };
|
|
1539
|
-
var crypt = { exports: {} };
|
|
1540
|
-
(function() {
|
|
1541
|
-
var base64map = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", crypt$1 = {
|
|
1542
|
-
// Bit-wise rotation left
|
|
1543
|
-
rotl: function(n, b) {
|
|
1544
|
-
return n << b | n >>> 32 - b;
|
|
1545
|
-
},
|
|
1546
|
-
// Bit-wise rotation right
|
|
1547
|
-
rotr: function(n, b) {
|
|
1548
|
-
return n << 32 - b | n >>> b;
|
|
1549
|
-
},
|
|
1550
|
-
// Swap big-endian to little-endian and vice versa
|
|
1551
|
-
endian: function(n) {
|
|
1552
|
-
if (n.constructor == Number) {
|
|
1553
|
-
return crypt$1.rotl(n, 8) & 16711935 | crypt$1.rotl(n, 24) & 4278255360;
|
|
1554
|
-
}
|
|
1555
|
-
for (var i = 0; i < n.length; i++)
|
|
1556
|
-
n[i] = crypt$1.endian(n[i]);
|
|
1557
|
-
return n;
|
|
1558
|
-
},
|
|
1559
|
-
// Generate an array of any length of random bytes
|
|
1560
|
-
randomBytes: function(n) {
|
|
1561
|
-
for (var bytes = []; n > 0; n--)
|
|
1562
|
-
bytes.push(Math.floor(Math.random() * 256));
|
|
1563
|
-
return bytes;
|
|
1564
|
-
},
|
|
1565
|
-
// Convert a byte array to big-endian 32-bit words
|
|
1566
|
-
bytesToWords: function(bytes) {
|
|
1567
|
-
for (var words = [], i = 0, b = 0; i < bytes.length; i++, b += 8)
|
|
1568
|
-
words[b >>> 5] |= bytes[i] << 24 - b % 32;
|
|
1569
|
-
return words;
|
|
1570
|
-
},
|
|
1571
|
-
// Convert big-endian 32-bit words to a byte array
|
|
1572
|
-
wordsToBytes: function(words) {
|
|
1573
|
-
for (var bytes = [], b = 0; b < words.length * 32; b += 8)
|
|
1574
|
-
bytes.push(words[b >>> 5] >>> 24 - b % 32 & 255);
|
|
1575
|
-
return bytes;
|
|
1576
|
-
},
|
|
1577
|
-
// Convert a byte array to a hex string
|
|
1578
|
-
bytesToHex: function(bytes) {
|
|
1579
|
-
for (var hex = [], i = 0; i < bytes.length; i++) {
|
|
1580
|
-
hex.push((bytes[i] >>> 4).toString(16));
|
|
1581
|
-
hex.push((bytes[i] & 15).toString(16));
|
|
1582
|
-
}
|
|
1583
|
-
return hex.join("");
|
|
1584
|
-
},
|
|
1585
|
-
// Convert a hex string to a byte array
|
|
1586
|
-
hexToBytes: function(hex) {
|
|
1587
|
-
for (var bytes = [], c = 0; c < hex.length; c += 2)
|
|
1588
|
-
bytes.push(parseInt(hex.substr(c, 2), 16));
|
|
1589
|
-
return bytes;
|
|
1590
|
-
},
|
|
1591
|
-
// Convert a byte array to a base-64 string
|
|
1592
|
-
bytesToBase64: function(bytes) {
|
|
1593
|
-
for (var base64 = [], i = 0; i < bytes.length; i += 3) {
|
|
1594
|
-
var triplet = bytes[i] << 16 | bytes[i + 1] << 8 | bytes[i + 2];
|
|
1595
|
-
for (var j = 0; j < 4; j++)
|
|
1596
|
-
if (i * 8 + j * 6 <= bytes.length * 8)
|
|
1597
|
-
base64.push(base64map.charAt(triplet >>> 6 * (3 - j) & 63));
|
|
1598
|
-
else
|
|
1599
|
-
base64.push("=");
|
|
1600
|
-
}
|
|
1601
|
-
return base64.join("");
|
|
1602
|
-
},
|
|
1603
|
-
// Convert a base-64 string to a byte array
|
|
1604
|
-
base64ToBytes: function(base64) {
|
|
1605
|
-
base64 = base64.replace(/[^A-Z0-9+\/]/ig, "");
|
|
1606
|
-
for (var bytes = [], i = 0, imod4 = 0; i < base64.length; imod4 = ++i % 4) {
|
|
1607
|
-
if (imod4 == 0)
|
|
1608
|
-
continue;
|
|
1609
|
-
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);
|
|
1610
|
-
}
|
|
1611
|
-
return bytes;
|
|
1612
|
-
}
|
|
1613
|
-
};
|
|
1614
|
-
crypt.exports = crypt$1;
|
|
1615
|
-
})();
|
|
1616
|
-
var cryptExports = crypt.exports;
|
|
1617
|
-
var charenc = {
|
|
1618
|
-
// UTF-8 encoding
|
|
1619
|
-
utf8: {
|
|
1620
|
-
// Convert a string to a byte array
|
|
1621
|
-
stringToBytes: function(str) {
|
|
1622
|
-
return charenc.bin.stringToBytes(unescape(encodeURIComponent(str)));
|
|
1623
|
-
},
|
|
1624
|
-
// Convert a byte array to a string
|
|
1625
|
-
bytesToString: function(bytes) {
|
|
1626
|
-
return decodeURIComponent(escape(charenc.bin.bytesToString(bytes)));
|
|
1627
|
-
}
|
|
1628
|
-
},
|
|
1629
|
-
// Binary encoding
|
|
1630
|
-
bin: {
|
|
1631
|
-
// Convert a string to a byte array
|
|
1632
|
-
stringToBytes: function(str) {
|
|
1633
|
-
for (var bytes = [], i = 0; i < str.length; i++)
|
|
1634
|
-
bytes.push(str.charCodeAt(i) & 255);
|
|
1635
|
-
return bytes;
|
|
1636
|
-
},
|
|
1637
|
-
// Convert a byte array to a string
|
|
1638
|
-
bytesToString: function(bytes) {
|
|
1639
|
-
for (var str = [], i = 0; i < bytes.length; i++)
|
|
1640
|
-
str.push(String.fromCharCode(bytes[i]));
|
|
1641
|
-
return str.join("");
|
|
1642
|
-
}
|
|
1643
|
-
}
|
|
1644
|
-
};
|
|
1645
|
-
var charenc_1 = charenc;
|
|
1646
|
-
/*!
|
|
1647
|
-
* Determine if an object is a Buffer
|
|
1648
|
-
*
|
|
1649
|
-
* @author Feross Aboukhadijeh <https://feross.org>
|
|
1650
|
-
* @license MIT
|
|
1651
|
-
*/
|
|
1652
|
-
var isBuffer_1 = function(obj) {
|
|
1653
|
-
return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer);
|
|
1654
|
-
};
|
|
1655
|
-
function isBuffer(obj) {
|
|
1656
|
-
return !!obj.constructor && typeof obj.constructor.isBuffer === "function" && obj.constructor.isBuffer(obj);
|
|
1657
|
-
}
|
|
1658
|
-
function isSlowBuffer(obj) {
|
|
1659
|
-
return typeof obj.readFloatLE === "function" && typeof obj.slice === "function" && isBuffer(obj.slice(0, 0));
|
|
1660
|
-
}
|
|
1661
|
-
(function() {
|
|
1662
|
-
var crypt2 = cryptExports, utf8 = charenc_1.utf8, isBuffer2 = isBuffer_1, bin = charenc_1.bin, md52 = function(message, options) {
|
|
1663
|
-
if (message.constructor == String)
|
|
1664
|
-
if (options && options.encoding === "binary")
|
|
1665
|
-
message = bin.stringToBytes(message);
|
|
1666
|
-
else
|
|
1667
|
-
message = utf8.stringToBytes(message);
|
|
1668
|
-
else if (isBuffer2(message))
|
|
1669
|
-
message = Array.prototype.slice.call(message, 0);
|
|
1670
|
-
else if (!Array.isArray(message) && message.constructor !== Uint8Array)
|
|
1671
|
-
message = message.toString();
|
|
1672
|
-
var m = crypt2.bytesToWords(message), l = message.length * 8, a = 1732584193, b = -271733879, c = -1732584194, d = 271733878;
|
|
1673
|
-
for (var i = 0; i < m.length; i++) {
|
|
1674
|
-
m[i] = (m[i] << 8 | m[i] >>> 24) & 16711935 | (m[i] << 24 | m[i] >>> 8) & 4278255360;
|
|
1675
|
-
}
|
|
1676
|
-
m[l >>> 5] |= 128 << l % 32;
|
|
1677
|
-
m[(l + 64 >>> 9 << 4) + 14] = l;
|
|
1678
|
-
var FF = md52._ff, GG = md52._gg, HH = md52._hh, II = md52._ii;
|
|
1679
|
-
for (var i = 0; i < m.length; i += 16) {
|
|
1680
|
-
var aa = a, bb = b, cc = c, dd = d;
|
|
1681
|
-
a = FF(a, b, c, d, m[i + 0], 7, -680876936);
|
|
1682
|
-
d = FF(d, a, b, c, m[i + 1], 12, -389564586);
|
|
1683
|
-
c = FF(c, d, a, b, m[i + 2], 17, 606105819);
|
|
1684
|
-
b = FF(b, c, d, a, m[i + 3], 22, -1044525330);
|
|
1685
|
-
a = FF(a, b, c, d, m[i + 4], 7, -176418897);
|
|
1686
|
-
d = FF(d, a, b, c, m[i + 5], 12, 1200080426);
|
|
1687
|
-
c = FF(c, d, a, b, m[i + 6], 17, -1473231341);
|
|
1688
|
-
b = FF(b, c, d, a, m[i + 7], 22, -45705983);
|
|
1689
|
-
a = FF(a, b, c, d, m[i + 8], 7, 1770035416);
|
|
1690
|
-
d = FF(d, a, b, c, m[i + 9], 12, -1958414417);
|
|
1691
|
-
c = FF(c, d, a, b, m[i + 10], 17, -42063);
|
|
1692
|
-
b = FF(b, c, d, a, m[i + 11], 22, -1990404162);
|
|
1693
|
-
a = FF(a, b, c, d, m[i + 12], 7, 1804603682);
|
|
1694
|
-
d = FF(d, a, b, c, m[i + 13], 12, -40341101);
|
|
1695
|
-
c = FF(c, d, a, b, m[i + 14], 17, -1502002290);
|
|
1696
|
-
b = FF(b, c, d, a, m[i + 15], 22, 1236535329);
|
|
1697
|
-
a = GG(a, b, c, d, m[i + 1], 5, -165796510);
|
|
1698
|
-
d = GG(d, a, b, c, m[i + 6], 9, -1069501632);
|
|
1699
|
-
c = GG(c, d, a, b, m[i + 11], 14, 643717713);
|
|
1700
|
-
b = GG(b, c, d, a, m[i + 0], 20, -373897302);
|
|
1701
|
-
a = GG(a, b, c, d, m[i + 5], 5, -701558691);
|
|
1702
|
-
d = GG(d, a, b, c, m[i + 10], 9, 38016083);
|
|
1703
|
-
c = GG(c, d, a, b, m[i + 15], 14, -660478335);
|
|
1704
|
-
b = GG(b, c, d, a, m[i + 4], 20, -405537848);
|
|
1705
|
-
a = GG(a, b, c, d, m[i + 9], 5, 568446438);
|
|
1706
|
-
d = GG(d, a, b, c, m[i + 14], 9, -1019803690);
|
|
1707
|
-
c = GG(c, d, a, b, m[i + 3], 14, -187363961);
|
|
1708
|
-
b = GG(b, c, d, a, m[i + 8], 20, 1163531501);
|
|
1709
|
-
a = GG(a, b, c, d, m[i + 13], 5, -1444681467);
|
|
1710
|
-
d = GG(d, a, b, c, m[i + 2], 9, -51403784);
|
|
1711
|
-
c = GG(c, d, a, b, m[i + 7], 14, 1735328473);
|
|
1712
|
-
b = GG(b, c, d, a, m[i + 12], 20, -1926607734);
|
|
1713
|
-
a = HH(a, b, c, d, m[i + 5], 4, -378558);
|
|
1714
|
-
d = HH(d, a, b, c, m[i + 8], 11, -2022574463);
|
|
1715
|
-
c = HH(c, d, a, b, m[i + 11], 16, 1839030562);
|
|
1716
|
-
b = HH(b, c, d, a, m[i + 14], 23, -35309556);
|
|
1717
|
-
a = HH(a, b, c, d, m[i + 1], 4, -1530992060);
|
|
1718
|
-
d = HH(d, a, b, c, m[i + 4], 11, 1272893353);
|
|
1719
|
-
c = HH(c, d, a, b, m[i + 7], 16, -155497632);
|
|
1720
|
-
b = HH(b, c, d, a, m[i + 10], 23, -1094730640);
|
|
1721
|
-
a = HH(a, b, c, d, m[i + 13], 4, 681279174);
|
|
1722
|
-
d = HH(d, a, b, c, m[i + 0], 11, -358537222);
|
|
1723
|
-
c = HH(c, d, a, b, m[i + 3], 16, -722521979);
|
|
1724
|
-
b = HH(b, c, d, a, m[i + 6], 23, 76029189);
|
|
1725
|
-
a = HH(a, b, c, d, m[i + 9], 4, -640364487);
|
|
1726
|
-
d = HH(d, a, b, c, m[i + 12], 11, -421815835);
|
|
1727
|
-
c = HH(c, d, a, b, m[i + 15], 16, 530742520);
|
|
1728
|
-
b = HH(b, c, d, a, m[i + 2], 23, -995338651);
|
|
1729
|
-
a = II(a, b, c, d, m[i + 0], 6, -198630844);
|
|
1730
|
-
d = II(d, a, b, c, m[i + 7], 10, 1126891415);
|
|
1731
|
-
c = II(c, d, a, b, m[i + 14], 15, -1416354905);
|
|
1732
|
-
b = II(b, c, d, a, m[i + 5], 21, -57434055);
|
|
1733
|
-
a = II(a, b, c, d, m[i + 12], 6, 1700485571);
|
|
1734
|
-
d = II(d, a, b, c, m[i + 3], 10, -1894986606);
|
|
1735
|
-
c = II(c, d, a, b, m[i + 10], 15, -1051523);
|
|
1736
|
-
b = II(b, c, d, a, m[i + 1], 21, -2054922799);
|
|
1737
|
-
a = II(a, b, c, d, m[i + 8], 6, 1873313359);
|
|
1738
|
-
d = II(d, a, b, c, m[i + 15], 10, -30611744);
|
|
1739
|
-
c = II(c, d, a, b, m[i + 6], 15, -1560198380);
|
|
1740
|
-
b = II(b, c, d, a, m[i + 13], 21, 1309151649);
|
|
1741
|
-
a = II(a, b, c, d, m[i + 4], 6, -145523070);
|
|
1742
|
-
d = II(d, a, b, c, m[i + 11], 10, -1120210379);
|
|
1743
|
-
c = II(c, d, a, b, m[i + 2], 15, 718787259);
|
|
1744
|
-
b = II(b, c, d, a, m[i + 9], 21, -343485551);
|
|
1745
|
-
a = a + aa >>> 0;
|
|
1746
|
-
b = b + bb >>> 0;
|
|
1747
|
-
c = c + cc >>> 0;
|
|
1748
|
-
d = d + dd >>> 0;
|
|
1749
|
-
}
|
|
1750
|
-
return crypt2.endian([a, b, c, d]);
|
|
1751
|
-
};
|
|
1752
|
-
md52._ff = function(a, b, c, d, x, s, t) {
|
|
1753
|
-
var n = a + (b & c | ~b & d) + (x >>> 0) + t;
|
|
1754
|
-
return (n << s | n >>> 32 - s) + b;
|
|
1755
|
-
};
|
|
1756
|
-
md52._gg = function(a, b, c, d, x, s, t) {
|
|
1757
|
-
var n = a + (b & d | c & ~d) + (x >>> 0) + t;
|
|
1758
|
-
return (n << s | n >>> 32 - s) + b;
|
|
1759
|
-
};
|
|
1760
|
-
md52._hh = function(a, b, c, d, x, s, t) {
|
|
1761
|
-
var n = a + (b ^ c ^ d) + (x >>> 0) + t;
|
|
1762
|
-
return (n << s | n >>> 32 - s) + b;
|
|
1763
|
-
};
|
|
1764
|
-
md52._ii = function(a, b, c, d, x, s, t) {
|
|
1765
|
-
var n = a + (c ^ (b | ~d)) + (x >>> 0) + t;
|
|
1766
|
-
return (n << s | n >>> 32 - s) + b;
|
|
1767
|
-
};
|
|
1768
|
-
md52._blocksize = 16;
|
|
1769
|
-
md52._digestsize = 16;
|
|
1770
|
-
md5$1.exports = function(message, options) {
|
|
1771
|
-
if (message === void 0 || message === null)
|
|
1772
|
-
throw new Error("Illegal argument " + message);
|
|
1773
|
-
var digestbytes = crypt2.wordsToBytes(md52(message, options));
|
|
1774
|
-
return options && options.asBytes ? digestbytes : options && options.asString ? bin.bytesToString(digestbytes) : crypt2.bytesToHex(digestbytes);
|
|
1775
|
-
};
|
|
1776
|
-
})();
|
|
1777
|
-
var md5Exports = md5$1.exports;
|
|
1778
|
-
const md5 = /* @__PURE__ */ getDefaultExportFromCjs(md5Exports);
|
|
1779
1247
|
let _installed = false;
|
|
1780
|
-
let _interceptorCleanup = [];
|
|
1781
|
-
const _defaultOpts = {
|
|
1782
|
-
tokenHeader: "x-token",
|
|
1783
|
-
autoToastError: true
|
|
1784
|
-
};
|
|
1785
1248
|
function useApp() {
|
|
1786
1249
|
const _plugins = [];
|
|
1787
1250
|
function use(pluginOrInstaller) {
|
|
@@ -1800,94 +1263,7 @@ var __publicField = (obj, key, value) => {
|
|
|
1800
1263
|
}
|
|
1801
1264
|
return createApp;
|
|
1802
1265
|
}
|
|
1803
|
-
return { install, use, hlw,
|
|
1804
|
-
}
|
|
1805
|
-
function buildSignString(url) {
|
|
1806
|
-
try {
|
|
1807
|
-
const [path, query] = url.split("?");
|
|
1808
|
-
if (!query)
|
|
1809
|
-
return path + "&";
|
|
1810
|
-
const params = query.split("&").filter(Boolean);
|
|
1811
|
-
params.sort();
|
|
1812
|
-
return params.join("&") + "&";
|
|
1813
|
-
} catch {
|
|
1814
|
-
return url;
|
|
1815
|
-
}
|
|
1816
|
-
}
|
|
1817
|
-
let _sigSecret = "";
|
|
1818
|
-
function setupInterceptors(options = {}) {
|
|
1819
|
-
const opts = { ..._defaultOpts, ...options };
|
|
1820
|
-
if (opts.sigSecret)
|
|
1821
|
-
_sigSecret = opts.sigSecret;
|
|
1822
|
-
if (opts.baseURL)
|
|
1823
|
-
http.setBaseURL(opts.baseURL);
|
|
1824
|
-
_interceptorCleanup.forEach((dispose) => dispose());
|
|
1825
|
-
_interceptorCleanup = [];
|
|
1826
|
-
const offRequest = http.onRequest((config2) => {
|
|
1827
|
-
const method = (config2.method ?? "GET").toUpperCase();
|
|
1828
|
-
if (method === "GET" && config2.data && typeof config2.data === "object") {
|
|
1829
|
-
const qs = Object.entries(config2.data).filter(([, v]) => v !== void 0 && v !== null).map(([k, v]) => `${encodeURIComponent(k)}=${encodeURIComponent(String(v))}`).join("&");
|
|
1830
|
-
if (qs) {
|
|
1831
|
-
config2.url = config2.url + (config2.url.includes("?") ? "&" : "?") + qs;
|
|
1832
|
-
}
|
|
1833
|
-
config2.data = void 0;
|
|
1834
|
-
}
|
|
1835
|
-
const device = useDevice();
|
|
1836
|
-
if (device.value) {
|
|
1837
|
-
const d = device.value;
|
|
1838
|
-
const query = [
|
|
1839
|
-
["appid", d.appid],
|
|
1840
|
-
["device_brand", d.device_brand],
|
|
1841
|
-
["device_model", d.device_model],
|
|
1842
|
-
["device_id", d.device_id],
|
|
1843
|
-
["device_type", d.device_type],
|
|
1844
|
-
["device_orientation", d.device_orientation],
|
|
1845
|
-
["platform", d.platform],
|
|
1846
|
-
["system", d.system],
|
|
1847
|
-
["os", d.os],
|
|
1848
|
-
["version", d.version],
|
|
1849
|
-
["sdk_version", d.sdk_version],
|
|
1850
|
-
["host_name", d.host_name],
|
|
1851
|
-
["host_version", d.host_version],
|
|
1852
|
-
["host_language", d.host_language],
|
|
1853
|
-
["language", d.language],
|
|
1854
|
-
["app_version", d.app_version],
|
|
1855
|
-
["app_version_code", d.app_version_code],
|
|
1856
|
-
["screen_width", String(d.screen_width)],
|
|
1857
|
-
["screen_height", String(d.screen_height)]
|
|
1858
|
-
].map(([k, v]) => `${encodeURIComponent(k)}=${encodeURIComponent(v ?? "")}`).join("&");
|
|
1859
|
-
config2.url = config2.url + (config2.url.includes("?") ? "&" : "?") + query;
|
|
1860
|
-
config2.headers = { ...config2.headers, "X-Appid": d.appid };
|
|
1861
|
-
}
|
|
1862
|
-
if (_sigSecret) {
|
|
1863
|
-
const signStr = buildSignString(config2.url);
|
|
1864
|
-
const sig = md5(signStr + _sigSecret);
|
|
1865
|
-
config2.url = config2.url + "&sig=" + sig;
|
|
1866
|
-
}
|
|
1867
|
-
if (opts.getToken) {
|
|
1868
|
-
const token = opts.getToken();
|
|
1869
|
-
if (token) {
|
|
1870
|
-
config2.headers = {
|
|
1871
|
-
...config2.headers,
|
|
1872
|
-
[opts.tokenHeader]: token
|
|
1873
|
-
};
|
|
1874
|
-
}
|
|
1875
|
-
}
|
|
1876
|
-
return config2;
|
|
1877
|
-
});
|
|
1878
|
-
const offResponse = http.onResponse((res) => {
|
|
1879
|
-
if (opts.autoToastError && res.code !== 1) {
|
|
1880
|
-
uni.showToast({ title: res.info || "请求失败", icon: "none" });
|
|
1881
|
-
}
|
|
1882
|
-
return res;
|
|
1883
|
-
});
|
|
1884
|
-
const offError = http.onError((err) => {
|
|
1885
|
-
var _a;
|
|
1886
|
-
if (err.message.includes("401")) {
|
|
1887
|
-
(_a = opts.onLogout) == null ? void 0 : _a.call(opts);
|
|
1888
|
-
}
|
|
1889
|
-
});
|
|
1890
|
-
_interceptorCleanup = [offRequest, offResponse, offError];
|
|
1266
|
+
return { install, use, hlw, request: useRequest() };
|
|
1891
1267
|
}
|
|
1892
1268
|
function copyText(data) {
|
|
1893
1269
|
uni.setClipboardData({
|
|
@@ -1926,10 +1302,12 @@ var __publicField = (obj, key, value) => {
|
|
|
1926
1302
|
exports2.APPEARANCE_KEY = APPEARANCE_KEY;
|
|
1927
1303
|
exports2.APPEARANCE_PRESETS = APPEARANCE_PRESETS;
|
|
1928
1304
|
exports2.APPEARANCE_VAR_MAP = APPEARANCE_VAR_MAP;
|
|
1305
|
+
exports2.BaseService = BaseService;
|
|
1929
1306
|
exports2.DEFAULT_THEMES = DEFAULT_THEMES;
|
|
1930
1307
|
exports2.FONT_PRESETS = FONT_PRESETS;
|
|
1931
1308
|
exports2.FONT_SCALE_KEY = FONT_SCALE_KEY;
|
|
1932
|
-
exports2.
|
|
1309
|
+
exports2.ServiceNamespace = ServiceNamespace;
|
|
1310
|
+
exports2.ServicePrefix = ServicePrefix;
|
|
1933
1311
|
exports2.THEME_CHANGE_EVENT = THEME_CHANGE_EVENT;
|
|
1934
1312
|
exports2.THEME_COLOR_KEY = THEME_COLOR_KEY;
|
|
1935
1313
|
exports2.THEME_SEMANTIC_COLORS = THEME_SEMANTIC_COLORS;
|
|
@@ -1939,8 +1317,6 @@ var __publicField = (obj, key, value) => {
|
|
|
1939
1317
|
exports2.buildThemeStyle = buildThemeStyle;
|
|
1940
1318
|
exports2.clearDeviceCache = clearDeviceCache;
|
|
1941
1319
|
exports2.cosAdapter = cosAdapter;
|
|
1942
|
-
exports2.destroyAds = destroyAds;
|
|
1943
|
-
exports2.deviceToQuery = deviceToQuery;
|
|
1944
1320
|
exports2.getAdapter = getAdapter;
|
|
1945
1321
|
exports2.getCurrentAppearance = getCurrentAppearance;
|
|
1946
1322
|
exports2.getCurrentAppearanceMode = getCurrentAppearanceMode;
|
|
@@ -1950,37 +1326,22 @@ var __publicField = (obj, key, value) => {
|
|
|
1950
1326
|
exports2.getCurrentThemeColor = getCurrentThemeColor;
|
|
1951
1327
|
exports2.getCurrentThemeVars = getCurrentThemeVars;
|
|
1952
1328
|
exports2.getCurrentTypographyVars = getCurrentTypographyVars;
|
|
1953
|
-
exports2.getErrorMessage = getErrorMessage;
|
|
1954
1329
|
exports2.hlw = hlw;
|
|
1955
|
-
exports2.http = http;
|
|
1956
1330
|
exports2.ossAdapter = ossAdapter;
|
|
1957
1331
|
exports2.qiniuAdapter = qiniuAdapter;
|
|
1958
1332
|
exports2.resolveAppearance = resolveAppearance;
|
|
1959
|
-
exports2.setConfigAd = setConfigAd;
|
|
1960
|
-
exports2.setConfigContact = setConfigContact;
|
|
1961
|
-
exports2.setConfigShare = setConfigShare;
|
|
1962
|
-
exports2.setupInterceptors = setupInterceptors;
|
|
1963
|
-
exports2.useAd = useAd;
|
|
1964
1333
|
exports2.useApp = useApp;
|
|
1965
|
-
exports2.useColor = useColor;
|
|
1966
|
-
exports2.useContact = useContact;
|
|
1967
1334
|
exports2.useDevice = useDevice;
|
|
1968
|
-
exports2.
|
|
1969
|
-
exports2.useLoading = useLoading;
|
|
1335
|
+
exports2.useHlwAd = useHlwAd;
|
|
1970
1336
|
exports2.useMsg = useMsg;
|
|
1971
|
-
exports2.
|
|
1337
|
+
exports2.useNavigate = useNavigate;
|
|
1972
1338
|
exports2.useRefs = useRefs;
|
|
1973
1339
|
exports2.useRequest = useRequest;
|
|
1974
|
-
exports2.useRouter = useRouter;
|
|
1975
1340
|
exports2.useShare = useShare;
|
|
1976
|
-
exports2.useShareConfig = useShareConfig;
|
|
1977
|
-
exports2.useStorage = useStorage;
|
|
1978
1341
|
exports2.useThemePageStyle = useThemePageStyle;
|
|
1979
1342
|
exports2.useThemeStore = useThemeStore;
|
|
1980
1343
|
exports2.useUpload = useUpload;
|
|
1981
1344
|
exports2.useUtils = useUtils;
|
|
1982
|
-
exports2.useUuid = useUuid;
|
|
1983
|
-
exports2.useValidate = useValidate;
|
|
1984
1345
|
exports2.vCopy = vCopy;
|
|
1985
1346
|
Object.defineProperty(exports2, Symbol.toStringTag, { value: "Module" });
|
|
1986
1347
|
});
|