@hlw-uni/mp-core 1.0.0 → 1.0.1
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/index.js +1058 -274
- package/dist/index.mjs +785 -3
- package/package.json +1 -1
- /package/dist/{assets/index.css → style.css} +0 -0
package/dist/index.js
CHANGED
|
@@ -1,310 +1,1094 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
(function(global, factory) {
|
|
2
|
+
typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("vue")) : typeof define === "function" && define.amd ? define(["exports", "vue"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.HlwUniCore = {}, global.vue));
|
|
3
|
+
})(this, function(exports2, vue) {
|
|
4
|
+
"use strict";var __defProp = Object.defineProperty;
|
|
3
5
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4
6
|
var __publicField = (obj, key, value) => {
|
|
5
7
|
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
6
8
|
return value;
|
|
7
9
|
};
|
|
8
|
-
|
|
9
|
-
const cosAdapter = {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
10
|
+
|
|
11
|
+
const cosAdapter = {
|
|
12
|
+
name: "cos",
|
|
13
|
+
buildFormData(ctx) {
|
|
14
|
+
const c = ctx.credentials ?? {};
|
|
15
|
+
return {
|
|
16
|
+
"q-ak": c["ak"] ?? "",
|
|
17
|
+
policy: c["policy"] ?? "",
|
|
18
|
+
"q-key-time": c["key-time"] ?? "",
|
|
19
|
+
"q-signature": c["signature"] ?? "",
|
|
20
|
+
"Content-Disposition": `inline;filename=${encodeURIComponent(ctx.fileName)}`,
|
|
21
|
+
success_action_status: 200,
|
|
22
|
+
...ctx.extraData ?? {}
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
const ossAdapter = {
|
|
27
|
+
name: "oss",
|
|
28
|
+
buildFormData(ctx) {
|
|
29
|
+
const c = ctx.credentials ?? {};
|
|
30
|
+
return {
|
|
31
|
+
policy: c["policy"] ?? "",
|
|
32
|
+
signature: c["signature"] ?? "",
|
|
33
|
+
OSSAccessKeyId: c["accessKeyId"] ?? "",
|
|
34
|
+
success_action_status: 200,
|
|
35
|
+
"Content-Disposition": `inline;filename=${encodeURIComponent(ctx.fileName)}`,
|
|
36
|
+
...ctx.extraData ?? {}
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
const qiniuAdapter = {
|
|
41
|
+
name: "qiniu",
|
|
42
|
+
buildFormData(ctx) {
|
|
43
|
+
const c = ctx.credentials ?? {};
|
|
44
|
+
return {
|
|
45
|
+
token: c["token"] ?? "",
|
|
46
|
+
key: c["key"] ?? ctx.fileName,
|
|
47
|
+
...ctx.extraData ?? {}
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
const alistAdapter = {
|
|
52
|
+
name: "alist",
|
|
53
|
+
buildFormData(ctx) {
|
|
54
|
+
const c = ctx.credentials ?? {};
|
|
55
|
+
return {
|
|
56
|
+
"file-path": c["file-path"] ?? ctx.fileName,
|
|
57
|
+
authorization: c["token"] ?? "",
|
|
58
|
+
...ctx.extraData ?? {}
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
const adapters = {
|
|
63
|
+
cos: cosAdapter,
|
|
64
|
+
oss: ossAdapter,
|
|
65
|
+
qiniu: qiniuAdapter,
|
|
66
|
+
alist: alistAdapter
|
|
67
|
+
};
|
|
68
|
+
function getAdapter(name) {
|
|
69
|
+
const adapter = adapters[name];
|
|
70
|
+
if (!adapter)
|
|
71
|
+
throw new Error(`[hlw] Unknown upload adapter: ${name}`);
|
|
72
|
+
return adapter;
|
|
22
73
|
}
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
74
|
+
var define_import_meta_env_default = {};
|
|
75
|
+
class HttpClient {
|
|
76
|
+
constructor(options = {}) {
|
|
77
|
+
__publicField(this, "_reqInterceptors", []);
|
|
78
|
+
__publicField(this, "_resInterceptors", []);
|
|
79
|
+
__publicField(this, "_errInterceptors", []);
|
|
80
|
+
__publicField(this, "_baseURL");
|
|
81
|
+
__publicField(this, "_defaultHeaders");
|
|
82
|
+
this._baseURL = options.baseURL ?? "";
|
|
83
|
+
this._defaultHeaders = {
|
|
84
|
+
"Content-Type": "application/json",
|
|
85
|
+
...options.headers
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
/** 添加请求拦截器,返回取消函数 */
|
|
89
|
+
onRequest(fn) {
|
|
90
|
+
this._reqInterceptors.push(fn);
|
|
91
|
+
return () => {
|
|
92
|
+
const idx = this._reqInterceptors.indexOf(fn);
|
|
93
|
+
if (idx > -1)
|
|
94
|
+
this._reqInterceptors.splice(idx, 1);
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
/** 添加响应拦截器 */
|
|
98
|
+
onResponse(fn) {
|
|
99
|
+
this._resInterceptors.push(fn);
|
|
100
|
+
return () => {
|
|
101
|
+
const idx = this._resInterceptors.indexOf(fn);
|
|
102
|
+
if (idx > -1)
|
|
103
|
+
this._resInterceptors.splice(idx, 1);
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
/** 添加错误拦截器 */
|
|
107
|
+
onError(fn) {
|
|
108
|
+
this._errInterceptors.push(fn);
|
|
109
|
+
return () => {
|
|
110
|
+
const idx = this._errInterceptors.indexOf(fn);
|
|
111
|
+
if (idx > -1)
|
|
112
|
+
this._errInterceptors.splice(idx, 1);
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* 全局请求
|
|
117
|
+
*/
|
|
118
|
+
async request(config) {
|
|
119
|
+
let cfg = {
|
|
120
|
+
method: "GET",
|
|
121
|
+
...config,
|
|
122
|
+
headers: { ...this._defaultHeaders, ...config.headers }
|
|
123
|
+
};
|
|
124
|
+
for (const fn of this._reqInterceptors) {
|
|
125
|
+
cfg = await fn(cfg);
|
|
126
|
+
}
|
|
127
|
+
const fullUrl = this._buildUrl(cfg.url);
|
|
128
|
+
const res = await this._doRequest(fullUrl, cfg);
|
|
129
|
+
for (const fn of this._resInterceptors) {
|
|
130
|
+
const modified = await fn(res);
|
|
131
|
+
if (modified !== void 0)
|
|
132
|
+
return modified;
|
|
133
|
+
}
|
|
134
|
+
return res;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* 组件内请求,返回带状态的 composable
|
|
138
|
+
*/
|
|
139
|
+
useRequest() {
|
|
140
|
+
const loading = vue.ref(false);
|
|
141
|
+
const data = vue.ref(null);
|
|
142
|
+
const error = vue.ref(null);
|
|
143
|
+
async function run(cfg) {
|
|
144
|
+
loading.value = true;
|
|
145
|
+
error.value = null;
|
|
146
|
+
try {
|
|
147
|
+
const res = await this.request(cfg);
|
|
148
|
+
data.value = res.data;
|
|
149
|
+
return res;
|
|
150
|
+
} catch (e) {
|
|
151
|
+
error.value = e;
|
|
152
|
+
await this._applyErrorInterceptors(e);
|
|
153
|
+
throw e;
|
|
154
|
+
} finally {
|
|
155
|
+
loading.value = false;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
const get = (url, d) => run({ url, method: "GET", data: d });
|
|
159
|
+
const post = (url, d) => run({ url, method: "POST", data: d });
|
|
160
|
+
const put = (url, d) => run({ url, method: "PUT", data: d });
|
|
161
|
+
const del = (url, d) => run({ url, method: "DELETE", data: d });
|
|
162
|
+
return { loading, data, error, run: run.bind(this), get, post, put, del };
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* 上传文件(策略模式)
|
|
166
|
+
*/
|
|
167
|
+
upload(config) {
|
|
168
|
+
const adapter = getAdapter(config.type);
|
|
169
|
+
const fileName = config.fileName ?? config.filePath.split("/").pop() ?? "file";
|
|
170
|
+
let server = config.server;
|
|
171
|
+
if (config.type === "local" && config.url)
|
|
172
|
+
server = config.url;
|
|
173
|
+
const formData = adapter.buildFormData({
|
|
174
|
+
filePath: config.filePath,
|
|
175
|
+
fileName,
|
|
176
|
+
credentials: config.credentials
|
|
177
|
+
});
|
|
178
|
+
return new Promise((resolve, reject) => {
|
|
179
|
+
uni.uploadFile({
|
|
180
|
+
url: server,
|
|
181
|
+
filePath: config.filePath,
|
|
182
|
+
name: "file",
|
|
183
|
+
formData,
|
|
184
|
+
header: config.header,
|
|
185
|
+
success: (res) => {
|
|
186
|
+
if (res.statusCode === 200) {
|
|
187
|
+
try {
|
|
188
|
+
const body = JSON.parse(res.data);
|
|
189
|
+
resolve({ code: body.code ?? 1, msg: body.message ?? "上传成功", data: body.data ?? "" });
|
|
190
|
+
} catch {
|
|
191
|
+
resolve({ code: 1, msg: "上传成功", data: res.data });
|
|
192
|
+
}
|
|
193
|
+
} else {
|
|
194
|
+
reject(new Error("上传失败"));
|
|
195
|
+
}
|
|
196
|
+
},
|
|
197
|
+
fail: (err) => reject(new Error(err.errMsg || "上传失败"))
|
|
198
|
+
});
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
_buildUrl(url) {
|
|
202
|
+
if (/^https?:\/\//.test(url))
|
|
203
|
+
return url;
|
|
204
|
+
const sep = url.includes("?") ? "&" : "?";
|
|
205
|
+
return `${this._baseURL}${url}${sep}_t=${Date.now()}`;
|
|
206
|
+
}
|
|
207
|
+
async _doRequest(url, cfg) {
|
|
208
|
+
return new Promise((resolve, reject) => {
|
|
209
|
+
uni.request({
|
|
210
|
+
url,
|
|
211
|
+
method: cfg.method,
|
|
212
|
+
data: cfg.data,
|
|
213
|
+
header: cfg.headers,
|
|
214
|
+
success: (res) => {
|
|
215
|
+
var _a;
|
|
216
|
+
if (res.statusCode >= 200 && res.statusCode < 300) {
|
|
217
|
+
resolve(res.data);
|
|
218
|
+
} else {
|
|
219
|
+
const msg = ((_a = res.data) == null ? void 0 : _a.message) ?? `请求失败: ${res.statusCode}`;
|
|
220
|
+
reject(new Error(msg));
|
|
221
|
+
}
|
|
222
|
+
},
|
|
223
|
+
fail: (err) => reject(new Error(err.errMsg || "网络请求失败"))
|
|
224
|
+
});
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
async _applyErrorInterceptors(err) {
|
|
228
|
+
for (const fn of this._errInterceptors) {
|
|
229
|
+
await fn(err);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
const http = new HttpClient({
|
|
234
|
+
baseURL: define_import_meta_env_default.VITE_API_BASE_URL ?? ""
|
|
235
|
+
});
|
|
236
|
+
function useRequest(options = {}) {
|
|
237
|
+
const { initialData = null, manual = false, onSuccess, onError } = options;
|
|
238
|
+
const loading = vue.ref(false);
|
|
239
|
+
const data = vue.ref(initialData);
|
|
240
|
+
const error = vue.ref(null);
|
|
241
|
+
async function run(config) {
|
|
242
|
+
loading.value = true;
|
|
243
|
+
error.value = null;
|
|
244
|
+
try {
|
|
245
|
+
const res = await http.request(config);
|
|
246
|
+
data.value = res.data;
|
|
247
|
+
onSuccess == null ? void 0 : onSuccess(res.data, res);
|
|
248
|
+
return res;
|
|
249
|
+
} catch (e) {
|
|
250
|
+
error.value = e;
|
|
251
|
+
onError == null ? void 0 : onError(e);
|
|
252
|
+
throw e;
|
|
253
|
+
} finally {
|
|
254
|
+
loading.value = false;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
function get(url, data2) {
|
|
258
|
+
return run({ url, method: "GET", data: data2 });
|
|
259
|
+
}
|
|
260
|
+
function post(url, data2) {
|
|
261
|
+
return run({ url, method: "POST", data: data2 });
|
|
262
|
+
}
|
|
263
|
+
function put(url, data2) {
|
|
264
|
+
return run({ url, method: "PUT", data: data2 });
|
|
265
|
+
}
|
|
266
|
+
function del(url, data2) {
|
|
267
|
+
return run({ url, method: "DELETE", data: data2 });
|
|
268
|
+
}
|
|
269
|
+
return { loading, data, error, run, get, post, put, del };
|
|
270
|
+
}
|
|
271
|
+
function useUpload() {
|
|
272
|
+
const uploading = vue.ref(false);
|
|
273
|
+
async function upload(options) {
|
|
274
|
+
uploading.value = true;
|
|
275
|
+
try {
|
|
276
|
+
return await http.upload(options);
|
|
277
|
+
} finally {
|
|
278
|
+
uploading.value = false;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
return { uploading, upload };
|
|
282
|
+
}
|
|
283
|
+
function useLoading() {
|
|
284
|
+
function showLoading(message = "加载中...") {
|
|
285
|
+
uni.showLoading({ title: message, mask: true });
|
|
286
|
+
}
|
|
287
|
+
function hideLoading() {
|
|
288
|
+
uni.hideLoading();
|
|
289
|
+
}
|
|
28
290
|
return {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
OSSAccessKeyId: c["accessKeyId"] ?? "",
|
|
32
|
-
success_action_status: 200,
|
|
33
|
-
"Content-Disposition": `inline;filename=${encodeURIComponent(ctx.fileName)}`,
|
|
34
|
-
...ctx.extraData ?? {}
|
|
291
|
+
showLoading,
|
|
292
|
+
hideLoading
|
|
35
293
|
};
|
|
36
294
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
295
|
+
function useMsg() {
|
|
296
|
+
function toast(opts) {
|
|
297
|
+
const { message, icon = "none", image, duration = 2e3, mask = false, position = "center" } = opts;
|
|
298
|
+
uni.showToast({ title: message, icon, image, duration, mask, position });
|
|
299
|
+
}
|
|
300
|
+
function success(message) {
|
|
301
|
+
uni.showToast({ title: message, icon: "success", duration: 2e3 });
|
|
302
|
+
}
|
|
303
|
+
function error(message) {
|
|
304
|
+
uni.showToast({ title: message, icon: "fail", duration: 2e3 });
|
|
305
|
+
}
|
|
306
|
+
function fail(message) {
|
|
307
|
+
uni.showToast({ title: message, icon: "fail", duration: 2e3 });
|
|
308
|
+
}
|
|
309
|
+
function showLoading(message = "加载中...") {
|
|
310
|
+
uni.showLoading({ title: message, mask: true });
|
|
311
|
+
}
|
|
312
|
+
function hideLoading() {
|
|
313
|
+
uni.hideLoading();
|
|
314
|
+
}
|
|
315
|
+
function confirm(opts) {
|
|
316
|
+
return new Promise((resolve) => {
|
|
317
|
+
const { title = "提示", content, confirmText = "确定", cancelText = "取消", confirmColor = "#3b82f6", cancelColor = "#999999" } = opts;
|
|
318
|
+
uni.showModal({
|
|
319
|
+
title,
|
|
320
|
+
content,
|
|
321
|
+
confirmText,
|
|
322
|
+
cancelText,
|
|
323
|
+
confirmColor,
|
|
324
|
+
cancelColor,
|
|
325
|
+
success: (res) => resolve(res.confirm),
|
|
326
|
+
fail: () => resolve(false)
|
|
327
|
+
});
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
function modal(opts) {
|
|
331
|
+
return confirm(opts);
|
|
332
|
+
}
|
|
333
|
+
function setLoadingBar(progress) {
|
|
334
|
+
const clamped = Math.max(0, Math.min(100, progress));
|
|
335
|
+
uni.setNavigationBarTitle({
|
|
336
|
+
title: `${"█".repeat(Math.round(clamped / 2))}${"░".repeat(50 - Math.round(clamped / 2))} ${clamped}%`
|
|
337
|
+
});
|
|
338
|
+
}
|
|
42
339
|
return {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
340
|
+
toast,
|
|
341
|
+
success,
|
|
342
|
+
error,
|
|
343
|
+
fail,
|
|
344
|
+
showLoading,
|
|
345
|
+
hideLoading,
|
|
346
|
+
confirm,
|
|
347
|
+
modal,
|
|
348
|
+
setLoadingBar
|
|
46
349
|
};
|
|
47
350
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
351
|
+
const _info = vue.ref(null);
|
|
352
|
+
function collect() {
|
|
353
|
+
var _a;
|
|
354
|
+
const sys = uni.getSystemInfoSync();
|
|
355
|
+
let appid = "";
|
|
356
|
+
try {
|
|
357
|
+
const accountInfo = uni.getAccountInfoSync();
|
|
358
|
+
appid = ((_a = accountInfo == null ? void 0 : accountInfo.miniProgram) == null ? void 0 : _a.appId) || "";
|
|
359
|
+
} catch {
|
|
360
|
+
appid = sys.appId || "";
|
|
361
|
+
}
|
|
362
|
+
let appName = "";
|
|
363
|
+
let appVersion = "";
|
|
364
|
+
let appVersionCode = "";
|
|
365
|
+
let hostName = "";
|
|
366
|
+
let hostVersion = "";
|
|
367
|
+
let hostLanguage = "";
|
|
368
|
+
let hostTheme = "";
|
|
369
|
+
try {
|
|
370
|
+
const appInfo = uni.getAppBaseInfo();
|
|
371
|
+
appName = appInfo.appName || "";
|
|
372
|
+
appVersion = appInfo.appVersion || "";
|
|
373
|
+
appVersionCode = appInfo.appVersionCode || "";
|
|
374
|
+
hostName = appInfo.hostName || "";
|
|
375
|
+
hostVersion = appInfo.hostVersion || "";
|
|
376
|
+
hostLanguage = appInfo.hostLanguage || "";
|
|
377
|
+
hostTheme = appInfo.hostTheme || "";
|
|
378
|
+
} catch {
|
|
379
|
+
appVersion = sys.appVersion || "";
|
|
380
|
+
}
|
|
381
|
+
const deviceBrand = sys.deviceBrand || "";
|
|
382
|
+
const deviceModel = sys.deviceModel || "";
|
|
383
|
+
const deviceId = sys.deviceId || "";
|
|
384
|
+
const deviceType = sys.deviceType || "";
|
|
385
|
+
const deviceOrientation = sys.deviceOrientation || "portrait";
|
|
386
|
+
const system = sys.system || "";
|
|
53
387
|
return {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
388
|
+
appid,
|
|
389
|
+
app_name: appName,
|
|
390
|
+
app_version: appVersion,
|
|
391
|
+
app_version_code: appVersionCode,
|
|
392
|
+
app_channel: sys.appChannel || "",
|
|
393
|
+
device_brand: deviceBrand,
|
|
394
|
+
device_model: deviceModel,
|
|
395
|
+
device_id: deviceId,
|
|
396
|
+
device_type: deviceType,
|
|
397
|
+
device_orientation: deviceOrientation,
|
|
398
|
+
brand: sys.brand || "",
|
|
399
|
+
model: sys.model || "",
|
|
400
|
+
system,
|
|
401
|
+
os: system.split(" ")[0] || "",
|
|
402
|
+
pixel_ratio: sys.pixelRatio || 0,
|
|
403
|
+
screen_width: sys.screenWidth || 0,
|
|
404
|
+
screen_height: sys.screenHeight || 0,
|
|
405
|
+
window_width: sys.windowWidth || 0,
|
|
406
|
+
window_height: sys.windowHeight || 0,
|
|
407
|
+
status_bar_height: sys.statusBarHeight || 0,
|
|
408
|
+
sdk_version: sys.SDKVersion || "",
|
|
409
|
+
host_name: hostName,
|
|
410
|
+
host_version: hostVersion,
|
|
411
|
+
host_language: hostLanguage,
|
|
412
|
+
host_theme: hostTheme,
|
|
413
|
+
platform: sys.platform || "",
|
|
414
|
+
language: sys.language || "",
|
|
415
|
+
version: sys.version || ""
|
|
57
416
|
};
|
|
58
417
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
qiniu: qiniuAdapter,
|
|
64
|
-
alist: alistAdapter
|
|
65
|
-
};
|
|
66
|
-
function getAdapter(name) {
|
|
67
|
-
const adapter = adapters[name];
|
|
68
|
-
if (!adapter)
|
|
69
|
-
throw new Error(`[hlw] Unknown upload adapter: ${name}`);
|
|
70
|
-
return adapter;
|
|
71
|
-
}
|
|
72
|
-
var define_import_meta_env_default = {};
|
|
73
|
-
class HttpClient {
|
|
74
|
-
constructor(options = {}) {
|
|
75
|
-
__publicField(this, "_reqInterceptors", []);
|
|
76
|
-
__publicField(this, "_resInterceptors", []);
|
|
77
|
-
__publicField(this, "_errInterceptors", []);
|
|
78
|
-
__publicField(this, "_baseURL");
|
|
79
|
-
__publicField(this, "_defaultHeaders");
|
|
80
|
-
this._baseURL = options.baseURL ?? "";
|
|
81
|
-
this._defaultHeaders = {
|
|
82
|
-
"Content-Type": "application/json",
|
|
83
|
-
...options.headers
|
|
84
|
-
};
|
|
418
|
+
function ensure() {
|
|
419
|
+
if (!_info.value) {
|
|
420
|
+
_info.value = collect();
|
|
421
|
+
}
|
|
85
422
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
return () => {
|
|
90
|
-
const idx = this._reqInterceptors.indexOf(fn);
|
|
91
|
-
if (idx > -1)
|
|
92
|
-
this._reqInterceptors.splice(idx, 1);
|
|
93
|
-
};
|
|
423
|
+
function useDevice() {
|
|
424
|
+
ensure();
|
|
425
|
+
return _info;
|
|
94
426
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
427
|
+
function deviceToQuery() {
|
|
428
|
+
ensure();
|
|
429
|
+
if (!_info.value)
|
|
430
|
+
return "";
|
|
431
|
+
return Object.entries(_info.value).filter(([, v]) => v !== "" && v !== 0).map(([k, v]) => `${k}=${encodeURIComponent(String(v))}`).join("&");
|
|
432
|
+
}
|
|
433
|
+
function clearDeviceCache() {
|
|
434
|
+
_info.value = null;
|
|
103
435
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
436
|
+
function useRefs() {
|
|
437
|
+
const refs = vue.ref({});
|
|
438
|
+
vue.onBeforeUpdate(() => {
|
|
439
|
+
refs.value = {};
|
|
440
|
+
});
|
|
441
|
+
const setRefs = (key) => (el) => {
|
|
442
|
+
if (el)
|
|
443
|
+
refs.value[key] = el;
|
|
111
444
|
};
|
|
445
|
+
return { refs, setRefs };
|
|
112
446
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
447
|
+
function usePageMeta() {
|
|
448
|
+
function setTitle(title) {
|
|
449
|
+
uni.setNavigationBarTitle({ title });
|
|
450
|
+
}
|
|
451
|
+
function setOptions(options) {
|
|
452
|
+
if (options.title)
|
|
453
|
+
setTitle(options.title);
|
|
454
|
+
if (options.enablePullDownRefresh !== void 0) {
|
|
455
|
+
uni.setBackgroundTextStyle({ textStyle: "dark" });
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
return {
|
|
459
|
+
setTitle,
|
|
460
|
+
setOptions
|
|
121
461
|
};
|
|
122
|
-
|
|
123
|
-
|
|
462
|
+
}
|
|
463
|
+
function useStorage() {
|
|
464
|
+
function get(key) {
|
|
465
|
+
try {
|
|
466
|
+
const value = uni.getStorageSync(key);
|
|
467
|
+
return value ?? null;
|
|
468
|
+
} catch {
|
|
469
|
+
return null;
|
|
470
|
+
}
|
|
124
471
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
return
|
|
472
|
+
function set(key, value) {
|
|
473
|
+
try {
|
|
474
|
+
uni.setStorageSync(key, value);
|
|
475
|
+
return true;
|
|
476
|
+
} catch {
|
|
477
|
+
return false;
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
function remove(key) {
|
|
481
|
+
try {
|
|
482
|
+
uni.removeStorageSync(key);
|
|
483
|
+
return true;
|
|
484
|
+
} catch {
|
|
485
|
+
return false;
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
function clear() {
|
|
489
|
+
try {
|
|
490
|
+
uni.clearStorageSync();
|
|
491
|
+
return true;
|
|
492
|
+
} catch {
|
|
493
|
+
return false;
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
function info() {
|
|
497
|
+
try {
|
|
498
|
+
return uni.getStorageInfoSync();
|
|
499
|
+
} catch {
|
|
500
|
+
return null;
|
|
501
|
+
}
|
|
131
502
|
}
|
|
132
|
-
return
|
|
503
|
+
return { get, set, remove, clear, info };
|
|
133
504
|
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
loading.value = true;
|
|
143
|
-
error.value = null;
|
|
505
|
+
function useValidate() {
|
|
506
|
+
function phone(value) {
|
|
507
|
+
return /^1[3-9]\d{9}$/.test(value);
|
|
508
|
+
}
|
|
509
|
+
function email(value) {
|
|
510
|
+
return /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(value);
|
|
511
|
+
}
|
|
512
|
+
function url(value) {
|
|
144
513
|
try {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
error.value = e;
|
|
150
|
-
await this._applyErrorInterceptors(e);
|
|
151
|
-
throw e;
|
|
152
|
-
} finally {
|
|
153
|
-
loading.value = false;
|
|
514
|
+
new URL(value);
|
|
515
|
+
return true;
|
|
516
|
+
} catch {
|
|
517
|
+
return false;
|
|
154
518
|
}
|
|
155
519
|
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
520
|
+
function idCard(value) {
|
|
521
|
+
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);
|
|
522
|
+
}
|
|
523
|
+
function carNumber(value) {
|
|
524
|
+
return /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领][A-Z][A-Z0-9]{5}$/.test(value);
|
|
525
|
+
}
|
|
526
|
+
function password(value) {
|
|
527
|
+
return /^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{8,}$/.test(value);
|
|
528
|
+
}
|
|
529
|
+
function empty(value) {
|
|
530
|
+
if (value == null)
|
|
531
|
+
return true;
|
|
532
|
+
if (typeof value === "string")
|
|
533
|
+
return value.trim() === "";
|
|
534
|
+
if (Array.isArray(value))
|
|
535
|
+
return value.length === 0;
|
|
536
|
+
if (typeof value === "object")
|
|
537
|
+
return Object.keys(value).length === 0;
|
|
538
|
+
return false;
|
|
539
|
+
}
|
|
540
|
+
return {
|
|
541
|
+
phone,
|
|
542
|
+
email,
|
|
543
|
+
url,
|
|
544
|
+
idCard,
|
|
545
|
+
carNumber,
|
|
546
|
+
password,
|
|
547
|
+
empty
|
|
548
|
+
};
|
|
161
549
|
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
}
|
|
191
|
-
} else {
|
|
192
|
-
reject(new Error("上传失败"));
|
|
193
|
-
}
|
|
194
|
-
},
|
|
195
|
-
fail: (err) => reject(new Error(err.errMsg || "上传失败"))
|
|
196
|
-
});
|
|
197
|
-
});
|
|
550
|
+
function useFormat() {
|
|
551
|
+
function date(date2, format = "YYYY-MM-DD HH:mm:ss") {
|
|
552
|
+
const d = new Date(date2);
|
|
553
|
+
if (isNaN(d.getTime()))
|
|
554
|
+
return "";
|
|
555
|
+
const year = d.getFullYear();
|
|
556
|
+
const month = String(d.getMonth() + 1).padStart(2, "0");
|
|
557
|
+
const day = String(d.getDate()).padStart(2, "0");
|
|
558
|
+
const hours = String(d.getHours()).padStart(2, "0");
|
|
559
|
+
const minutes = String(d.getMinutes()).padStart(2, "0");
|
|
560
|
+
const seconds = String(d.getSeconds()).padStart(2, "0");
|
|
561
|
+
return format.replace("YYYY", String(year)).replace("MM", month).replace("DD", day).replace("HH", hours).replace("mm", minutes).replace("ss", seconds);
|
|
562
|
+
}
|
|
563
|
+
function fileSize(bytes) {
|
|
564
|
+
if (bytes === 0)
|
|
565
|
+
return "0 B";
|
|
566
|
+
const k = 1024;
|
|
567
|
+
const sizes = ["B", "KB", "MB", "GB", "TB"];
|
|
568
|
+
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
569
|
+
return `${parseFloat((bytes / Math.pow(k, i)).toFixed(2))} ${sizes[i]}`;
|
|
570
|
+
}
|
|
571
|
+
function phone(value) {
|
|
572
|
+
return value.replace(/(\d{3})\d{4}(\d{4})/, "$1****$2");
|
|
573
|
+
}
|
|
574
|
+
function money(amount, decimals = 2, decPoint = ".", thousandsSep = ",") {
|
|
575
|
+
return amount.toFixed(decimals).replace(/\B(?=(\d{3})+(?!\d))/g, thousandsSep);
|
|
576
|
+
}
|
|
577
|
+
return { date, fileSize, phone, money };
|
|
198
578
|
}
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
579
|
+
const _msg = useMsg();
|
|
580
|
+
const _device = useDevice();
|
|
581
|
+
const hlw = {
|
|
582
|
+
$msg: _msg,
|
|
583
|
+
$device: _device,
|
|
584
|
+
$http: http
|
|
585
|
+
};
|
|
586
|
+
function getDefaultExportFromCjs(x) {
|
|
587
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
204
588
|
}
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
589
|
+
var md5$1 = { exports: {} };
|
|
590
|
+
var crypt = { exports: {} };
|
|
591
|
+
(function() {
|
|
592
|
+
var base64map = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", crypt$1 = {
|
|
593
|
+
// Bit-wise rotation left
|
|
594
|
+
rotl: function(n, b) {
|
|
595
|
+
return n << b | n >>> 32 - b;
|
|
596
|
+
},
|
|
597
|
+
// Bit-wise rotation right
|
|
598
|
+
rotr: function(n, b) {
|
|
599
|
+
return n << 32 - b | n >>> b;
|
|
600
|
+
},
|
|
601
|
+
// Swap big-endian to little-endian and vice versa
|
|
602
|
+
endian: function(n) {
|
|
603
|
+
if (n.constructor == Number) {
|
|
604
|
+
return crypt$1.rotl(n, 8) & 16711935 | crypt$1.rotl(n, 24) & 4278255360;
|
|
605
|
+
}
|
|
606
|
+
for (var i = 0; i < n.length; i++)
|
|
607
|
+
n[i] = crypt$1.endian(n[i]);
|
|
608
|
+
return n;
|
|
609
|
+
},
|
|
610
|
+
// Generate an array of any length of random bytes
|
|
611
|
+
randomBytes: function(n) {
|
|
612
|
+
for (var bytes = []; n > 0; n--)
|
|
613
|
+
bytes.push(Math.floor(Math.random() * 256));
|
|
614
|
+
return bytes;
|
|
615
|
+
},
|
|
616
|
+
// Convert a byte array to big-endian 32-bit words
|
|
617
|
+
bytesToWords: function(bytes) {
|
|
618
|
+
for (var words = [], i = 0, b = 0; i < bytes.length; i++, b += 8)
|
|
619
|
+
words[b >>> 5] |= bytes[i] << 24 - b % 32;
|
|
620
|
+
return words;
|
|
621
|
+
},
|
|
622
|
+
// Convert big-endian 32-bit words to a byte array
|
|
623
|
+
wordsToBytes: function(words) {
|
|
624
|
+
for (var bytes = [], b = 0; b < words.length * 32; b += 8)
|
|
625
|
+
bytes.push(words[b >>> 5] >>> 24 - b % 32 & 255);
|
|
626
|
+
return bytes;
|
|
627
|
+
},
|
|
628
|
+
// Convert a byte array to a hex string
|
|
629
|
+
bytesToHex: function(bytes) {
|
|
630
|
+
for (var hex = [], i = 0; i < bytes.length; i++) {
|
|
631
|
+
hex.push((bytes[i] >>> 4).toString(16));
|
|
632
|
+
hex.push((bytes[i] & 15).toString(16));
|
|
633
|
+
}
|
|
634
|
+
return hex.join("");
|
|
635
|
+
},
|
|
636
|
+
// Convert a hex string to a byte array
|
|
637
|
+
hexToBytes: function(hex) {
|
|
638
|
+
for (var bytes = [], c = 0; c < hex.length; c += 2)
|
|
639
|
+
bytes.push(parseInt(hex.substr(c, 2), 16));
|
|
640
|
+
return bytes;
|
|
641
|
+
},
|
|
642
|
+
// Convert a byte array to a base-64 string
|
|
643
|
+
bytesToBase64: function(bytes) {
|
|
644
|
+
for (var base64 = [], i = 0; i < bytes.length; i += 3) {
|
|
645
|
+
var triplet = bytes[i] << 16 | bytes[i + 1] << 8 | bytes[i + 2];
|
|
646
|
+
for (var j = 0; j < 4; j++)
|
|
647
|
+
if (i * 8 + j * 6 <= bytes.length * 8)
|
|
648
|
+
base64.push(base64map.charAt(triplet >>> 6 * (3 - j) & 63));
|
|
649
|
+
else
|
|
650
|
+
base64.push("=");
|
|
651
|
+
}
|
|
652
|
+
return base64.join("");
|
|
653
|
+
},
|
|
654
|
+
// Convert a base-64 string to a byte array
|
|
655
|
+
base64ToBytes: function(base64) {
|
|
656
|
+
base64 = base64.replace(/[^A-Z0-9+\/]/ig, "");
|
|
657
|
+
for (var bytes = [], i = 0, imod4 = 0; i < base64.length; imod4 = ++i % 4) {
|
|
658
|
+
if (imod4 == 0)
|
|
659
|
+
continue;
|
|
660
|
+
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);
|
|
661
|
+
}
|
|
662
|
+
return bytes;
|
|
663
|
+
}
|
|
664
|
+
};
|
|
665
|
+
crypt.exports = crypt$1;
|
|
666
|
+
})();
|
|
667
|
+
var cryptExports = crypt.exports;
|
|
668
|
+
var charenc = {
|
|
669
|
+
// UTF-8 encoding
|
|
670
|
+
utf8: {
|
|
671
|
+
// Convert a string to a byte array
|
|
672
|
+
stringToBytes: function(str) {
|
|
673
|
+
return charenc.bin.stringToBytes(unescape(encodeURIComponent(str)));
|
|
674
|
+
},
|
|
675
|
+
// Convert a byte array to a string
|
|
676
|
+
bytesToString: function(bytes) {
|
|
677
|
+
return decodeURIComponent(escape(charenc.bin.bytesToString(bytes)));
|
|
678
|
+
}
|
|
679
|
+
},
|
|
680
|
+
// Binary encoding
|
|
681
|
+
bin: {
|
|
682
|
+
// Convert a string to a byte array
|
|
683
|
+
stringToBytes: function(str) {
|
|
684
|
+
for (var bytes = [], i = 0; i < str.length; i++)
|
|
685
|
+
bytes.push(str.charCodeAt(i) & 255);
|
|
686
|
+
return bytes;
|
|
687
|
+
},
|
|
688
|
+
// Convert a byte array to a string
|
|
689
|
+
bytesToString: function(bytes) {
|
|
690
|
+
for (var str = [], i = 0; i < bytes.length; i++)
|
|
691
|
+
str.push(String.fromCharCode(bytes[i]));
|
|
692
|
+
return str.join("");
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
};
|
|
696
|
+
var charenc_1 = charenc;
|
|
697
|
+
/*!
|
|
698
|
+
* Determine if an object is a Buffer
|
|
699
|
+
*
|
|
700
|
+
* @author Feross Aboukhadijeh <https://feross.org>
|
|
701
|
+
* @license MIT
|
|
702
|
+
*/
|
|
703
|
+
var isBuffer_1 = function(obj) {
|
|
704
|
+
return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer);
|
|
705
|
+
};
|
|
706
|
+
function isBuffer(obj) {
|
|
707
|
+
return !!obj.constructor && typeof obj.constructor.isBuffer === "function" && obj.constructor.isBuffer(obj);
|
|
708
|
+
}
|
|
709
|
+
function isSlowBuffer(obj) {
|
|
710
|
+
return typeof obj.readFloatLE === "function" && typeof obj.slice === "function" && isBuffer(obj.slice(0, 0));
|
|
224
711
|
}
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
712
|
+
(function() {
|
|
713
|
+
var crypt2 = cryptExports, utf8 = charenc_1.utf8, isBuffer2 = isBuffer_1, bin = charenc_1.bin, md52 = function(message, options) {
|
|
714
|
+
if (message.constructor == String)
|
|
715
|
+
if (options && options.encoding === "binary")
|
|
716
|
+
message = bin.stringToBytes(message);
|
|
717
|
+
else
|
|
718
|
+
message = utf8.stringToBytes(message);
|
|
719
|
+
else if (isBuffer2(message))
|
|
720
|
+
message = Array.prototype.slice.call(message, 0);
|
|
721
|
+
else if (!Array.isArray(message) && message.constructor !== Uint8Array)
|
|
722
|
+
message = message.toString();
|
|
723
|
+
var m = crypt2.bytesToWords(message), l = message.length * 8, a = 1732584193, b = -271733879, c = -1732584194, d = 271733878;
|
|
724
|
+
for (var i = 0; i < m.length; i++) {
|
|
725
|
+
m[i] = (m[i] << 8 | m[i] >>> 24) & 16711935 | (m[i] << 24 | m[i] >>> 8) & 4278255360;
|
|
726
|
+
}
|
|
727
|
+
m[l >>> 5] |= 128 << l % 32;
|
|
728
|
+
m[(l + 64 >>> 9 << 4) + 14] = l;
|
|
729
|
+
var FF = md52._ff, GG = md52._gg, HH = md52._hh, II = md52._ii;
|
|
730
|
+
for (var i = 0; i < m.length; i += 16) {
|
|
731
|
+
var aa = a, bb = b, cc = c, dd = d;
|
|
732
|
+
a = FF(a, b, c, d, m[i + 0], 7, -680876936);
|
|
733
|
+
d = FF(d, a, b, c, m[i + 1], 12, -389564586);
|
|
734
|
+
c = FF(c, d, a, b, m[i + 2], 17, 606105819);
|
|
735
|
+
b = FF(b, c, d, a, m[i + 3], 22, -1044525330);
|
|
736
|
+
a = FF(a, b, c, d, m[i + 4], 7, -176418897);
|
|
737
|
+
d = FF(d, a, b, c, m[i + 5], 12, 1200080426);
|
|
738
|
+
c = FF(c, d, a, b, m[i + 6], 17, -1473231341);
|
|
739
|
+
b = FF(b, c, d, a, m[i + 7], 22, -45705983);
|
|
740
|
+
a = FF(a, b, c, d, m[i + 8], 7, 1770035416);
|
|
741
|
+
d = FF(d, a, b, c, m[i + 9], 12, -1958414417);
|
|
742
|
+
c = FF(c, d, a, b, m[i + 10], 17, -42063);
|
|
743
|
+
b = FF(b, c, d, a, m[i + 11], 22, -1990404162);
|
|
744
|
+
a = FF(a, b, c, d, m[i + 12], 7, 1804603682);
|
|
745
|
+
d = FF(d, a, b, c, m[i + 13], 12, -40341101);
|
|
746
|
+
c = FF(c, d, a, b, m[i + 14], 17, -1502002290);
|
|
747
|
+
b = FF(b, c, d, a, m[i + 15], 22, 1236535329);
|
|
748
|
+
a = GG(a, b, c, d, m[i + 1], 5, -165796510);
|
|
749
|
+
d = GG(d, a, b, c, m[i + 6], 9, -1069501632);
|
|
750
|
+
c = GG(c, d, a, b, m[i + 11], 14, 643717713);
|
|
751
|
+
b = GG(b, c, d, a, m[i + 0], 20, -373897302);
|
|
752
|
+
a = GG(a, b, c, d, m[i + 5], 5, -701558691);
|
|
753
|
+
d = GG(d, a, b, c, m[i + 10], 9, 38016083);
|
|
754
|
+
c = GG(c, d, a, b, m[i + 15], 14, -660478335);
|
|
755
|
+
b = GG(b, c, d, a, m[i + 4], 20, -405537848);
|
|
756
|
+
a = GG(a, b, c, d, m[i + 9], 5, 568446438);
|
|
757
|
+
d = GG(d, a, b, c, m[i + 14], 9, -1019803690);
|
|
758
|
+
c = GG(c, d, a, b, m[i + 3], 14, -187363961);
|
|
759
|
+
b = GG(b, c, d, a, m[i + 8], 20, 1163531501);
|
|
760
|
+
a = GG(a, b, c, d, m[i + 13], 5, -1444681467);
|
|
761
|
+
d = GG(d, a, b, c, m[i + 2], 9, -51403784);
|
|
762
|
+
c = GG(c, d, a, b, m[i + 7], 14, 1735328473);
|
|
763
|
+
b = GG(b, c, d, a, m[i + 12], 20, -1926607734);
|
|
764
|
+
a = HH(a, b, c, d, m[i + 5], 4, -378558);
|
|
765
|
+
d = HH(d, a, b, c, m[i + 8], 11, -2022574463);
|
|
766
|
+
c = HH(c, d, a, b, m[i + 11], 16, 1839030562);
|
|
767
|
+
b = HH(b, c, d, a, m[i + 14], 23, -35309556);
|
|
768
|
+
a = HH(a, b, c, d, m[i + 1], 4, -1530992060);
|
|
769
|
+
d = HH(d, a, b, c, m[i + 4], 11, 1272893353);
|
|
770
|
+
c = HH(c, d, a, b, m[i + 7], 16, -155497632);
|
|
771
|
+
b = HH(b, c, d, a, m[i + 10], 23, -1094730640);
|
|
772
|
+
a = HH(a, b, c, d, m[i + 13], 4, 681279174);
|
|
773
|
+
d = HH(d, a, b, c, m[i + 0], 11, -358537222);
|
|
774
|
+
c = HH(c, d, a, b, m[i + 3], 16, -722521979);
|
|
775
|
+
b = HH(b, c, d, a, m[i + 6], 23, 76029189);
|
|
776
|
+
a = HH(a, b, c, d, m[i + 9], 4, -640364487);
|
|
777
|
+
d = HH(d, a, b, c, m[i + 12], 11, -421815835);
|
|
778
|
+
c = HH(c, d, a, b, m[i + 15], 16, 530742520);
|
|
779
|
+
b = HH(b, c, d, a, m[i + 2], 23, -995338651);
|
|
780
|
+
a = II(a, b, c, d, m[i + 0], 6, -198630844);
|
|
781
|
+
d = II(d, a, b, c, m[i + 7], 10, 1126891415);
|
|
782
|
+
c = II(c, d, a, b, m[i + 14], 15, -1416354905);
|
|
783
|
+
b = II(b, c, d, a, m[i + 5], 21, -57434055);
|
|
784
|
+
a = II(a, b, c, d, m[i + 12], 6, 1700485571);
|
|
785
|
+
d = II(d, a, b, c, m[i + 3], 10, -1894986606);
|
|
786
|
+
c = II(c, d, a, b, m[i + 10], 15, -1051523);
|
|
787
|
+
b = II(b, c, d, a, m[i + 1], 21, -2054922799);
|
|
788
|
+
a = II(a, b, c, d, m[i + 8], 6, 1873313359);
|
|
789
|
+
d = II(d, a, b, c, m[i + 15], 10, -30611744);
|
|
790
|
+
c = II(c, d, a, b, m[i + 6], 15, -1560198380);
|
|
791
|
+
b = II(b, c, d, a, m[i + 13], 21, 1309151649);
|
|
792
|
+
a = II(a, b, c, d, m[i + 4], 6, -145523070);
|
|
793
|
+
d = II(d, a, b, c, m[i + 11], 10, -1120210379);
|
|
794
|
+
c = II(c, d, a, b, m[i + 2], 15, 718787259);
|
|
795
|
+
b = II(b, c, d, a, m[i + 9], 21, -343485551);
|
|
796
|
+
a = a + aa >>> 0;
|
|
797
|
+
b = b + bb >>> 0;
|
|
798
|
+
c = c + cc >>> 0;
|
|
799
|
+
d = d + dd >>> 0;
|
|
800
|
+
}
|
|
801
|
+
return crypt2.endian([a, b, c, d]);
|
|
802
|
+
};
|
|
803
|
+
md52._ff = function(a, b, c, d, x, s, t) {
|
|
804
|
+
var n = a + (b & c | ~b & d) + (x >>> 0) + t;
|
|
805
|
+
return (n << s | n >>> 32 - s) + b;
|
|
806
|
+
};
|
|
807
|
+
md52._gg = function(a, b, c, d, x, s, t) {
|
|
808
|
+
var n = a + (b & d | c & ~d) + (x >>> 0) + t;
|
|
809
|
+
return (n << s | n >>> 32 - s) + b;
|
|
810
|
+
};
|
|
811
|
+
md52._hh = function(a, b, c, d, x, s, t) {
|
|
812
|
+
var n = a + (b ^ c ^ d) + (x >>> 0) + t;
|
|
813
|
+
return (n << s | n >>> 32 - s) + b;
|
|
814
|
+
};
|
|
815
|
+
md52._ii = function(a, b, c, d, x, s, t) {
|
|
816
|
+
var n = a + (c ^ (b | ~d)) + (x >>> 0) + t;
|
|
817
|
+
return (n << s | n >>> 32 - s) + b;
|
|
818
|
+
};
|
|
819
|
+
md52._blocksize = 16;
|
|
820
|
+
md52._digestsize = 16;
|
|
821
|
+
md5$1.exports = function(message, options) {
|
|
822
|
+
if (message === void 0 || message === null)
|
|
823
|
+
throw new Error("Illegal argument " + message);
|
|
824
|
+
var digestbytes = crypt2.wordsToBytes(md52(message, options));
|
|
825
|
+
return options && options.asBytes ? digestbytes : options && options.asString ? bin.bytesToString(digestbytes) : crypt2.bytesToHex(digestbytes);
|
|
826
|
+
};
|
|
827
|
+
})();
|
|
828
|
+
var md5Exports = md5$1.exports;
|
|
829
|
+
const md5 = /* @__PURE__ */ getDefaultExportFromCjs(md5Exports);
|
|
830
|
+
let _installed = false;
|
|
831
|
+
const _defaultOpts = {
|
|
832
|
+
tokenHeader: "x-token",
|
|
833
|
+
autoToastError: true
|
|
834
|
+
};
|
|
835
|
+
function useApp() {
|
|
836
|
+
function install(app) {
|
|
837
|
+
if (_installed) {
|
|
838
|
+
console.warn("[hlw] useApp().install() 应只调用一次");
|
|
839
|
+
}
|
|
840
|
+
_installed = true;
|
|
841
|
+
const mainApp = vue.createSSRApp(app);
|
|
842
|
+
mainApp.config.globalProperties["hlw"] = hlw;
|
|
843
|
+
return { app: mainApp };
|
|
228
844
|
}
|
|
845
|
+
return { install, hlw, http };
|
|
229
846
|
}
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
appid = ((_a = accountInfo == null ? void 0 : accountInfo.miniProgram) == null ? void 0 : _a.appId) || "";
|
|
242
|
-
} catch {
|
|
243
|
-
appid = sys.appId || "";
|
|
847
|
+
function buildSignString(url) {
|
|
848
|
+
try {
|
|
849
|
+
const [path, query] = url.split("?");
|
|
850
|
+
if (!query)
|
|
851
|
+
return path + "&";
|
|
852
|
+
const params = query.split("&").filter(Boolean);
|
|
853
|
+
params.sort();
|
|
854
|
+
return params.join("&") + "&";
|
|
855
|
+
} catch {
|
|
856
|
+
return url;
|
|
857
|
+
}
|
|
244
858
|
}
|
|
245
|
-
let
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
859
|
+
let _sigSecret = "";
|
|
860
|
+
function setupDefaultInterceptors(options = {}) {
|
|
861
|
+
const opts = { ..._defaultOpts, ...options };
|
|
862
|
+
if (opts.sigSecret)
|
|
863
|
+
_sigSecret = opts.sigSecret;
|
|
864
|
+
http.onRequest((config) => {
|
|
865
|
+
const device = useDevice();
|
|
866
|
+
if (device.value) {
|
|
867
|
+
const params = new URLSearchParams();
|
|
868
|
+
params.append("appid", device.value.appid);
|
|
869
|
+
params.append("device_brand", device.value.device_brand);
|
|
870
|
+
params.append("device_model", device.value.device_model);
|
|
871
|
+
params.append("device_id", device.value.device_id);
|
|
872
|
+
params.append("device_type", device.value.device_type);
|
|
873
|
+
params.append("platform", device.value.platform);
|
|
874
|
+
params.append("version", device.value.version);
|
|
875
|
+
config.url = config.url + (config.url.includes("?") ? "&" : "?") + params.toString();
|
|
876
|
+
}
|
|
877
|
+
if (_sigSecret) {
|
|
878
|
+
const signStr = buildSignString(config.url);
|
|
879
|
+
const sig = md5(signStr + _sigSecret);
|
|
880
|
+
config.url = config.url + "&sig=" + sig;
|
|
881
|
+
}
|
|
882
|
+
if (opts.getToken) {
|
|
883
|
+
const token = opts.getToken();
|
|
884
|
+
if (token) {
|
|
885
|
+
config.headers = {
|
|
886
|
+
...config.headers,
|
|
887
|
+
[opts.tokenHeader]: token
|
|
888
|
+
};
|
|
889
|
+
}
|
|
890
|
+
}
|
|
891
|
+
return config;
|
|
892
|
+
});
|
|
893
|
+
http.onResponse((res) => {
|
|
894
|
+
if (opts.autoToastError && res.code !== 0) {
|
|
895
|
+
uni.showToast({ title: res.message || "请求失败", icon: "none" });
|
|
896
|
+
}
|
|
897
|
+
return res;
|
|
898
|
+
});
|
|
899
|
+
http.onError((err) => {
|
|
900
|
+
var _a;
|
|
901
|
+
if (err.message.includes("401")) {
|
|
902
|
+
(_a = opts.onUnauthorized) == null ? void 0 : _a.call(opts);
|
|
903
|
+
}
|
|
904
|
+
});
|
|
263
905
|
}
|
|
264
|
-
const
|
|
265
|
-
const
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
const deviceOrientation = sys.deviceOrientation || "portrait";
|
|
269
|
-
const system = sys.system || "";
|
|
270
|
-
return {
|
|
271
|
-
appid,
|
|
272
|
-
app_name: appName,
|
|
273
|
-
app_version: appVersion,
|
|
274
|
-
app_version_code: appVersionCode,
|
|
275
|
-
app_channel: sys.appChannel || "",
|
|
276
|
-
device_brand: deviceBrand,
|
|
277
|
-
device_model: deviceModel,
|
|
278
|
-
device_id: deviceId,
|
|
279
|
-
device_type: deviceType,
|
|
280
|
-
device_orientation: deviceOrientation,
|
|
281
|
-
brand: sys.brand || "",
|
|
282
|
-
model: sys.model || "",
|
|
283
|
-
system,
|
|
284
|
-
os: system.split(" ")[0] || "",
|
|
285
|
-
pixel_ratio: sys.pixelRatio || 0,
|
|
286
|
-
screen_width: sys.screenWidth || 0,
|
|
287
|
-
screen_height: sys.screenHeight || 0,
|
|
288
|
-
window_width: sys.windowWidth || 0,
|
|
289
|
-
window_height: sys.windowHeight || 0,
|
|
290
|
-
status_bar_height: sys.statusBarHeight || 0,
|
|
291
|
-
sdk_version: sys.SDKVersion || "",
|
|
292
|
-
host_name: hostName,
|
|
293
|
-
host_version: hostVersion,
|
|
294
|
-
host_language: hostLanguage,
|
|
295
|
-
host_theme: hostTheme,
|
|
296
|
-
platform: sys.platform || "",
|
|
297
|
-
language: sys.language || "",
|
|
298
|
-
version: sys.version || ""
|
|
906
|
+
const _hoisted_1$3 = ["src"];
|
|
907
|
+
const _hoisted_2$3 = {
|
|
908
|
+
key: 1,
|
|
909
|
+
class: "hlw-avatar__placeholder"
|
|
299
910
|
};
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
911
|
+
const _hoisted_3$3 = { class: "hlw-avatar__initial" };
|
|
912
|
+
const _sfc_main$3 = /* @__PURE__ */ vue.defineComponent({
|
|
913
|
+
__name: "Avatar",
|
|
914
|
+
props: {
|
|
915
|
+
src: {},
|
|
916
|
+
name: {},
|
|
917
|
+
size: {}
|
|
918
|
+
},
|
|
919
|
+
setup(__props) {
|
|
920
|
+
const props = __props;
|
|
921
|
+
const loadError = vue.ref(false);
|
|
922
|
+
const initial = vue.computed(() => {
|
|
923
|
+
if (!props.name)
|
|
924
|
+
return "?";
|
|
925
|
+
return props.name.charAt(0).toUpperCase();
|
|
926
|
+
});
|
|
927
|
+
function onError() {
|
|
928
|
+
loadError.value = true;
|
|
929
|
+
}
|
|
930
|
+
return (_ctx, _cache) => {
|
|
931
|
+
return vue.openBlock(), vue.createElementBlock("view", {
|
|
932
|
+
class: vue.normalizeClass(["hlw-avatar", [`hlw-avatar--${__props.size}`]])
|
|
933
|
+
}, [
|
|
934
|
+
__props.src && !loadError.value ? (vue.openBlock(), vue.createElementBlock("image", {
|
|
935
|
+
key: 0,
|
|
936
|
+
class: "hlw-avatar__image",
|
|
937
|
+
src: __props.src,
|
|
938
|
+
mode: "aspectFill",
|
|
939
|
+
onError
|
|
940
|
+
}, null, 40, _hoisted_1$3)) : (vue.openBlock(), vue.createElementBlock("view", _hoisted_2$3, [
|
|
941
|
+
vue.createElementVNode("text", _hoisted_3$3, vue.toDisplayString(initial.value), 1)
|
|
942
|
+
]))
|
|
943
|
+
], 2);
|
|
944
|
+
};
|
|
945
|
+
}
|
|
946
|
+
});
|
|
947
|
+
const _export_sfc = (sfc, props) => {
|
|
948
|
+
const target = sfc.__vccOpts || sfc;
|
|
949
|
+
for (const [key, val] of props) {
|
|
950
|
+
target[key] = val;
|
|
951
|
+
}
|
|
952
|
+
return target;
|
|
953
|
+
};
|
|
954
|
+
const Avatar = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__scopeId", "data-v-87dd25f7"]]);
|
|
955
|
+
const _hoisted_1$2 = { class: "hlw-empty" };
|
|
956
|
+
const _hoisted_2$2 = ["src"];
|
|
957
|
+
const _hoisted_3$2 = {
|
|
958
|
+
key: 1,
|
|
959
|
+
class: "hlw-empty__icon"
|
|
960
|
+
};
|
|
961
|
+
const _hoisted_4$1 = { class: "hlw-empty__text" };
|
|
962
|
+
const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
|
|
963
|
+
__name: "Empty",
|
|
964
|
+
props: {
|
|
965
|
+
text: {},
|
|
966
|
+
image: {}
|
|
967
|
+
},
|
|
968
|
+
setup(__props) {
|
|
969
|
+
return (_ctx, _cache) => {
|
|
970
|
+
return vue.openBlock(), vue.createElementBlock("view", _hoisted_1$2, [
|
|
971
|
+
__props.image ? (vue.openBlock(), vue.createElementBlock("image", {
|
|
972
|
+
key: 0,
|
|
973
|
+
class: "hlw-empty__image",
|
|
974
|
+
src: __props.image,
|
|
975
|
+
mode: "aspectFit"
|
|
976
|
+
}, null, 8, _hoisted_2$2)) : (vue.openBlock(), vue.createElementBlock("view", _hoisted_3$2, [..._cache[0] || (_cache[0] = [
|
|
977
|
+
vue.createElementVNode("text", null, "📦", -1)
|
|
978
|
+
])])),
|
|
979
|
+
vue.createElementVNode("text", _hoisted_4$1, vue.toDisplayString(__props.text || "暂无数据"), 1),
|
|
980
|
+
vue.renderSlot(_ctx.$slots, "default", {}, void 0, true)
|
|
981
|
+
]);
|
|
982
|
+
};
|
|
983
|
+
}
|
|
984
|
+
});
|
|
985
|
+
const Empty = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-d78ade08"]]);
|
|
986
|
+
const _hoisted_1$1 = { class: "hlw-loading" };
|
|
987
|
+
const _hoisted_2$1 = { class: "hlw-loading__spinner" };
|
|
988
|
+
const _hoisted_3$1 = {
|
|
989
|
+
key: 0,
|
|
990
|
+
class: "hlw-loading__text"
|
|
991
|
+
};
|
|
992
|
+
const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
|
|
993
|
+
__name: "Loading",
|
|
994
|
+
props: {
|
|
995
|
+
text: {}
|
|
996
|
+
},
|
|
997
|
+
setup(__props) {
|
|
998
|
+
return (_ctx, _cache) => {
|
|
999
|
+
return vue.openBlock(), vue.createElementBlock("view", _hoisted_1$1, [
|
|
1000
|
+
vue.createElementVNode("view", _hoisted_2$1, [
|
|
1001
|
+
(vue.openBlock(), vue.createElementBlock(vue.Fragment, null, vue.renderList(12, (i) => {
|
|
1002
|
+
return vue.createElementVNode("view", {
|
|
1003
|
+
key: i,
|
|
1004
|
+
class: "hlw-loading__dot"
|
|
1005
|
+
});
|
|
1006
|
+
}), 64))
|
|
1007
|
+
]),
|
|
1008
|
+
__props.text ? (vue.openBlock(), vue.createElementBlock("text", _hoisted_3$1, vue.toDisplayString(__props.text), 1)) : vue.createCommentVNode("", true)
|
|
1009
|
+
]);
|
|
1010
|
+
};
|
|
1011
|
+
}
|
|
1012
|
+
});
|
|
1013
|
+
const Loading = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-6bf3a5a2"]]);
|
|
1014
|
+
const _hoisted_1 = { class: "hlw-menu-list" };
|
|
1015
|
+
const _hoisted_2 = ["onTap"];
|
|
1016
|
+
const _hoisted_3 = { class: "hlw-menu-list__left" };
|
|
1017
|
+
const _hoisted_4 = {
|
|
1018
|
+
key: 0,
|
|
1019
|
+
class: "hlw-menu-list__icon"
|
|
1020
|
+
};
|
|
1021
|
+
const _hoisted_5 = { class: "hlw-menu-list__label" };
|
|
1022
|
+
const _hoisted_6 = { class: "hlw-menu-list__right" };
|
|
1023
|
+
const _hoisted_7 = {
|
|
1024
|
+
key: 0,
|
|
1025
|
+
class: "hlw-menu-list__value"
|
|
1026
|
+
};
|
|
1027
|
+
const _sfc_main = /* @__PURE__ */ vue.defineComponent({
|
|
1028
|
+
__name: "MenuList",
|
|
1029
|
+
props: {
|
|
1030
|
+
items: {}
|
|
1031
|
+
},
|
|
1032
|
+
emits: ["click"],
|
|
1033
|
+
setup(__props, { emit: __emit }) {
|
|
1034
|
+
const emit = __emit;
|
|
1035
|
+
function onTap(item) {
|
|
1036
|
+
if (item.url) {
|
|
1037
|
+
uni.navigateTo({ url: item.url });
|
|
1038
|
+
} else if (item.action) {
|
|
1039
|
+
item.action();
|
|
1040
|
+
}
|
|
1041
|
+
emit("click", item);
|
|
1042
|
+
}
|
|
1043
|
+
return (_ctx, _cache) => {
|
|
1044
|
+
return vue.openBlock(), vue.createElementBlock("view", _hoisted_1, [
|
|
1045
|
+
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(__props.items, (item) => {
|
|
1046
|
+
return vue.openBlock(), vue.createElementBlock("view", {
|
|
1047
|
+
key: item.key,
|
|
1048
|
+
class: "hlw-menu-list__item",
|
|
1049
|
+
onTap: ($event) => onTap(item)
|
|
1050
|
+
}, [
|
|
1051
|
+
vue.createElementVNode("view", _hoisted_3, [
|
|
1052
|
+
item.icon ? (vue.openBlock(), vue.createElementBlock("text", _hoisted_4, vue.toDisplayString(item.icon), 1)) : vue.createCommentVNode("", true),
|
|
1053
|
+
vue.createElementVNode("text", _hoisted_5, vue.toDisplayString(item.label), 1)
|
|
1054
|
+
]),
|
|
1055
|
+
vue.createElementVNode("view", _hoisted_6, [
|
|
1056
|
+
item.value ? (vue.openBlock(), vue.createElementBlock("text", _hoisted_7, vue.toDisplayString(item.value), 1)) : vue.createCommentVNode("", true),
|
|
1057
|
+
_cache[0] || (_cache[0] = vue.createElementVNode("text", { class: "hlw-menu-list__arrow" }, "›", -1))
|
|
1058
|
+
])
|
|
1059
|
+
], 40, _hoisted_2);
|
|
1060
|
+
}), 128))
|
|
1061
|
+
]);
|
|
1062
|
+
};
|
|
1063
|
+
}
|
|
1064
|
+
});
|
|
1065
|
+
const MenuList = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-1dfe912b"]]);
|
|
1066
|
+
exports2.Avatar = Avatar;
|
|
1067
|
+
exports2.Empty = Empty;
|
|
1068
|
+
exports2.HttpClient = HttpClient;
|
|
1069
|
+
exports2.Loading = Loading;
|
|
1070
|
+
exports2.MenuList = MenuList;
|
|
1071
|
+
exports2.adapters = adapters;
|
|
1072
|
+
exports2.alistAdapter = alistAdapter;
|
|
1073
|
+
exports2.clearDeviceCache = clearDeviceCache;
|
|
1074
|
+
exports2.cosAdapter = cosAdapter;
|
|
1075
|
+
exports2.deviceToQuery = deviceToQuery;
|
|
1076
|
+
exports2.getAdapter = getAdapter;
|
|
1077
|
+
exports2.hlw = hlw;
|
|
1078
|
+
exports2.http = http;
|
|
1079
|
+
exports2.ossAdapter = ossAdapter;
|
|
1080
|
+
exports2.qiniuAdapter = qiniuAdapter;
|
|
1081
|
+
exports2.setupDefaultInterceptors = setupDefaultInterceptors;
|
|
1082
|
+
exports2.useApp = useApp;
|
|
1083
|
+
exports2.useDevice = useDevice;
|
|
1084
|
+
exports2.useFormat = useFormat;
|
|
1085
|
+
exports2.useLoading = useLoading;
|
|
1086
|
+
exports2.useMsg = useMsg;
|
|
1087
|
+
exports2.usePageMeta = usePageMeta;
|
|
1088
|
+
exports2.useRefs = useRefs;
|
|
1089
|
+
exports2.useRequest = useRequest;
|
|
1090
|
+
exports2.useStorage = useStorage;
|
|
1091
|
+
exports2.useUpload = useUpload;
|
|
1092
|
+
exports2.useValidate = useValidate;
|
|
1093
|
+
Object.defineProperty(exports2, Symbol.toStringTag, { value: "Module" });
|
|
1094
|
+
});
|