@kevisual/kv-login 0.0.6 → 0.0.7

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.
@@ -1,3819 +0,0 @@
1
- const Je = globalThis, ue = Je.trustedTypes, tt = ue ? ue.createPolicy("lit-html", { createHTML: (n) => n }) : void 0, Vt = "$lit$", j = `lit$${Math.random().toFixed(9).slice(2)}$`, Ot = "?" + j, pn = `<${Ot}>`, W = document, re = () => W.createComment(""), oe = (n) => n === null || typeof n != "object" && typeof n != "function", Qe = Array.isArray, wn = (n) => Qe(n) || typeof n?.[Symbol.iterator] == "function", ve = `[
2
- \f\r]`, te = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, nt = /-->/g, rt = />/g, V = RegExp(`>|${ve}(?:([^\\s"'>=/]+)(${ve}*=${ve}*(?:[^
3
- \f\r"'\`<>=]|("|')|))|$)`, "g"), ot = /'/g, st = /"/g, Wt = /^(?:script|style|textarea|title)$/i, yn = (n) => (e, ...t) => ({ _$litType$: n, strings: e, values: t }), I = yn(1), X = Symbol.for("lit-noChange"), B = Symbol.for("lit-nothing"), it = /* @__PURE__ */ new WeakMap(), O = W.createTreeWalker(W, 129);
4
- function Kt(n, e) {
5
- if (!Qe(n) || !n.hasOwnProperty("raw")) throw Error("invalid template strings array");
6
- return tt !== void 0 ? tt.createHTML(e) : e;
7
- }
8
- const vn = (n, e) => {
9
- const t = n.length - 1, r = [];
10
- let o, s = e === 2 ? "<svg>" : e === 3 ? "<math>" : "", i = te;
11
- for (let c = 0; c < t; c++) {
12
- const a = n[c];
13
- let l, u, h = -1, f = 0;
14
- for (; f < a.length && (i.lastIndex = f, u = i.exec(a), u !== null); ) f = i.lastIndex, i === te ? u[1] === "!--" ? i = nt : u[1] !== void 0 ? i = rt : u[2] !== void 0 ? (Wt.test(u[2]) && (o = RegExp("</" + u[2], "g")), i = V) : u[3] !== void 0 && (i = V) : i === V ? u[0] === ">" ? (i = o ?? te, h = -1) : u[1] === void 0 ? h = -2 : (h = i.lastIndex - u[2].length, l = u[1], i = u[3] === void 0 ? V : u[3] === '"' ? st : ot) : i === st || i === ot ? i = V : i === nt || i === rt ? i = te : (i = V, o = void 0);
15
- const d = i === V && n[c + 1].startsWith("/>") ? " " : "";
16
- s += i === te ? a + pn : h >= 0 ? (r.push(l), a.slice(0, h) + Vt + a.slice(h) + j + d) : a + j + (h === -2 ? c : d);
17
- }
18
- return [Kt(n, s + (n[t] || "<?>") + (e === 2 ? "</svg>" : e === 3 ? "</math>" : "")), r];
19
- };
20
- class se {
21
- constructor({ strings: e, _$litType$: t }, r) {
22
- let o;
23
- this.parts = [];
24
- let s = 0, i = 0;
25
- const c = e.length - 1, a = this.parts, [l, u] = vn(e, t);
26
- if (this.el = se.createElement(l, r), O.currentNode = this.el.content, t === 2 || t === 3) {
27
- const h = this.el.content.firstChild;
28
- h.replaceWith(...h.childNodes);
29
- }
30
- for (; (o = O.nextNode()) !== null && a.length < c; ) {
31
- if (o.nodeType === 1) {
32
- if (o.hasAttributes()) for (const h of o.getAttributeNames()) if (h.endsWith(Vt)) {
33
- const f = u[i++], d = o.getAttribute(h).split(j), g = /([.?@])?(.*)/.exec(f);
34
- a.push({ type: 1, index: s, name: g[2], strings: d, ctor: g[1] === "." ? Cn : g[1] === "?" ? An : g[1] === "@" ? Tn : ge }), o.removeAttribute(h);
35
- } else h.startsWith(j) && (a.push({ type: 6, index: s }), o.removeAttribute(h));
36
- if (Wt.test(o.tagName)) {
37
- const h = o.textContent.split(j), f = h.length - 1;
38
- if (f > 0) {
39
- o.textContent = ue ? ue.emptyScript : "";
40
- for (let d = 0; d < f; d++) o.append(h[d], re()), O.nextNode(), a.push({ type: 2, index: ++s });
41
- o.append(h[f], re());
42
- }
43
- }
44
- } else if (o.nodeType === 8) if (o.data === Ot) a.push({ type: 2, index: s });
45
- else {
46
- let h = -1;
47
- for (; (h = o.data.indexOf(j, h + 1)) !== -1; ) a.push({ type: 7, index: s }), h += j.length - 1;
48
- }
49
- s++;
50
- }
51
- }
52
- static createElement(e, t) {
53
- const r = W.createElement("template");
54
- return r.innerHTML = e, r;
55
- }
56
- }
57
- function Z(n, e, t = n, r) {
58
- if (e === X) return e;
59
- let o = r !== void 0 ? t._$Co?.[r] : t._$Cl;
60
- const s = oe(e) ? void 0 : e._$litDirective$;
61
- return o?.constructor !== s && (o?._$AO?.(!1), s === void 0 ? o = void 0 : (o = new s(n), o._$AT(n, t, r)), r !== void 0 ? (t._$Co ??= [])[r] = o : t._$Cl = o), o !== void 0 && (e = Z(n, o._$AS(n, e.values), o, r)), e;
62
- }
63
- class bn {
64
- constructor(e, t) {
65
- this._$AV = [], this._$AN = void 0, this._$AD = e, this._$AM = t;
66
- }
67
- get parentNode() {
68
- return this._$AM.parentNode;
69
- }
70
- get _$AU() {
71
- return this._$AM._$AU;
72
- }
73
- u(e) {
74
- const { el: { content: t }, parts: r } = this._$AD, o = (e?.creationScope ?? W).importNode(t, !0);
75
- O.currentNode = o;
76
- let s = O.nextNode(), i = 0, c = 0, a = r[0];
77
- for (; a !== void 0; ) {
78
- if (i === a.index) {
79
- let l;
80
- a.type === 2 ? l = new ae(s, s.nextSibling, this, e) : a.type === 1 ? l = new a.ctor(s, a.name, a.strings, this, e) : a.type === 6 && (l = new En(s, this, e)), this._$AV.push(l), a = r[++c];
81
- }
82
- i !== a?.index && (s = O.nextNode(), i++);
83
- }
84
- return O.currentNode = W, o;
85
- }
86
- p(e) {
87
- let t = 0;
88
- for (const r of this._$AV) r !== void 0 && (r.strings !== void 0 ? (r._$AI(e, r, t), t += r.strings.length - 2) : r._$AI(e[t])), t++;
89
- }
90
- }
91
- class ae {
92
- get _$AU() {
93
- return this._$AM?._$AU ?? this._$Cv;
94
- }
95
- constructor(e, t, r, o) {
96
- this.type = 2, this._$AH = B, this._$AN = void 0, this._$AA = e, this._$AB = t, this._$AM = r, this.options = o, this._$Cv = o?.isConnected ?? !0;
97
- }
98
- get parentNode() {
99
- let e = this._$AA.parentNode;
100
- const t = this._$AM;
101
- return t !== void 0 && e?.nodeType === 11 && (e = t.parentNode), e;
102
- }
103
- get startNode() {
104
- return this._$AA;
105
- }
106
- get endNode() {
107
- return this._$AB;
108
- }
109
- _$AI(e, t = this) {
110
- e = Z(this, e, t), oe(e) ? e === B || e == null || e === "" ? (this._$AH !== B && this._$AR(), this._$AH = B) : e !== this._$AH && e !== X && this._(e) : e._$litType$ !== void 0 ? this.$(e) : e.nodeType !== void 0 ? this.T(e) : wn(e) ? this.k(e) : this._(e);
111
- }
112
- O(e) {
113
- return this._$AA.parentNode.insertBefore(e, this._$AB);
114
- }
115
- T(e) {
116
- this._$AH !== e && (this._$AR(), this._$AH = this.O(e));
117
- }
118
- _(e) {
119
- this._$AH !== B && oe(this._$AH) ? this._$AA.nextSibling.data = e : this.T(W.createTextNode(e)), this._$AH = e;
120
- }
121
- $(e) {
122
- const { values: t, _$litType$: r } = e, o = typeof r == "number" ? this._$AC(e) : (r.el === void 0 && (r.el = se.createElement(Kt(r.h, r.h[0]), this.options)), r);
123
- if (this._$AH?._$AD === o) this._$AH.p(t);
124
- else {
125
- const s = new bn(o, this), i = s.u(this.options);
126
- s.p(t), this.T(i), this._$AH = s;
127
- }
128
- }
129
- _$AC(e) {
130
- let t = it.get(e.strings);
131
- return t === void 0 && it.set(e.strings, t = new se(e)), t;
132
- }
133
- k(e) {
134
- Qe(this._$AH) || (this._$AH = [], this._$AR());
135
- const t = this._$AH;
136
- let r, o = 0;
137
- for (const s of e) o === t.length ? t.push(r = new ae(this.O(re()), this.O(re()), this, this.options)) : r = t[o], r._$AI(s), o++;
138
- o < t.length && (this._$AR(r && r._$AB.nextSibling, o), t.length = o);
139
- }
140
- _$AR(e = this._$AA.nextSibling, t) {
141
- for (this._$AP?.(!1, !0, t); e !== this._$AB; ) {
142
- const r = e.nextSibling;
143
- e.remove(), e = r;
144
- }
145
- }
146
- setConnected(e) {
147
- this._$AM === void 0 && (this._$Cv = e, this._$AP?.(e));
148
- }
149
- }
150
- class ge {
151
- get tagName() {
152
- return this.element.tagName;
153
- }
154
- get _$AU() {
155
- return this._$AM._$AU;
156
- }
157
- constructor(e, t, r, o, s) {
158
- this.type = 1, this._$AH = B, this._$AN = void 0, this.element = e, this.name = t, this._$AM = o, this.options = s, r.length > 2 || r[0] !== "" || r[1] !== "" ? (this._$AH = Array(r.length - 1).fill(new String()), this.strings = r) : this._$AH = B;
159
- }
160
- _$AI(e, t = this, r, o) {
161
- const s = this.strings;
162
- let i = !1;
163
- if (s === void 0) e = Z(this, e, t, 0), i = !oe(e) || e !== this._$AH && e !== X, i && (this._$AH = e);
164
- else {
165
- const c = e;
166
- let a, l;
167
- for (e = s[0], a = 0; a < s.length - 1; a++) l = Z(this, c[r + a], t, a), l === X && (l = this._$AH[a]), i ||= !oe(l) || l !== this._$AH[a], l === B ? e = B : e !== B && (e += (l ?? "") + s[a + 1]), this._$AH[a] = l;
168
- }
169
- i && !o && this.j(e);
170
- }
171
- j(e) {
172
- e === B ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, e ?? "");
173
- }
174
- }
175
- class Cn extends ge {
176
- constructor() {
177
- super(...arguments), this.type = 3;
178
- }
179
- j(e) {
180
- this.element[this.name] = e === B ? void 0 : e;
181
- }
182
- }
183
- class An extends ge {
184
- constructor() {
185
- super(...arguments), this.type = 4;
186
- }
187
- j(e) {
188
- this.element.toggleAttribute(this.name, !!e && e !== B);
189
- }
190
- }
191
- class Tn extends ge {
192
- constructor(e, t, r, o, s) {
193
- super(e, t, r, o, s), this.type = 5;
194
- }
195
- _$AI(e, t = this) {
196
- if ((e = Z(this, e, t, 0) ?? B) === X) return;
197
- const r = this._$AH, o = e === B && r !== B || e.capture !== r.capture || e.once !== r.once || e.passive !== r.passive, s = e !== B && (r === B || o);
198
- o && this.element.removeEventListener(this.name, this, r), s && this.element.addEventListener(this.name, this, e), this._$AH = e;
199
- }
200
- handleEvent(e) {
201
- typeof this._$AH == "function" ? this._$AH.call(this.options?.host ?? this.element, e) : this._$AH.handleEvent(e);
202
- }
203
- }
204
- class En {
205
- constructor(e, t, r) {
206
- this.element = e, this.type = 6, this._$AN = void 0, this._$AM = t, this.options = r;
207
- }
208
- get _$AU() {
209
- return this._$AM._$AU;
210
- }
211
- _$AI(e) {
212
- Z(this, e);
213
- }
214
- }
215
- const _n = Je.litHtmlPolyfillSupport;
216
- _n?.(se, ae), (Je.litHtmlVersions ??= []).push("3.3.1");
217
- const Jt = (n, e, t) => {
218
- const r = e;
219
- let o = r._$litPart$;
220
- return o === void 0 && (r._$litPart$ = o = new ae(e.insertBefore(re(), null), null, void 0, {})), o._$AI(n), o;
221
- };
222
- const kn = { CHILD: 2 }, xn = (n) => (...e) => ({ _$litDirective$: n, values: e });
223
- class Rn {
224
- constructor(e) {
225
- }
226
- get _$AU() {
227
- return this._$AM._$AU;
228
- }
229
- _$AT(e, t, r) {
230
- this._$Ct = e, this._$AM = t, this._$Ci = r;
231
- }
232
- _$AS(e, t) {
233
- return this.update(e, t);
234
- }
235
- update(e, t) {
236
- return this.render(...t);
237
- }
238
- }
239
- class Ke extends Rn {
240
- constructor(e) {
241
- if (super(e), this.it = B, e.type !== kn.CHILD) throw Error(this.constructor.directiveName + "() can only be used in child bindings");
242
- }
243
- render(e) {
244
- if (e === B || e == null) return this._t = void 0, this.it = e;
245
- if (e === X) return e;
246
- if (typeof e != "string") throw Error(this.constructor.directiveName + "() called with a non-string value");
247
- if (e === this.it) return this._t;
248
- this.it = e;
249
- const t = [e];
250
- return t.raw = t, this._t = { _$litType$: this.constructor.resultType, strings: t, values: [] };
251
- }
252
- }
253
- Ke.directiveName = "unsafeHTML", Ke.resultType = 1;
254
- const at = xn(Ke), Sn = (n) => n ? ["text/", "xml", "html", "javascript", "css", "csv", "plain", "x-www-form-urlencoded"].some((t) => n.includes(t)) : !1, ct = async (n = {}, e) => {
255
- const t = new AbortController(), r = t.signal, o = n.isBlob || !1, s = n.isText || !1, i = n.isPostFile || !1, c = n.timeout || 6e4 * 3, a = setTimeout(() => {
256
- t.abort();
257
- }, c);
258
- let l = e?.method || n?.method || "POST", u = { ...n?.headers, ...e?.headers }, h = "", f;
259
- n?.url?.startsWith("http") ? f = new URL(n.url) : (h = window?.location?.origin || "http://localhost:51015", f = new URL(n.url, h));
260
- const d = l === "GET";
261
- d && (f.search = new URLSearchParams(n.body).toString());
262
- let g;
263
- return d ? g = void 0 : i ? g = n.body : (u = {
264
- "Content-Type": "application/json",
265
- ...u
266
- }, g = JSON.stringify(n.body)), fetch(f, {
267
- method: l.toUpperCase(),
268
- signal: r,
269
- body: g,
270
- ...e,
271
- headers: u
272
- }).then(async (p) => {
273
- const m = p.headers.get("Content-Type");
274
- return o ? await p.blob() : m && m.includes("application/json") && !s ? await p.json() : Sn(m) ? {
275
- code: 200,
276
- status: p.status,
277
- data: await p.text()
278
- // 直接返回文本内容
279
- } : p;
280
- }).catch((p) => (p.name === "AbortError" && console.log("Request timed out and was aborted"), console.error(p), {
281
- code: 500
282
- })).finally(() => {
283
- clearTimeout(a);
284
- });
285
- }, lt = (n) => (n.success = n.code === 200, n.showError = (e) => {
286
- !n.success && !n.noMsg && e?.();
287
- }, n), be = ({ code: n, message: e }) => ({
288
- code: n || 500,
289
- success: !1,
290
- message: e || "api request error",
291
- showError: (r) => {
292
- },
293
- noMsg: !0
294
- });
295
- class Qt {
296
- adapter;
297
- url;
298
- beforeRequest;
299
- afterResponse;
300
- headers;
301
- timeout;
302
- /**
303
- * 需要突然停止请求,比如401的时候
304
- */
305
- stop;
306
- // 默认不使用ws
307
- qws;
308
- constructor(e) {
309
- this.adapter = e?.adapter || ct, this.url = e?.url || "/api/router", this.headers = e?.headers || {
310
- "Content-Type": "application/json"
311
- }, this.timeout = e?.timeout || 6e4 * 3;
312
- }
313
- setQueryWs(e) {
314
- this.qws = e;
315
- }
316
- /**
317
- * 突然停止请求
318
- */
319
- setStop(e) {
320
- this.stop = e;
321
- }
322
- /**
323
- * 发送 get 请求,转到 post 请求
324
- * T是请求类型自定义
325
- * S是返回类型自定义
326
- * @param params 请求参数
327
- * @param options 请求配置
328
- * @returns 请求结果
329
- */
330
- async get(e, t) {
331
- return this.post(e, t);
332
- }
333
- /**
334
- * 发送 post 请求
335
- * T是请求类型自定义
336
- * S是返回类型自定义
337
- * @param body 请求体
338
- * @param options 请求配置
339
- * @returns 请求结果
340
- */
341
- async post(e, t) {
342
- const r = t?.url || this.url, { headers: o, adapter: s, beforeRequest: i, afterResponse: c, timeout: a, ...l } = t || {}, u = { ...this.headers, ...o }, h = s || this.adapter, f = i || this.beforeRequest, d = c || this.afterResponse, g = a || this.timeout, p = {
343
- url: r,
344
- headers: u,
345
- body: e,
346
- timeout: g,
347
- ...l
348
- };
349
- try {
350
- if (f && await f(p) === !1)
351
- return be({
352
- code: 500,
353
- message: "request is cancel",
354
- // @ts-ignore
355
- req: p
356
- });
357
- } catch (m) {
358
- return console.error("request beforeFn error", m, p), be({
359
- code: 500,
360
- message: "api request beforeFn error"
361
- });
362
- }
363
- if (this.stop && !t?.noStop) {
364
- const m = this;
365
- await new Promise((y) => {
366
- let E = 0;
367
- const w = setInterval(() => {
368
- m.stop || (clearInterval(w), y(!0)), E++, E > 30 && console.error("request stop: timeout", p.url, E);
369
- }, 1e3);
370
- });
371
- }
372
- return h(p).then(async (m) => {
373
- try {
374
- return lt(m), d ? await d(m, {
375
- req: p,
376
- res: m,
377
- fetch: s
378
- }) : m;
379
- } catch (y) {
380
- return console.error("request afterFn error", y, p), be({
381
- code: 500,
382
- message: "api request afterFn error"
383
- });
384
- }
385
- });
386
- }
387
- /**
388
- * 请求前处理,设置请求前处理函数
389
- * @param fn 处理函数
390
- */
391
- before(e) {
392
- this.beforeRequest = e;
393
- }
394
- /**
395
- * 请求后处理,设置请求后处理函数
396
- * @param fn 处理函数
397
- */
398
- after(e) {
399
- this.afterResponse = e;
400
- }
401
- async fetchText(e, t) {
402
- let r = { ...t };
403
- typeof e == "string" && !r.url && (r.url = e), typeof e == "object" && (r = { ...e, ...r });
404
- const o = await ct({
405
- method: "GET",
406
- ...r,
407
- headers: {
408
- ...this.headers,
409
- ...r?.headers || {}
410
- }
411
- });
412
- return lt(o);
413
- }
414
- }
415
- class Mn {
416
- query;
417
- queryDefine;
418
- constructor(e) {
419
- e?.clientQuery ? this.query = e.clientQuery : this.query = e?.query, e.queryDefine && (this.queryDefine = e.queryDefine, this.queryDefine.query = this.query);
420
- }
421
- get chain() {
422
- return this.queryDefine.queryChain;
423
- }
424
- post(e, t) {
425
- return this.query.post(e, t);
426
- }
427
- get(e, t) {
428
- return this.query.get(e, t);
429
- }
430
- }
431
- const ut = (n) => (n.success = n.code === 200, n.showError = (e) => {
432
- !n.success && !n.noMsg && e?.();
433
- }, n);
434
- function L(n) {
435
- return new Promise((e, t) => {
436
- n.oncomplete = n.onsuccess = () => e(n.result), n.onabort = n.onerror = () => t(n.error);
437
- });
438
- }
439
- function Gt(n, e) {
440
- const t = indexedDB.open(n);
441
- t.onupgradeneeded = () => t.result.createObjectStore(e);
442
- const r = L(t);
443
- return (o, s) => r.then((i) => s(i.transaction(e, o).objectStore(e)));
444
- }
445
- let Ce;
446
- function $() {
447
- return Ce || (Ce = Gt("keyval-store", "keyval")), Ce;
448
- }
449
- function Yt(n, e = $()) {
450
- return e("readonly", (t) => L(t.get(n)));
451
- }
452
- function Xt(n, e, t = $()) {
453
- return t("readwrite", (r) => (r.put(e, n), L(r.transaction)));
454
- }
455
- function Bn(n, e = $()) {
456
- return e("readwrite", (t) => (n.forEach((r) => t.put(r[1], r[0])), L(t.transaction)));
457
- }
458
- function Ln(n, e = $()) {
459
- return e("readonly", (t) => Promise.all(n.map((r) => L(t.get(r)))));
460
- }
461
- function In(n, e, t = $()) {
462
- return t("readwrite", (r) => (
463
- // Need to create the promise manually.
464
- // If I try to chain promises, the transaction closes in browsers
465
- // that use a promise polyfill (IE10/11).
466
- new Promise((o, s) => {
467
- r.get(n).onsuccess = function() {
468
- try {
469
- r.put(e(this.result), n), o(L(r.transaction));
470
- } catch (i) {
471
- s(i);
472
- }
473
- };
474
- })
475
- ));
476
- }
477
- function Zt(n, e = $()) {
478
- return e("readwrite", (t) => (t.delete(n), L(t.transaction)));
479
- }
480
- function $n(n, e = $()) {
481
- return e("readwrite", (t) => (n.forEach((r) => t.delete(r)), L(t.transaction)));
482
- }
483
- function en(n = $()) {
484
- return n("readwrite", (e) => (e.clear(), L(e.transaction)));
485
- }
486
- function Ge(n, e) {
487
- return n.openCursor().onsuccess = function() {
488
- this.result && (e(this.result), this.result.continue());
489
- }, L(n.transaction);
490
- }
491
- function Pn(n = $()) {
492
- return n("readonly", (e) => {
493
- if (e.getAllKeys)
494
- return L(e.getAllKeys());
495
- const t = [];
496
- return Ge(e, (r) => t.push(r.key)).then(() => t);
497
- });
498
- }
499
- function qn(n = $()) {
500
- return n("readonly", (e) => {
501
- if (e.getAll)
502
- return L(e.getAll());
503
- const t = [];
504
- return Ge(e, (r) => t.push(r.value)).then(() => t);
505
- });
506
- }
507
- function Nn(n = $()) {
508
- return n("readonly", (e) => {
509
- if (e.getAll && e.getAllKeys)
510
- return Promise.all([
511
- L(e.getAllKeys()),
512
- L(e.getAll())
513
- ]).then(([r, o]) => r.map((s, i) => [s, o[i]]));
514
- const t = [];
515
- return n("readonly", (r) => Ge(r, (o) => t.push([o.key, o.value])).then(() => t));
516
- });
517
- }
518
- var Dn = /* @__PURE__ */ Object.freeze({
519
- __proto__: null,
520
- clear: en,
521
- createStore: Gt,
522
- del: Zt,
523
- delMany: $n,
524
- entries: Nn,
525
- get: Yt,
526
- getMany: Ln,
527
- keys: Pn,
528
- promisifyRequest: L,
529
- set: Xt,
530
- setMany: Bn,
531
- update: In,
532
- values: qn
533
- });
534
- class Un {
535
- storage;
536
- data = null;
537
- constructor() {
538
- this.storage = Dn;
539
- }
540
- async get(e) {
541
- const t = await Yt(e);
542
- return this.data = t, t;
543
- }
544
- async set(e, t) {
545
- this.data = t, await Xt(e, t);
546
- }
547
- async del(e) {
548
- this.data = null, await Zt(e);
549
- }
550
- /**
551
- * Clear all values in the store.
552
- */
553
- async clear() {
554
- await en();
555
- }
556
- }
557
- class Fn extends Un {
558
- name;
559
- updatedAt;
560
- constructor(e) {
561
- super(), this.name = e || "my-cache";
562
- }
563
- async getData() {
564
- const e = await super.get(this.name);
565
- return this.updatedAt = e.updatedAt, e.expireTime && e.expireTime < Date.now() ? (await super.del(this.name), {}) : e.data;
566
- }
567
- /**
568
- * 设置缓存数据,默认过期时间为10天
569
- * @param data
570
- * @param opts
571
- */
572
- async setData(e, t) {
573
- const o = Date.now() + (t?.expireTime || 1e3 * 60 * 60 * 24 * 10), s = {
574
- data: e,
575
- updatedAt: t?.updatedAt || Date.now(),
576
- expireTime: o
577
- };
578
- await super.set(this.name, s), this.updatedAt = s.updatedAt;
579
- }
580
- async del() {
581
- await super.del(this.name);
582
- }
583
- }
584
- var zn = class {
585
- cache;
586
- name;
587
- cacheData;
588
- constructor(n) {
589
- if (!n.cache)
590
- throw new Error("cache is required");
591
- this.cache = n.cache, this.cacheData = {
592
- loginUsers: [],
593
- user: void 0,
594
- id: void 0,
595
- accessToken: void 0,
596
- refreshToken: void 0
597
- }, this.name = n.name;
598
- }
599
- /**
600
- * 设置缓存
601
- * @param key
602
- * @param value
603
- * @returns
604
- */
605
- async setValue(n) {
606
- return await this.cache.set(this.name, n), this.cacheData = n, n;
607
- }
608
- /**
609
- * 删除缓存
610
- */
611
- async delValue() {
612
- await this.cache.del();
613
- }
614
- getValue() {
615
- return this.cache.get(this.name);
616
- }
617
- /**
618
- * 初始化,设置默认值
619
- */
620
- async init() {
621
- const n = {
622
- loginUsers: [],
623
- user: null,
624
- id: null,
625
- accessToken: null,
626
- refreshToken: null
627
- };
628
- if (this.cache.init)
629
- try {
630
- const e = await this.cache.init();
631
- this.cacheData = e || n;
632
- } catch (e) {
633
- console.log("cacheInit error", e);
634
- }
635
- else
636
- this.cacheData = await this.getValue() || n;
637
- }
638
- /**
639
- * 设置当前用户
640
- * @param user
641
- */
642
- async setLoginUser(n) {
643
- this.cacheData.loginUsers.find((t) => t.id === n.id) && (this.cacheData.loginUsers = this.cacheData?.loginUsers?.filter((t) => t?.id && t.id !== n.id)), this.cacheData.loginUsers.push(n), this.cacheData.user = n.user, this.cacheData.id = n.id, this.cacheData.accessToken = n.accessToken, this.cacheData.refreshToken = n.refreshToken, await this.setValue(this.cacheData);
644
- }
645
- getCurrentUser() {
646
- const n = this.cacheData;
647
- return Promise.resolve(n.user);
648
- }
649
- getCurrentUserList() {
650
- return Promise.resolve(this.cacheData.loginUsers.filter((n) => n?.id));
651
- }
652
- getRefreshToken() {
653
- const n = this.cacheData;
654
- return Promise.resolve(n.refreshToken || "");
655
- }
656
- getAccessToken() {
657
- const n = this.cacheData;
658
- return Promise.resolve(n.accessToken || "");
659
- }
660
- async clearCurrentUser() {
661
- const n = await this.getCurrentUser();
662
- this.cacheData.loginUsers.find((t) => t.id === n.id) && (this.cacheData.loginUsers = this.cacheData?.loginUsers?.filter((t) => t?.id && t.id !== n.id)), this.cacheData.user = void 0, this.cacheData.id = void 0, this.cacheData.accessToken = void 0, this.cacheData.refreshToken = void 0, await this.setValue(this.cacheData);
663
- }
664
- async clearAll() {
665
- this.cacheData.loginUsers = [], this.cacheData.user = void 0, this.cacheData.id = void 0, this.cacheData.accessToken = void 0, this.cacheData.refreshToken = void 0, await this.setValue(this.cacheData);
666
- }
667
- }, Hn = class extends Mn {
668
- /**
669
- * query login cache, 非实际操作, 一个cache的包裹模块
670
- */
671
- cacheStore;
672
- isBrowser;
673
- load;
674
- storage;
675
- onLoad;
676
- constructor(n) {
677
- super({
678
- query: n?.query || new Qt()
679
- }), this.cacheStore = new zn({ name: "login", cache: n.cache }), this.isBrowser = n?.isBrowser ?? !0, this.init(), this.onLoad = n?.onLoad, this.storage = n?.storage || localStorage;
680
- }
681
- setQuery(n) {
682
- this.query = n;
683
- }
684
- async init() {
685
- await this.cacheStore.init(), this.load = !0, this.onLoad?.();
686
- }
687
- async post(n, e) {
688
- try {
689
- return this.query.post({ path: "user", ...n }, e);
690
- } catch (t) {
691
- return console.log("error", t), {
692
- code: 400
693
- };
694
- }
695
- }
696
- /**
697
- * 登录,
698
- * @param data
699
- * @returns
700
- */
701
- async login(n) {
702
- const e = await this.post({ key: "login", ...n });
703
- if (e.code === 200) {
704
- const { accessToken: t, refreshToken: r } = e?.data || {};
705
- this.storage.setItem("token", t || ""), await this.beforeSetLoginUser({ accessToken: t, refreshToken: r });
706
- }
707
- return e;
708
- }
709
- /**
710
- * 手机号登录
711
- * @param data
712
- * @returns
713
- */
714
- async loginByCode(n) {
715
- const e = await this.post({ path: "sms", key: "login", data: n });
716
- if (e.code === 200) {
717
- const { accessToken: t, refreshToken: r } = e?.data || {};
718
- this.storage.setItem("token", t || ""), await this.beforeSetLoginUser({ accessToken: t, refreshToken: r });
719
- }
720
- return e;
721
- }
722
- /**
723
- * 设置token
724
- * @param token
725
- */
726
- async setLoginToken(n) {
727
- const { accessToken: e, refreshToken: t } = n;
728
- this.storage.setItem("token", e || ""), await this.beforeSetLoginUser({ accessToken: e, refreshToken: t });
729
- }
730
- async loginByWechat(n) {
731
- const e = await this.post({ path: "wx", key: "open-login", code: n.code });
732
- if (e.code === 200) {
733
- const { accessToken: t, refreshToken: r } = e?.data || {};
734
- this.storage.setItem("token", t || ""), await this.beforeSetLoginUser({ accessToken: t, refreshToken: r });
735
- }
736
- return e;
737
- }
738
- /**
739
- * 检测微信登录,登陆成功后,调用onSuccess,否则调用onError
740
- * @param param0
741
- */
742
- async checkWechat({ onSuccess: n, onError: e }) {
743
- const t = new URL(window.location.href), r = t.searchParams.get("code"), o = t.searchParams.get("state");
744
- if (r && o) {
745
- const s = await this.loginByWechat({ code: r });
746
- s.code === 200 ? n?.(s.data) : e?.(s);
747
- }
748
- }
749
- /**
750
- * 登陆成功,需要获取用户信息进行缓存
751
- * @param param0
752
- */
753
- async beforeSetLoginUser({ accessToken: n, refreshToken: e, check401: t }) {
754
- if (n && e) {
755
- const r = await this.getMe(n, t);
756
- if (r.code === 200) {
757
- const o = r.data;
758
- o ? this.cacheStore.setLoginUser({
759
- user: o,
760
- id: o.id,
761
- accessToken: n,
762
- refreshToken: e
763
- }) : console.error("登录失败");
764
- }
765
- }
766
- }
767
- /**
768
- * 刷新token
769
- * @param refreshToken
770
- * @returns
771
- */
772
- async queryRefreshToken(n) {
773
- const e = n || this.cacheStore.getRefreshToken();
774
- let t = { refreshToken: e };
775
- return e ? this.post(
776
- { key: "refreshToken", data: t },
777
- {
778
- afterResponse: async (r, o) => (ut(r), r)
779
- }
780
- ) : (await this.cacheStore.clearCurrentUser(), {
781
- code: 401,
782
- message: "请先登录",
783
- data: {}
784
- });
785
- }
786
- /**
787
- * 检查401错误,并刷新token, 如果refreshToken存在,则刷新token, 否则返回401
788
- * 拦截请求,请使用run401Action, 不要直接使用 afterCheck401ToRefreshToken
789
- * @param response
790
- * @param ctx
791
- * @param refetch
792
- * @returns
793
- */
794
- async afterCheck401ToRefreshToken(n, e, t) {
795
- const r = this;
796
- if (n?.code === 401) {
797
- const o = await r.cacheStore.getRefreshToken();
798
- if (o) {
799
- const s = await r.queryRefreshToken(o);
800
- if (s.code === 200) {
801
- const { accessToken: i, refreshToken: c } = s?.data || {};
802
- if (r.storage.setItem("token", i || ""), await r.beforeSetLoginUser({ accessToken: i, refreshToken: c, check401: !1 }), t && e && e.req && e.req.url && e.fetch) {
803
- await new Promise((f) => setTimeout(f, 1500));
804
- const a = e.req?.url, l = e.req?.body, u = e.req?.headers, h = await e.fetch(a, {
805
- method: "POST",
806
- body: l,
807
- headers: { ...u, Authorization: `Bearer ${i}` }
808
- });
809
- return ut(h), h;
810
- }
811
- } else
812
- r.storage.removeItem("token"), await r.cacheStore.clearCurrentUser();
813
- return s;
814
- }
815
- }
816
- return n;
817
- }
818
- /**
819
- * 一个简单的401处理, 如果401,则刷新token, 如果refreshToken不存在,则返回401
820
- * refetch 是否重新请求, 会有bug,无限循环,按需要使用
821
- * TODO:
822
- * @param response
823
- * @param ctx
824
- * @param opts
825
- * @returns
826
- */
827
- async run401Action(n, e, t) {
828
- const r = this, o = t?.refetch ?? !1;
829
- if (n?.code === 401) {
830
- if (r.query.stop === !0)
831
- return { code: 500, success: !1, message: "refresh token loading..." };
832
- r.query.stop = !0;
833
- const s = await r.afterCheck401ToRefreshToken(n, e, o);
834
- return r.query.stop = !1, t?.afterCheck?.(s), s.code === 401 && t?.afterAlso401?.(s), s;
835
- } else
836
- return n;
837
- }
838
- /**
839
- * 获取用户信息
840
- * @param token
841
- * @returns
842
- */
843
- async getMe(n, e = !0) {
844
- const t = n || this.storage.getItem("token"), r = this;
845
- return r.post(
846
- { key: "me" },
847
- {
848
- beforeRequest: async (o) => (o.headers && (o.headers.Authorization = `Bearer ${t}`), o),
849
- afterResponse: async (o, s) => o?.code === 401 && e && !n ? await r.afterCheck401ToRefreshToken(o, s) : o
850
- }
851
- );
852
- }
853
- /**
854
- * 检查本地用户,如果本地用户存在,则返回本地用户,否则返回null
855
- * @returns
856
- */
857
- async checkLocalUser() {
858
- const n = await this.cacheStore.getCurrentUser();
859
- return n || null;
860
- }
861
- /**
862
- * 检查本地token是否存在,简单的判断是否已经属于登陆状态
863
- * @returns
864
- */
865
- async checkLocalToken() {
866
- return !!this.storage.getItem("token");
867
- }
868
- /**
869
- * 请求更新,切换用户, 使用switchUser
870
- * @param username
871
- * @returns
872
- */
873
- async postSwitchUser(n) {
874
- return this.post({ key: "switchCheck", data: { username: n } });
875
- }
876
- /**
877
- * 切换用户
878
- * @param username
879
- * @returns
880
- */
881
- async switchUser(n) {
882
- const t = (await this.cacheStore.getCurrentUserList()).find((o) => o.user.username === n);
883
- if (t)
884
- return this.storage.setItem("token", t.accessToken || ""), await this.beforeSetLoginUser({ accessToken: t.accessToken, refreshToken: t.refreshToken }), {
885
- code: 200,
886
- data: {
887
- accessToken: t.accessToken,
888
- refreshToken: t.refreshToken
889
- },
890
- success: !0,
891
- message: "切换用户成功"
892
- };
893
- const r = await this.postSwitchUser(n);
894
- if (r.code === 200) {
895
- const { accessToken: o, refreshToken: s } = r?.data || {};
896
- this.storage.setItem("token", o || ""), await this.beforeSetLoginUser({ accessToken: o, refreshToken: s });
897
- }
898
- return r;
899
- }
900
- /**
901
- * 退出登陆,去掉token, 并删除缓存
902
- * @returns
903
- */
904
- async logout() {
905
- this.storage.removeItem("token");
906
- const e = (await this.cacheStore.getCurrentUserList()).map((t) => t?.accessToken).filter(Boolean);
907
- return this.cacheStore.delValue(), this.post({ key: "logout", data: { tokens: e } });
908
- }
909
- /**
910
- * 检查用户名的组,这个用户是否存在
911
- * @param username
912
- * @returns
913
- */
914
- async hasUser(n) {
915
- const e = this;
916
- return this.post(
917
- {
918
- path: "org",
919
- key: "hasUser",
920
- data: {
921
- username: n
922
- }
923
- },
924
- {
925
- afterResponse: async (t, r) => t?.code === 401 ? await e.afterCheck401ToRefreshToken(t, r, !0) : t
926
- }
927
- );
928
- }
929
- /**
930
- * 检查登录状态
931
- * @param token
932
- * @returns
933
- */
934
- async checkLoginStatus(n) {
935
- const e = await this.post({
936
- path: "user",
937
- key: "checkLoginStatus",
938
- loginToken: n
939
- });
940
- if (e.code === 200) {
941
- const t = e.data?.accessToken;
942
- return this.storage.setItem("token", t || ""), await this.beforeSetLoginUser({ accessToken: t, refreshToken: e.data?.refreshToken }), e;
943
- }
944
- return !1;
945
- }
946
- /**
947
- * 使用web登录,创建url地址, 需要MD5和jsonwebtoken
948
- */
949
- loginWithWeb(n, { MD5: e, jsonwebtoken: t }) {
950
- const r = Math.random().toString(36).substring(2, 15), o = Date.now(), s = "xiao" + r, i = e(`${s}${o}`).toString(), c = t.sign({ randomId: r, timestamp: o, sign: i }, s, {
951
- // 10分钟过期
952
- expiresIn: 600
953
- // 10分钟
954
- });
955
- return { url: `${n}/api/router?path=user&key=webLogin&p&loginToken=${c}&sign=${i}&randomId=${r}`, token: c, tokenSecret: s };
956
- }
957
- }, jn = class extends Hn {
958
- constructor(n) {
959
- super({
960
- ...n,
961
- cache: new Fn("login")
962
- });
963
- }
964
- };
965
- const Vn = new Qt(), U = new jn({
966
- query: Vn
967
- });
968
- class On extends HTMLElement {
969
- options;
970
- timer = null;
971
- constructor() {
972
- super(), this.options = {
973
- type: "success",
974
- message: "",
975
- duration: 2e3,
976
- closable: !0
977
- };
978
- }
979
- connectedCallback() {
980
- this.render();
981
- }
982
- setOptions(e) {
983
- this.options = { ...this.options, ...e }, this.render();
984
- }
985
- render() {
986
- const { type: e, message: t, closable: r } = this.options, s = I`
987
- <style>
988
- :host {
989
- display: block;
990
- margin-bottom: 12px;
991
- animation: slideIn 0.3s ease-out;
992
- }
993
-
994
- .message-container {
995
- display: flex;
996
- align-items: center;
997
- gap: 8px;
998
- padding: 12px 16px;
999
- border-radius: 6px;
1000
- box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
1001
- background: white;
1002
- position: relative;
1003
- min-width: 300px;
1004
- max-width: 500px;
1005
- font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
1006
- font-size: 14px;
1007
- line-height: 1.4;
1008
- }
1009
-
1010
- .message-container.success {
1011
- border-left: 4px solid #52c41a;
1012
- }
1013
-
1014
- .message-container.error {
1015
- border-left: 4px solid #ff4d4f;
1016
- }
1017
-
1018
- .message-container.loading {
1019
- border-left: 4px solid #1890ff;
1020
- }
1021
-
1022
- .message-icon {
1023
- display: flex;
1024
- align-items: center;
1025
- justify-content: center;
1026
- width: 16px;
1027
- height: 16px;
1028
- flex-shrink: 0;
1029
- }
1030
-
1031
- .success .message-icon {
1032
- color: #52c41a;
1033
- font-weight: bold;
1034
- }
1035
-
1036
- .error .message-icon {
1037
- color: #ff4d4f;
1038
- font-weight: bold;
1039
- }
1040
-
1041
- .loading .message-icon {
1042
- color: #1890ff;
1043
- }
1044
-
1045
- .loading-spinner {
1046
- width: 14px;
1047
- height: 14px;
1048
- border: 2px solid #f3f3f3;
1049
- border-top: 2px solid #1890ff;
1050
- border-radius: 50%;
1051
- animation: spin 1s linear infinite;
1052
- }
1053
-
1054
- .message-content {
1055
- flex: 1;
1056
- color: #333;
1057
- }
1058
-
1059
- .message-close {
1060
- display: flex;
1061
- align-items: center;
1062
- justify-content: center;
1063
- width: 16px;
1064
- height: 16px;
1065
- cursor: pointer;
1066
- color: #999;
1067
- background: none;
1068
- border: none;
1069
- font-size: 12px;
1070
- border-radius: 50%;
1071
- transition: all 0.2s;
1072
- }
1073
-
1074
- .message-close:hover {
1075
- color: #666;
1076
- background: #f0f0f0;
1077
- }
1078
-
1079
- @keyframes slideIn {
1080
- from {
1081
- transform: translateX(100%);
1082
- opacity: 0;
1083
- }
1084
- to {
1085
- transform: translateX(0);
1086
- opacity: 1;
1087
- }
1088
- }
1089
-
1090
- @keyframes slideOut {
1091
- from {
1092
- transform: translateX(0);
1093
- opacity: 1;
1094
- }
1095
- to {
1096
- transform: translateX(100%);
1097
- opacity: 0;
1098
- }
1099
- }
1100
-
1101
- @keyframes spin {
1102
- 0% { transform: rotate(0deg); }
1103
- 100% { transform: rotate(360deg); }
1104
- }
1105
-
1106
- .removing {
1107
- animation: slideOut 0.3s ease-out forwards;
1108
- }
1109
- </style>
1110
-
1111
- <div class="message-container ${e}">
1112
- <div class="message-icon">
1113
- ${(() => {
1114
- switch (e) {
1115
- case "success":
1116
- return "✓";
1117
- case "error":
1118
- return "✕";
1119
- case "loading":
1120
- return I`<div class="loading-spinner"></div>`;
1121
- default:
1122
- return "";
1123
- }
1124
- })()}
1125
- </div>
1126
- <div class="message-content">${t}</div>
1127
- ${r ? I`
1128
- <button class="message-close" @click=${() => this.remove()}>&times;</button>
1129
- ` : ""}
1130
- </div>
1131
- `;
1132
- Jt(s, this), e !== "loading" && this.options.duration && this.options.duration > 0 && this.setTimer();
1133
- }
1134
- setTimer() {
1135
- this.timer && clearTimeout(this.timer), this.timer = window.setTimeout(() => {
1136
- this.remove();
1137
- }, this.options.duration);
1138
- }
1139
- remove() {
1140
- this.timer && (clearTimeout(this.timer), this.timer = null), this.classList.add("removing"), setTimeout(() => {
1141
- this.parentNode && this.parentNode.removeChild(this);
1142
- }, 300);
1143
- }
1144
- disconnectedCallback() {
1145
- this.timer && (clearTimeout(this.timer), this.timer = null);
1146
- }
1147
- }
1148
- customElements.define("kv-message", On);
1149
- class Y {
1150
- static instance;
1151
- container = null;
1152
- defaultPosition = "center";
1153
- static getInstance() {
1154
- return Y.instance || (Y.instance = new Y()), Y.instance;
1155
- }
1156
- setDefaultPosition(e) {
1157
- this.defaultPosition = e;
1158
- }
1159
- getContainer(e) {
1160
- const t = e || this.defaultPosition;
1161
- return this.container || (this.container = document.getElementById("messages"), this.container || (this.container = document.createElement("div"), this.container.id = "messages", t === "center" ? this.container.style.cssText = `
1162
- position: fixed;
1163
- top: 20px;
1164
- left: 50%;
1165
- transform: translateX(-50%);
1166
- z-index: 9999;
1167
- display: flex;
1168
- gap: 8px;
1169
- flex-direction: column;
1170
- align-items: center;
1171
- pointer-events: none;
1172
- ` : this.container.style.cssText = `
1173
- position: fixed;
1174
- top: 20px;
1175
- right: 20px;
1176
- z-index: 9999;
1177
- display: flex;
1178
- gap: 8px;
1179
- flex-direction: column;
1180
- align-items: flex-end;
1181
- pointer-events: none;
1182
- `, document.body.appendChild(this.container))), this.container;
1183
- }
1184
- show(e) {
1185
- const t = this.getContainer(e.position), r = document.createElement("kv-message");
1186
- return r.setOptions(e), r.style.cssText = "pointer-events: auto;", t.appendChild(r), r;
1187
- }
1188
- success(e, t) {
1189
- return this.show({
1190
- type: "success",
1191
- message: e,
1192
- duration: t?.duration || 2e3,
1193
- position: t?.position,
1194
- closable: t?.closable
1195
- });
1196
- }
1197
- error(e, t) {
1198
- return this.show({
1199
- type: "error",
1200
- message: e,
1201
- duration: t?.duration || 3e3,
1202
- position: t?.position,
1203
- closable: t?.closable
1204
- });
1205
- }
1206
- loading(e, t) {
1207
- return this.show({
1208
- type: "loading",
1209
- message: e,
1210
- duration: 0,
1211
- position: t?.position,
1212
- closable: t?.closable
1213
- });
1214
- }
1215
- remove(e) {
1216
- e.remove();
1217
- }
1218
- clear() {
1219
- this.getContainer().querySelectorAll("kv-message").forEach((r) => {
1220
- r.remove();
1221
- });
1222
- }
1223
- }
1224
- const tn = () => Y.getInstance();
1225
- window.createMessage = tn;
1226
- let Wn = class {
1227
- events = /* @__PURE__ */ new Map();
1228
- /**
1229
- * 监听事件
1230
- * @param type 事件类型
1231
- * @param handler 事件处理函数
1232
- */
1233
- on(e, t) {
1234
- this.events.has(e) || this.events.set(e, /* @__PURE__ */ new Set()), this.events.get(e).add(t);
1235
- }
1236
- /**
1237
- * 移除事件监听器
1238
- * @param type 事件类型
1239
- * @param handler 事件处理函数 (可选,如果不提供则移除该类型的所有监听器)
1240
- */
1241
- off(e, t) {
1242
- this.events.has(e) && (t ? (this.events.get(e).delete(t), this.events.get(e).size === 0 && this.events.delete(e)) : this.events.delete(e));
1243
- }
1244
- /**
1245
- * 触发事件
1246
- * @param event 事件对象,包含 type 和 data
1247
- */
1248
- emit(e) {
1249
- const { type: t } = e;
1250
- if (!this.events.has(t))
1251
- return;
1252
- this.events.get(t).forEach((o) => {
1253
- try {
1254
- o(e);
1255
- } catch (s) {
1256
- console.error(`Error in event handler for type "${t}":`, s);
1257
- }
1258
- });
1259
- }
1260
- /**
1261
- * 触发事件(简化版本,直接传递type和data)
1262
- * @param type 事件类型
1263
- * @param data 事件数据
1264
- */
1265
- emitSimple(e, t) {
1266
- this.emit({ type: e, data: t });
1267
- }
1268
- /**
1269
- * 清空所有事件监听器
1270
- */
1271
- clear() {
1272
- this.events.clear();
1273
- }
1274
- /**
1275
- * 获取指定类型的监听器数量
1276
- * @param type 事件类型
1277
- * @returns 监听器数量
1278
- */
1279
- listenerCount(e) {
1280
- return this.events.get(e)?.size || 0;
1281
- }
1282
- /**
1283
- * 获取所有事件类型
1284
- * @returns 事件类型数组
1285
- */
1286
- eventNames() {
1287
- return Array.from(this.events.keys());
1288
- }
1289
- /**
1290
- * 检查是否有指定类型的监听器
1291
- * @param type 事件类型
1292
- * @returns 是否有监听器
1293
- */
1294
- hasListeners(e) {
1295
- return this.events.has(e) && this.events.get(e).size > 0;
1296
- }
1297
- /**
1298
- * 只监听一次事件
1299
- * @param type 事件类型
1300
- * @param handler 事件处理函数
1301
- */
1302
- once(e, t) {
1303
- const r = (o) => {
1304
- t(o), this.off(e, r);
1305
- };
1306
- this.on(e, r);
1307
- }
1308
- };
1309
- const nn = new Wn(), Kn = (n) => nn.emit(n), F = tn(), ie = () => {
1310
- const n = window.location.href, t = new URL(n).searchParams.get("redirect");
1311
- if (t) {
1312
- const r = decodeURIComponent(t);
1313
- window.open(r, "_self");
1314
- }
1315
- Kn({ type: "login-success", data: {} });
1316
- }, Jn = async (n) => {
1317
- const { loginMethod: e, data: t } = n;
1318
- switch (e) {
1319
- case "password":
1320
- await Qn(t);
1321
- break;
1322
- case "phone":
1323
- await Gn(t);
1324
- break;
1325
- case "wechat-mp":
1326
- await Xn(t);
1327
- break;
1328
- case "wechat":
1329
- await Yn(t);
1330
- break;
1331
- default:
1332
- console.warn("未知的登录方式:", e);
1333
- }
1334
- }, Qn = async (n) => {
1335
- console.log("使用用户名密码登录:", n);
1336
- let e = !0;
1337
- if (await U.checkLocalToken() && (await U.checkLocalUser())?.username === n?.username && (await U.getMe()).code === 200 && (e = !1, console.log("已登录,跳过登录步骤"), F.success("已登录")), !e) {
1338
- ie();
1339
- return;
1340
- }
1341
- const r = await U.login({
1342
- username: n.username,
1343
- password: n.password
1344
- });
1345
- r.code === 200 ? (console.log("登录成功"), F.success("登录成功"), ie()) : F.error(`登录失败: ${r.message}`);
1346
- }, Gn = async (n) => {
1347
- console.log("使用手机号登录:", n);
1348
- }, Yn = async (n) => {
1349
- console.log("使用微信登录:", n);
1350
- }, Xn = async (n) => {
1351
- console.log("使用微信公众号登录:", n);
1352
- }, Zn = () => {
1353
- const n = new URL(window.location.href);
1354
- n.searchParams.delete("code"), n.searchParams.delete("state"), window.history.replaceState({}, document.title, n.toString());
1355
- }, er = async () => {
1356
- const n = new URL(window.location.href), e = n.searchParams.get("code");
1357
- if (n.searchParams.get("state")?.includes?.("-") || !e)
1358
- return;
1359
- const r = await U.loginByWechat({ code: e });
1360
- r.code === 200 ? (F.success("登录成功"), ie()) : (F.error(r.message || "登录失败"), Zn());
1361
- }, tr = async () => {
1362
- const n = new URL(window.location.href), e = n.searchParams.get("state"), [t, r] = e ? e.split("-") : [null, null];
1363
- if (console.log("检查微信公众号登录流程:", t, r, e), t === "1")
1364
- rr();
1365
- else if (t === "2") {
1366
- const o = n.searchParams.get("code"), s = await U.post({
1367
- path: "wx",
1368
- key: "mplogin",
1369
- state: r,
1370
- code: o
1371
- });
1372
- s.code === 200 ? F.success("登录成功") : F.error(s.message || "登录失败"), rn();
1373
- }
1374
- }, nr = () => {
1375
- const n = navigator.userAgent.toLowerCase();
1376
- return /micromessenger/i.test(n);
1377
- }, rn = (n = 2e3) => {
1378
- if (!nr()) {
1379
- setTimeout(() => {
1380
- window.close();
1381
- }, n);
1382
- return;
1383
- }
1384
- window.WeixinJSBridge ? setTimeout(() => {
1385
- window.WeixinJSBridge.call("closeWindow");
1386
- }, n) : setTimeout(() => {
1387
- window.close();
1388
- }, n);
1389
- }, rr = async () => {
1390
- const n = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=APPID&redirect_uri=REDIRECT_URI&response_type=code&scope=SCOPE&state=STATE#wechat_redirect", e = dn, t = new URL(window.location.href), r = t.searchParams.get("state");
1391
- let [o, s] = r ? r.split("-") : [null, null];
1392
- const i = new URL(t.pathname, t.origin);
1393
- s = "2-" + s;
1394
- const c = encodeURIComponent(i.toString());
1395
- document.body.innerHTML = "<p>正在准备跳转到微信公众号授权页面...</p>";
1396
- const a = "snsapi_userinfo";
1397
- if (!s) {
1398
- alert("Invalid state. Please try again later."), rn();
1399
- return;
1400
- }
1401
- const l = n.replace("APPID", e).replace("REDIRECT_URI", c).replace("SCOPE", a).replace("STATE", s);
1402
- setTimeout(() => {
1403
- window.location.href = l;
1404
- }, 100);
1405
- };
1406
- setTimeout(() => {
1407
- tr();
1408
- }, 100);
1409
- const or = async () => {
1410
- const n = await U.post({
1411
- path: "wx",
1412
- key: "get-qrcode-ticket"
1413
- });
1414
- return n.code !== 200 ? (F.error("获取二维码失败"), null) : n?.data;
1415
- }, sr = (n) => {
1416
- let e = !0;
1417
- const t = async () => {
1418
- const s = await U.post({
1419
- path: "wx",
1420
- key: "check-qrcode-login",
1421
- payload: { ticket: n }
1422
- });
1423
- s.code === 200 ? (F.success("登录成功"), clearTimeout(r), ie()) : (s.code === 401 ? console.log("等待扫码登录...") : console.log("扫码登录状态:", s), e && setTimeout(t, 2e3));
1424
- }, r = setTimeout(t, 2e3);
1425
- return () => {
1426
- console.log("停止检测扫码登录状态"), clearTimeout(r), e = !1;
1427
- };
1428
- }, ht = async (n) => {
1429
- let e = n?.redirect_uri;
1430
- const { appid: t } = n || {};
1431
- e || (e = window.location.href);
1432
- const r = new URL(e);
1433
- if (r.searchParams.delete("code"), r.searchParams.delete("state"), e = r.toString(), console.log("redirect_uri", e), !t) {
1434
- console.error("appid is not cant be empty");
1435
- return;
1436
- }
1437
- const o = new WxLogin({
1438
- self_redirect: !1,
1439
- id: "weixinLogin",
1440
- // 需要显示的容器id
1441
- appid: t,
1442
- // 微信开放平台appid wx*******
1443
- scope: "snsapi_login",
1444
- // 网页默认即可 snsapi_userinfo
1445
- redirect_uri: encodeURIComponent(e),
1446
- // 授权成功后回调的url
1447
- state: Math.ceil(Math.random() * 1e3),
1448
- // 可设置为简单的随机数加session用来校验
1449
- stylelite: !0,
1450
- // 是否使用简洁模式
1451
- // https://juejin.cn/post/6982473580063752223
1452
- href: "data:text/css;base64,LmltcG93ZXJCb3ggLnFyY29kZSB7d2lkdGg6IDIwMHB4O30NCi5pbXBvd2VyQm94IC50aXRsZSB7ZGlzcGxheTogbm9uZTt9DQouaW1wb3dlckJveCAuaW5mbyB7d2lkdGg6IDIwMHB4O30NCi5zdGF0dXNfaWNvbiB7ZGlzcGxheTogbm9uZX0NCi5pbXBvd2VyQm94IC5zdGF0dXMge3RleHQtYWxpZ246IGNlbnRlcjt9"
1453
- }), s = document.querySelector("#weixinLogin");
1454
- if (s) {
1455
- const i = s.querySelector("iframe");
1456
- i && (i.style.height = "300px");
1457
- }
1458
- return o;
1459
- };
1460
- function ir(n) {
1461
- const e = document.createElement("script");
1462
- if (e.type = "text/javascript", e.src = "//res.wx.qq.com/connect/zh_CN/htmledition/js/wxLogin.js", e.id = "weixinLogin-js", document.getElementById("weixinLogin-js")) {
1463
- ht(n);
1464
- return;
1465
- }
1466
- const t = document.body.appendChild(e);
1467
- t.onload = function() {
1468
- ht(n);
1469
- };
1470
- }
1471
- function ar(n) {
1472
- return n && n.__esModule && Object.prototype.hasOwnProperty.call(n, "default") ? n.default : n;
1473
- }
1474
- var G = {}, Ae, dt;
1475
- function cr() {
1476
- return dt || (dt = 1, Ae = function() {
1477
- return typeof Promise == "function" && Promise.prototype && Promise.prototype.then;
1478
- }), Ae;
1479
- }
1480
- var Te = {}, H = {}, ft;
1481
- function K() {
1482
- if (ft) return H;
1483
- ft = 1;
1484
- let n;
1485
- const e = [
1486
- 0,
1487
- // Not used
1488
- 26,
1489
- 44,
1490
- 70,
1491
- 100,
1492
- 134,
1493
- 172,
1494
- 196,
1495
- 242,
1496
- 292,
1497
- 346,
1498
- 404,
1499
- 466,
1500
- 532,
1501
- 581,
1502
- 655,
1503
- 733,
1504
- 815,
1505
- 901,
1506
- 991,
1507
- 1085,
1508
- 1156,
1509
- 1258,
1510
- 1364,
1511
- 1474,
1512
- 1588,
1513
- 1706,
1514
- 1828,
1515
- 1921,
1516
- 2051,
1517
- 2185,
1518
- 2323,
1519
- 2465,
1520
- 2611,
1521
- 2761,
1522
- 2876,
1523
- 3034,
1524
- 3196,
1525
- 3362,
1526
- 3532,
1527
- 3706
1528
- ];
1529
- return H.getSymbolSize = function(r) {
1530
- if (!r) throw new Error('"version" cannot be null or undefined');
1531
- if (r < 1 || r > 40) throw new Error('"version" should be in range from 1 to 40');
1532
- return r * 4 + 17;
1533
- }, H.getSymbolTotalCodewords = function(r) {
1534
- return e[r];
1535
- }, H.getBCHDigit = function(t) {
1536
- let r = 0;
1537
- for (; t !== 0; )
1538
- r++, t >>>= 1;
1539
- return r;
1540
- }, H.setToSJISFunction = function(r) {
1541
- if (typeof r != "function")
1542
- throw new Error('"toSJISFunc" is not a valid function.');
1543
- n = r;
1544
- }, H.isKanjiModeEnabled = function() {
1545
- return typeof n < "u";
1546
- }, H.toSJIS = function(r) {
1547
- return n(r);
1548
- }, H;
1549
- }
1550
- var Ee = {}, gt;
1551
- function Ye() {
1552
- return gt || (gt = 1, (function(n) {
1553
- n.L = { bit: 1 }, n.M = { bit: 0 }, n.Q = { bit: 3 }, n.H = { bit: 2 };
1554
- function e(t) {
1555
- if (typeof t != "string")
1556
- throw new Error("Param is not a string");
1557
- switch (t.toLowerCase()) {
1558
- case "l":
1559
- case "low":
1560
- return n.L;
1561
- case "m":
1562
- case "medium":
1563
- return n.M;
1564
- case "q":
1565
- case "quartile":
1566
- return n.Q;
1567
- case "h":
1568
- case "high":
1569
- return n.H;
1570
- default:
1571
- throw new Error("Unknown EC Level: " + t);
1572
- }
1573
- }
1574
- n.isValid = function(r) {
1575
- return r && typeof r.bit < "u" && r.bit >= 0 && r.bit < 4;
1576
- }, n.from = function(r, o) {
1577
- if (n.isValid(r))
1578
- return r;
1579
- try {
1580
- return e(r);
1581
- } catch {
1582
- return o;
1583
- }
1584
- };
1585
- })(Ee)), Ee;
1586
- }
1587
- var _e, mt;
1588
- function lr() {
1589
- if (mt) return _e;
1590
- mt = 1;
1591
- function n() {
1592
- this.buffer = [], this.length = 0;
1593
- }
1594
- return n.prototype = {
1595
- get: function(e) {
1596
- const t = Math.floor(e / 8);
1597
- return (this.buffer[t] >>> 7 - e % 8 & 1) === 1;
1598
- },
1599
- put: function(e, t) {
1600
- for (let r = 0; r < t; r++)
1601
- this.putBit((e >>> t - r - 1 & 1) === 1);
1602
- },
1603
- getLengthInBits: function() {
1604
- return this.length;
1605
- },
1606
- putBit: function(e) {
1607
- const t = Math.floor(this.length / 8);
1608
- this.buffer.length <= t && this.buffer.push(0), e && (this.buffer[t] |= 128 >>> this.length % 8), this.length++;
1609
- }
1610
- }, _e = n, _e;
1611
- }
1612
- var ke, pt;
1613
- function ur() {
1614
- if (pt) return ke;
1615
- pt = 1;
1616
- function n(e) {
1617
- if (!e || e < 1)
1618
- throw new Error("BitMatrix size must be defined and greater than 0");
1619
- this.size = e, this.data = new Uint8Array(e * e), this.reservedBit = new Uint8Array(e * e);
1620
- }
1621
- return n.prototype.set = function(e, t, r, o) {
1622
- const s = e * this.size + t;
1623
- this.data[s] = r, o && (this.reservedBit[s] = !0);
1624
- }, n.prototype.get = function(e, t) {
1625
- return this.data[e * this.size + t];
1626
- }, n.prototype.xor = function(e, t, r) {
1627
- this.data[e * this.size + t] ^= r;
1628
- }, n.prototype.isReserved = function(e, t) {
1629
- return this.reservedBit[e * this.size + t];
1630
- }, ke = n, ke;
1631
- }
1632
- var xe = {}, wt;
1633
- function hr() {
1634
- return wt || (wt = 1, (function(n) {
1635
- const e = K().getSymbolSize;
1636
- n.getRowColCoords = function(r) {
1637
- if (r === 1) return [];
1638
- const o = Math.floor(r / 7) + 2, s = e(r), i = s === 145 ? 26 : Math.ceil((s - 13) / (2 * o - 2)) * 2, c = [s - 7];
1639
- for (let a = 1; a < o - 1; a++)
1640
- c[a] = c[a - 1] - i;
1641
- return c.push(6), c.reverse();
1642
- }, n.getPositions = function(r) {
1643
- const o = [], s = n.getRowColCoords(r), i = s.length;
1644
- for (let c = 0; c < i; c++)
1645
- for (let a = 0; a < i; a++)
1646
- c === 0 && a === 0 || // top-left
1647
- c === 0 && a === i - 1 || // bottom-left
1648
- c === i - 1 && a === 0 || o.push([s[c], s[a]]);
1649
- return o;
1650
- };
1651
- })(xe)), xe;
1652
- }
1653
- var Re = {}, yt;
1654
- function dr() {
1655
- if (yt) return Re;
1656
- yt = 1;
1657
- const n = K().getSymbolSize, e = 7;
1658
- return Re.getPositions = function(r) {
1659
- const o = n(r);
1660
- return [
1661
- // top-left
1662
- [0, 0],
1663
- // top-right
1664
- [o - e, 0],
1665
- // bottom-left
1666
- [0, o - e]
1667
- ];
1668
- }, Re;
1669
- }
1670
- var Se = {}, vt;
1671
- function fr() {
1672
- return vt || (vt = 1, (function(n) {
1673
- n.Patterns = {
1674
- PATTERN000: 0,
1675
- PATTERN001: 1,
1676
- PATTERN010: 2,
1677
- PATTERN011: 3,
1678
- PATTERN100: 4,
1679
- PATTERN101: 5,
1680
- PATTERN110: 6,
1681
- PATTERN111: 7
1682
- };
1683
- const e = {
1684
- N1: 3,
1685
- N2: 3,
1686
- N3: 40,
1687
- N4: 10
1688
- };
1689
- n.isValid = function(o) {
1690
- return o != null && o !== "" && !isNaN(o) && o >= 0 && o <= 7;
1691
- }, n.from = function(o) {
1692
- return n.isValid(o) ? parseInt(o, 10) : void 0;
1693
- }, n.getPenaltyN1 = function(o) {
1694
- const s = o.size;
1695
- let i = 0, c = 0, a = 0, l = null, u = null;
1696
- for (let h = 0; h < s; h++) {
1697
- c = a = 0, l = u = null;
1698
- for (let f = 0; f < s; f++) {
1699
- let d = o.get(h, f);
1700
- d === l ? c++ : (c >= 5 && (i += e.N1 + (c - 5)), l = d, c = 1), d = o.get(f, h), d === u ? a++ : (a >= 5 && (i += e.N1 + (a - 5)), u = d, a = 1);
1701
- }
1702
- c >= 5 && (i += e.N1 + (c - 5)), a >= 5 && (i += e.N1 + (a - 5));
1703
- }
1704
- return i;
1705
- }, n.getPenaltyN2 = function(o) {
1706
- const s = o.size;
1707
- let i = 0;
1708
- for (let c = 0; c < s - 1; c++)
1709
- for (let a = 0; a < s - 1; a++) {
1710
- const l = o.get(c, a) + o.get(c, a + 1) + o.get(c + 1, a) + o.get(c + 1, a + 1);
1711
- (l === 4 || l === 0) && i++;
1712
- }
1713
- return i * e.N2;
1714
- }, n.getPenaltyN3 = function(o) {
1715
- const s = o.size;
1716
- let i = 0, c = 0, a = 0;
1717
- for (let l = 0; l < s; l++) {
1718
- c = a = 0;
1719
- for (let u = 0; u < s; u++)
1720
- c = c << 1 & 2047 | o.get(l, u), u >= 10 && (c === 1488 || c === 93) && i++, a = a << 1 & 2047 | o.get(u, l), u >= 10 && (a === 1488 || a === 93) && i++;
1721
- }
1722
- return i * e.N3;
1723
- }, n.getPenaltyN4 = function(o) {
1724
- let s = 0;
1725
- const i = o.data.length;
1726
- for (let a = 0; a < i; a++) s += o.data[a];
1727
- return Math.abs(Math.ceil(s * 100 / i / 5) - 10) * e.N4;
1728
- };
1729
- function t(r, o, s) {
1730
- switch (r) {
1731
- case n.Patterns.PATTERN000:
1732
- return (o + s) % 2 === 0;
1733
- case n.Patterns.PATTERN001:
1734
- return o % 2 === 0;
1735
- case n.Patterns.PATTERN010:
1736
- return s % 3 === 0;
1737
- case n.Patterns.PATTERN011:
1738
- return (o + s) % 3 === 0;
1739
- case n.Patterns.PATTERN100:
1740
- return (Math.floor(o / 2) + Math.floor(s / 3)) % 2 === 0;
1741
- case n.Patterns.PATTERN101:
1742
- return o * s % 2 + o * s % 3 === 0;
1743
- case n.Patterns.PATTERN110:
1744
- return (o * s % 2 + o * s % 3) % 2 === 0;
1745
- case n.Patterns.PATTERN111:
1746
- return (o * s % 3 + (o + s) % 2) % 2 === 0;
1747
- default:
1748
- throw new Error("bad maskPattern:" + r);
1749
- }
1750
- }
1751
- n.applyMask = function(o, s) {
1752
- const i = s.size;
1753
- for (let c = 0; c < i; c++)
1754
- for (let a = 0; a < i; a++)
1755
- s.isReserved(a, c) || s.xor(a, c, t(o, a, c));
1756
- }, n.getBestMask = function(o, s) {
1757
- const i = Object.keys(n.Patterns).length;
1758
- let c = 0, a = 1 / 0;
1759
- for (let l = 0; l < i; l++) {
1760
- s(l), n.applyMask(l, o);
1761
- const u = n.getPenaltyN1(o) + n.getPenaltyN2(o) + n.getPenaltyN3(o) + n.getPenaltyN4(o);
1762
- n.applyMask(l, o), u < a && (a = u, c = l);
1763
- }
1764
- return c;
1765
- };
1766
- })(Se)), Se;
1767
- }
1768
- var le = {}, bt;
1769
- function on() {
1770
- if (bt) return le;
1771
- bt = 1;
1772
- const n = Ye(), e = [
1773
- // L M Q H
1774
- 1,
1775
- 1,
1776
- 1,
1777
- 1,
1778
- 1,
1779
- 1,
1780
- 1,
1781
- 1,
1782
- 1,
1783
- 1,
1784
- 2,
1785
- 2,
1786
- 1,
1787
- 2,
1788
- 2,
1789
- 4,
1790
- 1,
1791
- 2,
1792
- 4,
1793
- 4,
1794
- 2,
1795
- 4,
1796
- 4,
1797
- 4,
1798
- 2,
1799
- 4,
1800
- 6,
1801
- 5,
1802
- 2,
1803
- 4,
1804
- 6,
1805
- 6,
1806
- 2,
1807
- 5,
1808
- 8,
1809
- 8,
1810
- 4,
1811
- 5,
1812
- 8,
1813
- 8,
1814
- 4,
1815
- 5,
1816
- 8,
1817
- 11,
1818
- 4,
1819
- 8,
1820
- 10,
1821
- 11,
1822
- 4,
1823
- 9,
1824
- 12,
1825
- 16,
1826
- 4,
1827
- 9,
1828
- 16,
1829
- 16,
1830
- 6,
1831
- 10,
1832
- 12,
1833
- 18,
1834
- 6,
1835
- 10,
1836
- 17,
1837
- 16,
1838
- 6,
1839
- 11,
1840
- 16,
1841
- 19,
1842
- 6,
1843
- 13,
1844
- 18,
1845
- 21,
1846
- 7,
1847
- 14,
1848
- 21,
1849
- 25,
1850
- 8,
1851
- 16,
1852
- 20,
1853
- 25,
1854
- 8,
1855
- 17,
1856
- 23,
1857
- 25,
1858
- 9,
1859
- 17,
1860
- 23,
1861
- 34,
1862
- 9,
1863
- 18,
1864
- 25,
1865
- 30,
1866
- 10,
1867
- 20,
1868
- 27,
1869
- 32,
1870
- 12,
1871
- 21,
1872
- 29,
1873
- 35,
1874
- 12,
1875
- 23,
1876
- 34,
1877
- 37,
1878
- 12,
1879
- 25,
1880
- 34,
1881
- 40,
1882
- 13,
1883
- 26,
1884
- 35,
1885
- 42,
1886
- 14,
1887
- 28,
1888
- 38,
1889
- 45,
1890
- 15,
1891
- 29,
1892
- 40,
1893
- 48,
1894
- 16,
1895
- 31,
1896
- 43,
1897
- 51,
1898
- 17,
1899
- 33,
1900
- 45,
1901
- 54,
1902
- 18,
1903
- 35,
1904
- 48,
1905
- 57,
1906
- 19,
1907
- 37,
1908
- 51,
1909
- 60,
1910
- 19,
1911
- 38,
1912
- 53,
1913
- 63,
1914
- 20,
1915
- 40,
1916
- 56,
1917
- 66,
1918
- 21,
1919
- 43,
1920
- 59,
1921
- 70,
1922
- 22,
1923
- 45,
1924
- 62,
1925
- 74,
1926
- 24,
1927
- 47,
1928
- 65,
1929
- 77,
1930
- 25,
1931
- 49,
1932
- 68,
1933
- 81
1934
- ], t = [
1935
- // L M Q H
1936
- 7,
1937
- 10,
1938
- 13,
1939
- 17,
1940
- 10,
1941
- 16,
1942
- 22,
1943
- 28,
1944
- 15,
1945
- 26,
1946
- 36,
1947
- 44,
1948
- 20,
1949
- 36,
1950
- 52,
1951
- 64,
1952
- 26,
1953
- 48,
1954
- 72,
1955
- 88,
1956
- 36,
1957
- 64,
1958
- 96,
1959
- 112,
1960
- 40,
1961
- 72,
1962
- 108,
1963
- 130,
1964
- 48,
1965
- 88,
1966
- 132,
1967
- 156,
1968
- 60,
1969
- 110,
1970
- 160,
1971
- 192,
1972
- 72,
1973
- 130,
1974
- 192,
1975
- 224,
1976
- 80,
1977
- 150,
1978
- 224,
1979
- 264,
1980
- 96,
1981
- 176,
1982
- 260,
1983
- 308,
1984
- 104,
1985
- 198,
1986
- 288,
1987
- 352,
1988
- 120,
1989
- 216,
1990
- 320,
1991
- 384,
1992
- 132,
1993
- 240,
1994
- 360,
1995
- 432,
1996
- 144,
1997
- 280,
1998
- 408,
1999
- 480,
2000
- 168,
2001
- 308,
2002
- 448,
2003
- 532,
2004
- 180,
2005
- 338,
2006
- 504,
2007
- 588,
2008
- 196,
2009
- 364,
2010
- 546,
2011
- 650,
2012
- 224,
2013
- 416,
2014
- 600,
2015
- 700,
2016
- 224,
2017
- 442,
2018
- 644,
2019
- 750,
2020
- 252,
2021
- 476,
2022
- 690,
2023
- 816,
2024
- 270,
2025
- 504,
2026
- 750,
2027
- 900,
2028
- 300,
2029
- 560,
2030
- 810,
2031
- 960,
2032
- 312,
2033
- 588,
2034
- 870,
2035
- 1050,
2036
- 336,
2037
- 644,
2038
- 952,
2039
- 1110,
2040
- 360,
2041
- 700,
2042
- 1020,
2043
- 1200,
2044
- 390,
2045
- 728,
2046
- 1050,
2047
- 1260,
2048
- 420,
2049
- 784,
2050
- 1140,
2051
- 1350,
2052
- 450,
2053
- 812,
2054
- 1200,
2055
- 1440,
2056
- 480,
2057
- 868,
2058
- 1290,
2059
- 1530,
2060
- 510,
2061
- 924,
2062
- 1350,
2063
- 1620,
2064
- 540,
2065
- 980,
2066
- 1440,
2067
- 1710,
2068
- 570,
2069
- 1036,
2070
- 1530,
2071
- 1800,
2072
- 570,
2073
- 1064,
2074
- 1590,
2075
- 1890,
2076
- 600,
2077
- 1120,
2078
- 1680,
2079
- 1980,
2080
- 630,
2081
- 1204,
2082
- 1770,
2083
- 2100,
2084
- 660,
2085
- 1260,
2086
- 1860,
2087
- 2220,
2088
- 720,
2089
- 1316,
2090
- 1950,
2091
- 2310,
2092
- 750,
2093
- 1372,
2094
- 2040,
2095
- 2430
2096
- ];
2097
- return le.getBlocksCount = function(o, s) {
2098
- switch (s) {
2099
- case n.L:
2100
- return e[(o - 1) * 4 + 0];
2101
- case n.M:
2102
- return e[(o - 1) * 4 + 1];
2103
- case n.Q:
2104
- return e[(o - 1) * 4 + 2];
2105
- case n.H:
2106
- return e[(o - 1) * 4 + 3];
2107
- default:
2108
- return;
2109
- }
2110
- }, le.getTotalCodewordsCount = function(o, s) {
2111
- switch (s) {
2112
- case n.L:
2113
- return t[(o - 1) * 4 + 0];
2114
- case n.M:
2115
- return t[(o - 1) * 4 + 1];
2116
- case n.Q:
2117
- return t[(o - 1) * 4 + 2];
2118
- case n.H:
2119
- return t[(o - 1) * 4 + 3];
2120
- default:
2121
- return;
2122
- }
2123
- }, le;
2124
- }
2125
- var Me = {}, ne = {}, Ct;
2126
- function gr() {
2127
- if (Ct) return ne;
2128
- Ct = 1;
2129
- const n = new Uint8Array(512), e = new Uint8Array(256);
2130
- return (function() {
2131
- let r = 1;
2132
- for (let o = 0; o < 255; o++)
2133
- n[o] = r, e[r] = o, r <<= 1, r & 256 && (r ^= 285);
2134
- for (let o = 255; o < 512; o++)
2135
- n[o] = n[o - 255];
2136
- })(), ne.log = function(r) {
2137
- if (r < 1) throw new Error("log(" + r + ")");
2138
- return e[r];
2139
- }, ne.exp = function(r) {
2140
- return n[r];
2141
- }, ne.mul = function(r, o) {
2142
- return r === 0 || o === 0 ? 0 : n[e[r] + e[o]];
2143
- }, ne;
2144
- }
2145
- var At;
2146
- function mr() {
2147
- return At || (At = 1, (function(n) {
2148
- const e = gr();
2149
- n.mul = function(r, o) {
2150
- const s = new Uint8Array(r.length + o.length - 1);
2151
- for (let i = 0; i < r.length; i++)
2152
- for (let c = 0; c < o.length; c++)
2153
- s[i + c] ^= e.mul(r[i], o[c]);
2154
- return s;
2155
- }, n.mod = function(r, o) {
2156
- let s = new Uint8Array(r);
2157
- for (; s.length - o.length >= 0; ) {
2158
- const i = s[0];
2159
- for (let a = 0; a < o.length; a++)
2160
- s[a] ^= e.mul(o[a], i);
2161
- let c = 0;
2162
- for (; c < s.length && s[c] === 0; ) c++;
2163
- s = s.slice(c);
2164
- }
2165
- return s;
2166
- }, n.generateECPolynomial = function(r) {
2167
- let o = new Uint8Array([1]);
2168
- for (let s = 0; s < r; s++)
2169
- o = n.mul(o, new Uint8Array([1, e.exp(s)]));
2170
- return o;
2171
- };
2172
- })(Me)), Me;
2173
- }
2174
- var Be, Tt;
2175
- function pr() {
2176
- if (Tt) return Be;
2177
- Tt = 1;
2178
- const n = mr();
2179
- function e(t) {
2180
- this.genPoly = void 0, this.degree = t, this.degree && this.initialize(this.degree);
2181
- }
2182
- return e.prototype.initialize = function(r) {
2183
- this.degree = r, this.genPoly = n.generateECPolynomial(this.degree);
2184
- }, e.prototype.encode = function(r) {
2185
- if (!this.genPoly)
2186
- throw new Error("Encoder not initialized");
2187
- const o = new Uint8Array(r.length + this.degree);
2188
- o.set(r);
2189
- const s = n.mod(o, this.genPoly), i = this.degree - s.length;
2190
- if (i > 0) {
2191
- const c = new Uint8Array(this.degree);
2192
- return c.set(s, i), c;
2193
- }
2194
- return s;
2195
- }, Be = e, Be;
2196
- }
2197
- var Le = {}, Ie = {}, $e = {}, Et;
2198
- function sn() {
2199
- return Et || (Et = 1, $e.isValid = function(e) {
2200
- return !isNaN(e) && e >= 1 && e <= 40;
2201
- }), $e;
2202
- }
2203
- var P = {}, _t;
2204
- function an() {
2205
- if (_t) return P;
2206
- _t = 1;
2207
- const n = "[0-9]+", e = "[A-Z $%*+\\-./:]+";
2208
- let t = "(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";
2209
- t = t.replace(/u/g, "\\u");
2210
- const r = "(?:(?![A-Z0-9 $%*+\\-./:]|" + t + `)(?:.|[\r
2211
- ]))+`;
2212
- P.KANJI = new RegExp(t, "g"), P.BYTE_KANJI = new RegExp("[^A-Z0-9 $%*+\\-./:]+", "g"), P.BYTE = new RegExp(r, "g"), P.NUMERIC = new RegExp(n, "g"), P.ALPHANUMERIC = new RegExp(e, "g");
2213
- const o = new RegExp("^" + t + "$"), s = new RegExp("^" + n + "$"), i = new RegExp("^[A-Z0-9 $%*+\\-./:]+$");
2214
- return P.testKanji = function(a) {
2215
- return o.test(a);
2216
- }, P.testNumeric = function(a) {
2217
- return s.test(a);
2218
- }, P.testAlphanumeric = function(a) {
2219
- return i.test(a);
2220
- }, P;
2221
- }
2222
- var kt;
2223
- function J() {
2224
- return kt || (kt = 1, (function(n) {
2225
- const e = sn(), t = an();
2226
- n.NUMERIC = {
2227
- id: "Numeric",
2228
- bit: 1,
2229
- ccBits: [10, 12, 14]
2230
- }, n.ALPHANUMERIC = {
2231
- id: "Alphanumeric",
2232
- bit: 2,
2233
- ccBits: [9, 11, 13]
2234
- }, n.BYTE = {
2235
- id: "Byte",
2236
- bit: 4,
2237
- ccBits: [8, 16, 16]
2238
- }, n.KANJI = {
2239
- id: "Kanji",
2240
- bit: 8,
2241
- ccBits: [8, 10, 12]
2242
- }, n.MIXED = {
2243
- bit: -1
2244
- }, n.getCharCountIndicator = function(s, i) {
2245
- if (!s.ccBits) throw new Error("Invalid mode: " + s);
2246
- if (!e.isValid(i))
2247
- throw new Error("Invalid version: " + i);
2248
- return i >= 1 && i < 10 ? s.ccBits[0] : i < 27 ? s.ccBits[1] : s.ccBits[2];
2249
- }, n.getBestModeForData = function(s) {
2250
- return t.testNumeric(s) ? n.NUMERIC : t.testAlphanumeric(s) ? n.ALPHANUMERIC : t.testKanji(s) ? n.KANJI : n.BYTE;
2251
- }, n.toString = function(s) {
2252
- if (s && s.id) return s.id;
2253
- throw new Error("Invalid mode");
2254
- }, n.isValid = function(s) {
2255
- return s && s.bit && s.ccBits;
2256
- };
2257
- function r(o) {
2258
- if (typeof o != "string")
2259
- throw new Error("Param is not a string");
2260
- switch (o.toLowerCase()) {
2261
- case "numeric":
2262
- return n.NUMERIC;
2263
- case "alphanumeric":
2264
- return n.ALPHANUMERIC;
2265
- case "kanji":
2266
- return n.KANJI;
2267
- case "byte":
2268
- return n.BYTE;
2269
- default:
2270
- throw new Error("Unknown mode: " + o);
2271
- }
2272
- }
2273
- n.from = function(s, i) {
2274
- if (n.isValid(s))
2275
- return s;
2276
- try {
2277
- return r(s);
2278
- } catch {
2279
- return i;
2280
- }
2281
- };
2282
- })(Ie)), Ie;
2283
- }
2284
- var xt;
2285
- function wr() {
2286
- return xt || (xt = 1, (function(n) {
2287
- const e = K(), t = on(), r = Ye(), o = J(), s = sn(), i = 7973, c = e.getBCHDigit(i);
2288
- function a(f, d, g) {
2289
- for (let p = 1; p <= 40; p++)
2290
- if (d <= n.getCapacity(p, g, f))
2291
- return p;
2292
- }
2293
- function l(f, d) {
2294
- return o.getCharCountIndicator(f, d) + 4;
2295
- }
2296
- function u(f, d) {
2297
- let g = 0;
2298
- return f.forEach(function(p) {
2299
- const m = l(p.mode, d);
2300
- g += m + p.getBitsLength();
2301
- }), g;
2302
- }
2303
- function h(f, d) {
2304
- for (let g = 1; g <= 40; g++)
2305
- if (u(f, g) <= n.getCapacity(g, d, o.MIXED))
2306
- return g;
2307
- }
2308
- n.from = function(d, g) {
2309
- return s.isValid(d) ? parseInt(d, 10) : g;
2310
- }, n.getCapacity = function(d, g, p) {
2311
- if (!s.isValid(d))
2312
- throw new Error("Invalid QR Code version");
2313
- typeof p > "u" && (p = o.BYTE);
2314
- const m = e.getSymbolTotalCodewords(d), y = t.getTotalCodewordsCount(d, g), E = (m - y) * 8;
2315
- if (p === o.MIXED) return E;
2316
- const w = E - l(p, d);
2317
- switch (p) {
2318
- case o.NUMERIC:
2319
- return Math.floor(w / 10 * 3);
2320
- case o.ALPHANUMERIC:
2321
- return Math.floor(w / 11 * 2);
2322
- case o.KANJI:
2323
- return Math.floor(w / 13);
2324
- case o.BYTE:
2325
- default:
2326
- return Math.floor(w / 8);
2327
- }
2328
- }, n.getBestVersionForData = function(d, g) {
2329
- let p;
2330
- const m = r.from(g, r.M);
2331
- if (Array.isArray(d)) {
2332
- if (d.length > 1)
2333
- return h(d, m);
2334
- if (d.length === 0)
2335
- return 1;
2336
- p = d[0];
2337
- } else
2338
- p = d;
2339
- return a(p.mode, p.getLength(), m);
2340
- }, n.getEncodedBits = function(d) {
2341
- if (!s.isValid(d) || d < 7)
2342
- throw new Error("Invalid QR Code version");
2343
- let g = d << 12;
2344
- for (; e.getBCHDigit(g) - c >= 0; )
2345
- g ^= i << e.getBCHDigit(g) - c;
2346
- return d << 12 | g;
2347
- };
2348
- })(Le)), Le;
2349
- }
2350
- var Pe = {}, Rt;
2351
- function yr() {
2352
- if (Rt) return Pe;
2353
- Rt = 1;
2354
- const n = K(), e = 1335, t = 21522, r = n.getBCHDigit(e);
2355
- return Pe.getEncodedBits = function(s, i) {
2356
- const c = s.bit << 3 | i;
2357
- let a = c << 10;
2358
- for (; n.getBCHDigit(a) - r >= 0; )
2359
- a ^= e << n.getBCHDigit(a) - r;
2360
- return (c << 10 | a) ^ t;
2361
- }, Pe;
2362
- }
2363
- var qe = {}, Ne, St;
2364
- function vr() {
2365
- if (St) return Ne;
2366
- St = 1;
2367
- const n = J();
2368
- function e(t) {
2369
- this.mode = n.NUMERIC, this.data = t.toString();
2370
- }
2371
- return e.getBitsLength = function(r) {
2372
- return 10 * Math.floor(r / 3) + (r % 3 ? r % 3 * 3 + 1 : 0);
2373
- }, e.prototype.getLength = function() {
2374
- return this.data.length;
2375
- }, e.prototype.getBitsLength = function() {
2376
- return e.getBitsLength(this.data.length);
2377
- }, e.prototype.write = function(r) {
2378
- let o, s, i;
2379
- for (o = 0; o + 3 <= this.data.length; o += 3)
2380
- s = this.data.substr(o, 3), i = parseInt(s, 10), r.put(i, 10);
2381
- const c = this.data.length - o;
2382
- c > 0 && (s = this.data.substr(o), i = parseInt(s, 10), r.put(i, c * 3 + 1));
2383
- }, Ne = e, Ne;
2384
- }
2385
- var De, Mt;
2386
- function br() {
2387
- if (Mt) return De;
2388
- Mt = 1;
2389
- const n = J(), e = [
2390
- "0",
2391
- "1",
2392
- "2",
2393
- "3",
2394
- "4",
2395
- "5",
2396
- "6",
2397
- "7",
2398
- "8",
2399
- "9",
2400
- "A",
2401
- "B",
2402
- "C",
2403
- "D",
2404
- "E",
2405
- "F",
2406
- "G",
2407
- "H",
2408
- "I",
2409
- "J",
2410
- "K",
2411
- "L",
2412
- "M",
2413
- "N",
2414
- "O",
2415
- "P",
2416
- "Q",
2417
- "R",
2418
- "S",
2419
- "T",
2420
- "U",
2421
- "V",
2422
- "W",
2423
- "X",
2424
- "Y",
2425
- "Z",
2426
- " ",
2427
- "$",
2428
- "%",
2429
- "*",
2430
- "+",
2431
- "-",
2432
- ".",
2433
- "/",
2434
- ":"
2435
- ];
2436
- function t(r) {
2437
- this.mode = n.ALPHANUMERIC, this.data = r;
2438
- }
2439
- return t.getBitsLength = function(o) {
2440
- return 11 * Math.floor(o / 2) + 6 * (o % 2);
2441
- }, t.prototype.getLength = function() {
2442
- return this.data.length;
2443
- }, t.prototype.getBitsLength = function() {
2444
- return t.getBitsLength(this.data.length);
2445
- }, t.prototype.write = function(o) {
2446
- let s;
2447
- for (s = 0; s + 2 <= this.data.length; s += 2) {
2448
- let i = e.indexOf(this.data[s]) * 45;
2449
- i += e.indexOf(this.data[s + 1]), o.put(i, 11);
2450
- }
2451
- this.data.length % 2 && o.put(e.indexOf(this.data[s]), 6);
2452
- }, De = t, De;
2453
- }
2454
- var Ue, Bt;
2455
- function Cr() {
2456
- if (Bt) return Ue;
2457
- Bt = 1;
2458
- const n = J();
2459
- function e(t) {
2460
- this.mode = n.BYTE, typeof t == "string" ? this.data = new TextEncoder().encode(t) : this.data = new Uint8Array(t);
2461
- }
2462
- return e.getBitsLength = function(r) {
2463
- return r * 8;
2464
- }, e.prototype.getLength = function() {
2465
- return this.data.length;
2466
- }, e.prototype.getBitsLength = function() {
2467
- return e.getBitsLength(this.data.length);
2468
- }, e.prototype.write = function(t) {
2469
- for (let r = 0, o = this.data.length; r < o; r++)
2470
- t.put(this.data[r], 8);
2471
- }, Ue = e, Ue;
2472
- }
2473
- var Fe, Lt;
2474
- function Ar() {
2475
- if (Lt) return Fe;
2476
- Lt = 1;
2477
- const n = J(), e = K();
2478
- function t(r) {
2479
- this.mode = n.KANJI, this.data = r;
2480
- }
2481
- return t.getBitsLength = function(o) {
2482
- return o * 13;
2483
- }, t.prototype.getLength = function() {
2484
- return this.data.length;
2485
- }, t.prototype.getBitsLength = function() {
2486
- return t.getBitsLength(this.data.length);
2487
- }, t.prototype.write = function(r) {
2488
- let o;
2489
- for (o = 0; o < this.data.length; o++) {
2490
- let s = e.toSJIS(this.data[o]);
2491
- if (s >= 33088 && s <= 40956)
2492
- s -= 33088;
2493
- else if (s >= 57408 && s <= 60351)
2494
- s -= 49472;
2495
- else
2496
- throw new Error(
2497
- "Invalid SJIS character: " + this.data[o] + `
2498
- Make sure your charset is UTF-8`
2499
- );
2500
- s = (s >>> 8 & 255) * 192 + (s & 255), r.put(s, 13);
2501
- }
2502
- }, Fe = t, Fe;
2503
- }
2504
- var ze = { exports: {} }, It;
2505
- function Tr() {
2506
- return It || (It = 1, (function(n) {
2507
- var e = {
2508
- single_source_shortest_paths: function(t, r, o) {
2509
- var s = {}, i = {};
2510
- i[r] = 0;
2511
- var c = e.PriorityQueue.make();
2512
- c.push(r, 0);
2513
- for (var a, l, u, h, f, d, g, p, m; !c.empty(); ) {
2514
- a = c.pop(), l = a.value, h = a.cost, f = t[l] || {};
2515
- for (u in f)
2516
- f.hasOwnProperty(u) && (d = f[u], g = h + d, p = i[u], m = typeof i[u] > "u", (m || p > g) && (i[u] = g, c.push(u, g), s[u] = l));
2517
- }
2518
- if (typeof o < "u" && typeof i[o] > "u") {
2519
- var y = ["Could not find a path from ", r, " to ", o, "."].join("");
2520
- throw new Error(y);
2521
- }
2522
- return s;
2523
- },
2524
- extract_shortest_path_from_predecessor_list: function(t, r) {
2525
- for (var o = [], s = r; s; )
2526
- o.push(s), t[s], s = t[s];
2527
- return o.reverse(), o;
2528
- },
2529
- find_path: function(t, r, o) {
2530
- var s = e.single_source_shortest_paths(t, r, o);
2531
- return e.extract_shortest_path_from_predecessor_list(
2532
- s,
2533
- o
2534
- );
2535
- },
2536
- /**
2537
- * A very naive priority queue implementation.
2538
- */
2539
- PriorityQueue: {
2540
- make: function(t) {
2541
- var r = e.PriorityQueue, o = {}, s;
2542
- t = t || {};
2543
- for (s in r)
2544
- r.hasOwnProperty(s) && (o[s] = r[s]);
2545
- return o.queue = [], o.sorter = t.sorter || r.default_sorter, o;
2546
- },
2547
- default_sorter: function(t, r) {
2548
- return t.cost - r.cost;
2549
- },
2550
- /**
2551
- * Add a new item to the queue and ensure the highest priority element
2552
- * is at the front of the queue.
2553
- */
2554
- push: function(t, r) {
2555
- var o = { value: t, cost: r };
2556
- this.queue.push(o), this.queue.sort(this.sorter);
2557
- },
2558
- /**
2559
- * Return the highest priority element in the queue.
2560
- */
2561
- pop: function() {
2562
- return this.queue.shift();
2563
- },
2564
- empty: function() {
2565
- return this.queue.length === 0;
2566
- }
2567
- }
2568
- };
2569
- n.exports = e;
2570
- })(ze)), ze.exports;
2571
- }
2572
- var $t;
2573
- function Er() {
2574
- return $t || ($t = 1, (function(n) {
2575
- const e = J(), t = vr(), r = br(), o = Cr(), s = Ar(), i = an(), c = K(), a = Tr();
2576
- function l(y) {
2577
- return unescape(encodeURIComponent(y)).length;
2578
- }
2579
- function u(y, E, w) {
2580
- const x = [];
2581
- let M;
2582
- for (; (M = y.exec(w)) !== null; )
2583
- x.push({
2584
- data: M[0],
2585
- index: M.index,
2586
- mode: E,
2587
- length: M[0].length
2588
- });
2589
- return x;
2590
- }
2591
- function h(y) {
2592
- const E = u(i.NUMERIC, e.NUMERIC, y), w = u(i.ALPHANUMERIC, e.ALPHANUMERIC, y);
2593
- let x, M;
2594
- return c.isKanjiModeEnabled() ? (x = u(i.BYTE, e.BYTE, y), M = u(i.KANJI, e.KANJI, y)) : (x = u(i.BYTE_KANJI, e.BYTE, y), M = []), E.concat(w, x, M).sort(function(_, T) {
2595
- return _.index - T.index;
2596
- }).map(function(_) {
2597
- return {
2598
- data: _.data,
2599
- mode: _.mode,
2600
- length: _.length
2601
- };
2602
- });
2603
- }
2604
- function f(y, E) {
2605
- switch (E) {
2606
- case e.NUMERIC:
2607
- return t.getBitsLength(y);
2608
- case e.ALPHANUMERIC:
2609
- return r.getBitsLength(y);
2610
- case e.KANJI:
2611
- return s.getBitsLength(y);
2612
- case e.BYTE:
2613
- return o.getBitsLength(y);
2614
- }
2615
- }
2616
- function d(y) {
2617
- return y.reduce(function(E, w) {
2618
- const x = E.length - 1 >= 0 ? E[E.length - 1] : null;
2619
- return x && x.mode === w.mode ? (E[E.length - 1].data += w.data, E) : (E.push(w), E);
2620
- }, []);
2621
- }
2622
- function g(y) {
2623
- const E = [];
2624
- for (let w = 0; w < y.length; w++) {
2625
- const x = y[w];
2626
- switch (x.mode) {
2627
- case e.NUMERIC:
2628
- E.push([
2629
- x,
2630
- { data: x.data, mode: e.ALPHANUMERIC, length: x.length },
2631
- { data: x.data, mode: e.BYTE, length: x.length }
2632
- ]);
2633
- break;
2634
- case e.ALPHANUMERIC:
2635
- E.push([
2636
- x,
2637
- { data: x.data, mode: e.BYTE, length: x.length }
2638
- ]);
2639
- break;
2640
- case e.KANJI:
2641
- E.push([
2642
- x,
2643
- { data: x.data, mode: e.BYTE, length: l(x.data) }
2644
- ]);
2645
- break;
2646
- case e.BYTE:
2647
- E.push([
2648
- { data: x.data, mode: e.BYTE, length: l(x.data) }
2649
- ]);
2650
- }
2651
- }
2652
- return E;
2653
- }
2654
- function p(y, E) {
2655
- const w = {}, x = { start: {} };
2656
- let M = ["start"];
2657
- for (let b = 0; b < y.length; b++) {
2658
- const _ = y[b], T = [];
2659
- for (let v = 0; v < _.length; v++) {
2660
- const R = _[v], C = "" + b + v;
2661
- T.push(C), w[C] = { node: R, lastCount: 0 }, x[C] = {};
2662
- for (let k = 0; k < M.length; k++) {
2663
- const A = M[k];
2664
- w[A] && w[A].node.mode === R.mode ? (x[A][C] = f(w[A].lastCount + R.length, R.mode) - f(w[A].lastCount, R.mode), w[A].lastCount += R.length) : (w[A] && (w[A].lastCount = R.length), x[A][C] = f(R.length, R.mode) + 4 + e.getCharCountIndicator(R.mode, E));
2665
- }
2666
- }
2667
- M = T;
2668
- }
2669
- for (let b = 0; b < M.length; b++)
2670
- x[M[b]].end = 0;
2671
- return { map: x, table: w };
2672
- }
2673
- function m(y, E) {
2674
- let w;
2675
- const x = e.getBestModeForData(y);
2676
- if (w = e.from(E, x), w !== e.BYTE && w.bit < x.bit)
2677
- throw new Error('"' + y + '" cannot be encoded with mode ' + e.toString(w) + `.
2678
- Suggested mode is: ` + e.toString(x));
2679
- switch (w === e.KANJI && !c.isKanjiModeEnabled() && (w = e.BYTE), w) {
2680
- case e.NUMERIC:
2681
- return new t(y);
2682
- case e.ALPHANUMERIC:
2683
- return new r(y);
2684
- case e.KANJI:
2685
- return new s(y);
2686
- case e.BYTE:
2687
- return new o(y);
2688
- }
2689
- }
2690
- n.fromArray = function(E) {
2691
- return E.reduce(function(w, x) {
2692
- return typeof x == "string" ? w.push(m(x, null)) : x.data && w.push(m(x.data, x.mode)), w;
2693
- }, []);
2694
- }, n.fromString = function(E, w) {
2695
- const x = h(E, c.isKanjiModeEnabled()), M = g(x), b = p(M, w), _ = a.find_path(b.map, "start", "end"), T = [];
2696
- for (let v = 1; v < _.length - 1; v++)
2697
- T.push(b.table[_[v]].node);
2698
- return n.fromArray(d(T));
2699
- }, n.rawSplit = function(E) {
2700
- return n.fromArray(
2701
- h(E, c.isKanjiModeEnabled())
2702
- );
2703
- };
2704
- })(qe)), qe;
2705
- }
2706
- var Pt;
2707
- function _r() {
2708
- if (Pt) return Te;
2709
- Pt = 1;
2710
- const n = K(), e = Ye(), t = lr(), r = ur(), o = hr(), s = dr(), i = fr(), c = on(), a = pr(), l = wr(), u = yr(), h = J(), f = Er();
2711
- function d(b, _) {
2712
- const T = b.size, v = s.getPositions(_);
2713
- for (let R = 0; R < v.length; R++) {
2714
- const C = v[R][0], k = v[R][1];
2715
- for (let A = -1; A <= 7; A++)
2716
- if (!(C + A <= -1 || T <= C + A))
2717
- for (let S = -1; S <= 7; S++)
2718
- k + S <= -1 || T <= k + S || (A >= 0 && A <= 6 && (S === 0 || S === 6) || S >= 0 && S <= 6 && (A === 0 || A === 6) || A >= 2 && A <= 4 && S >= 2 && S <= 4 ? b.set(C + A, k + S, !0, !0) : b.set(C + A, k + S, !1, !0));
2719
- }
2720
- }
2721
- function g(b) {
2722
- const _ = b.size;
2723
- for (let T = 8; T < _ - 8; T++) {
2724
- const v = T % 2 === 0;
2725
- b.set(T, 6, v, !0), b.set(6, T, v, !0);
2726
- }
2727
- }
2728
- function p(b, _) {
2729
- const T = o.getPositions(_);
2730
- for (let v = 0; v < T.length; v++) {
2731
- const R = T[v][0], C = T[v][1];
2732
- for (let k = -2; k <= 2; k++)
2733
- for (let A = -2; A <= 2; A++)
2734
- k === -2 || k === 2 || A === -2 || A === 2 || k === 0 && A === 0 ? b.set(R + k, C + A, !0, !0) : b.set(R + k, C + A, !1, !0);
2735
- }
2736
- }
2737
- function m(b, _) {
2738
- const T = b.size, v = l.getEncodedBits(_);
2739
- let R, C, k;
2740
- for (let A = 0; A < 18; A++)
2741
- R = Math.floor(A / 3), C = A % 3 + T - 8 - 3, k = (v >> A & 1) === 1, b.set(R, C, k, !0), b.set(C, R, k, !0);
2742
- }
2743
- function y(b, _, T) {
2744
- const v = b.size, R = u.getEncodedBits(_, T);
2745
- let C, k;
2746
- for (C = 0; C < 15; C++)
2747
- k = (R >> C & 1) === 1, C < 6 ? b.set(C, 8, k, !0) : C < 8 ? b.set(C + 1, 8, k, !0) : b.set(v - 15 + C, 8, k, !0), C < 8 ? b.set(8, v - C - 1, k, !0) : C < 9 ? b.set(8, 15 - C - 1 + 1, k, !0) : b.set(8, 15 - C - 1, k, !0);
2748
- b.set(v - 8, 8, 1, !0);
2749
- }
2750
- function E(b, _) {
2751
- const T = b.size;
2752
- let v = -1, R = T - 1, C = 7, k = 0;
2753
- for (let A = T - 1; A > 0; A -= 2)
2754
- for (A === 6 && A--; ; ) {
2755
- for (let S = 0; S < 2; S++)
2756
- if (!b.isReserved(R, A - S)) {
2757
- let z = !1;
2758
- k < _.length && (z = (_[k] >>> C & 1) === 1), b.set(R, A - S, z), C--, C === -1 && (k++, C = 7);
2759
- }
2760
- if (R += v, R < 0 || T <= R) {
2761
- R -= v, v = -v;
2762
- break;
2763
- }
2764
- }
2765
- }
2766
- function w(b, _, T) {
2767
- const v = new t();
2768
- T.forEach(function(S) {
2769
- v.put(S.mode.bit, 4), v.put(S.getLength(), h.getCharCountIndicator(S.mode, b)), S.write(v);
2770
- });
2771
- const R = n.getSymbolTotalCodewords(b), C = c.getTotalCodewordsCount(b, _), k = (R - C) * 8;
2772
- for (v.getLengthInBits() + 4 <= k && v.put(0, 4); v.getLengthInBits() % 8 !== 0; )
2773
- v.putBit(0);
2774
- const A = (k - v.getLengthInBits()) / 8;
2775
- for (let S = 0; S < A; S++)
2776
- v.put(S % 2 ? 17 : 236, 8);
2777
- return x(v, b, _);
2778
- }
2779
- function x(b, _, T) {
2780
- const v = n.getSymbolTotalCodewords(_), R = c.getTotalCodewordsCount(_, T), C = v - R, k = c.getBlocksCount(_, T), A = v % k, S = k - A, z = Math.floor(v / k), ee = Math.floor(C / k), fn = ee + 1, Xe = z - ee, gn = new a(Xe);
2781
- let me = 0;
2782
- const ce = new Array(k), Ze = new Array(k);
2783
- let pe = 0;
2784
- const mn = new Uint8Array(b.buffer);
2785
- for (let Q = 0; Q < k; Q++) {
2786
- const ye = Q < S ? ee : fn;
2787
- ce[Q] = mn.slice(me, me + ye), Ze[Q] = gn.encode(ce[Q]), me += ye, pe = Math.max(pe, ye);
2788
- }
2789
- const we = new Uint8Array(v);
2790
- let et = 0, q, N;
2791
- for (q = 0; q < pe; q++)
2792
- for (N = 0; N < k; N++)
2793
- q < ce[N].length && (we[et++] = ce[N][q]);
2794
- for (q = 0; q < Xe; q++)
2795
- for (N = 0; N < k; N++)
2796
- we[et++] = Ze[N][q];
2797
- return we;
2798
- }
2799
- function M(b, _, T, v) {
2800
- let R;
2801
- if (Array.isArray(b))
2802
- R = f.fromArray(b);
2803
- else if (typeof b == "string") {
2804
- let z = _;
2805
- if (!z) {
2806
- const ee = f.rawSplit(b);
2807
- z = l.getBestVersionForData(ee, T);
2808
- }
2809
- R = f.fromString(b, z || 40);
2810
- } else
2811
- throw new Error("Invalid data");
2812
- const C = l.getBestVersionForData(R, T);
2813
- if (!C)
2814
- throw new Error("The amount of data is too big to be stored in a QR Code");
2815
- if (!_)
2816
- _ = C;
2817
- else if (_ < C)
2818
- throw new Error(
2819
- `
2820
- The chosen QR Code version cannot contain this amount of data.
2821
- Minimum version required to store current data is: ` + C + `.
2822
- `
2823
- );
2824
- const k = w(_, T, R), A = n.getSymbolSize(_), S = new r(A);
2825
- return d(S, _), g(S), p(S, _), y(S, T, 0), _ >= 7 && m(S, _), E(S, k), isNaN(v) && (v = i.getBestMask(
2826
- S,
2827
- y.bind(null, S, T)
2828
- )), i.applyMask(v, S), y(S, T, v), {
2829
- modules: S,
2830
- version: _,
2831
- errorCorrectionLevel: T,
2832
- maskPattern: v,
2833
- segments: R
2834
- };
2835
- }
2836
- return Te.create = function(_, T) {
2837
- if (typeof _ > "u" || _ === "")
2838
- throw new Error("No input text");
2839
- let v = e.M, R, C;
2840
- return typeof T < "u" && (v = e.from(T.errorCorrectionLevel, e.M), R = l.from(T.version), C = i.from(T.maskPattern), T.toSJISFunc && n.setToSJISFunction(T.toSJISFunc)), M(_, R, v, C);
2841
- }, Te;
2842
- }
2843
- var He = {}, je = {}, qt;
2844
- function cn() {
2845
- return qt || (qt = 1, (function(n) {
2846
- function e(t) {
2847
- if (typeof t == "number" && (t = t.toString()), typeof t != "string")
2848
- throw new Error("Color should be defined as hex string");
2849
- let r = t.slice().replace("#", "").split("");
2850
- if (r.length < 3 || r.length === 5 || r.length > 8)
2851
- throw new Error("Invalid hex color: " + t);
2852
- (r.length === 3 || r.length === 4) && (r = Array.prototype.concat.apply([], r.map(function(s) {
2853
- return [s, s];
2854
- }))), r.length === 6 && r.push("F", "F");
2855
- const o = parseInt(r.join(""), 16);
2856
- return {
2857
- r: o >> 24 & 255,
2858
- g: o >> 16 & 255,
2859
- b: o >> 8 & 255,
2860
- a: o & 255,
2861
- hex: "#" + r.slice(0, 6).join("")
2862
- };
2863
- }
2864
- n.getOptions = function(r) {
2865
- r || (r = {}), r.color || (r.color = {});
2866
- const o = typeof r.margin > "u" || r.margin === null || r.margin < 0 ? 4 : r.margin, s = r.width && r.width >= 21 ? r.width : void 0, i = r.scale || 4;
2867
- return {
2868
- width: s,
2869
- scale: s ? 4 : i,
2870
- margin: o,
2871
- color: {
2872
- dark: e(r.color.dark || "#000000ff"),
2873
- light: e(r.color.light || "#ffffffff")
2874
- },
2875
- type: r.type,
2876
- rendererOpts: r.rendererOpts || {}
2877
- };
2878
- }, n.getScale = function(r, o) {
2879
- return o.width && o.width >= r + o.margin * 2 ? o.width / (r + o.margin * 2) : o.scale;
2880
- }, n.getImageWidth = function(r, o) {
2881
- const s = n.getScale(r, o);
2882
- return Math.floor((r + o.margin * 2) * s);
2883
- }, n.qrToImageData = function(r, o, s) {
2884
- const i = o.modules.size, c = o.modules.data, a = n.getScale(i, s), l = Math.floor((i + s.margin * 2) * a), u = s.margin * a, h = [s.color.light, s.color.dark];
2885
- for (let f = 0; f < l; f++)
2886
- for (let d = 0; d < l; d++) {
2887
- let g = (f * l + d) * 4, p = s.color.light;
2888
- if (f >= u && d >= u && f < l - u && d < l - u) {
2889
- const m = Math.floor((f - u) / a), y = Math.floor((d - u) / a);
2890
- p = h[c[m * i + y] ? 1 : 0];
2891
- }
2892
- r[g++] = p.r, r[g++] = p.g, r[g++] = p.b, r[g] = p.a;
2893
- }
2894
- };
2895
- })(je)), je;
2896
- }
2897
- var Nt;
2898
- function kr() {
2899
- return Nt || (Nt = 1, (function(n) {
2900
- const e = cn();
2901
- function t(o, s, i) {
2902
- o.clearRect(0, 0, s.width, s.height), s.style || (s.style = {}), s.height = i, s.width = i, s.style.height = i + "px", s.style.width = i + "px";
2903
- }
2904
- function r() {
2905
- try {
2906
- return document.createElement("canvas");
2907
- } catch {
2908
- throw new Error("You need to specify a canvas element");
2909
- }
2910
- }
2911
- n.render = function(s, i, c) {
2912
- let a = c, l = i;
2913
- typeof a > "u" && (!i || !i.getContext) && (a = i, i = void 0), i || (l = r()), a = e.getOptions(a);
2914
- const u = e.getImageWidth(s.modules.size, a), h = l.getContext("2d"), f = h.createImageData(u, u);
2915
- return e.qrToImageData(f.data, s, a), t(h, l, u), h.putImageData(f, 0, 0), l;
2916
- }, n.renderToDataURL = function(s, i, c) {
2917
- let a = c;
2918
- typeof a > "u" && (!i || !i.getContext) && (a = i, i = void 0), a || (a = {});
2919
- const l = n.render(s, i, a), u = a.type || "image/png", h = a.rendererOpts || {};
2920
- return l.toDataURL(u, h.quality);
2921
- };
2922
- })(He)), He;
2923
- }
2924
- var Ve = {}, Dt;
2925
- function xr() {
2926
- if (Dt) return Ve;
2927
- Dt = 1;
2928
- const n = cn();
2929
- function e(o, s) {
2930
- const i = o.a / 255, c = s + '="' + o.hex + '"';
2931
- return i < 1 ? c + " " + s + '-opacity="' + i.toFixed(2).slice(1) + '"' : c;
2932
- }
2933
- function t(o, s, i) {
2934
- let c = o + s;
2935
- return typeof i < "u" && (c += " " + i), c;
2936
- }
2937
- function r(o, s, i) {
2938
- let c = "", a = 0, l = !1, u = 0;
2939
- for (let h = 0; h < o.length; h++) {
2940
- const f = Math.floor(h % s), d = Math.floor(h / s);
2941
- !f && !l && (l = !0), o[h] ? (u++, h > 0 && f > 0 && o[h - 1] || (c += l ? t("M", f + i, 0.5 + d + i) : t("m", a, 0), a = 0, l = !1), f + 1 < s && o[h + 1] || (c += t("h", u), u = 0)) : a++;
2942
- }
2943
- return c;
2944
- }
2945
- return Ve.render = function(s, i, c) {
2946
- const a = n.getOptions(i), l = s.modules.size, u = s.modules.data, h = l + a.margin * 2, f = a.color.light.a ? "<path " + e(a.color.light, "fill") + ' d="M0 0h' + h + "v" + h + 'H0z"/>' : "", d = "<path " + e(a.color.dark, "stroke") + ' d="' + r(u, l, a.margin) + '"/>', g = 'viewBox="0 0 ' + h + " " + h + '"', m = '<svg xmlns="http://www.w3.org/2000/svg" ' + (a.width ? 'width="' + a.width + '" height="' + a.width + '" ' : "") + g + ' shape-rendering="crispEdges">' + f + d + `</svg>
2947
- `;
2948
- return typeof c == "function" && c(null, m), m;
2949
- }, Ve;
2950
- }
2951
- var Ut;
2952
- function Rr() {
2953
- if (Ut) return G;
2954
- Ut = 1;
2955
- const n = cr(), e = _r(), t = kr(), r = xr();
2956
- function o(s, i, c, a, l) {
2957
- const u = [].slice.call(arguments, 1), h = u.length, f = typeof u[h - 1] == "function";
2958
- if (!f && !n())
2959
- throw new Error("Callback required as last argument");
2960
- if (f) {
2961
- if (h < 2)
2962
- throw new Error("Too few arguments provided");
2963
- h === 2 ? (l = c, c = i, i = a = void 0) : h === 3 && (i.getContext && typeof l > "u" ? (l = a, a = void 0) : (l = a, a = c, c = i, i = void 0));
2964
- } else {
2965
- if (h < 1)
2966
- throw new Error("Too few arguments provided");
2967
- return h === 1 ? (c = i, i = a = void 0) : h === 2 && !i.getContext && (a = c, c = i, i = void 0), new Promise(function(d, g) {
2968
- try {
2969
- const p = e.create(c, a);
2970
- d(s(p, i, a));
2971
- } catch (p) {
2972
- g(p);
2973
- }
2974
- });
2975
- }
2976
- try {
2977
- const d = e.create(c, a);
2978
- l(null, s(d, i, a));
2979
- } catch (d) {
2980
- l(d);
2981
- }
2982
- }
2983
- return G.create = e.create, G.toCanvas = o.bind(null, t.render), G.toDataURL = o.bind(null, t.renderToDataURL), G.toString = o.bind(null, function(s, i, c) {
2984
- return r.render(s, c);
2985
- }), G;
2986
- }
2987
- var Sr = Rr();
2988
- const Mr = /* @__PURE__ */ ar(Sr), Br = (n) => {
2989
- var e = {
2990
- errorCorrectionLevel: "H",
2991
- type: "image/jpeg",
2992
- margin: 1,
2993
- width: 300
2994
- };
2995
- let t = null;
2996
- const r = async (a) => {
2997
- const l = new URL(window.location.href), u = new URL(l.pathname, l.origin);
2998
- u.searchParams.set("state", "1-" + a), console.log("生成登录二维码链接:", u.toString());
2999
- var h = n || document.getElementById("qrcode");
3000
- await Mr.toDataURL(h, u.toString(), e);
3001
- }, o = async (a) => {
3002
- const l = await fetch(`/api/router?path=wx&key=checkLogin&state=${a}`).then((u) => u.json());
3003
- if (l.code === 200) {
3004
- console.log(l);
3005
- const u = l.data;
3006
- u && (localStorage.setItem("token", u.accessToken), await U.setLoginToken(u)), c(), setTimeout(() => {
3007
- ie();
3008
- }, 1e3);
3009
- } else
3010
- t = setTimeout(() => {
3011
- o(a), console.log("继续检测登录状态");
3012
- }, 2e3);
3013
- }, s = Math.random().toString(36).substring(2, 15);
3014
- r(s), o(s);
3015
- const i = setInterval(() => {
3016
- const a = Math.random().toString(36).substring(2, 15);
3017
- clearTimeout(t), r(a), o(a), console.log("更新二维码");
3018
- }, 9e4), c = () => {
3019
- clearTimeout(t), clearInterval(i), console.log("停止检测登录状态");
3020
- };
3021
- return { createQrcode: r, clear: c };
3022
- };
3023
- function Lr(n) {
3024
- return n && n.__esModule && Object.prototype.hasOwnProperty.call(n, "default") ? n.default : n;
3025
- }
3026
- var Oe = { exports: {} }, Ft;
3027
- function Ir() {
3028
- return Ft || (Ft = 1, (function(n) {
3029
- var e = Object.prototype.hasOwnProperty, t = "~";
3030
- function r() {
3031
- }
3032
- Object.create && (r.prototype = /* @__PURE__ */ Object.create(null), new r().__proto__ || (t = !1));
3033
- function o(a, l, u) {
3034
- this.fn = a, this.context = l, this.once = u || !1;
3035
- }
3036
- function s(a, l, u, h, f) {
3037
- if (typeof u != "function")
3038
- throw new TypeError("The listener must be a function");
3039
- var d = new o(u, h || a, f), g = t ? t + l : l;
3040
- return a._events[g] ? a._events[g].fn ? a._events[g] = [a._events[g], d] : a._events[g].push(d) : (a._events[g] = d, a._eventsCount++), a;
3041
- }
3042
- function i(a, l) {
3043
- --a._eventsCount === 0 ? a._events = new r() : delete a._events[l];
3044
- }
3045
- function c() {
3046
- this._events = new r(), this._eventsCount = 0;
3047
- }
3048
- c.prototype.eventNames = function() {
3049
- var l = [], u, h;
3050
- if (this._eventsCount === 0)
3051
- return l;
3052
- for (h in u = this._events)
3053
- e.call(u, h) && l.push(t ? h.slice(1) : h);
3054
- return Object.getOwnPropertySymbols ? l.concat(Object.getOwnPropertySymbols(u)) : l;
3055
- }, c.prototype.listeners = function(l) {
3056
- var u = t ? t + l : l, h = this._events[u];
3057
- if (!h)
3058
- return [];
3059
- if (h.fn)
3060
- return [h.fn];
3061
- for (var f = 0, d = h.length, g = new Array(d); f < d; f++)
3062
- g[f] = h[f].fn;
3063
- return g;
3064
- }, c.prototype.listenerCount = function(l) {
3065
- var u = t ? t + l : l, h = this._events[u];
3066
- return h ? h.fn ? 1 : h.length : 0;
3067
- }, c.prototype.emit = function(l, u, h, f, d, g) {
3068
- var p = t ? t + l : l;
3069
- if (!this._events[p])
3070
- return !1;
3071
- var m = this._events[p], y = arguments.length, E, w;
3072
- if (m.fn) {
3073
- switch (m.once && this.removeListener(l, m.fn, void 0, !0), y) {
3074
- case 1:
3075
- return m.fn.call(m.context), !0;
3076
- case 2:
3077
- return m.fn.call(m.context, u), !0;
3078
- case 3:
3079
- return m.fn.call(m.context, u, h), !0;
3080
- case 4:
3081
- return m.fn.call(m.context, u, h, f), !0;
3082
- case 5:
3083
- return m.fn.call(m.context, u, h, f, d), !0;
3084
- case 6:
3085
- return m.fn.call(m.context, u, h, f, d, g), !0;
3086
- }
3087
- for (w = 1, E = new Array(y - 1); w < y; w++)
3088
- E[w - 1] = arguments[w];
3089
- m.fn.apply(m.context, E);
3090
- } else {
3091
- var x = m.length, M;
3092
- for (w = 0; w < x; w++)
3093
- switch (m[w].once && this.removeListener(l, m[w].fn, void 0, !0), y) {
3094
- case 1:
3095
- m[w].fn.call(m[w].context);
3096
- break;
3097
- case 2:
3098
- m[w].fn.call(m[w].context, u);
3099
- break;
3100
- case 3:
3101
- m[w].fn.call(m[w].context, u, h);
3102
- break;
3103
- case 4:
3104
- m[w].fn.call(m[w].context, u, h, f);
3105
- break;
3106
- default:
3107
- if (!E)
3108
- for (M = 1, E = new Array(y - 1); M < y; M++)
3109
- E[M - 1] = arguments[M];
3110
- m[w].fn.apply(m[w].context, E);
3111
- }
3112
- }
3113
- return !0;
3114
- }, c.prototype.on = function(l, u, h) {
3115
- return s(this, l, u, h, !1);
3116
- }, c.prototype.once = function(l, u, h) {
3117
- return s(this, l, u, h, !0);
3118
- }, c.prototype.removeListener = function(l, u, h, f) {
3119
- var d = t ? t + l : l;
3120
- if (!this._events[d])
3121
- return this;
3122
- if (!u)
3123
- return i(this, d), this;
3124
- var g = this._events[d];
3125
- if (g.fn)
3126
- g.fn === u && (!f || g.once) && (!h || g.context === h) && i(this, d);
3127
- else {
3128
- for (var p = 0, m = [], y = g.length; p < y; p++)
3129
- (g[p].fn !== u || f && !g[p].once || h && g[p].context !== h) && m.push(g[p]);
3130
- m.length ? this._events[d] = m.length === 1 ? m[0] : m : i(this, d);
3131
- }
3132
- return this;
3133
- }, c.prototype.removeAllListeners = function(l) {
3134
- var u;
3135
- return l ? (u = t ? t + l : l, this._events[u] && i(this, u)) : (this._events = new r(), this._eventsCount = 0), this;
3136
- }, c.prototype.off = c.prototype.removeListener, c.prototype.addListener = c.prototype.on, c.prefixed = t, c.EventEmitter = c, n.exports = c;
3137
- })(Oe)), Oe.exports;
3138
- }
3139
- var $r = Ir(), Pr = /* @__PURE__ */ Lr($r), zt = (n) => {
3140
- const e = n.timeout || 3e5, t = n.interval || 1e3, r = n?.checkSuccess || (() => !0), o = n.signal;
3141
- return new Promise(async (s, i) => {
3142
- let c, a = setTimeout(() => {
3143
- clearTimeout(c), s({
3144
- code: 500,
3145
- message: "timeout"
3146
- });
3147
- }, e);
3148
- const l = n.fn || (() => !0), u = async () => {
3149
- if (o?.aborted)
3150
- return clearInterval(c), clearTimeout(a), s({
3151
- code: 499,
3152
- message: "operation cancelled"
3153
- });
3154
- const h = await l();
3155
- r(h) ? (clearInterval(c), clearTimeout(a), s({
3156
- code: 200,
3157
- data: h
3158
- })) : setTimeout(() => {
3159
- u();
3160
- }, t);
3161
- };
3162
- o && o.addEventListener("abort", () => {
3163
- clearInterval(c), clearTimeout(a), s({
3164
- code: 499,
3165
- message: "operation cancelled"
3166
- });
3167
- }), u();
3168
- });
3169
- };
3170
- class ln {
3171
- modules = /* @__PURE__ */ new Map();
3172
- event;
3173
- loading;
3174
- static reRunFn = zt;
3175
- timeout = 300 * 1e3;
3176
- constructor() {
3177
- this.event = new Pr(), this.loading = !1;
3178
- }
3179
- listenKey(e, t) {
3180
- const r = t?.timeout ?? this.timeout;
3181
- return new Promise((o) => {
3182
- const s = setTimeout(() => {
3183
- this.event.removeListener(e, i), o({
3184
- code: 500,
3185
- message: "timeout"
3186
- });
3187
- }, r), i = (c) => {
3188
- if (clearTimeout(s), c)
3189
- return o({
3190
- code: 500,
3191
- message: c
3192
- });
3193
- const a = this.modules.get(e);
3194
- a?.loadSuccessClear && this.remove(e), o({
3195
- code: 200,
3196
- data: a?.modules
3197
- });
3198
- };
3199
- this.event.once(e, i);
3200
- });
3201
- }
3202
- async hasLoaded(e, t) {
3203
- if (!e)
3204
- return {
3205
- code: 404,
3206
- message: "key is required"
3207
- };
3208
- if (!this.modules.has(e)) {
3209
- const s = t?.isExist ?? !0, i = t?.timeout ?? this.timeout;
3210
- return s ? await this.listenKey(e, { timeout: i }) : {
3211
- code: 404
3212
- };
3213
- }
3214
- const o = this.modules.get(e);
3215
- return o?.status === "loaded" ? {
3216
- code: 200,
3217
- data: o.modules
3218
- } : o?.status === "loading" ? await this.listenKey(e, { timeout: t?.timeout ?? this.timeout }) : o?.status === "error" ? {
3219
- code: 500,
3220
- message: "load error"
3221
- } : o?.status === "cancel" ? {
3222
- code: 499,
3223
- message: "operation cancelled"
3224
- } : {
3225
- code: 404
3226
- };
3227
- }
3228
- async loadFn(e, t) {
3229
- const r = t.key;
3230
- if (!r)
3231
- return {
3232
- code: 404,
3233
- message: "key is required"
3234
- };
3235
- const o = {
3236
- key: t.key,
3237
- status: "loading",
3238
- loading: !0,
3239
- loadSuccessClear: t.loadSuccessClear ?? !0
3240
- };
3241
- let s = "";
3242
- try {
3243
- const i = t.isReRun ?? !1;
3244
- let c;
3245
- if (!i)
3246
- this.modules.set(r, o), c = await e();
3247
- else {
3248
- o.controller = new AbortController();
3249
- const a = o.controller.signal;
3250
- this.modules.set(r, o);
3251
- const l = await zt({
3252
- timeout: t.timeout,
3253
- interval: t.interval,
3254
- checkSuccess: t.checkSuccess,
3255
- fn: e,
3256
- signal: a
3257
- });
3258
- if (o.controller = null, l.code === 499)
3259
- return o.status = "cancel", {
3260
- code: 499,
3261
- message: "operation cancelled"
3262
- };
3263
- if (l.code !== 200)
3264
- throw new Error(l.message);
3265
- c = l.data;
3266
- }
3267
- return o.modules = c, o.status = "loaded", {
3268
- code: 200,
3269
- data: c
3270
- };
3271
- } catch (i) {
3272
- return s = i.message, o.status = "error", {
3273
- code: 500,
3274
- message: i
3275
- };
3276
- } finally {
3277
- o.loading = !1, this.modules.set(t.key, o), s ? this.event.emit(t.key, s) : this.event.emit(t.key);
3278
- }
3279
- }
3280
- async load(e, t) {
3281
- this.loading = !0;
3282
- const r = t.key;
3283
- if (!r)
3284
- return {
3285
- code: 404,
3286
- message: "key is required"
3287
- };
3288
- if (t?.force && this.remove(r), this.modules.has(r))
3289
- return await this.hasLoaded(r);
3290
- if (typeof e == "function")
3291
- return this.loadFn(e, t);
3292
- console.error("loadContent is not a function and not has loaded");
3293
- }
3294
- remove(e) {
3295
- this.modules.has(e) && (this.checkRemoveController(e), this.modules.delete(e));
3296
- }
3297
- emitLoaded(e) {
3298
- this.checkRemoveController(e), this.event.emit(e);
3299
- }
3300
- setModule(e, t, r) {
3301
- const o = {
3302
- key: e,
3303
- status: "loaded",
3304
- loading: !1,
3305
- modules: t || {},
3306
- ...r
3307
- };
3308
- return this.modules.set(e, o), this.emitLoaded(e), o;
3309
- }
3310
- cancel(e) {
3311
- this.checkRemoveController(e);
3312
- }
3313
- checkRemoveController(e) {
3314
- const t = this.modules.get(e);
3315
- t?.controller && (t.controller?.abort?.(), delete t.controller, this.modules.set(e, t));
3316
- }
3317
- }
3318
- var D = globalThis || window || self, un = (n, e = "config", t) => {
3319
- const r = D[e], o = r || n;
3320
- return r || (o ? D[e] = o : D[e] = {}), D[e];
3321
- }, he = (n, e, t = "config") => {
3322
- const r = un({}, t);
3323
- if (n && typeof r[n] < "u")
3324
- return r[n];
3325
- if (n && e) {
3326
- if (typeof e != "function" && (r[n] = e), typeof e == "function") {
3327
- const o = e();
3328
- if (o instanceof Promise)
3329
- return o.then((s) => (r[n] = s, s));
3330
- r[n] = o;
3331
- }
3332
- return r[n];
3333
- }
3334
- if (n) {
3335
- const o = new ln(), s = async () => r[n];
3336
- return (async () => (await o.load(s, {
3337
- key: n,
3338
- isReRun: !0,
3339
- checkSuccess: () => r[n],
3340
- timeout: 3e5,
3341
- interval: 1e3
3342
- })).code !== 200 ? (console.error("load key error"), null) : r[n])();
3343
- }
3344
- return console.error("key is empty "), null;
3345
- }, hn = (n, e = "config", t) => {
3346
- const r = un({}, e);
3347
- if (n && delete r[n], t?.getNew && t.init)
3348
- return he(n, t.init, e);
3349
- if (t?.getNew)
3350
- return he(n, null, e);
3351
- }, de = (n, e, t) => t ? hn(n, "context", { getNew: !0, init: e }) : he(n, e, "context"), Ht = de, jt = (n, e, t) => t ? hn(n, "config", { getNew: !0, init: e }) : he(n, e, "config");
3352
- class fe {
3353
- static isInit = !1;
3354
- static init(e) {
3355
- if (fe.isInit)
3356
- return;
3357
- const { load: t = !0, page: r = !1 } = e || {};
3358
- fe.isInit = !0, D.useConfigKey = jt, D.useContextKey = de, D.use = Ht, D.webEnv = { useConfigKey: jt, useContextKey: de, use: Ht }, t && (D.Load = ln);
3359
- }
3360
- }
3361
- fe.init();
3362
- const qr = de("login-emitter", nn), dn = "wxff97d569b1db16b6", Nr = '<svg t="1764510467010" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1958" width="32" height="32"><path d="M615.904 388.48c8.8 0 17.536 0.64 26.176 1.6-23.52-109.536-140.608-190.912-274.272-190.912C218.4 199.2 96 301.056 96 430.4c0 74.656 40.736 135.936 108.768 183.488l-27.2 81.792 95.04-47.648c33.984 6.72 61.28 13.632 95.2 13.632 8.544 0 16.992-0.416 25.376-1.088a202.496 202.496 0 0 1-8.384-56.96c0-118.752 101.984-215.136 231.104-215.136zM469.76 314.784c20.48 0 34.016 13.472 34.016 33.92 0 20.352-13.536 34.016-34.016 34.016-20.384 0-40.832-13.664-40.832-34.016 0-20.448 20.448-33.92 40.832-33.92zM279.52 382.72c-20.384 0-40.928-13.664-40.928-34.016 0-20.448 20.544-33.92 40.928-33.92 20.352 0 33.92 13.472 33.92 33.92 0 20.384-13.568 34.016-33.92 34.016z" fill="" p-id="1959"></path><path d="M864 600.352c0-108.672-108.736-197.28-230.88-197.28-129.344 0-231.2 88.576-231.2 197.28 0 108.864 101.856 197.248 231.2 197.248 27.072 0 54.368-6.816 81.568-13.632l74.56 40.8-20.448-67.904C823.328 715.936 864 661.664 864 600.352z m-305.856-34.016c-13.536 0-27.2-13.44-27.2-27.2 0-13.568 13.664-27.2 27.2-27.2 20.576 0 34.016 13.632 34.016 27.2 0 13.76-13.44 27.2-34.016 27.2z m149.536 0c-13.44 0-27.008-13.44-27.008-27.2 0-13.568 13.568-27.2 27.008-27.2 20.352 0 34.016 13.632 34.016 27.2 0 13.76-13.664 27.2-34.016 27.2z" fill="" p-id="1960"></path></svg>', Dr = '<svg t="1764511395617" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="3882" width="32" height="32"><path d="M256 259.584c-29.184 0-51.2 14.848-51.2 44.032s29.184 44.032 51.2 44.032c29.184 0 44.032-14.848 44.032-44.032s-22.016-44.032-44.032-44.032zM541.184 303.616c0-29.184-14.848-44.032-44.032-44.032-29.184 0-51.2 14.848-51.2 44.032s29.184 44.032 51.2 44.032c29.696 0 44.032-22.016 44.032-44.032zM614.4 508.416c-14.848 0-36.352 14.848-36.352 36.352 0 14.848 14.848 36.352 36.352 36.352 29.184 0 44.032-14.848 44.032-36.352 0-14.336-14.848-36.352-44.032-36.352z" p-id="3883"></path><path d="M1024 625.152c0-138.752-124.416-256-285.184-270.848-29.184-153.6-189.952-263.168-373.248-263.168C160.768 91.648 0 230.4 0 406.016c0 95.232 44.032 175.616 138.752 241.152L109.568 742.4c0 7.168 0 14.848 7.168 22.016h14.848l117.248-58.368h14.848c36.352 7.168 66.048 14.848 109.568 14.848 14.848 0 44.032-7.168 44.032-7.168C460.8 822.784 578.048 896 716.8 896c36.352 0 73.216-7.168 102.4-14.848l87.552 51.2h14.848c7.168-7.168 7.168-7.168 7.168-14.848l-22.016-87.552c80.896-58.368 117.248-131.584 117.248-204.8z m-621.568 51.2h-36.352c-36.352 0-66.048-7.168-95.232-14.848l-22.016-7.168h-7.168L153.6 698.368l22.016-66.048c0-7.168 0-14.848-7.168-14.848C80.384 559.616 36.352 486.4 36.352 398.848 36.352 245.248 182.784 128 358.4 128c160.768 0 300.032 95.232 329.216 226.816-168.448 0-300.032 117.248-300.032 263.168 7.168 22.016 14.848 44.032 14.848 58.368z m467.968 132.096c-7.168 7.168-7.168 7.168-7.168 14.848l14.848 51.2L819.2 844.8h-14.848c-29.184 7.168-66.048 14.848-95.232 14.848-146.432 0-270.848-102.4-270.848-226.816 0-131.584 124.416-233.984 270.848-233.984s270.848 102.4 270.848 226.816c0 65.536-36.352 123.904-109.568 182.784z" p-id="3884"></path><path d="M804.352 508.416c-14.848 0-36.352 14.848-36.352 36.352 0 14.848 14.848 36.352 36.352 36.352 29.184 0 44.032-14.848 44.032-36.352 0-14.336-14.336-36.352-44.032-36.352z" p-id="3885"></path></svg>', Ur = '<svg t="1764511425462" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5097" width="32" height="32"><path d="M820.409449 797.228346q0 25.19685-10.07874 46.866142t-27.716535 38.299213-41.322835 26.204724-50.897638 9.574803l-357.795276 0q-27.212598 0-50.897638-9.574803t-41.322835-26.204724-27.716535-38.299213-10.07874-46.866142l0-675.275591q0-25.19685 10.07874-47.370079t27.716535-38.80315 41.322835-26.204724 50.897638-9.574803l357.795276 0q27.212598 0 50.897638 9.574803t41.322835 26.204724 27.716535 38.80315 10.07874 47.370079l0 675.275591zM738.771654 170.330709l-455.559055 0 0 577.511811 455.559055 0 0-577.511811zM510.992126 776.062992q-21.165354 0-36.787402 15.11811t-15.622047 37.291339q0 21.165354 15.622047 36.787402t36.787402 15.622047q22.173228 0 37.291339-15.622047t15.11811-36.787402q0-22.173228-15.11811-37.291339t-37.291339-15.11811zM591.622047 84.661417q0-8.062992-5.03937-12.598425t-11.086614-4.535433l-128 0q-5.03937 0-10.582677 4.535433t-5.543307 12.598425 5.03937 12.598425 11.086614 4.535433l128 0q6.047244 0 11.086614-4.535433t5.03937-12.598425z" p-id="5098"></path></svg>', Fr = '<svg t="1764511500570" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="10511" width="32" height="32"><path d="M768.9216 422.72768 372.06016 422.72768C378.88 365.21984 329.37984 131.42016 512.2048 125.72672c173.83424-6.59456 146.78016 213.34016 146.78016 213.34016l85.13536 0.57344c0 0 24.73984-294.4-231.91552-295.8336C232.09984 58.01984 297.82016 377.18016 289.28 422.72768c1.98656 0 4.56704 0 7.29088 0-55.88992 0-101.21216 45.34272-101.21216 101.21216l0 337.38752c0 55.88992 45.34272 101.21216 101.21216 101.21216l472.35072 0c55.88992 0 101.21216-45.34272 101.21216-101.21216L870.13376 523.93984C870.13376 468.0704 824.79104 422.72768 768.9216 422.72768zM566.4768 717.02528l0 76.84096c0 18.57536-15.1552 33.73056-33.73056 33.73056-18.57536 0-33.73056-15.1552-33.73056-33.73056l0-76.84096c-20.09088-11.69408-33.73056-33.21856-33.73056-58.12224 0-37.2736 30.208-67.4816 67.4816-67.4816 37.2736 0 67.4816 30.208 67.4816 67.4816C600.22784 683.80672 586.58816 705.3312 566.4768 717.02528z" fill="#272636" p-id="10512"></path></svg>', We = {
3363
- pwd: Fr,
3364
- phone: Ur,
3365
- wxmpSvg: Nr,
3366
- wxOpenSvg: Dr
3367
- }, zr = [
3368
- { id: "password", name: "密码登录", icon: "pwd" },
3369
- { id: "wechat", name: "微信登录", icon: "wxmpSvg", appid: "wx9378885c8390e09b" },
3370
- { id: "wechat-mp", name: "微信公众号", icon: "wxOpenSvg", appid: dn },
3371
- { id: "wechat-mp-ticket", name: "微信公众号", icon: "wxOpenSvg" },
3372
- { id: "phone", name: "手机号登录", icon: "phone" }
3373
- ], Hr = () => {
3374
- const n = window.location.hostname;
3375
- let e = [];
3376
- switch (n) {
3377
- case "kevisual.xiongxiao.me":
3378
- e = ["password", "wechat-mp"];
3379
- break;
3380
- case "kevisual.cn":
3381
- e = ["password", "wechat", "wechat-mp-ticket"];
3382
- break;
3383
- default:
3384
- e = ["password", "phone", "wechat", "wechat-mp", "wechat-mp-ticket"];
3385
- break;
3386
- }
3387
- return zr.filter((t) => e.includes(t.id));
3388
- };
3389
- class jr extends HTMLElement {
3390
- selectedMethod = "password";
3391
- loginMethods = Hr();
3392
- setLoginMethods(e) {
3393
- this.loginMethods = e, this.render();
3394
- }
3395
- constructor() {
3396
- super();
3397
- }
3398
- connectedCallback() {
3399
- this.attachShadow({ mode: "open" }), this.render(), this.bindEvents(), er();
3400
- }
3401
- #e = null;
3402
- selectLoginMethod(e) {
3403
- this.selectedMethod = e, this.render(), this.#e && (this.#e(), this.#e = null);
3404
- }
3405
- getMethodData(e) {
3406
- return this.loginMethods.find((t) => t.id === e);
3407
- }
3408
- bindEvents() {
3409
- this.shadowRoot && (this.shadowRoot.addEventListener("click", (e) => {
3410
- const r = e.target.closest(".login-method");
3411
- if (r) {
3412
- const o = r.getAttribute("data-method");
3413
- o && this.selectLoginMethod(o);
3414
- }
3415
- }), this.shadowRoot.addEventListener("submit", (e) => {
3416
- const t = e.target;
3417
- t && t.id === "loginForm" && (e.preventDefault(), this.handleLogin());
3418
- }), qr.on("login-success", () => {
3419
- console.log("收到登录成功事件,处理后续逻辑");
3420
- }));
3421
- }
3422
- handleLogin() {
3423
- const e = this.getFormData();
3424
- Jn({
3425
- loginMethod: this.selectedMethod,
3426
- data: e
3427
- }), this.dispatchEvent(new CustomEvent("login", {
3428
- detail: {
3429
- method: this.selectedMethod,
3430
- data: e
3431
- },
3432
- bubbles: !0
3433
- }));
3434
- }
3435
- getFormData() {
3436
- if (!this.shadowRoot) return {};
3437
- switch (this.selectedMethod) {
3438
- case "password":
3439
- const e = this.shadowRoot.querySelector("#username"), t = this.shadowRoot.querySelector("#password");
3440
- return {
3441
- username: e?.value || "",
3442
- password: t?.value || ""
3443
- };
3444
- case "phone":
3445
- const r = this.shadowRoot.querySelector("#phone"), o = this.shadowRoot.querySelector("#code");
3446
- return {
3447
- phone: r?.value || "",
3448
- code: o?.value || ""
3449
- };
3450
- case "wechat":
3451
- return {
3452
- wechatCode: "mock_wechat_code"
3453
- };
3454
- case "wechat-mp":
3455
- return {
3456
- wechatMpCode: "mock_wechat_mp_code"
3457
- };
3458
- default:
3459
- return {};
3460
- }
3461
- }
3462
- renderPasswordForm() {
3463
- return I`
3464
- <form id="loginForm" class="login-form">
3465
- <div class="form-group">
3466
- <input
3467
- type="text"
3468
- id="username"
3469
- name="username"
3470
- placeholder="请输入用户名"
3471
- autocomplete="username"
3472
- required
3473
- />
3474
- </div>
3475
- <div class="form-group">
3476
- <input
3477
- type="password"
3478
- id="password"
3479
- name="password"
3480
- placeholder="请输入密码"
3481
- autocomplete="current-password"
3482
- required
3483
- />
3484
- </div>
3485
- <button type="submit" class="login-button">登录</button>
3486
- </form>
3487
- `;
3488
- }
3489
- renderPhoneForm() {
3490
- return I`
3491
- <form id="loginForm" class="login-form">
3492
- <div class="form-group">
3493
- <input
3494
- type="tel"
3495
- id="phone"
3496
- name="phone"
3497
- placeholder="请输入手机号"
3498
- pattern="[0-9]{11}"
3499
- autocomplete="tel"
3500
- required
3501
- />
3502
- </div>
3503
- <div class="form-group code-group">
3504
- <input
3505
- type="text"
3506
- id="code"
3507
- name="code"
3508
- placeholder="请输入验证码"
3509
- autocomplete="one-time-code"
3510
- required
3511
- />
3512
- <button type="button" class="code-button" @click=${this.sendVerificationCode}>获取验证码</button>
3513
- </div>
3514
- <button type="submit" class="login-button">登录</button>
3515
- </form>
3516
- `;
3517
- }
3518
- renderWechatForm() {
3519
- return I`
3520
- <div class="wechat-login">
3521
- <slot></slot>
3522
- </div>
3523
- `;
3524
- }
3525
- renderWechatMpForm() {
3526
- const e = this;
3527
- return setTimeout(() => {
3528
- const t = e.shadowRoot.querySelector("#qrcode"), { clear: r } = Br(t);
3529
- e.#e = r;
3530
- }, 0), I`
3531
- <div class="wechat-login">
3532
- <div class="qr-container">
3533
- <div class="qr-placeholder">
3534
- <canvas id='qrcode' width='300' height='300'></canvas>
3535
- <p class="qr-desc">请使用微信扫描二维码登录</p>
3536
- </div>
3537
- </div>
3538
- </div>
3539
- `;
3540
- }
3541
- renderWechatMpTicketForm() {
3542
- const e = this;
3543
- return setTimeout(async () => {
3544
- const t = await or();
3545
- if (!t) return;
3546
- const r = e.shadowRoot.querySelector(".qrcode");
3547
- if (t.url) {
3548
- r.src = t.url;
3549
- const o = sr(t.ticket);
3550
- e.#e = o;
3551
- }
3552
- }, 0), I`
3553
- <div class="wechat-login">
3554
- <div class="qr-container">
3555
- <div class="qr-placeholder">
3556
- <img class="qrcode" width="300" height="300" data-appid="" data-size="200" data-ticket=""></img>
3557
- <p class="qr-desc">请使用微信扫描二维码登录</p>
3558
- </div>
3559
- </div>
3560
- </div>
3561
- `;
3562
- }
3563
- sendVerificationCode() {
3564
- console.log("发送验证码");
3565
- }
3566
- refreshQR() {
3567
- console.log("刷新二维码");
3568
- }
3569
- renderLoginForm() {
3570
- const e = this.getMethodData(this.selectedMethod);
3571
- switch (this.selectedMethod) {
3572
- case "password":
3573
- return this.renderPasswordForm();
3574
- case "phone":
3575
- return this.renderPhoneForm();
3576
- case "wechat":
3577
- return ir({ appid: e?.appid || "" }), this.renderWechatForm();
3578
- case "wechat-mp":
3579
- return this.renderWechatMpForm();
3580
- case "wechat-mp-ticket":
3581
- return this.renderWechatMpTicketForm();
3582
- default:
3583
- return this.renderPasswordForm();
3584
- }
3585
- }
3586
- render() {
3587
- if (!this.shadowRoot) return;
3588
- const e = (r) => typeof r == "string" && !We[r] ? I`<span class="method-icon-emoji">${r}</span>` : typeof r == "string" && We[r] ? I`<span class="method-icon-svg">${at(We[r])}</span>` : typeof r == "string" && (r.includes("<svg") || r.includes("<?xml")) ? I`<span class="method-icon-svg">${at(r)}</span>` : I`<span class="method-icon-emoji">${r}</span>`, t = I`
3589
- <style>
3590
- :host {
3591
- display: block;
3592
- width: 100%;
3593
- min-width: 400px;
3594
- font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
3595
- }
3596
-
3597
- .login-sidebar {
3598
- background: white;
3599
- border-radius: 12px;
3600
- box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
3601
- overflow: hidden;
3602
- }
3603
-
3604
- .login-methods {
3605
- display: flex;
3606
- background: #f8f9fa;
3607
- border-bottom: 1px solid #e9ecef;
3608
- }
3609
-
3610
- .login-method {
3611
- flex: 1;
3612
- padding: 16px 8px;
3613
- border: none;
3614
- background: none;
3615
- cursor: pointer;
3616
- display: flex;
3617
- flex-direction: column;
3618
- align-items: center;
3619
- gap: 4px;
3620
- transition: all 0.3s ease;
3621
- position: relative;
3622
- }
3623
-
3624
- .login-method:hover {
3625
- background: #e9ecef;
3626
- }
3627
-
3628
- .login-method.active {
3629
- background: white;
3630
- color: #000000;
3631
- }
3632
-
3633
- .login-method.active::after {
3634
- content: '';
3635
- position: absolute;
3636
- bottom: 0;
3637
- left: 0;
3638
- right: 0;
3639
- height: 2px;
3640
- background: #000000;
3641
- }
3642
-
3643
- .method-icon {
3644
- font-size: 20px;
3645
- display: flex;
3646
- align-items: center;
3647
- justify-content: center;
3648
- width: 24px;
3649
- height: 24px;
3650
- }
3651
-
3652
- .method-icon-emoji {
3653
- font-size: 20px;
3654
- line-height: 1;
3655
- }
3656
-
3657
- .method-icon-svg {
3658
- display: flex;
3659
- align-items: center;
3660
- justify-content: center;
3661
- }
3662
-
3663
- .method-icon-svg svg {
3664
- width: 32px;
3665
- height: 32px;
3666
- display: block;
3667
- }
3668
-
3669
- .method-name {
3670
- font-size: 12px;
3671
- font-weight: 500;
3672
- }
3673
-
3674
- .login-content {
3675
- padding: 32px 24px;
3676
- }
3677
- .impowerBox .qrcode {
3678
- width: 200px !important;
3679
- }
3680
- .login-form {
3681
- display: flex;
3682
- flex-direction: column;
3683
- gap: 16px;
3684
- }
3685
-
3686
- .form-group {
3687
- position: relative;
3688
- }
3689
-
3690
- .form-group input {
3691
- width: 100%;
3692
- padding: 12px 16px;
3693
- border: 2px solid #e9ecef;
3694
- border-radius: 8px;
3695
- font-size: 14px;
3696
- transition: border-color 0.3s ease;
3697
- box-sizing: border-box;
3698
- }
3699
-
3700
- .form-group input:focus {
3701
- outline: none;
3702
- border-color: #000000;
3703
- }
3704
-
3705
- .code-group {
3706
- display: flex;
3707
- gap: 12px;
3708
- }
3709
-
3710
- .code-group input {
3711
- flex: 1;
3712
- }
3713
-
3714
- .code-button {
3715
- padding: 0 16px;
3716
- background: #6c757d;
3717
- color: white;
3718
- border: none;
3719
- border-radius: 8px;
3720
- font-size: 14px;
3721
- cursor: pointer;
3722
- white-space: nowrap;
3723
- transition: background-color 0.3s ease;
3724
- }
3725
-
3726
- .code-button:hover {
3727
- background: #5a6268;
3728
- }
3729
-
3730
- .login-button {
3731
- padding: 12px;
3732
- background: #000000;
3733
- color: white;
3734
- border: none;
3735
- border-radius: 8px;
3736
- font-size: 16px;
3737
- font-weight: 500;
3738
- cursor: pointer;
3739
- transition: background-color 0.3s ease;
3740
- }
3741
-
3742
- .login-button:hover {
3743
- background: #333333;
3744
- }
3745
-
3746
- .wechat-login {
3747
- display: flex;
3748
- flex-direction: column;
3749
- align-items: center;
3750
- gap: 20px;
3751
- }
3752
-
3753
- .qr-container {
3754
- width: 340px;
3755
- height: 340px;
3756
- border: 2px dashed #cccccc;
3757
- border-radius: 8px;
3758
- display: flex;
3759
- align-items: center;
3760
- justify-content: center;
3761
- }
3762
-
3763
- .qr-placeholder {
3764
- text-align: center;
3765
- color: #6c757d;
3766
- }
3767
-
3768
- .qr-icon {
3769
- font-size: 48px;
3770
- margin-bottom: 8px;
3771
- }
3772
-
3773
- .qr-desc {
3774
- font-size: 12px;
3775
- margin-top: 4px;
3776
- }
3777
-
3778
- .refresh-button {
3779
- padding: 8px 16px;
3780
- background: #6c757d;
3781
- color: white;
3782
- border: none;
3783
- border-radius: 6px;
3784
- font-size: 14px;
3785
- cursor: pointer;
3786
- transition: background-color 0.3s ease;
3787
- }
3788
-
3789
- .refresh-button:hover {
3790
- background: #5a6268;
3791
- }
3792
- .method-icon svg {
3793
- width: 24px;
3794
- height: 24px;
3795
- }
3796
- </style>
3797
-
3798
- <div class="login-sidebar">
3799
- <div class="login-methods">
3800
- ${this.loginMethods.map((r) => I`
3801
- <button
3802
- class="login-method ${this.selectedMethod === r.id ? "active" : ""}"
3803
- data-method="${r.id}"
3804
- >
3805
- ${e(r.icon)}
3806
- <span class="method-name">${r.name}</span>
3807
- </button>
3808
- `)}
3809
- </div>
3810
-
3811
- <div class="login-content">
3812
- ${this.renderLoginForm()}
3813
- </div>
3814
- </div>
3815
- `;
3816
- Jt(t, this.shadowRoot);
3817
- }
3818
- }
3819
- customElements.define("kv-login", jr);