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