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