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