@kevisual/kv-login 0.0.1 → 0.0.3
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 +1063 -955
- package/dist/kv-login.umd.js +63 -28
- package/package.json +2 -2
- package/readme.md +7 -0
- package/src/modules/login-handle.ts +52 -3
- package/src/pages/kv-login.ts +101 -18
package/dist/kv-login.es.js
CHANGED
|
@@ -1,68 +1,68 @@
|
|
|
1
|
-
const
|
|
2
|
-
\f\r]`,
|
|
3
|
-
\f\r"'\`<>=]|("|')|))|$)`, "g"),
|
|
4
|
-
function
|
|
5
|
-
if (!
|
|
6
|
-
return
|
|
7
|
-
}
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
let o, s = e === 2 ? "<svg>" : e === 3 ? "<math>" : "", i =
|
|
11
|
-
for (let c = 0; c <
|
|
1
|
+
const je = globalThis, le = je.trustedTypes, Ge = le ? le.createPolicy("lit-html", { createHTML: (t) => t }) : void 0, Pt = "$lit$", H = `lit$${Math.random().toFixed(9).slice(2)}$`, qt = "?" + H, rn = `<${qt}>`, W = document, ne = () => W.createComment(""), re = (t) => t === null || typeof t != "object" && typeof t != "function", Ve = Array.isArray, on = (t) => Ve(t) || typeof t?.[Symbol.iterator] == "function", pe = `[
|
|
2
|
+
\f\r]`, ee = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, Ye = /-->/g, Xe = />/g, j = RegExp(`>|${pe}(?:([^\\s"'>=/]+)(${pe}*=${pe}*(?:[^
|
|
3
|
+
\f\r"'\`<>=]|("|')|))|$)`, "g"), Ze = /'/g, et = /"/g, Dt = /^(?:script|style|textarea|title)$/i, sn = (t) => (e, ...r) => ({ _$litType$: t, strings: e, values: r }), L = sn(1), Y = Symbol.for("lit-noChange"), M = Symbol.for("lit-nothing"), tt = /* @__PURE__ */ new WeakMap(), V = W.createTreeWalker(W, 129);
|
|
4
|
+
function Nt(t, e) {
|
|
5
|
+
if (!Ve(t) || !t.hasOwnProperty("raw")) throw Error("invalid template strings array");
|
|
6
|
+
return Ge !== void 0 ? Ge.createHTML(e) : e;
|
|
7
|
+
}
|
|
8
|
+
const an = (t, e) => {
|
|
9
|
+
const r = t.length - 1, n = [];
|
|
10
|
+
let o, s = e === 2 ? "<svg>" : e === 3 ? "<math>" : "", i = ee;
|
|
11
|
+
for (let c = 0; c < r; c++) {
|
|
12
12
|
const a = t[c];
|
|
13
|
-
let
|
|
14
|
-
for (; f < a.length && (i.lastIndex = f,
|
|
15
|
-
const d = i ===
|
|
16
|
-
s += i ===
|
|
13
|
+
let l, u, h = -1, f = 0;
|
|
14
|
+
for (; f < a.length && (i.lastIndex = f, u = i.exec(a), u !== null); ) f = i.lastIndex, i === ee ? u[1] === "!--" ? i = Ye : u[1] !== void 0 ? i = Xe : u[2] !== void 0 ? (Dt.test(u[2]) && (o = RegExp("</" + u[2], "g")), i = j) : u[3] !== void 0 && (i = j) : i === j ? u[0] === ">" ? (i = o ?? ee, h = -1) : u[1] === void 0 ? h = -2 : (h = i.lastIndex - u[2].length, l = u[1], i = u[3] === void 0 ? j : u[3] === '"' ? et : Ze) : i === et || i === Ze ? i = j : i === Ye || i === Xe ? i = ee : (i = j, o = void 0);
|
|
15
|
+
const d = i === j && t[c + 1].startsWith("/>") ? " " : "";
|
|
16
|
+
s += i === ee ? a + rn : h >= 0 ? (n.push(l), a.slice(0, h) + Pt + a.slice(h) + H + d) : a + H + (h === -2 ? c : d);
|
|
17
17
|
}
|
|
18
|
-
return [
|
|
18
|
+
return [Nt(t, s + (t[r] || "<?>") + (e === 2 ? "</svg>" : e === 3 ? "</math>" : "")), n];
|
|
19
19
|
};
|
|
20
20
|
class oe {
|
|
21
|
-
constructor({ strings: e, _$litType$:
|
|
21
|
+
constructor({ strings: e, _$litType$: r }, n) {
|
|
22
22
|
let o;
|
|
23
23
|
this.parts = [];
|
|
24
24
|
let s = 0, i = 0;
|
|
25
|
-
const c = e.length - 1, a = this.parts, [
|
|
26
|
-
if (this.el = oe.createElement(
|
|
25
|
+
const c = e.length - 1, a = this.parts, [l, u] = an(e, r);
|
|
26
|
+
if (this.el = oe.createElement(l, n), V.currentNode = this.el.content, r === 2 || r === 3) {
|
|
27
27
|
const h = this.el.content.firstChild;
|
|
28
28
|
h.replaceWith(...h.childNodes);
|
|
29
29
|
}
|
|
30
|
-
for (; (o =
|
|
30
|
+
for (; (o = V.nextNode()) !== null && a.length < c; ) {
|
|
31
31
|
if (o.nodeType === 1) {
|
|
32
|
-
if (o.hasAttributes()) for (const h of o.getAttributeNames()) if (h.endsWith(
|
|
33
|
-
const f =
|
|
34
|
-
a.push({ type: 1, index: s, name: w[2], strings: d, ctor: w[1] === "." ?
|
|
35
|
-
} else h.startsWith(
|
|
36
|
-
if (
|
|
37
|
-
const h = o.textContent.split(
|
|
32
|
+
if (o.hasAttributes()) for (const h of o.getAttributeNames()) if (h.endsWith(Pt)) {
|
|
33
|
+
const f = u[i++], d = o.getAttribute(h).split(H), w = /([.?@])?(.*)/.exec(f);
|
|
34
|
+
a.push({ type: 1, index: s, name: w[2], strings: d, ctor: w[1] === "." ? ln : w[1] === "?" ? un : w[1] === "@" ? hn : ue }), o.removeAttribute(h);
|
|
35
|
+
} else h.startsWith(H) && (a.push({ type: 6, index: s }), o.removeAttribute(h));
|
|
36
|
+
if (Dt.test(o.tagName)) {
|
|
37
|
+
const h = o.textContent.split(H), f = h.length - 1;
|
|
38
38
|
if (f > 0) {
|
|
39
|
-
o.textContent =
|
|
40
|
-
for (let d = 0; d < f; d++) o.append(h[d],
|
|
41
|
-
o.append(h[f],
|
|
39
|
+
o.textContent = le ? le.emptyScript : "";
|
|
40
|
+
for (let d = 0; d < f; d++) o.append(h[d], ne()), V.nextNode(), a.push({ type: 2, index: ++s });
|
|
41
|
+
o.append(h[f], ne());
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
|
-
} else if (o.nodeType === 8) if (o.data ===
|
|
44
|
+
} else if (o.nodeType === 8) if (o.data === qt) a.push({ type: 2, index: s });
|
|
45
45
|
else {
|
|
46
46
|
let h = -1;
|
|
47
|
-
for (; (h = o.data.indexOf(
|
|
47
|
+
for (; (h = o.data.indexOf(H, h + 1)) !== -1; ) a.push({ type: 7, index: s }), h += H.length - 1;
|
|
48
48
|
}
|
|
49
49
|
s++;
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
|
-
static createElement(e,
|
|
53
|
-
const
|
|
54
|
-
return
|
|
52
|
+
static createElement(e, r) {
|
|
53
|
+
const n = W.createElement("template");
|
|
54
|
+
return n.innerHTML = e, n;
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
|
-
function
|
|
58
|
-
if (e ===
|
|
59
|
-
let o =
|
|
60
|
-
const s =
|
|
61
|
-
return o?.constructor !== s && (o?._$AO?.(!1), s === void 0 ? o = void 0 : (o = new s(t), o._$AT(t,
|
|
57
|
+
function X(t, e, r = t, n) {
|
|
58
|
+
if (e === Y) return e;
|
|
59
|
+
let o = n !== void 0 ? r._$Co?.[n] : r._$Cl;
|
|
60
|
+
const s = re(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, r, n)), n !== void 0 ? (r._$Co ??= [])[n] = o : r._$Cl = o), o !== void 0 && (e = X(t, o._$AS(t, e.values), o, n)), e;
|
|
62
62
|
}
|
|
63
|
-
class
|
|
64
|
-
constructor(e,
|
|
65
|
-
this._$AV = [], this._$AN = void 0, this._$AD = e, this._$AM =
|
|
63
|
+
class cn {
|
|
64
|
+
constructor(e, r) {
|
|
65
|
+
this._$AV = [], this._$AN = void 0, this._$AD = e, this._$AM = r;
|
|
66
66
|
}
|
|
67
67
|
get parentNode() {
|
|
68
68
|
return this._$AM.parentNode;
|
|
@@ -71,34 +71,34 @@ class on {
|
|
|
71
71
|
return this._$AM._$AU;
|
|
72
72
|
}
|
|
73
73
|
u(e) {
|
|
74
|
-
const { el: { content:
|
|
75
|
-
|
|
76
|
-
let s =
|
|
74
|
+
const { el: { content: r }, parts: n } = this._$AD, o = (e?.creationScope ?? W).importNode(r, !0);
|
|
75
|
+
V.currentNode = o;
|
|
76
|
+
let s = V.nextNode(), i = 0, c = 0, a = n[0];
|
|
77
77
|
for (; a !== void 0; ) {
|
|
78
78
|
if (i === a.index) {
|
|
79
|
-
let
|
|
80
|
-
a.type === 2 ?
|
|
79
|
+
let l;
|
|
80
|
+
a.type === 2 ? l = new ie(s, s.nextSibling, this, e) : a.type === 1 ? l = new a.ctor(s, a.name, a.strings, this, e) : a.type === 6 && (l = new dn(s, this, e)), this._$AV.push(l), a = n[++c];
|
|
81
81
|
}
|
|
82
|
-
i !== a?.index && (s =
|
|
82
|
+
i !== a?.index && (s = V.nextNode(), i++);
|
|
83
83
|
}
|
|
84
|
-
return
|
|
84
|
+
return V.currentNode = W, o;
|
|
85
85
|
}
|
|
86
86
|
p(e) {
|
|
87
|
-
let
|
|
88
|
-
for (const
|
|
87
|
+
let r = 0;
|
|
88
|
+
for (const n of this._$AV) n !== void 0 && (n.strings !== void 0 ? (n._$AI(e, n, r), r += n.strings.length - 2) : n._$AI(e[r])), r++;
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
|
-
class
|
|
91
|
+
class ie {
|
|
92
92
|
get _$AU() {
|
|
93
93
|
return this._$AM?._$AU ?? this._$Cv;
|
|
94
94
|
}
|
|
95
|
-
constructor(e,
|
|
96
|
-
this.type = 2, this._$AH =
|
|
95
|
+
constructor(e, r, n, o) {
|
|
96
|
+
this.type = 2, this._$AH = M, this._$AN = void 0, this._$AA = e, this._$AB = r, this._$AM = n, this.options = o, this._$Cv = o?.isConnected ?? !0;
|
|
97
97
|
}
|
|
98
98
|
get parentNode() {
|
|
99
99
|
let e = this._$AA.parentNode;
|
|
100
|
-
const
|
|
101
|
-
return
|
|
100
|
+
const r = this._$AM;
|
|
101
|
+
return r !== void 0 && e?.nodeType === 11 && (e = r.parentNode), e;
|
|
102
102
|
}
|
|
103
103
|
get startNode() {
|
|
104
104
|
return this._$AA;
|
|
@@ -106,8 +106,8 @@ class se {
|
|
|
106
106
|
get endNode() {
|
|
107
107
|
return this._$AB;
|
|
108
108
|
}
|
|
109
|
-
_$AI(e,
|
|
110
|
-
e =
|
|
109
|
+
_$AI(e, r = this) {
|
|
110
|
+
e = X(this, e, r), re(e) ? e === M || e == null || e === "" ? (this._$AH !== M && this._$AR(), this._$AH = M) : e !== this._$AH && e !== Y && this._(e) : e._$litType$ !== void 0 ? this.$(e) : e.nodeType !== void 0 ? this.T(e) : on(e) ? this.k(e) : this._(e);
|
|
111
111
|
}
|
|
112
112
|
O(e) {
|
|
113
113
|
return this._$AA.parentNode.insertBefore(e, this._$AB);
|
|
@@ -116,150 +116,183 @@ class se {
|
|
|
116
116
|
this._$AH !== e && (this._$AR(), this._$AH = this.O(e));
|
|
117
117
|
}
|
|
118
118
|
_(e) {
|
|
119
|
-
this._$AH !==
|
|
119
|
+
this._$AH !== M && re(this._$AH) ? this._$AA.nextSibling.data = e : this.T(W.createTextNode(e)), this._$AH = e;
|
|
120
120
|
}
|
|
121
121
|
$(e) {
|
|
122
|
-
const { values:
|
|
123
|
-
if (this._$AH?._$AD === o) this._$AH.p(
|
|
122
|
+
const { values: r, _$litType$: n } = e, o = typeof n == "number" ? this._$AC(e) : (n.el === void 0 && (n.el = oe.createElement(Nt(n.h, n.h[0]), this.options)), n);
|
|
123
|
+
if (this._$AH?._$AD === o) this._$AH.p(r);
|
|
124
124
|
else {
|
|
125
|
-
const s = new
|
|
126
|
-
s.p(
|
|
125
|
+
const s = new cn(o, this), i = s.u(this.options);
|
|
126
|
+
s.p(r), this.T(i), this._$AH = s;
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
129
|
_$AC(e) {
|
|
130
|
-
let
|
|
131
|
-
return
|
|
130
|
+
let r = tt.get(e.strings);
|
|
131
|
+
return r === void 0 && tt.set(e.strings, r = new oe(e)), r;
|
|
132
132
|
}
|
|
133
133
|
k(e) {
|
|
134
|
-
|
|
135
|
-
const
|
|
136
|
-
let
|
|
137
|
-
for (const s of e) o ===
|
|
138
|
-
o <
|
|
139
|
-
}
|
|
140
|
-
_$AR(e = this._$AA.nextSibling,
|
|
141
|
-
for (this._$AP?.(!1, !0,
|
|
142
|
-
const
|
|
143
|
-
e.remove(), e =
|
|
134
|
+
Ve(this._$AH) || (this._$AH = [], this._$AR());
|
|
135
|
+
const r = this._$AH;
|
|
136
|
+
let n, o = 0;
|
|
137
|
+
for (const s of e) o === r.length ? r.push(n = new ie(this.O(ne()), this.O(ne()), this, this.options)) : n = r[o], n._$AI(s), o++;
|
|
138
|
+
o < r.length && (this._$AR(n && n._$AB.nextSibling, o), r.length = o);
|
|
139
|
+
}
|
|
140
|
+
_$AR(e = this._$AA.nextSibling, r) {
|
|
141
|
+
for (this._$AP?.(!1, !0, r); e !== this._$AB; ) {
|
|
142
|
+
const n = e.nextSibling;
|
|
143
|
+
e.remove(), e = n;
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
146
|
setConnected(e) {
|
|
147
147
|
this._$AM === void 0 && (this._$Cv = e, this._$AP?.(e));
|
|
148
148
|
}
|
|
149
149
|
}
|
|
150
|
-
class
|
|
150
|
+
class ue {
|
|
151
151
|
get tagName() {
|
|
152
152
|
return this.element.tagName;
|
|
153
153
|
}
|
|
154
154
|
get _$AU() {
|
|
155
155
|
return this._$AM._$AU;
|
|
156
156
|
}
|
|
157
|
-
constructor(e,
|
|
158
|
-
this.type = 1, this._$AH =
|
|
157
|
+
constructor(e, r, n, o, s) {
|
|
158
|
+
this.type = 1, this._$AH = M, this._$AN = void 0, this.element = e, this.name = r, this._$AM = o, this.options = s, n.length > 2 || n[0] !== "" || n[1] !== "" ? (this._$AH = Array(n.length - 1).fill(new String()), this.strings = n) : this._$AH = M;
|
|
159
159
|
}
|
|
160
|
-
_$AI(e,
|
|
160
|
+
_$AI(e, r = this, n, o) {
|
|
161
161
|
const s = this.strings;
|
|
162
162
|
let i = !1;
|
|
163
|
-
if (s === void 0) e =
|
|
163
|
+
if (s === void 0) e = X(this, e, r, 0), i = !re(e) || e !== this._$AH && e !== Y, i && (this._$AH = e);
|
|
164
164
|
else {
|
|
165
165
|
const c = e;
|
|
166
|
-
let a,
|
|
167
|
-
for (e = s[0], a = 0; a < s.length - 1; a++)
|
|
166
|
+
let a, l;
|
|
167
|
+
for (e = s[0], a = 0; a < s.length - 1; a++) l = X(this, c[n + a], r, a), l === Y && (l = this._$AH[a]), i ||= !re(l) || l !== this._$AH[a], l === M ? e = M : e !== M && (e += (l ?? "") + s[a + 1]), this._$AH[a] = l;
|
|
168
168
|
}
|
|
169
169
|
i && !o && this.j(e);
|
|
170
170
|
}
|
|
171
171
|
j(e) {
|
|
172
|
-
e ===
|
|
172
|
+
e === M ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, e ?? "");
|
|
173
173
|
}
|
|
174
174
|
}
|
|
175
|
-
class
|
|
175
|
+
class ln extends ue {
|
|
176
176
|
constructor() {
|
|
177
177
|
super(...arguments), this.type = 3;
|
|
178
178
|
}
|
|
179
179
|
j(e) {
|
|
180
|
-
this.element[this.name] = e ===
|
|
180
|
+
this.element[this.name] = e === M ? void 0 : e;
|
|
181
181
|
}
|
|
182
182
|
}
|
|
183
|
-
class
|
|
183
|
+
class un extends ue {
|
|
184
184
|
constructor() {
|
|
185
185
|
super(...arguments), this.type = 4;
|
|
186
186
|
}
|
|
187
187
|
j(e) {
|
|
188
|
-
this.element.toggleAttribute(this.name, !!e && e !==
|
|
188
|
+
this.element.toggleAttribute(this.name, !!e && e !== M);
|
|
189
189
|
}
|
|
190
190
|
}
|
|
191
|
-
class
|
|
192
|
-
constructor(e,
|
|
193
|
-
super(e,
|
|
191
|
+
class hn extends ue {
|
|
192
|
+
constructor(e, r, n, o, s) {
|
|
193
|
+
super(e, r, n, o, s), this.type = 5;
|
|
194
194
|
}
|
|
195
|
-
_$AI(e,
|
|
196
|
-
if ((e =
|
|
197
|
-
const
|
|
198
|
-
o && this.element.removeEventListener(this.name, this,
|
|
195
|
+
_$AI(e, r = this) {
|
|
196
|
+
if ((e = X(this, e, r, 0) ?? M) === Y) return;
|
|
197
|
+
const n = this._$AH, o = e === M && n !== M || e.capture !== n.capture || e.once !== n.once || e.passive !== n.passive, s = e !== M && (n === M || o);
|
|
198
|
+
o && this.element.removeEventListener(this.name, this, n), s && this.element.addEventListener(this.name, this, e), this._$AH = e;
|
|
199
199
|
}
|
|
200
200
|
handleEvent(e) {
|
|
201
201
|
typeof this._$AH == "function" ? this._$AH.call(this.options?.host ?? this.element, e) : this._$AH.handleEvent(e);
|
|
202
202
|
}
|
|
203
203
|
}
|
|
204
|
-
class
|
|
205
|
-
constructor(e,
|
|
206
|
-
this.element = e, this.type = 6, this._$AN = void 0, this._$AM =
|
|
204
|
+
class dn {
|
|
205
|
+
constructor(e, r, n) {
|
|
206
|
+
this.element = e, this.type = 6, this._$AN = void 0, this._$AM = r, this.options = n;
|
|
207
207
|
}
|
|
208
208
|
get _$AU() {
|
|
209
209
|
return this._$AM._$AU;
|
|
210
210
|
}
|
|
211
211
|
_$AI(e) {
|
|
212
|
-
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
const
|
|
216
|
-
|
|
217
|
-
const
|
|
218
|
-
const
|
|
219
|
-
let o =
|
|
220
|
-
return o === void 0 && (
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
|
|
212
|
+
X(this, e);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
const fn = je.litHtmlPolyfillSupport;
|
|
216
|
+
fn?.(oe, ie), (je.litHtmlVersions ??= []).push("3.3.1");
|
|
217
|
+
const Ut = (t, e, r) => {
|
|
218
|
+
const n = e;
|
|
219
|
+
let o = n._$litPart$;
|
|
220
|
+
return o === void 0 && (n._$litPart$ = o = new ie(e.insertBefore(ne(), null), null, void 0, {})), o._$AI(t), o;
|
|
221
|
+
};
|
|
222
|
+
const gn = { CHILD: 2 }, pn = (t) => (...e) => ({ _$litDirective$: t, values: e });
|
|
223
|
+
class mn {
|
|
224
|
+
constructor(e) {
|
|
225
|
+
}
|
|
226
|
+
get _$AU() {
|
|
227
|
+
return this._$AM._$AU;
|
|
228
|
+
}
|
|
229
|
+
_$AT(e, r, n) {
|
|
230
|
+
this._$Ct = e, this._$AM = r, this._$Ci = n;
|
|
231
|
+
}
|
|
232
|
+
_$AS(e, r) {
|
|
233
|
+
return this.update(e, r);
|
|
234
|
+
}
|
|
235
|
+
update(e, r) {
|
|
236
|
+
return this.render(...r);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
class He extends mn {
|
|
240
|
+
constructor(e) {
|
|
241
|
+
if (super(e), this.it = M, e.type !== gn.CHILD) throw Error(this.constructor.directiveName + "() can only be used in child bindings");
|
|
242
|
+
}
|
|
243
|
+
render(e) {
|
|
244
|
+
if (e === M || e == null) return this._t = void 0, this.it = e;
|
|
245
|
+
if (e === Y) return e;
|
|
246
|
+
if (typeof e != "string") throw Error(this.constructor.directiveName + "() called with a non-string value");
|
|
247
|
+
if (e === this.it) return this._t;
|
|
248
|
+
this.it = e;
|
|
249
|
+
const r = [e];
|
|
250
|
+
return r.raw = r, this._t = { _$litType$: this.constructor.resultType, strings: r, values: [] };
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
He.directiveName = "unsafeHTML", He.resultType = 1;
|
|
254
|
+
const nt = pn(He), wn = (t) => t ? ["text/", "xml", "html", "javascript", "css", "csv", "plain", "x-www-form-urlencoded"].some((r) => t.includes(r)) : !1, rt = async (t = {}, e) => {
|
|
255
|
+
const r = new AbortController(), n = r.signal, o = t.isBlob || !1, s = t.isText || !1, i = t.isPostFile || !1, c = t.timeout || 6e4 * 3, a = setTimeout(() => {
|
|
256
|
+
r.abort();
|
|
224
257
|
}, c);
|
|
225
|
-
let
|
|
258
|
+
let l = e?.method || t?.method || "POST", u = { ...t?.headers, ...e?.headers }, h = "", f;
|
|
226
259
|
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 =
|
|
260
|
+
const d = l === "GET";
|
|
228
261
|
d && (f.search = new URLSearchParams(t.body).toString());
|
|
229
262
|
let w;
|
|
230
|
-
return d ? w = void 0 : i ? w = t.body : (
|
|
263
|
+
return d ? w = void 0 : i ? w = t.body : (u = {
|
|
231
264
|
"Content-Type": "application/json",
|
|
232
|
-
...
|
|
265
|
+
...u
|
|
233
266
|
}, w = JSON.stringify(t.body)), fetch(f, {
|
|
234
|
-
method:
|
|
235
|
-
signal:
|
|
267
|
+
method: l.toUpperCase(),
|
|
268
|
+
signal: n,
|
|
236
269
|
body: w,
|
|
237
270
|
...e,
|
|
238
|
-
headers:
|
|
239
|
-
}).then(async (
|
|
240
|
-
const
|
|
241
|
-
return o ? await
|
|
271
|
+
headers: u
|
|
272
|
+
}).then(async (p) => {
|
|
273
|
+
const B = p.headers.get("Content-Type");
|
|
274
|
+
return o ? await p.blob() : B && B.includes("application/json") && !s ? await p.json() : wn(B) ? {
|
|
242
275
|
code: 200,
|
|
243
|
-
status:
|
|
244
|
-
data: await
|
|
276
|
+
status: p.status,
|
|
277
|
+
data: await p.text()
|
|
245
278
|
// 直接返回文本内容
|
|
246
|
-
} :
|
|
247
|
-
}).catch((
|
|
279
|
+
} : p;
|
|
280
|
+
}).catch((p) => (p.name === "AbortError" && console.log("Request timed out and was aborted"), console.error(p), {
|
|
248
281
|
code: 500
|
|
249
282
|
})).finally(() => {
|
|
250
283
|
clearTimeout(a);
|
|
251
284
|
});
|
|
252
|
-
},
|
|
285
|
+
}, ot = (t) => (t.success = t.code === 200, t.showError = (e) => {
|
|
253
286
|
!t.success && !t.noMsg && e?.();
|
|
254
|
-
}, t),
|
|
287
|
+
}, t), me = ({ code: t, message: e }) => ({
|
|
255
288
|
code: t || 500,
|
|
256
289
|
success: !1,
|
|
257
290
|
message: e || "api request error",
|
|
258
|
-
showError: (
|
|
291
|
+
showError: (n) => {
|
|
259
292
|
},
|
|
260
293
|
noMsg: !0
|
|
261
294
|
});
|
|
262
|
-
class
|
|
295
|
+
class Ft {
|
|
263
296
|
adapter;
|
|
264
297
|
url;
|
|
265
298
|
beforeRequest;
|
|
@@ -273,7 +306,7 @@ class Dt {
|
|
|
273
306
|
// 默认不使用ws
|
|
274
307
|
qws;
|
|
275
308
|
constructor(e) {
|
|
276
|
-
this.adapter = e?.adapter ||
|
|
309
|
+
this.adapter = e?.adapter || rt, this.url = e?.url || "/api/router", this.headers = e?.headers || {
|
|
277
310
|
"Content-Type": "application/json"
|
|
278
311
|
}, this.timeout = e?.timeout || 6e4 * 3;
|
|
279
312
|
}
|
|
@@ -294,8 +327,8 @@ class Dt {
|
|
|
294
327
|
* @param options 请求配置
|
|
295
328
|
* @returns 请求结果
|
|
296
329
|
*/
|
|
297
|
-
async get(e,
|
|
298
|
-
return this.post(e,
|
|
330
|
+
async get(e, r) {
|
|
331
|
+
return this.post(e, r);
|
|
299
332
|
}
|
|
300
333
|
/**
|
|
301
334
|
* 发送 post 请求
|
|
@@ -305,46 +338,46 @@ class Dt {
|
|
|
305
338
|
* @param options 请求配置
|
|
306
339
|
* @returns 请求结果
|
|
307
340
|
*/
|
|
308
|
-
async post(e,
|
|
309
|
-
const
|
|
310
|
-
url:
|
|
311
|
-
headers:
|
|
341
|
+
async post(e, r) {
|
|
342
|
+
const n = r?.url || this.url, { headers: o, adapter: s, beforeRequest: i, afterResponse: c, timeout: a, ...l } = r || {}, u = { ...this.headers, ...o }, h = s || this.adapter, f = i || this.beforeRequest, d = c || this.afterResponse, w = a || this.timeout, p = {
|
|
343
|
+
url: n,
|
|
344
|
+
headers: u,
|
|
312
345
|
body: e,
|
|
313
346
|
timeout: w,
|
|
314
|
-
...
|
|
347
|
+
...l
|
|
315
348
|
};
|
|
316
349
|
try {
|
|
317
|
-
if (f && await f(
|
|
318
|
-
return
|
|
350
|
+
if (f && await f(p) === !1)
|
|
351
|
+
return me({
|
|
319
352
|
code: 500,
|
|
320
353
|
message: "request is cancel",
|
|
321
354
|
// @ts-ignore
|
|
322
|
-
req:
|
|
355
|
+
req: p
|
|
323
356
|
});
|
|
324
|
-
} catch (
|
|
325
|
-
return console.error("request beforeFn error",
|
|
357
|
+
} catch (B) {
|
|
358
|
+
return console.error("request beforeFn error", B, p), me({
|
|
326
359
|
code: 500,
|
|
327
360
|
message: "api request beforeFn error"
|
|
328
361
|
});
|
|
329
362
|
}
|
|
330
|
-
if (this.stop && !
|
|
331
|
-
const
|
|
332
|
-
await new Promise((
|
|
333
|
-
let
|
|
363
|
+
if (this.stop && !r?.noStop) {
|
|
364
|
+
const B = this;
|
|
365
|
+
await new Promise((A) => {
|
|
366
|
+
let S = 0;
|
|
334
367
|
const k = setInterval(() => {
|
|
335
|
-
|
|
368
|
+
B.stop || (clearInterval(k), A(!0)), S++, S > 30 && console.error("request stop: timeout", p.url, S);
|
|
336
369
|
}, 1e3);
|
|
337
370
|
});
|
|
338
371
|
}
|
|
339
|
-
return h(
|
|
372
|
+
return h(p).then(async (B) => {
|
|
340
373
|
try {
|
|
341
|
-
return
|
|
342
|
-
req:
|
|
343
|
-
res:
|
|
374
|
+
return ot(B), d ? await d(B, {
|
|
375
|
+
req: p,
|
|
376
|
+
res: B,
|
|
344
377
|
fetch: s
|
|
345
|
-
}) :
|
|
346
|
-
} catch (
|
|
347
|
-
return console.error("request afterFn error",
|
|
378
|
+
}) : B;
|
|
379
|
+
} catch (A) {
|
|
380
|
+
return console.error("request afterFn error", A, p), me({
|
|
348
381
|
code: 500,
|
|
349
382
|
message: "api request afterFn error"
|
|
350
383
|
});
|
|
@@ -365,21 +398,21 @@ class Dt {
|
|
|
365
398
|
after(e) {
|
|
366
399
|
this.afterResponse = e;
|
|
367
400
|
}
|
|
368
|
-
async fetchText(e,
|
|
369
|
-
let
|
|
370
|
-
typeof e == "string" && !
|
|
371
|
-
const o = await
|
|
401
|
+
async fetchText(e, r) {
|
|
402
|
+
let n = { ...r };
|
|
403
|
+
typeof e == "string" && !n.url && (n.url = e), typeof e == "object" && (n = { ...e, ...n });
|
|
404
|
+
const o = await rt({
|
|
372
405
|
method: "GET",
|
|
373
|
-
...
|
|
406
|
+
...n,
|
|
374
407
|
headers: {
|
|
375
408
|
...this.headers,
|
|
376
|
-
...
|
|
409
|
+
...n?.headers || {}
|
|
377
410
|
}
|
|
378
411
|
});
|
|
379
|
-
return
|
|
412
|
+
return ot(o);
|
|
380
413
|
}
|
|
381
414
|
}
|
|
382
|
-
class
|
|
415
|
+
class yn {
|
|
383
416
|
query;
|
|
384
417
|
queryDefine;
|
|
385
418
|
constructor(e) {
|
|
@@ -388,52 +421,52 @@ class dn {
|
|
|
388
421
|
get chain() {
|
|
389
422
|
return this.queryDefine.queryChain;
|
|
390
423
|
}
|
|
391
|
-
post(e,
|
|
392
|
-
return this.query.post(e,
|
|
424
|
+
post(e, r) {
|
|
425
|
+
return this.query.post(e, r);
|
|
393
426
|
}
|
|
394
|
-
get(e,
|
|
395
|
-
return this.query.get(e,
|
|
427
|
+
get(e, r) {
|
|
428
|
+
return this.query.get(e, r);
|
|
396
429
|
}
|
|
397
430
|
}
|
|
398
|
-
const
|
|
431
|
+
const st = (t) => (t.success = t.code === 200, t.showError = (e) => {
|
|
399
432
|
!t.success && !t.noMsg && e?.();
|
|
400
433
|
}, t);
|
|
401
|
-
function
|
|
402
|
-
return new Promise((e,
|
|
403
|
-
t.oncomplete = t.onsuccess = () => e(t.result), t.onabort = t.onerror = () =>
|
|
434
|
+
function $(t) {
|
|
435
|
+
return new Promise((e, r) => {
|
|
436
|
+
t.oncomplete = t.onsuccess = () => e(t.result), t.onabort = t.onerror = () => r(t.error);
|
|
404
437
|
});
|
|
405
438
|
}
|
|
406
|
-
function
|
|
407
|
-
const
|
|
408
|
-
|
|
409
|
-
const
|
|
410
|
-
return (o, s) =>
|
|
439
|
+
function zt(t, e) {
|
|
440
|
+
const r = indexedDB.open(t);
|
|
441
|
+
r.onupgradeneeded = () => r.result.createObjectStore(e);
|
|
442
|
+
const n = $(r);
|
|
443
|
+
return (o, s) => n.then((i) => s(i.transaction(e, o).objectStore(e)));
|
|
411
444
|
}
|
|
412
445
|
let we;
|
|
413
|
-
function
|
|
414
|
-
return we || (we =
|
|
446
|
+
function I() {
|
|
447
|
+
return we || (we = zt("keyval-store", "keyval")), we;
|
|
415
448
|
}
|
|
416
|
-
function
|
|
417
|
-
return e("readonly", (
|
|
449
|
+
function Ht(t, e = I()) {
|
|
450
|
+
return e("readonly", (r) => $(r.get(t)));
|
|
418
451
|
}
|
|
419
|
-
function
|
|
420
|
-
return
|
|
452
|
+
function jt(t, e, r = I()) {
|
|
453
|
+
return r("readwrite", (n) => (n.put(e, t), $(n.transaction)));
|
|
421
454
|
}
|
|
422
|
-
function
|
|
423
|
-
return e("readwrite", (
|
|
455
|
+
function bn(t, e = I()) {
|
|
456
|
+
return e("readwrite", (r) => (t.forEach((n) => r.put(n[1], n[0])), $(r.transaction)));
|
|
424
457
|
}
|
|
425
|
-
function
|
|
426
|
-
return e("readonly", (
|
|
458
|
+
function vn(t, e = I()) {
|
|
459
|
+
return e("readonly", (r) => Promise.all(t.map((n) => $(r.get(n)))));
|
|
427
460
|
}
|
|
428
|
-
function
|
|
429
|
-
return
|
|
461
|
+
function An(t, e, r = I()) {
|
|
462
|
+
return r("readwrite", (n) => (
|
|
430
463
|
// Need to create the promise manually.
|
|
431
464
|
// If I try to chain promises, the transaction closes in browsers
|
|
432
465
|
// that use a promise polyfill (IE10/11).
|
|
433
466
|
new Promise((o, s) => {
|
|
434
|
-
|
|
467
|
+
n.get(t).onsuccess = function() {
|
|
435
468
|
try {
|
|
436
|
-
|
|
469
|
+
n.put(e(this.result), t), o($(n.transaction));
|
|
437
470
|
} catch (i) {
|
|
438
471
|
s(i);
|
|
439
472
|
}
|
|
@@ -441,87 +474,87 @@ function mn(t, e, n = x()) {
|
|
|
441
474
|
})
|
|
442
475
|
));
|
|
443
476
|
}
|
|
444
|
-
function
|
|
445
|
-
return e("readwrite", (
|
|
477
|
+
function Vt(t, e = I()) {
|
|
478
|
+
return e("readwrite", (r) => (r.delete(t), $(r.transaction)));
|
|
446
479
|
}
|
|
447
|
-
function
|
|
448
|
-
return e("readwrite", (
|
|
480
|
+
function Cn(t, e = I()) {
|
|
481
|
+
return e("readwrite", (r) => (t.forEach((n) => r.delete(n)), $(r.transaction)));
|
|
449
482
|
}
|
|
450
|
-
function
|
|
451
|
-
return t("readwrite", (e) => (e.clear(),
|
|
483
|
+
function Wt(t = I()) {
|
|
484
|
+
return t("readwrite", (e) => (e.clear(), $(e.transaction)));
|
|
452
485
|
}
|
|
453
|
-
function
|
|
486
|
+
function We(t, e) {
|
|
454
487
|
return t.openCursor().onsuccess = function() {
|
|
455
488
|
this.result && (e(this.result), this.result.continue());
|
|
456
|
-
},
|
|
489
|
+
}, $(t.transaction);
|
|
457
490
|
}
|
|
458
|
-
function
|
|
491
|
+
function Tn(t = I()) {
|
|
459
492
|
return t("readonly", (e) => {
|
|
460
493
|
if (e.getAllKeys)
|
|
461
|
-
return
|
|
462
|
-
const
|
|
463
|
-
return
|
|
494
|
+
return $(e.getAllKeys());
|
|
495
|
+
const r = [];
|
|
496
|
+
return We(e, (n) => r.push(n.key)).then(() => r);
|
|
464
497
|
});
|
|
465
498
|
}
|
|
466
|
-
function
|
|
499
|
+
function kn(t = I()) {
|
|
467
500
|
return t("readonly", (e) => {
|
|
468
501
|
if (e.getAll)
|
|
469
|
-
return
|
|
470
|
-
const
|
|
471
|
-
return
|
|
502
|
+
return $(e.getAll());
|
|
503
|
+
const r = [];
|
|
504
|
+
return We(e, (n) => r.push(n.value)).then(() => r);
|
|
472
505
|
});
|
|
473
506
|
}
|
|
474
|
-
function
|
|
507
|
+
function En(t = I()) {
|
|
475
508
|
return t("readonly", (e) => {
|
|
476
509
|
if (e.getAll && e.getAllKeys)
|
|
477
510
|
return Promise.all([
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
]).then(([
|
|
481
|
-
const
|
|
482
|
-
return t("readonly", (
|
|
511
|
+
$(e.getAllKeys()),
|
|
512
|
+
$(e.getAll())
|
|
513
|
+
]).then(([n, o]) => n.map((s, i) => [s, o[i]]));
|
|
514
|
+
const r = [];
|
|
515
|
+
return t("readonly", (n) => We(n, (o) => r.push([o.key, o.value])).then(() => r));
|
|
483
516
|
});
|
|
484
517
|
}
|
|
485
|
-
var
|
|
518
|
+
var _n = /* @__PURE__ */ Object.freeze({
|
|
486
519
|
__proto__: null,
|
|
487
|
-
clear:
|
|
488
|
-
createStore:
|
|
489
|
-
del:
|
|
490
|
-
delMany:
|
|
491
|
-
entries:
|
|
492
|
-
get:
|
|
493
|
-
getMany:
|
|
494
|
-
keys:
|
|
495
|
-
promisifyRequest:
|
|
496
|
-
set:
|
|
497
|
-
setMany:
|
|
498
|
-
update:
|
|
499
|
-
values:
|
|
520
|
+
clear: Wt,
|
|
521
|
+
createStore: zt,
|
|
522
|
+
del: Vt,
|
|
523
|
+
delMany: Cn,
|
|
524
|
+
entries: En,
|
|
525
|
+
get: Ht,
|
|
526
|
+
getMany: vn,
|
|
527
|
+
keys: Tn,
|
|
528
|
+
promisifyRequest: $,
|
|
529
|
+
set: jt,
|
|
530
|
+
setMany: bn,
|
|
531
|
+
update: An,
|
|
532
|
+
values: kn
|
|
500
533
|
});
|
|
501
|
-
class
|
|
534
|
+
class Rn {
|
|
502
535
|
storage;
|
|
503
536
|
data = null;
|
|
504
537
|
constructor() {
|
|
505
|
-
this.storage =
|
|
538
|
+
this.storage = _n;
|
|
506
539
|
}
|
|
507
540
|
async get(e) {
|
|
508
|
-
const
|
|
509
|
-
return this.data =
|
|
541
|
+
const r = await Ht(e);
|
|
542
|
+
return this.data = r, r;
|
|
510
543
|
}
|
|
511
|
-
async set(e,
|
|
512
|
-
this.data =
|
|
544
|
+
async set(e, r) {
|
|
545
|
+
this.data = r, await jt(e, r);
|
|
513
546
|
}
|
|
514
547
|
async del(e) {
|
|
515
|
-
this.data = null, await
|
|
548
|
+
this.data = null, await Vt(e);
|
|
516
549
|
}
|
|
517
550
|
/**
|
|
518
551
|
* Clear all values in the store.
|
|
519
552
|
*/
|
|
520
553
|
async clear() {
|
|
521
|
-
await
|
|
554
|
+
await Wt();
|
|
522
555
|
}
|
|
523
556
|
}
|
|
524
|
-
class
|
|
557
|
+
class Sn extends Rn {
|
|
525
558
|
name;
|
|
526
559
|
updatedAt;
|
|
527
560
|
constructor(e) {
|
|
@@ -536,10 +569,10 @@ class Tn extends Cn {
|
|
|
536
569
|
* @param data
|
|
537
570
|
* @param opts
|
|
538
571
|
*/
|
|
539
|
-
async setData(e,
|
|
540
|
-
const o = Date.now() + (
|
|
572
|
+
async setData(e, r) {
|
|
573
|
+
const o = Date.now() + (r?.expireTime || 1e3 * 60 * 60 * 24 * 10), s = {
|
|
541
574
|
data: e,
|
|
542
|
-
updatedAt:
|
|
575
|
+
updatedAt: r?.updatedAt || Date.now(),
|
|
543
576
|
expireTime: o
|
|
544
577
|
};
|
|
545
578
|
await super.set(this.name, s), this.updatedAt = s.updatedAt;
|
|
@@ -548,7 +581,7 @@ class Tn extends Cn {
|
|
|
548
581
|
await super.del(this.name);
|
|
549
582
|
}
|
|
550
583
|
}
|
|
551
|
-
var
|
|
584
|
+
var Bn = class {
|
|
552
585
|
cache;
|
|
553
586
|
name;
|
|
554
587
|
cacheData;
|
|
@@ -607,7 +640,7 @@ var vn = class {
|
|
|
607
640
|
* @param user
|
|
608
641
|
*/
|
|
609
642
|
async setLoginUser(t) {
|
|
610
|
-
this.cacheData.loginUsers.find((
|
|
643
|
+
this.cacheData.loginUsers.find((r) => r.id === t.id) && (this.cacheData.loginUsers = this.cacheData?.loginUsers?.filter((r) => r?.id && r.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
644
|
}
|
|
612
645
|
getCurrentUser() {
|
|
613
646
|
const t = this.cacheData;
|
|
@@ -626,12 +659,12 @@ var vn = class {
|
|
|
626
659
|
}
|
|
627
660
|
async clearCurrentUser() {
|
|
628
661
|
const t = await this.getCurrentUser();
|
|
629
|
-
this.cacheData.loginUsers.find((
|
|
662
|
+
this.cacheData.loginUsers.find((r) => r.id === t.id) && (this.cacheData.loginUsers = this.cacheData?.loginUsers?.filter((r) => r?.id && r.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
663
|
}
|
|
631
664
|
async clearAll() {
|
|
632
665
|
this.cacheData.loginUsers = [], this.cacheData.user = void 0, this.cacheData.id = void 0, this.cacheData.accessToken = void 0, this.cacheData.refreshToken = void 0, await this.setValue(this.cacheData);
|
|
633
666
|
}
|
|
634
|
-
},
|
|
667
|
+
}, Mn = class extends yn {
|
|
635
668
|
/**
|
|
636
669
|
* query login cache, 非实际操作, 一个cache的包裹模块
|
|
637
670
|
*/
|
|
@@ -642,8 +675,8 @@ var vn = class {
|
|
|
642
675
|
onLoad;
|
|
643
676
|
constructor(t) {
|
|
644
677
|
super({
|
|
645
|
-
query: t?.query || new
|
|
646
|
-
}), this.cacheStore = new
|
|
678
|
+
query: t?.query || new Ft()
|
|
679
|
+
}), this.cacheStore = new Bn({ name: "login", cache: t.cache }), this.isBrowser = t?.isBrowser ?? !0, this.init(), this.onLoad = t?.onLoad, this.storage = t?.storage || localStorage;
|
|
647
680
|
}
|
|
648
681
|
setQuery(t) {
|
|
649
682
|
this.query = t;
|
|
@@ -654,8 +687,8 @@ var vn = class {
|
|
|
654
687
|
async post(t, e) {
|
|
655
688
|
try {
|
|
656
689
|
return this.query.post({ path: "user", ...t }, e);
|
|
657
|
-
} catch (
|
|
658
|
-
return console.log("error",
|
|
690
|
+
} catch (r) {
|
|
691
|
+
return console.log("error", r), {
|
|
659
692
|
code: 400
|
|
660
693
|
};
|
|
661
694
|
}
|
|
@@ -668,8 +701,8 @@ var vn = class {
|
|
|
668
701
|
async login(t) {
|
|
669
702
|
const e = await this.post({ key: "login", ...t });
|
|
670
703
|
if (e.code === 200) {
|
|
671
|
-
const { accessToken:
|
|
672
|
-
this.storage.setItem("token",
|
|
704
|
+
const { accessToken: r, refreshToken: n } = e?.data || {};
|
|
705
|
+
this.storage.setItem("token", r || ""), await this.beforeSetLoginUser({ accessToken: r, refreshToken: n });
|
|
673
706
|
}
|
|
674
707
|
return e;
|
|
675
708
|
}
|
|
@@ -681,8 +714,8 @@ var vn = class {
|
|
|
681
714
|
async loginByCode(t) {
|
|
682
715
|
const e = await this.post({ path: "sms", key: "login", data: t });
|
|
683
716
|
if (e.code === 200) {
|
|
684
|
-
const { accessToken:
|
|
685
|
-
this.storage.setItem("token",
|
|
717
|
+
const { accessToken: r, refreshToken: n } = e?.data || {};
|
|
718
|
+
this.storage.setItem("token", r || ""), await this.beforeSetLoginUser({ accessToken: r, refreshToken: n });
|
|
686
719
|
}
|
|
687
720
|
return e;
|
|
688
721
|
}
|
|
@@ -691,14 +724,14 @@ var vn = class {
|
|
|
691
724
|
* @param token
|
|
692
725
|
*/
|
|
693
726
|
async setLoginToken(t) {
|
|
694
|
-
const { accessToken: e, refreshToken:
|
|
695
|
-
this.storage.setItem("token", e || ""), await this.beforeSetLoginUser({ accessToken: e, refreshToken:
|
|
727
|
+
const { accessToken: e, refreshToken: r } = t;
|
|
728
|
+
this.storage.setItem("token", e || ""), await this.beforeSetLoginUser({ accessToken: e, refreshToken: r });
|
|
696
729
|
}
|
|
697
730
|
async loginByWechat(t) {
|
|
698
731
|
const e = await this.post({ path: "wx", key: "open-login", code: t.code });
|
|
699
732
|
if (e.code === 200) {
|
|
700
|
-
const { accessToken:
|
|
701
|
-
this.storage.setItem("token",
|
|
733
|
+
const { accessToken: r, refreshToken: n } = e?.data || {};
|
|
734
|
+
this.storage.setItem("token", r || ""), await this.beforeSetLoginUser({ accessToken: r, refreshToken: n });
|
|
702
735
|
}
|
|
703
736
|
return e;
|
|
704
737
|
}
|
|
@@ -707,9 +740,9 @@ var vn = class {
|
|
|
707
740
|
* @param param0
|
|
708
741
|
*/
|
|
709
742
|
async checkWechat({ onSuccess: t, onError: e }) {
|
|
710
|
-
const
|
|
711
|
-
if (
|
|
712
|
-
const s = await this.loginByWechat({ code:
|
|
743
|
+
const r = new URL(window.location.href), n = r.searchParams.get("code"), o = r.searchParams.get("state");
|
|
744
|
+
if (n && o) {
|
|
745
|
+
const s = await this.loginByWechat({ code: n });
|
|
713
746
|
s.code === 200 ? t?.(s.data) : e?.(s);
|
|
714
747
|
}
|
|
715
748
|
}
|
|
@@ -717,11 +750,11 @@ var vn = class {
|
|
|
717
750
|
* 登陆成功,需要获取用户信息进行缓存
|
|
718
751
|
* @param param0
|
|
719
752
|
*/
|
|
720
|
-
async beforeSetLoginUser({ accessToken: t, refreshToken: e, check401:
|
|
753
|
+
async beforeSetLoginUser({ accessToken: t, refreshToken: e, check401: r }) {
|
|
721
754
|
if (t && e) {
|
|
722
|
-
const
|
|
723
|
-
if (
|
|
724
|
-
const o =
|
|
755
|
+
const n = await this.getMe(t, r);
|
|
756
|
+
if (n.code === 200) {
|
|
757
|
+
const o = n.data;
|
|
725
758
|
o ? this.cacheStore.setLoginUser({
|
|
726
759
|
user: o,
|
|
727
760
|
id: o.id,
|
|
@@ -738,11 +771,11 @@ var vn = class {
|
|
|
738
771
|
*/
|
|
739
772
|
async queryRefreshToken(t) {
|
|
740
773
|
const e = t || this.cacheStore.getRefreshToken();
|
|
741
|
-
let
|
|
774
|
+
let r = { refreshToken: e };
|
|
742
775
|
return e ? this.post(
|
|
743
|
-
{ key: "refreshToken", data:
|
|
776
|
+
{ key: "refreshToken", data: r },
|
|
744
777
|
{
|
|
745
|
-
afterResponse: async (
|
|
778
|
+
afterResponse: async (n, o) => (st(n), n)
|
|
746
779
|
}
|
|
747
780
|
) : (await this.cacheStore.clearCurrentUser(), {
|
|
748
781
|
code: 401,
|
|
@@ -758,25 +791,25 @@ var vn = class {
|
|
|
758
791
|
* @param refetch
|
|
759
792
|
* @returns
|
|
760
793
|
*/
|
|
761
|
-
async afterCheck401ToRefreshToken(t, e,
|
|
762
|
-
const
|
|
794
|
+
async afterCheck401ToRefreshToken(t, e, r) {
|
|
795
|
+
const n = this;
|
|
763
796
|
if (t?.code === 401) {
|
|
764
|
-
const o = await
|
|
797
|
+
const o = await n.cacheStore.getRefreshToken();
|
|
765
798
|
if (o) {
|
|
766
|
-
const s = await
|
|
799
|
+
const s = await n.queryRefreshToken(o);
|
|
767
800
|
if (s.code === 200) {
|
|
768
801
|
const { accessToken: i, refreshToken: c } = s?.data || {};
|
|
769
|
-
if (
|
|
802
|
+
if (n.storage.setItem("token", i || ""), await n.beforeSetLoginUser({ accessToken: i, refreshToken: c, check401: !1 }), r && e && e.req && e.req.url && e.fetch) {
|
|
770
803
|
await new Promise((f) => setTimeout(f, 1500));
|
|
771
|
-
const a = e.req?.url,
|
|
804
|
+
const a = e.req?.url, l = e.req?.body, u = e.req?.headers, h = await e.fetch(a, {
|
|
772
805
|
method: "POST",
|
|
773
|
-
body:
|
|
774
|
-
headers: { ...
|
|
806
|
+
body: l,
|
|
807
|
+
headers: { ...u, Authorization: `Bearer ${i}` }
|
|
775
808
|
});
|
|
776
|
-
return
|
|
809
|
+
return st(h), h;
|
|
777
810
|
}
|
|
778
811
|
} else
|
|
779
|
-
|
|
812
|
+
n.storage.removeItem("token"), await n.cacheStore.clearCurrentUser();
|
|
780
813
|
return s;
|
|
781
814
|
}
|
|
782
815
|
}
|
|
@@ -791,14 +824,14 @@ var vn = class {
|
|
|
791
824
|
* @param opts
|
|
792
825
|
* @returns
|
|
793
826
|
*/
|
|
794
|
-
async run401Action(t, e,
|
|
795
|
-
const
|
|
827
|
+
async run401Action(t, e, r) {
|
|
828
|
+
const n = this, o = r?.refetch ?? !1;
|
|
796
829
|
if (t?.code === 401) {
|
|
797
|
-
if (
|
|
830
|
+
if (n.query.stop === !0)
|
|
798
831
|
return { code: 500, success: !1, message: "refresh token loading..." };
|
|
799
|
-
|
|
800
|
-
const s = await
|
|
801
|
-
return
|
|
832
|
+
n.query.stop = !0;
|
|
833
|
+
const s = await n.afterCheck401ToRefreshToken(t, e, o);
|
|
834
|
+
return n.query.stop = !1, r?.afterCheck?.(s), s.code === 401 && r?.afterAlso401?.(s), s;
|
|
802
835
|
} else
|
|
803
836
|
return t;
|
|
804
837
|
}
|
|
@@ -808,12 +841,12 @@ var vn = class {
|
|
|
808
841
|
* @returns
|
|
809
842
|
*/
|
|
810
843
|
async getMe(t, e = !0) {
|
|
811
|
-
const
|
|
812
|
-
return
|
|
844
|
+
const r = t || this.storage.getItem("token"), n = this;
|
|
845
|
+
return n.post(
|
|
813
846
|
{ key: "me" },
|
|
814
847
|
{
|
|
815
|
-
beforeRequest: async (o) => (o.headers && (o.headers.Authorization = `Bearer ${
|
|
816
|
-
afterResponse: async (o, s) => o?.code === 401 && e && !t ? await
|
|
848
|
+
beforeRequest: async (o) => (o.headers && (o.headers.Authorization = `Bearer ${r}`), o),
|
|
849
|
+
afterResponse: async (o, s) => o?.code === 401 && e && !t ? await n.afterCheck401ToRefreshToken(o, s) : o
|
|
817
850
|
}
|
|
818
851
|
);
|
|
819
852
|
}
|
|
@@ -846,23 +879,23 @@ var vn = class {
|
|
|
846
879
|
* @returns
|
|
847
880
|
*/
|
|
848
881
|
async switchUser(t) {
|
|
849
|
-
const
|
|
850
|
-
if (
|
|
851
|
-
return this.storage.setItem("token",
|
|
882
|
+
const r = (await this.cacheStore.getCurrentUserList()).find((o) => o.user.username === t);
|
|
883
|
+
if (r)
|
|
884
|
+
return this.storage.setItem("token", r.accessToken || ""), await this.beforeSetLoginUser({ accessToken: r.accessToken, refreshToken: r.refreshToken }), {
|
|
852
885
|
code: 200,
|
|
853
886
|
data: {
|
|
854
|
-
accessToken:
|
|
855
|
-
refreshToken:
|
|
887
|
+
accessToken: r.accessToken,
|
|
888
|
+
refreshToken: r.refreshToken
|
|
856
889
|
},
|
|
857
890
|
success: !0,
|
|
858
891
|
message: "切换用户成功"
|
|
859
892
|
};
|
|
860
|
-
const
|
|
861
|
-
if (
|
|
862
|
-
const { accessToken: o, refreshToken: s } =
|
|
893
|
+
const n = await this.postSwitchUser(t);
|
|
894
|
+
if (n.code === 200) {
|
|
895
|
+
const { accessToken: o, refreshToken: s } = n?.data || {};
|
|
863
896
|
this.storage.setItem("token", o || ""), await this.beforeSetLoginUser({ accessToken: o, refreshToken: s });
|
|
864
897
|
}
|
|
865
|
-
return
|
|
898
|
+
return n;
|
|
866
899
|
}
|
|
867
900
|
/**
|
|
868
901
|
* 退出登陆,去掉token, 并删除缓存
|
|
@@ -870,7 +903,7 @@ var vn = class {
|
|
|
870
903
|
*/
|
|
871
904
|
async logout() {
|
|
872
905
|
this.storage.removeItem("token");
|
|
873
|
-
const e = (await this.cacheStore.getCurrentUserList()).map((
|
|
906
|
+
const e = (await this.cacheStore.getCurrentUserList()).map((r) => r?.accessToken).filter(Boolean);
|
|
874
907
|
return this.cacheStore.delValue(), this.post({ key: "logout", data: { tokens: e } });
|
|
875
908
|
}
|
|
876
909
|
/**
|
|
@@ -889,7 +922,7 @@ var vn = class {
|
|
|
889
922
|
}
|
|
890
923
|
},
|
|
891
924
|
{
|
|
892
|
-
afterResponse: async (
|
|
925
|
+
afterResponse: async (r, n) => r?.code === 401 ? await e.afterCheck401ToRefreshToken(r, n, !0) : r
|
|
893
926
|
}
|
|
894
927
|
);
|
|
895
928
|
}
|
|
@@ -905,34 +938,34 @@ var vn = class {
|
|
|
905
938
|
loginToken: t
|
|
906
939
|
});
|
|
907
940
|
if (e.code === 200) {
|
|
908
|
-
const
|
|
909
|
-
return this.storage.setItem("token",
|
|
941
|
+
const r = e.data?.accessToken;
|
|
942
|
+
return this.storage.setItem("token", r || ""), await this.beforeSetLoginUser({ accessToken: r, refreshToken: e.data?.refreshToken }), e;
|
|
910
943
|
}
|
|
911
944
|
return !1;
|
|
912
945
|
}
|
|
913
946
|
/**
|
|
914
947
|
* 使用web登录,创建url地址, 需要MD5和jsonwebtoken
|
|
915
948
|
*/
|
|
916
|
-
loginWithWeb(t, { MD5: e, jsonwebtoken:
|
|
917
|
-
const
|
|
949
|
+
loginWithWeb(t, { MD5: e, jsonwebtoken: r }) {
|
|
950
|
+
const n = Math.random().toString(36).substring(2, 15), o = Date.now(), s = "xiao" + n, i = e(`${s}${o}`).toString(), c = r.sign({ randomId: n, timestamp: o, sign: i }, s, {
|
|
918
951
|
// 10分钟过期
|
|
919
952
|
expiresIn: 600
|
|
920
953
|
// 10分钟
|
|
921
954
|
});
|
|
922
|
-
return { url: `${t}/api/router?path=user&key=webLogin&p&loginToken=${c}&sign=${i}&randomId=${
|
|
955
|
+
return { url: `${t}/api/router?path=user&key=webLogin&p&loginToken=${c}&sign=${i}&randomId=${n}`, token: c, tokenSecret: s };
|
|
923
956
|
}
|
|
924
|
-
},
|
|
957
|
+
}, xn = class extends Mn {
|
|
925
958
|
constructor(t) {
|
|
926
959
|
super({
|
|
927
960
|
...t,
|
|
928
|
-
cache: new
|
|
961
|
+
cache: new Sn("login")
|
|
929
962
|
});
|
|
930
963
|
}
|
|
931
964
|
};
|
|
932
|
-
const
|
|
933
|
-
query:
|
|
965
|
+
const $n = new Ft(), N = new xn({
|
|
966
|
+
query: $n
|
|
934
967
|
});
|
|
935
|
-
class
|
|
968
|
+
class Ln extends HTMLElement {
|
|
936
969
|
options;
|
|
937
970
|
timer = null;
|
|
938
971
|
constructor() {
|
|
@@ -950,7 +983,7 @@ class Rn extends HTMLElement {
|
|
|
950
983
|
this.options = { ...this.options, ...e }, this.render();
|
|
951
984
|
}
|
|
952
985
|
render() {
|
|
953
|
-
const { type: e, message:
|
|
986
|
+
const { type: e, message: r, closable: n } = this.options, s = L`
|
|
954
987
|
<style>
|
|
955
988
|
:host {
|
|
956
989
|
display: block;
|
|
@@ -1084,19 +1117,19 @@ class Rn extends HTMLElement {
|
|
|
1084
1117
|
case "error":
|
|
1085
1118
|
return "✕";
|
|
1086
1119
|
case "loading":
|
|
1087
|
-
return
|
|
1120
|
+
return L`<div class="loading-spinner"></div>`;
|
|
1088
1121
|
default:
|
|
1089
1122
|
return "";
|
|
1090
1123
|
}
|
|
1091
1124
|
})()}
|
|
1092
1125
|
</div>
|
|
1093
|
-
<div class="message-content">${
|
|
1094
|
-
${
|
|
1126
|
+
<div class="message-content">${r}</div>
|
|
1127
|
+
${n ? L`
|
|
1095
1128
|
<button class="message-close" @click=${() => this.remove()}>×</button>
|
|
1096
1129
|
` : ""}
|
|
1097
1130
|
</div>
|
|
1098
1131
|
`;
|
|
1099
|
-
|
|
1132
|
+
Ut(s, this), e !== "loading" && this.options.duration && this.options.duration > 0 && this.setTimer();
|
|
1100
1133
|
}
|
|
1101
1134
|
setTimer() {
|
|
1102
1135
|
this.timer && clearTimeout(this.timer), this.timer = window.setTimeout(() => {
|
|
@@ -1112,20 +1145,20 @@ class Rn extends HTMLElement {
|
|
|
1112
1145
|
this.timer && (clearTimeout(this.timer), this.timer = null);
|
|
1113
1146
|
}
|
|
1114
1147
|
}
|
|
1115
|
-
customElements.define("kv-message",
|
|
1116
|
-
class
|
|
1148
|
+
customElements.define("kv-message", Ln);
|
|
1149
|
+
class G {
|
|
1117
1150
|
static instance;
|
|
1118
1151
|
container = null;
|
|
1119
1152
|
defaultPosition = "center";
|
|
1120
1153
|
static getInstance() {
|
|
1121
|
-
return
|
|
1154
|
+
return G.instance || (G.instance = new G()), G.instance;
|
|
1122
1155
|
}
|
|
1123
1156
|
setDefaultPosition(e) {
|
|
1124
1157
|
this.defaultPosition = e;
|
|
1125
1158
|
}
|
|
1126
1159
|
getContainer(e) {
|
|
1127
|
-
const
|
|
1128
|
-
return this.container || (this.container = document.getElementById("messages"), this.container || (this.container = document.createElement("div"), this.container.id = "messages",
|
|
1160
|
+
const r = e || this.defaultPosition;
|
|
1161
|
+
return this.container || (this.container = document.getElementById("messages"), this.container || (this.container = document.createElement("div"), this.container.id = "messages", r === "center" ? this.container.style.cssText = `
|
|
1129
1162
|
position: fixed;
|
|
1130
1163
|
top: 20px;
|
|
1131
1164
|
left: 50%;
|
|
@@ -1149,118 +1182,118 @@ class Q {
|
|
|
1149
1182
|
`, document.body.appendChild(this.container))), this.container;
|
|
1150
1183
|
}
|
|
1151
1184
|
show(e) {
|
|
1152
|
-
const
|
|
1153
|
-
return
|
|
1185
|
+
const r = this.getContainer(e.position), n = document.createElement("kv-message");
|
|
1186
|
+
return n.setOptions(e), n.style.cssText = "pointer-events: auto;", r.appendChild(n), n;
|
|
1154
1187
|
}
|
|
1155
|
-
success(e,
|
|
1188
|
+
success(e, r) {
|
|
1156
1189
|
return this.show({
|
|
1157
1190
|
type: "success",
|
|
1158
1191
|
message: e,
|
|
1159
|
-
duration:
|
|
1160
|
-
position:
|
|
1161
|
-
closable:
|
|
1192
|
+
duration: r?.duration || 2e3,
|
|
1193
|
+
position: r?.position,
|
|
1194
|
+
closable: r?.closable
|
|
1162
1195
|
});
|
|
1163
1196
|
}
|
|
1164
|
-
error(e,
|
|
1197
|
+
error(e, r) {
|
|
1165
1198
|
return this.show({
|
|
1166
1199
|
type: "error",
|
|
1167
1200
|
message: e,
|
|
1168
|
-
duration:
|
|
1169
|
-
position:
|
|
1170
|
-
closable:
|
|
1201
|
+
duration: r?.duration || 3e3,
|
|
1202
|
+
position: r?.position,
|
|
1203
|
+
closable: r?.closable
|
|
1171
1204
|
});
|
|
1172
1205
|
}
|
|
1173
|
-
loading(e,
|
|
1206
|
+
loading(e, r) {
|
|
1174
1207
|
return this.show({
|
|
1175
1208
|
type: "loading",
|
|
1176
1209
|
message: e,
|
|
1177
1210
|
duration: 0,
|
|
1178
|
-
position:
|
|
1179
|
-
closable:
|
|
1211
|
+
position: r?.position,
|
|
1212
|
+
closable: r?.closable
|
|
1180
1213
|
});
|
|
1181
1214
|
}
|
|
1182
1215
|
remove(e) {
|
|
1183
1216
|
e.remove();
|
|
1184
1217
|
}
|
|
1185
1218
|
clear() {
|
|
1186
|
-
this.getContainer().querySelectorAll("kv-message").forEach((
|
|
1187
|
-
|
|
1219
|
+
this.getContainer().querySelectorAll("kv-message").forEach((n) => {
|
|
1220
|
+
n.remove();
|
|
1188
1221
|
});
|
|
1189
1222
|
}
|
|
1190
1223
|
}
|
|
1191
|
-
const
|
|
1192
|
-
window.createMessage =
|
|
1193
|
-
const
|
|
1224
|
+
const Ot = () => G.getInstance();
|
|
1225
|
+
window.createMessage = Ot;
|
|
1226
|
+
const U = Ot(), se = () => {
|
|
1194
1227
|
console.log("重定向到首页");
|
|
1195
|
-
const t = window.location.href,
|
|
1196
|
-
if (
|
|
1197
|
-
const
|
|
1198
|
-
window.open(
|
|
1228
|
+
const t = window.location.href, r = new URL(t).searchParams.get("redirect");
|
|
1229
|
+
if (r) {
|
|
1230
|
+
const n = decodeURIComponent(r);
|
|
1231
|
+
window.open(n, "_self");
|
|
1199
1232
|
} else
|
|
1200
1233
|
window.open("/root/home", "_self");
|
|
1201
|
-
},
|
|
1202
|
-
const { loginMethod: e, data:
|
|
1234
|
+
}, In = async (t) => {
|
|
1235
|
+
const { loginMethod: e, data: r } = t;
|
|
1203
1236
|
switch (e) {
|
|
1204
1237
|
case "password":
|
|
1205
|
-
await
|
|
1238
|
+
await Pn(r);
|
|
1206
1239
|
break;
|
|
1207
1240
|
case "phone":
|
|
1208
|
-
await
|
|
1241
|
+
await qn(r);
|
|
1209
1242
|
break;
|
|
1210
1243
|
case "wechat-mp":
|
|
1211
|
-
await
|
|
1244
|
+
await Nn(r);
|
|
1212
1245
|
break;
|
|
1213
1246
|
case "wechat":
|
|
1214
|
-
await
|
|
1247
|
+
await Dn(r);
|
|
1215
1248
|
break;
|
|
1216
1249
|
default:
|
|
1217
1250
|
console.warn("未知的登录方式:", e);
|
|
1218
1251
|
}
|
|
1219
|
-
},
|
|
1252
|
+
}, Pn = async (t) => {
|
|
1220
1253
|
console.log("使用用户名密码登录:", t);
|
|
1221
1254
|
let e = !0;
|
|
1222
|
-
if (await
|
|
1223
|
-
|
|
1255
|
+
if (await N.checkLocalToken() && (await N.checkLocalUser())?.username === t?.username && (await N.getMe()).code === 200 && (e = !1, console.log("已登录,跳过登录步骤"), U.success("已登录")), !e) {
|
|
1256
|
+
se();
|
|
1224
1257
|
return;
|
|
1225
1258
|
}
|
|
1226
|
-
const
|
|
1259
|
+
const n = await N.login({
|
|
1227
1260
|
username: t.username,
|
|
1228
1261
|
password: t.password
|
|
1229
1262
|
});
|
|
1230
|
-
|
|
1231
|
-
},
|
|
1263
|
+
n.code === 200 ? (console.log("登录成功"), U.success("登录成功"), se()) : U.error(`登录失败: ${n.message}`);
|
|
1264
|
+
}, qn = async (t) => {
|
|
1232
1265
|
console.log("使用手机号登录:", t);
|
|
1233
|
-
},
|
|
1266
|
+
}, Dn = async (t) => {
|
|
1234
1267
|
console.log("使用微信登录:", t);
|
|
1235
|
-
},
|
|
1268
|
+
}, Nn = async (t) => {
|
|
1236
1269
|
console.log("使用微信公众号登录:", t);
|
|
1237
|
-
},
|
|
1270
|
+
}, Un = () => {
|
|
1238
1271
|
const t = new URL(window.location.href);
|
|
1239
1272
|
t.searchParams.delete("code"), t.searchParams.delete("state"), window.history.replaceState({}, document.title, t.toString());
|
|
1240
|
-
},
|
|
1273
|
+
}, Fn = async () => {
|
|
1241
1274
|
const t = new URL(window.location.href), e = t.searchParams.get("code");
|
|
1242
1275
|
if (t.searchParams.get("state")?.includes?.("-") || !e)
|
|
1243
1276
|
return;
|
|
1244
|
-
const
|
|
1245
|
-
|
|
1246
|
-
},
|
|
1247
|
-
const t = new URL(window.location.href), e = t.searchParams.get("state"), [
|
|
1248
|
-
if (console.log("检查微信公众号登录流程:",
|
|
1249
|
-
|
|
1250
|
-
else if (
|
|
1251
|
-
const o = t.searchParams.get("code"), s = await
|
|
1277
|
+
const n = await N.loginByWechat({ code: e });
|
|
1278
|
+
n.code === 200 ? (U.success("登录成功"), se()) : (U.error(n.message || "登录失败"), Un());
|
|
1279
|
+
}, zn = async () => {
|
|
1280
|
+
const t = new URL(window.location.href), e = t.searchParams.get("state"), [r, n] = e ? e.split("-") : [null, null];
|
|
1281
|
+
if (console.log("检查微信公众号登录流程:", r, n, e), r === "1")
|
|
1282
|
+
jn();
|
|
1283
|
+
else if (r === "2") {
|
|
1284
|
+
const o = t.searchParams.get("code"), s = await N.post({
|
|
1252
1285
|
path: "wx",
|
|
1253
1286
|
key: "mplogin",
|
|
1254
|
-
state:
|
|
1287
|
+
state: n,
|
|
1255
1288
|
code: o
|
|
1256
1289
|
});
|
|
1257
|
-
s.code === 200 ?
|
|
1290
|
+
s.code === 200 ? U.success("登录成功") : U.error(s.message || "登录失败"), Jt();
|
|
1258
1291
|
}
|
|
1259
|
-
},
|
|
1292
|
+
}, Hn = () => {
|
|
1260
1293
|
const t = navigator.userAgent.toLowerCase();
|
|
1261
1294
|
return /micromessenger/i.test(t);
|
|
1262
|
-
},
|
|
1263
|
-
if (!
|
|
1295
|
+
}, Jt = (t = 2e3) => {
|
|
1296
|
+
if (!Hn()) {
|
|
1264
1297
|
setTimeout(() => {
|
|
1265
1298
|
window.close();
|
|
1266
1299
|
}, t);
|
|
@@ -1271,32 +1304,51 @@ const j = Vt(), ue = () => {
|
|
|
1271
1304
|
}, t) : setTimeout(() => {
|
|
1272
1305
|
window.close();
|
|
1273
1306
|
}, t);
|
|
1274
|
-
},
|
|
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 =
|
|
1276
|
-
let [o, s] =
|
|
1277
|
-
const i = new URL(
|
|
1307
|
+
}, jn = async () => {
|
|
1308
|
+
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 = Xt, r = new URL(window.location.href), n = r.searchParams.get("state");
|
|
1309
|
+
let [o, s] = n ? n.split("-") : [null, null];
|
|
1310
|
+
const i = new URL(r.pathname, r.origin);
|
|
1278
1311
|
s = "2-" + s;
|
|
1279
1312
|
const c = encodeURIComponent(i.toString());
|
|
1280
1313
|
document.body.innerHTML = "<p>正在准备跳转到微信公众号授权页面...</p>";
|
|
1281
1314
|
const a = "snsapi_userinfo";
|
|
1282
1315
|
if (!s) {
|
|
1283
|
-
alert("Invalid state. Please try again later."),
|
|
1316
|
+
alert("Invalid state. Please try again later."), Jt();
|
|
1284
1317
|
return;
|
|
1285
1318
|
}
|
|
1286
|
-
const
|
|
1319
|
+
const l = t.replace("APPID", e).replace("REDIRECT_URI", c).replace("SCOPE", a).replace("STATE", s);
|
|
1287
1320
|
setTimeout(() => {
|
|
1288
|
-
window.location.href =
|
|
1321
|
+
window.location.href = l;
|
|
1289
1322
|
}, 100);
|
|
1290
1323
|
};
|
|
1291
1324
|
setTimeout(() => {
|
|
1292
|
-
|
|
1325
|
+
zn();
|
|
1293
1326
|
}, 100);
|
|
1294
|
-
const
|
|
1327
|
+
const Vn = async () => {
|
|
1328
|
+
const t = await N.post({
|
|
1329
|
+
path: "wx",
|
|
1330
|
+
key: "get-qrcode-ticket"
|
|
1331
|
+
});
|
|
1332
|
+
return t.code !== 200 ? (U.error("获取二维码失败"), null) : t?.data;
|
|
1333
|
+
}, Wn = (t) => {
|
|
1334
|
+
let e = !0;
|
|
1335
|
+
const r = async () => {
|
|
1336
|
+
const s = await N.post({
|
|
1337
|
+
path: "wx",
|
|
1338
|
+
key: "check-qrcode-login",
|
|
1339
|
+
payload: { ticket: t }
|
|
1340
|
+
});
|
|
1341
|
+
s.code === 200 ? (U.success("登录成功"), clearTimeout(n), se()) : (s.code === 401 ? console.log("等待扫码登录...") : console.log("扫码登录状态:", s), e && setTimeout(r, 2e3));
|
|
1342
|
+
}, n = setTimeout(r, 2e3);
|
|
1343
|
+
return () => {
|
|
1344
|
+
console.log("停止检测扫码登录状态"), clearTimeout(n), e = !1;
|
|
1345
|
+
};
|
|
1346
|
+
}, it = async (t) => {
|
|
1295
1347
|
let e = t?.redirect_uri;
|
|
1296
|
-
const { appid:
|
|
1348
|
+
const { appid: r } = t || {};
|
|
1297
1349
|
e || (e = window.location.href);
|
|
1298
|
-
const
|
|
1299
|
-
if (
|
|
1350
|
+
const n = new URL(e);
|
|
1351
|
+
if (n.searchParams.delete("code"), n.searchParams.delete("state"), e = n.toString(), console.log("redirect_uri", e), !r) {
|
|
1300
1352
|
console.error("appid is not cant be empty");
|
|
1301
1353
|
return;
|
|
1302
1354
|
}
|
|
@@ -1304,7 +1356,7 @@ const rt = async (t) => {
|
|
|
1304
1356
|
self_redirect: !1,
|
|
1305
1357
|
id: "weixinLogin",
|
|
1306
1358
|
// 需要显示的容器id
|
|
1307
|
-
appid:
|
|
1359
|
+
appid: r,
|
|
1308
1360
|
// 微信开放平台appid wx*******
|
|
1309
1361
|
scope: "snsapi_login",
|
|
1310
1362
|
// 网页默认即可 snsapi_userinfo
|
|
@@ -1323,30 +1375,30 @@ const rt = async (t) => {
|
|
|
1323
1375
|
}
|
|
1324
1376
|
return o;
|
|
1325
1377
|
};
|
|
1326
|
-
function
|
|
1378
|
+
function On(t) {
|
|
1327
1379
|
const e = document.createElement("script");
|
|
1328
1380
|
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
|
-
|
|
1381
|
+
it(t);
|
|
1330
1382
|
return;
|
|
1331
1383
|
}
|
|
1332
|
-
const
|
|
1333
|
-
|
|
1334
|
-
|
|
1384
|
+
const r = document.body.appendChild(e);
|
|
1385
|
+
r.onload = function() {
|
|
1386
|
+
it(t);
|
|
1335
1387
|
};
|
|
1336
1388
|
}
|
|
1337
|
-
function
|
|
1389
|
+
function Jn(t) {
|
|
1338
1390
|
return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
|
|
1339
1391
|
}
|
|
1340
|
-
var
|
|
1341
|
-
function
|
|
1342
|
-
return
|
|
1392
|
+
var Q = {}, ye, at;
|
|
1393
|
+
function Kn() {
|
|
1394
|
+
return at || (at = 1, ye = function() {
|
|
1343
1395
|
return typeof Promise == "function" && Promise.prototype && Promise.prototype.then;
|
|
1344
1396
|
}), ye;
|
|
1345
1397
|
}
|
|
1346
|
-
var be = {},
|
|
1398
|
+
var be = {}, z = {}, ct;
|
|
1347
1399
|
function O() {
|
|
1348
|
-
if (
|
|
1349
|
-
|
|
1400
|
+
if (ct) return z;
|
|
1401
|
+
ct = 1;
|
|
1350
1402
|
let t;
|
|
1351
1403
|
const e = [
|
|
1352
1404
|
0,
|
|
@@ -1392,35 +1444,35 @@ function O() {
|
|
|
1392
1444
|
3532,
|
|
1393
1445
|
3706
|
|
1394
1446
|
];
|
|
1395
|
-
return
|
|
1396
|
-
if (!
|
|
1397
|
-
if (
|
|
1398
|
-
return
|
|
1399
|
-
},
|
|
1400
|
-
return e[
|
|
1401
|
-
},
|
|
1402
|
-
let
|
|
1403
|
-
for (;
|
|
1404
|
-
|
|
1405
|
-
return
|
|
1406
|
-
},
|
|
1407
|
-
if (typeof
|
|
1447
|
+
return z.getSymbolSize = function(n) {
|
|
1448
|
+
if (!n) throw new Error('"version" cannot be null or undefined');
|
|
1449
|
+
if (n < 1 || n > 40) throw new Error('"version" should be in range from 1 to 40');
|
|
1450
|
+
return n * 4 + 17;
|
|
1451
|
+
}, z.getSymbolTotalCodewords = function(n) {
|
|
1452
|
+
return e[n];
|
|
1453
|
+
}, z.getBCHDigit = function(r) {
|
|
1454
|
+
let n = 0;
|
|
1455
|
+
for (; r !== 0; )
|
|
1456
|
+
n++, r >>>= 1;
|
|
1457
|
+
return n;
|
|
1458
|
+
}, z.setToSJISFunction = function(n) {
|
|
1459
|
+
if (typeof n != "function")
|
|
1408
1460
|
throw new Error('"toSJISFunc" is not a valid function.');
|
|
1409
|
-
t =
|
|
1410
|
-
},
|
|
1461
|
+
t = n;
|
|
1462
|
+
}, z.isKanjiModeEnabled = function() {
|
|
1411
1463
|
return typeof t < "u";
|
|
1412
|
-
},
|
|
1413
|
-
return t(
|
|
1414
|
-
},
|
|
1464
|
+
}, z.toSJIS = function(n) {
|
|
1465
|
+
return t(n);
|
|
1466
|
+
}, z;
|
|
1415
1467
|
}
|
|
1416
|
-
var
|
|
1417
|
-
function
|
|
1418
|
-
return
|
|
1468
|
+
var ve = {}, lt;
|
|
1469
|
+
function Oe() {
|
|
1470
|
+
return lt || (lt = 1, (function(t) {
|
|
1419
1471
|
t.L = { bit: 1 }, t.M = { bit: 0 }, t.Q = { bit: 3 }, t.H = { bit: 2 };
|
|
1420
|
-
function e(
|
|
1421
|
-
if (typeof
|
|
1472
|
+
function e(r) {
|
|
1473
|
+
if (typeof r != "string")
|
|
1422
1474
|
throw new Error("Param is not a string");
|
|
1423
|
-
switch (
|
|
1475
|
+
switch (r.toLowerCase()) {
|
|
1424
1476
|
case "l":
|
|
1425
1477
|
case "low":
|
|
1426
1478
|
return t.L;
|
|
@@ -1434,79 +1486,79 @@ function je() {
|
|
|
1434
1486
|
case "high":
|
|
1435
1487
|
return t.H;
|
|
1436
1488
|
default:
|
|
1437
|
-
throw new Error("Unknown EC Level: " +
|
|
1489
|
+
throw new Error("Unknown EC Level: " + r);
|
|
1438
1490
|
}
|
|
1439
1491
|
}
|
|
1440
|
-
t.isValid = function(
|
|
1441
|
-
return
|
|
1442
|
-
}, t.from = function(
|
|
1443
|
-
if (t.isValid(
|
|
1444
|
-
return
|
|
1492
|
+
t.isValid = function(n) {
|
|
1493
|
+
return n && typeof n.bit < "u" && n.bit >= 0 && n.bit < 4;
|
|
1494
|
+
}, t.from = function(n, o) {
|
|
1495
|
+
if (t.isValid(n))
|
|
1496
|
+
return n;
|
|
1445
1497
|
try {
|
|
1446
|
-
return e(
|
|
1498
|
+
return e(n);
|
|
1447
1499
|
} catch {
|
|
1448
1500
|
return o;
|
|
1449
1501
|
}
|
|
1450
1502
|
};
|
|
1451
|
-
})(
|
|
1503
|
+
})(ve)), ve;
|
|
1452
1504
|
}
|
|
1453
|
-
var
|
|
1454
|
-
function
|
|
1455
|
-
if (
|
|
1456
|
-
|
|
1505
|
+
var Ae, ut;
|
|
1506
|
+
function Qn() {
|
|
1507
|
+
if (ut) return Ae;
|
|
1508
|
+
ut = 1;
|
|
1457
1509
|
function t() {
|
|
1458
1510
|
this.buffer = [], this.length = 0;
|
|
1459
1511
|
}
|
|
1460
1512
|
return t.prototype = {
|
|
1461
1513
|
get: function(e) {
|
|
1462
|
-
const
|
|
1463
|
-
return (this.buffer[
|
|
1514
|
+
const r = Math.floor(e / 8);
|
|
1515
|
+
return (this.buffer[r] >>> 7 - e % 8 & 1) === 1;
|
|
1464
1516
|
},
|
|
1465
|
-
put: function(e,
|
|
1466
|
-
for (let
|
|
1467
|
-
this.putBit((e >>>
|
|
1517
|
+
put: function(e, r) {
|
|
1518
|
+
for (let n = 0; n < r; n++)
|
|
1519
|
+
this.putBit((e >>> r - n - 1 & 1) === 1);
|
|
1468
1520
|
},
|
|
1469
1521
|
getLengthInBits: function() {
|
|
1470
1522
|
return this.length;
|
|
1471
1523
|
},
|
|
1472
1524
|
putBit: function(e) {
|
|
1473
|
-
const
|
|
1474
|
-
this.buffer.length <=
|
|
1525
|
+
const r = Math.floor(this.length / 8);
|
|
1526
|
+
this.buffer.length <= r && this.buffer.push(0), e && (this.buffer[r] |= 128 >>> this.length % 8), this.length++;
|
|
1475
1527
|
}
|
|
1476
|
-
},
|
|
1528
|
+
}, Ae = t, Ae;
|
|
1477
1529
|
}
|
|
1478
|
-
var
|
|
1479
|
-
function
|
|
1480
|
-
if (
|
|
1481
|
-
|
|
1530
|
+
var Ce, ht;
|
|
1531
|
+
function Gn() {
|
|
1532
|
+
if (ht) return Ce;
|
|
1533
|
+
ht = 1;
|
|
1482
1534
|
function t(e) {
|
|
1483
1535
|
if (!e || e < 1)
|
|
1484
1536
|
throw new Error("BitMatrix size must be defined and greater than 0");
|
|
1485
1537
|
this.size = e, this.data = new Uint8Array(e * e), this.reservedBit = new Uint8Array(e * e);
|
|
1486
1538
|
}
|
|
1487
|
-
return t.prototype.set = function(e,
|
|
1488
|
-
const s = e * this.size +
|
|
1489
|
-
this.data[s] =
|
|
1490
|
-
}, t.prototype.get = function(e,
|
|
1491
|
-
return this.data[e * this.size +
|
|
1492
|
-
}, t.prototype.xor = function(e,
|
|
1493
|
-
this.data[e * this.size +
|
|
1494
|
-
}, t.prototype.isReserved = function(e,
|
|
1495
|
-
return this.reservedBit[e * this.size +
|
|
1496
|
-
},
|
|
1497
|
-
}
|
|
1498
|
-
var
|
|
1499
|
-
function
|
|
1500
|
-
return
|
|
1539
|
+
return t.prototype.set = function(e, r, n, o) {
|
|
1540
|
+
const s = e * this.size + r;
|
|
1541
|
+
this.data[s] = n, o && (this.reservedBit[s] = !0);
|
|
1542
|
+
}, t.prototype.get = function(e, r) {
|
|
1543
|
+
return this.data[e * this.size + r];
|
|
1544
|
+
}, t.prototype.xor = function(e, r, n) {
|
|
1545
|
+
this.data[e * this.size + r] ^= n;
|
|
1546
|
+
}, t.prototype.isReserved = function(e, r) {
|
|
1547
|
+
return this.reservedBit[e * this.size + r];
|
|
1548
|
+
}, Ce = t, Ce;
|
|
1549
|
+
}
|
|
1550
|
+
var Te = {}, dt;
|
|
1551
|
+
function Yn() {
|
|
1552
|
+
return dt || (dt = 1, (function(t) {
|
|
1501
1553
|
const e = O().getSymbolSize;
|
|
1502
|
-
t.getRowColCoords = function(
|
|
1503
|
-
if (
|
|
1504
|
-
const o = Math.floor(
|
|
1554
|
+
t.getRowColCoords = function(n) {
|
|
1555
|
+
if (n === 1) return [];
|
|
1556
|
+
const o = Math.floor(n / 7) + 2, s = e(n), i = s === 145 ? 26 : Math.ceil((s - 13) / (2 * o - 2)) * 2, c = [s - 7];
|
|
1505
1557
|
for (let a = 1; a < o - 1; a++)
|
|
1506
1558
|
c[a] = c[a - 1] - i;
|
|
1507
1559
|
return c.push(6), c.reverse();
|
|
1508
|
-
}, t.getPositions = function(
|
|
1509
|
-
const o = [], s = t.getRowColCoords(
|
|
1560
|
+
}, t.getPositions = function(n) {
|
|
1561
|
+
const o = [], s = t.getRowColCoords(n), i = s.length;
|
|
1510
1562
|
for (let c = 0; c < i; c++)
|
|
1511
1563
|
for (let a = 0; a < i; a++)
|
|
1512
1564
|
c === 0 && a === 0 || // top-left
|
|
@@ -1514,15 +1566,15 @@ function Vn() {
|
|
|
1514
1566
|
c === i - 1 && a === 0 || o.push([s[c], s[a]]);
|
|
1515
1567
|
return o;
|
|
1516
1568
|
};
|
|
1517
|
-
})(
|
|
1569
|
+
})(Te)), Te;
|
|
1518
1570
|
}
|
|
1519
|
-
var ke = {},
|
|
1520
|
-
function
|
|
1521
|
-
if (
|
|
1522
|
-
|
|
1571
|
+
var ke = {}, ft;
|
|
1572
|
+
function Xn() {
|
|
1573
|
+
if (ft) return ke;
|
|
1574
|
+
ft = 1;
|
|
1523
1575
|
const t = O().getSymbolSize, e = 7;
|
|
1524
|
-
return ke.getPositions = function(
|
|
1525
|
-
const o = t(
|
|
1576
|
+
return ke.getPositions = function(n) {
|
|
1577
|
+
const o = t(n);
|
|
1526
1578
|
return [
|
|
1527
1579
|
// top-left
|
|
1528
1580
|
[0, 0],
|
|
@@ -1533,9 +1585,9 @@ function jn() {
|
|
|
1533
1585
|
];
|
|
1534
1586
|
}, ke;
|
|
1535
1587
|
}
|
|
1536
|
-
var Ee = {},
|
|
1537
|
-
function
|
|
1538
|
-
return
|
|
1588
|
+
var Ee = {}, gt;
|
|
1589
|
+
function Zn() {
|
|
1590
|
+
return gt || (gt = 1, (function(t) {
|
|
1539
1591
|
t.Patterns = {
|
|
1540
1592
|
PATTERN000: 0,
|
|
1541
1593
|
PATTERN001: 1,
|
|
@@ -1558,12 +1610,12 @@ function Wn() {
|
|
|
1558
1610
|
return t.isValid(o) ? parseInt(o, 10) : void 0;
|
|
1559
1611
|
}, t.getPenaltyN1 = function(o) {
|
|
1560
1612
|
const s = o.size;
|
|
1561
|
-
let i = 0, c = 0, a = 0,
|
|
1613
|
+
let i = 0, c = 0, a = 0, l = null, u = null;
|
|
1562
1614
|
for (let h = 0; h < s; h++) {
|
|
1563
|
-
c = a = 0,
|
|
1615
|
+
c = a = 0, l = u = null;
|
|
1564
1616
|
for (let f = 0; f < s; f++) {
|
|
1565
1617
|
let d = o.get(h, f);
|
|
1566
|
-
d ===
|
|
1618
|
+
d === l ? c++ : (c >= 5 && (i += e.N1 + (c - 5)), l = d, c = 1), d = o.get(f, h), d === u ? a++ : (a >= 5 && (i += e.N1 + (a - 5)), u = d, a = 1);
|
|
1567
1619
|
}
|
|
1568
1620
|
c >= 5 && (i += e.N1 + (c - 5)), a >= 5 && (i += e.N1 + (a - 5));
|
|
1569
1621
|
}
|
|
@@ -1573,17 +1625,17 @@ function Wn() {
|
|
|
1573
1625
|
let i = 0;
|
|
1574
1626
|
for (let c = 0; c < s - 1; c++)
|
|
1575
1627
|
for (let a = 0; a < s - 1; a++) {
|
|
1576
|
-
const
|
|
1577
|
-
(
|
|
1628
|
+
const l = o.get(c, a) + o.get(c, a + 1) + o.get(c + 1, a) + o.get(c + 1, a + 1);
|
|
1629
|
+
(l === 4 || l === 0) && i++;
|
|
1578
1630
|
}
|
|
1579
1631
|
return i * e.N2;
|
|
1580
1632
|
}, t.getPenaltyN3 = function(o) {
|
|
1581
1633
|
const s = o.size;
|
|
1582
1634
|
let i = 0, c = 0, a = 0;
|
|
1583
|
-
for (let
|
|
1635
|
+
for (let l = 0; l < s; l++) {
|
|
1584
1636
|
c = a = 0;
|
|
1585
|
-
for (let
|
|
1586
|
-
c = c << 1 & 2047 | o.get(
|
|
1637
|
+
for (let u = 0; u < s; u++)
|
|
1638
|
+
c = c << 1 & 2047 | o.get(l, u), u >= 10 && (c === 1488 || c === 93) && i++, a = a << 1 & 2047 | o.get(u, l), u >= 10 && (a === 1488 || a === 93) && i++;
|
|
1587
1639
|
}
|
|
1588
1640
|
return i * e.N3;
|
|
1589
1641
|
}, t.getPenaltyN4 = function(o) {
|
|
@@ -1592,8 +1644,8 @@ function Wn() {
|
|
|
1592
1644
|
for (let a = 0; a < i; a++) s += o.data[a];
|
|
1593
1645
|
return Math.abs(Math.ceil(s * 100 / i / 5) - 10) * e.N4;
|
|
1594
1646
|
};
|
|
1595
|
-
function n
|
|
1596
|
-
switch (
|
|
1647
|
+
function r(n, o, s) {
|
|
1648
|
+
switch (n) {
|
|
1597
1649
|
case t.Patterns.PATTERN000:
|
|
1598
1650
|
return (o + s) % 2 === 0;
|
|
1599
1651
|
case t.Patterns.PATTERN001:
|
|
@@ -1611,31 +1663,31 @@ function Wn() {
|
|
|
1611
1663
|
case t.Patterns.PATTERN111:
|
|
1612
1664
|
return (o * s % 3 + (o + s) % 2) % 2 === 0;
|
|
1613
1665
|
default:
|
|
1614
|
-
throw new Error("bad maskPattern:" +
|
|
1666
|
+
throw new Error("bad maskPattern:" + n);
|
|
1615
1667
|
}
|
|
1616
1668
|
}
|
|
1617
1669
|
t.applyMask = function(o, s) {
|
|
1618
1670
|
const i = s.size;
|
|
1619
1671
|
for (let c = 0; c < i; c++)
|
|
1620
1672
|
for (let a = 0; a < i; a++)
|
|
1621
|
-
s.isReserved(a, c) || s.xor(a, c,
|
|
1673
|
+
s.isReserved(a, c) || s.xor(a, c, r(o, a, c));
|
|
1622
1674
|
}, t.getBestMask = function(o, s) {
|
|
1623
1675
|
const i = Object.keys(t.Patterns).length;
|
|
1624
1676
|
let c = 0, a = 1 / 0;
|
|
1625
|
-
for (let
|
|
1626
|
-
s(
|
|
1627
|
-
const
|
|
1628
|
-
t.applyMask(
|
|
1677
|
+
for (let l = 0; l < i; l++) {
|
|
1678
|
+
s(l), t.applyMask(l, o);
|
|
1679
|
+
const u = t.getPenaltyN1(o) + t.getPenaltyN2(o) + t.getPenaltyN3(o) + t.getPenaltyN4(o);
|
|
1680
|
+
t.applyMask(l, o), u < a && (a = u, c = l);
|
|
1629
1681
|
}
|
|
1630
1682
|
return c;
|
|
1631
1683
|
};
|
|
1632
1684
|
})(Ee)), Ee;
|
|
1633
1685
|
}
|
|
1634
|
-
var
|
|
1635
|
-
function
|
|
1636
|
-
if (
|
|
1637
|
-
|
|
1638
|
-
const t =
|
|
1686
|
+
var ce = {}, pt;
|
|
1687
|
+
function Kt() {
|
|
1688
|
+
if (pt) return ce;
|
|
1689
|
+
pt = 1;
|
|
1690
|
+
const t = Oe(), e = [
|
|
1639
1691
|
// L M Q H
|
|
1640
1692
|
1,
|
|
1641
1693
|
1,
|
|
@@ -1797,7 +1849,7 @@ function Wt() {
|
|
|
1797
1849
|
49,
|
|
1798
1850
|
68,
|
|
1799
1851
|
81
|
|
1800
|
-
],
|
|
1852
|
+
], r = [
|
|
1801
1853
|
// L M Q H
|
|
1802
1854
|
7,
|
|
1803
1855
|
10,
|
|
@@ -1960,7 +2012,7 @@ function Wt() {
|
|
|
1960
2012
|
2040,
|
|
1961
2013
|
2430
|
|
1962
2014
|
];
|
|
1963
|
-
return
|
|
2015
|
+
return ce.getBlocksCount = function(o, s) {
|
|
1964
2016
|
switch (s) {
|
|
1965
2017
|
case t.L:
|
|
1966
2018
|
return e[(o - 1) * 4 + 0];
|
|
@@ -1973,53 +2025,53 @@ function Wt() {
|
|
|
1973
2025
|
default:
|
|
1974
2026
|
return;
|
|
1975
2027
|
}
|
|
1976
|
-
},
|
|
2028
|
+
}, ce.getTotalCodewordsCount = function(o, s) {
|
|
1977
2029
|
switch (s) {
|
|
1978
2030
|
case t.L:
|
|
1979
|
-
return
|
|
2031
|
+
return r[(o - 1) * 4 + 0];
|
|
1980
2032
|
case t.M:
|
|
1981
|
-
return
|
|
2033
|
+
return r[(o - 1) * 4 + 1];
|
|
1982
2034
|
case t.Q:
|
|
1983
|
-
return
|
|
2035
|
+
return r[(o - 1) * 4 + 2];
|
|
1984
2036
|
case t.H:
|
|
1985
|
-
return
|
|
2037
|
+
return r[(o - 1) * 4 + 3];
|
|
1986
2038
|
default:
|
|
1987
2039
|
return;
|
|
1988
2040
|
}
|
|
1989
|
-
},
|
|
2041
|
+
}, ce;
|
|
1990
2042
|
}
|
|
1991
|
-
var _e = {},
|
|
1992
|
-
function
|
|
1993
|
-
if (
|
|
1994
|
-
|
|
2043
|
+
var _e = {}, te = {}, mt;
|
|
2044
|
+
function er() {
|
|
2045
|
+
if (mt) return te;
|
|
2046
|
+
mt = 1;
|
|
1995
2047
|
const t = new Uint8Array(512), e = new Uint8Array(256);
|
|
1996
2048
|
return (function() {
|
|
1997
|
-
let
|
|
2049
|
+
let n = 1;
|
|
1998
2050
|
for (let o = 0; o < 255; o++)
|
|
1999
|
-
t[o] =
|
|
2051
|
+
t[o] = n, e[n] = o, n <<= 1, n & 256 && (n ^= 285);
|
|
2000
2052
|
for (let o = 255; o < 512; o++)
|
|
2001
2053
|
t[o] = t[o - 255];
|
|
2002
|
-
})(),
|
|
2003
|
-
if (
|
|
2004
|
-
return e[
|
|
2005
|
-
},
|
|
2006
|
-
return t[
|
|
2007
|
-
},
|
|
2008
|
-
return
|
|
2009
|
-
},
|
|
2010
|
-
}
|
|
2011
|
-
var
|
|
2012
|
-
function
|
|
2013
|
-
return
|
|
2014
|
-
const e =
|
|
2015
|
-
t.mul = function(
|
|
2016
|
-
const s = new Uint8Array(
|
|
2017
|
-
for (let i = 0; i <
|
|
2054
|
+
})(), te.log = function(n) {
|
|
2055
|
+
if (n < 1) throw new Error("log(" + n + ")");
|
|
2056
|
+
return e[n];
|
|
2057
|
+
}, te.exp = function(n) {
|
|
2058
|
+
return t[n];
|
|
2059
|
+
}, te.mul = function(n, o) {
|
|
2060
|
+
return n === 0 || o === 0 ? 0 : t[e[n] + e[o]];
|
|
2061
|
+
}, te;
|
|
2062
|
+
}
|
|
2063
|
+
var wt;
|
|
2064
|
+
function tr() {
|
|
2065
|
+
return wt || (wt = 1, (function(t) {
|
|
2066
|
+
const e = er();
|
|
2067
|
+
t.mul = function(n, o) {
|
|
2068
|
+
const s = new Uint8Array(n.length + o.length - 1);
|
|
2069
|
+
for (let i = 0; i < n.length; i++)
|
|
2018
2070
|
for (let c = 0; c < o.length; c++)
|
|
2019
|
-
s[i + c] ^= e.mul(
|
|
2071
|
+
s[i + c] ^= e.mul(n[i], o[c]);
|
|
2020
2072
|
return s;
|
|
2021
|
-
}, t.mod = function(
|
|
2022
|
-
let s = new Uint8Array(
|
|
2073
|
+
}, t.mod = function(n, o) {
|
|
2074
|
+
let s = new Uint8Array(n);
|
|
2023
2075
|
for (; s.length - o.length >= 0; ) {
|
|
2024
2076
|
const i = s[0];
|
|
2025
2077
|
for (let a = 0; a < o.length; a++)
|
|
@@ -2029,29 +2081,29 @@ function Jn() {
|
|
|
2029
2081
|
s = s.slice(c);
|
|
2030
2082
|
}
|
|
2031
2083
|
return s;
|
|
2032
|
-
}, t.generateECPolynomial = function(
|
|
2084
|
+
}, t.generateECPolynomial = function(n) {
|
|
2033
2085
|
let o = new Uint8Array([1]);
|
|
2034
|
-
for (let s = 0; s <
|
|
2086
|
+
for (let s = 0; s < n; s++)
|
|
2035
2087
|
o = t.mul(o, new Uint8Array([1, e.exp(s)]));
|
|
2036
2088
|
return o;
|
|
2037
2089
|
};
|
|
2038
2090
|
})(_e)), _e;
|
|
2039
2091
|
}
|
|
2040
|
-
var Re,
|
|
2041
|
-
function
|
|
2042
|
-
if (
|
|
2043
|
-
|
|
2044
|
-
const t =
|
|
2045
|
-
function e(
|
|
2046
|
-
this.genPoly = void 0, this.degree =
|
|
2047
|
-
}
|
|
2048
|
-
return e.prototype.initialize = function(
|
|
2049
|
-
this.degree =
|
|
2050
|
-
}, e.prototype.encode = function(
|
|
2092
|
+
var Re, yt;
|
|
2093
|
+
function nr() {
|
|
2094
|
+
if (yt) return Re;
|
|
2095
|
+
yt = 1;
|
|
2096
|
+
const t = tr();
|
|
2097
|
+
function e(r) {
|
|
2098
|
+
this.genPoly = void 0, this.degree = r, this.degree && this.initialize(this.degree);
|
|
2099
|
+
}
|
|
2100
|
+
return e.prototype.initialize = function(n) {
|
|
2101
|
+
this.degree = n, this.genPoly = t.generateECPolynomial(this.degree);
|
|
2102
|
+
}, e.prototype.encode = function(n) {
|
|
2051
2103
|
if (!this.genPoly)
|
|
2052
2104
|
throw new Error("Encoder not initialized");
|
|
2053
|
-
const o = new Uint8Array(
|
|
2054
|
-
o.set(
|
|
2105
|
+
const o = new Uint8Array(n.length + this.degree);
|
|
2106
|
+
o.set(n);
|
|
2055
2107
|
const s = t.mod(o, this.genPoly), i = this.degree - s.length;
|
|
2056
2108
|
if (i > 0) {
|
|
2057
2109
|
const c = new Uint8Array(this.degree);
|
|
@@ -2060,23 +2112,23 @@ function Kn() {
|
|
|
2060
2112
|
return s;
|
|
2061
2113
|
}, Re = e, Re;
|
|
2062
2114
|
}
|
|
2063
|
-
var
|
|
2064
|
-
function
|
|
2065
|
-
return
|
|
2115
|
+
var Se = {}, Be = {}, Me = {}, bt;
|
|
2116
|
+
function Qt() {
|
|
2117
|
+
return bt || (bt = 1, Me.isValid = function(e) {
|
|
2066
2118
|
return !isNaN(e) && e >= 1 && e <= 40;
|
|
2067
2119
|
}), Me;
|
|
2068
2120
|
}
|
|
2069
|
-
var P = {},
|
|
2070
|
-
function
|
|
2071
|
-
if (
|
|
2072
|
-
|
|
2121
|
+
var P = {}, vt;
|
|
2122
|
+
function Gt() {
|
|
2123
|
+
if (vt) return P;
|
|
2124
|
+
vt = 1;
|
|
2073
2125
|
const t = "[0-9]+", e = "[A-Z $%*+\\-./:]+";
|
|
2074
|
-
let
|
|
2075
|
-
|
|
2076
|
-
const
|
|
2126
|
+
let r = "(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";
|
|
2127
|
+
r = r.replace(/u/g, "\\u");
|
|
2128
|
+
const n = "(?:(?![A-Z0-9 $%*+\\-./:]|" + r + `)(?:.|[\r
|
|
2077
2129
|
]))+`;
|
|
2078
|
-
P.KANJI = new RegExp(
|
|
2079
|
-
const o = new RegExp("^" +
|
|
2130
|
+
P.KANJI = new RegExp(r, "g"), P.BYTE_KANJI = new RegExp("[^A-Z0-9 $%*+\\-./:]+", "g"), P.BYTE = new RegExp(n, "g"), P.NUMERIC = new RegExp(t, "g"), P.ALPHANUMERIC = new RegExp(e, "g");
|
|
2131
|
+
const o = new RegExp("^" + r + "$"), s = new RegExp("^" + t + "$"), i = new RegExp("^[A-Z0-9 $%*+\\-./:]+$");
|
|
2080
2132
|
return P.testKanji = function(a) {
|
|
2081
2133
|
return o.test(a);
|
|
2082
2134
|
}, P.testNumeric = function(a) {
|
|
@@ -2085,10 +2137,10 @@ function Jt() {
|
|
|
2085
2137
|
return i.test(a);
|
|
2086
2138
|
}, P;
|
|
2087
2139
|
}
|
|
2088
|
-
var
|
|
2140
|
+
var At;
|
|
2089
2141
|
function J() {
|
|
2090
|
-
return
|
|
2091
|
-
const e =
|
|
2142
|
+
return At || (At = 1, (function(t) {
|
|
2143
|
+
const e = Qt(), r = Gt();
|
|
2092
2144
|
t.NUMERIC = {
|
|
2093
2145
|
id: "Numeric",
|
|
2094
2146
|
bit: 1,
|
|
@@ -2113,14 +2165,14 @@ function J() {
|
|
|
2113
2165
|
throw new Error("Invalid version: " + i);
|
|
2114
2166
|
return i >= 1 && i < 10 ? s.ccBits[0] : i < 27 ? s.ccBits[1] : s.ccBits[2];
|
|
2115
2167
|
}, t.getBestModeForData = function(s) {
|
|
2116
|
-
return
|
|
2168
|
+
return r.testNumeric(s) ? t.NUMERIC : r.testAlphanumeric(s) ? t.ALPHANUMERIC : r.testKanji(s) ? t.KANJI : t.BYTE;
|
|
2117
2169
|
}, t.toString = function(s) {
|
|
2118
2170
|
if (s && s.id) return s.id;
|
|
2119
2171
|
throw new Error("Invalid mode");
|
|
2120
2172
|
}, t.isValid = function(s) {
|
|
2121
2173
|
return s && s.bit && s.ccBits;
|
|
2122
2174
|
};
|
|
2123
|
-
function
|
|
2175
|
+
function n(o) {
|
|
2124
2176
|
if (typeof o != "string")
|
|
2125
2177
|
throw new Error("Param is not a string");
|
|
2126
2178
|
switch (o.toLowerCase()) {
|
|
@@ -2140,47 +2192,47 @@ function J() {
|
|
|
2140
2192
|
if (t.isValid(s))
|
|
2141
2193
|
return s;
|
|
2142
2194
|
try {
|
|
2143
|
-
return
|
|
2195
|
+
return n(s);
|
|
2144
2196
|
} catch {
|
|
2145
2197
|
return i;
|
|
2146
2198
|
}
|
|
2147
2199
|
};
|
|
2148
|
-
})(
|
|
2200
|
+
})(Be)), Be;
|
|
2149
2201
|
}
|
|
2150
|
-
var
|
|
2151
|
-
function
|
|
2152
|
-
return
|
|
2153
|
-
const e = O(),
|
|
2202
|
+
var Ct;
|
|
2203
|
+
function rr() {
|
|
2204
|
+
return Ct || (Ct = 1, (function(t) {
|
|
2205
|
+
const e = O(), r = Kt(), n = Oe(), o = J(), s = Qt(), i = 7973, c = e.getBCHDigit(i);
|
|
2154
2206
|
function a(f, d, w) {
|
|
2155
|
-
for (let
|
|
2156
|
-
if (d <= t.getCapacity(
|
|
2157
|
-
return
|
|
2207
|
+
for (let p = 1; p <= 40; p++)
|
|
2208
|
+
if (d <= t.getCapacity(p, w, f))
|
|
2209
|
+
return p;
|
|
2158
2210
|
}
|
|
2159
|
-
function
|
|
2211
|
+
function l(f, d) {
|
|
2160
2212
|
return o.getCharCountIndicator(f, d) + 4;
|
|
2161
2213
|
}
|
|
2162
|
-
function
|
|
2214
|
+
function u(f, d) {
|
|
2163
2215
|
let w = 0;
|
|
2164
|
-
return f.forEach(function(
|
|
2165
|
-
const
|
|
2166
|
-
w +=
|
|
2216
|
+
return f.forEach(function(p) {
|
|
2217
|
+
const B = l(p.mode, d);
|
|
2218
|
+
w += B + p.getBitsLength();
|
|
2167
2219
|
}), w;
|
|
2168
2220
|
}
|
|
2169
2221
|
function h(f, d) {
|
|
2170
2222
|
for (let w = 1; w <= 40; w++)
|
|
2171
|
-
if (
|
|
2223
|
+
if (u(f, w) <= t.getCapacity(w, d, o.MIXED))
|
|
2172
2224
|
return w;
|
|
2173
2225
|
}
|
|
2174
2226
|
t.from = function(d, w) {
|
|
2175
2227
|
return s.isValid(d) ? parseInt(d, 10) : w;
|
|
2176
|
-
}, t.getCapacity = function(d, w,
|
|
2228
|
+
}, t.getCapacity = function(d, w, p) {
|
|
2177
2229
|
if (!s.isValid(d))
|
|
2178
2230
|
throw new Error("Invalid QR Code version");
|
|
2179
|
-
typeof
|
|
2180
|
-
const
|
|
2181
|
-
if (
|
|
2182
|
-
const k =
|
|
2183
|
-
switch (
|
|
2231
|
+
typeof p > "u" && (p = o.BYTE);
|
|
2232
|
+
const B = e.getSymbolTotalCodewords(d), A = r.getTotalCodewordsCount(d, w), S = (B - A) * 8;
|
|
2233
|
+
if (p === o.MIXED) return S;
|
|
2234
|
+
const k = S - l(p, d);
|
|
2235
|
+
switch (p) {
|
|
2184
2236
|
case o.NUMERIC:
|
|
2185
2237
|
return Math.floor(k / 10 * 3);
|
|
2186
2238
|
case o.ALPHANUMERIC:
|
|
@@ -2192,17 +2244,17 @@ function Gn() {
|
|
|
2192
2244
|
return Math.floor(k / 8);
|
|
2193
2245
|
}
|
|
2194
2246
|
}, t.getBestVersionForData = function(d, w) {
|
|
2195
|
-
let
|
|
2196
|
-
const
|
|
2247
|
+
let p;
|
|
2248
|
+
const B = n.from(w, n.M);
|
|
2197
2249
|
if (Array.isArray(d)) {
|
|
2198
2250
|
if (d.length > 1)
|
|
2199
|
-
return h(d,
|
|
2251
|
+
return h(d, B);
|
|
2200
2252
|
if (d.length === 0)
|
|
2201
2253
|
return 1;
|
|
2202
|
-
|
|
2254
|
+
p = d[0];
|
|
2203
2255
|
} else
|
|
2204
|
-
|
|
2205
|
-
return a(
|
|
2256
|
+
p = d;
|
|
2257
|
+
return a(p.mode, p.getLength(), B);
|
|
2206
2258
|
}, t.getEncodedBits = function(d) {
|
|
2207
2259
|
if (!s.isValid(d) || d < 7)
|
|
2208
2260
|
throw new Error("Invalid QR Code version");
|
|
@@ -2211,47 +2263,47 @@ function Gn() {
|
|
|
2211
2263
|
w ^= i << e.getBCHDigit(w) - c;
|
|
2212
2264
|
return d << 12 | w;
|
|
2213
2265
|
};
|
|
2214
|
-
})(
|
|
2266
|
+
})(Se)), Se;
|
|
2215
2267
|
}
|
|
2216
|
-
var
|
|
2217
|
-
function
|
|
2218
|
-
if (
|
|
2219
|
-
|
|
2220
|
-
const t = O(), e = 1335,
|
|
2221
|
-
return
|
|
2268
|
+
var xe = {}, Tt;
|
|
2269
|
+
function or() {
|
|
2270
|
+
if (Tt) return xe;
|
|
2271
|
+
Tt = 1;
|
|
2272
|
+
const t = O(), e = 1335, r = 21522, n = t.getBCHDigit(e);
|
|
2273
|
+
return xe.getEncodedBits = function(s, i) {
|
|
2222
2274
|
const c = s.bit << 3 | i;
|
|
2223
2275
|
let a = c << 10;
|
|
2224
|
-
for (; t.getBCHDigit(a) -
|
|
2225
|
-
a ^= e << t.getBCHDigit(a) -
|
|
2226
|
-
return (c << 10 | a) ^
|
|
2227
|
-
},
|
|
2276
|
+
for (; t.getBCHDigit(a) - n >= 0; )
|
|
2277
|
+
a ^= e << t.getBCHDigit(a) - n;
|
|
2278
|
+
return (c << 10 | a) ^ r;
|
|
2279
|
+
}, xe;
|
|
2228
2280
|
}
|
|
2229
|
-
var
|
|
2230
|
-
function
|
|
2231
|
-
if (
|
|
2232
|
-
|
|
2281
|
+
var $e = {}, Le, kt;
|
|
2282
|
+
function sr() {
|
|
2283
|
+
if (kt) return Le;
|
|
2284
|
+
kt = 1;
|
|
2233
2285
|
const t = J();
|
|
2234
|
-
function e(
|
|
2235
|
-
this.mode = t.NUMERIC, this.data =
|
|
2286
|
+
function e(r) {
|
|
2287
|
+
this.mode = t.NUMERIC, this.data = r.toString();
|
|
2236
2288
|
}
|
|
2237
|
-
return e.getBitsLength = function(
|
|
2238
|
-
return 10 * Math.floor(
|
|
2289
|
+
return e.getBitsLength = function(n) {
|
|
2290
|
+
return 10 * Math.floor(n / 3) + (n % 3 ? n % 3 * 3 + 1 : 0);
|
|
2239
2291
|
}, e.prototype.getLength = function() {
|
|
2240
2292
|
return this.data.length;
|
|
2241
2293
|
}, e.prototype.getBitsLength = function() {
|
|
2242
2294
|
return e.getBitsLength(this.data.length);
|
|
2243
|
-
}, e.prototype.write = function(
|
|
2295
|
+
}, e.prototype.write = function(n) {
|
|
2244
2296
|
let o, s, i;
|
|
2245
2297
|
for (o = 0; o + 3 <= this.data.length; o += 3)
|
|
2246
|
-
s = this.data.substr(o, 3), i = parseInt(s, 10),
|
|
2298
|
+
s = this.data.substr(o, 3), i = parseInt(s, 10), n.put(i, 10);
|
|
2247
2299
|
const c = this.data.length - o;
|
|
2248
|
-
c > 0 && (s = this.data.substr(o), i = parseInt(s, 10),
|
|
2249
|
-
},
|
|
2300
|
+
c > 0 && (s = this.data.substr(o), i = parseInt(s, 10), n.put(i, c * 3 + 1));
|
|
2301
|
+
}, Le = e, Le;
|
|
2250
2302
|
}
|
|
2251
|
-
var
|
|
2252
|
-
function
|
|
2253
|
-
if (
|
|
2254
|
-
|
|
2303
|
+
var Ie, Et;
|
|
2304
|
+
function ir() {
|
|
2305
|
+
if (Et) return Ie;
|
|
2306
|
+
Et = 1;
|
|
2255
2307
|
const t = J(), e = [
|
|
2256
2308
|
"0",
|
|
2257
2309
|
"1",
|
|
@@ -2299,58 +2351,58 @@ function Xn() {
|
|
|
2299
2351
|
"/",
|
|
2300
2352
|
":"
|
|
2301
2353
|
];
|
|
2302
|
-
function n
|
|
2303
|
-
this.mode = t.ALPHANUMERIC, this.data =
|
|
2354
|
+
function r(n) {
|
|
2355
|
+
this.mode = t.ALPHANUMERIC, this.data = n;
|
|
2304
2356
|
}
|
|
2305
|
-
return
|
|
2357
|
+
return r.getBitsLength = function(o) {
|
|
2306
2358
|
return 11 * Math.floor(o / 2) + 6 * (o % 2);
|
|
2307
|
-
},
|
|
2359
|
+
}, r.prototype.getLength = function() {
|
|
2308
2360
|
return this.data.length;
|
|
2309
|
-
},
|
|
2310
|
-
return
|
|
2311
|
-
},
|
|
2361
|
+
}, r.prototype.getBitsLength = function() {
|
|
2362
|
+
return r.getBitsLength(this.data.length);
|
|
2363
|
+
}, r.prototype.write = function(o) {
|
|
2312
2364
|
let s;
|
|
2313
2365
|
for (s = 0; s + 2 <= this.data.length; s += 2) {
|
|
2314
2366
|
let i = e.indexOf(this.data[s]) * 45;
|
|
2315
2367
|
i += e.indexOf(this.data[s + 1]), o.put(i, 11);
|
|
2316
2368
|
}
|
|
2317
2369
|
this.data.length % 2 && o.put(e.indexOf(this.data[s]), 6);
|
|
2318
|
-
},
|
|
2370
|
+
}, Ie = r, Ie;
|
|
2319
2371
|
}
|
|
2320
|
-
var
|
|
2321
|
-
function
|
|
2322
|
-
if (
|
|
2323
|
-
|
|
2372
|
+
var Pe, _t;
|
|
2373
|
+
function ar() {
|
|
2374
|
+
if (_t) return Pe;
|
|
2375
|
+
_t = 1;
|
|
2324
2376
|
const t = J();
|
|
2325
|
-
function e(
|
|
2326
|
-
this.mode = t.BYTE, typeof
|
|
2377
|
+
function e(r) {
|
|
2378
|
+
this.mode = t.BYTE, typeof r == "string" ? this.data = new TextEncoder().encode(r) : this.data = new Uint8Array(r);
|
|
2327
2379
|
}
|
|
2328
|
-
return e.getBitsLength = function(
|
|
2329
|
-
return
|
|
2380
|
+
return e.getBitsLength = function(n) {
|
|
2381
|
+
return n * 8;
|
|
2330
2382
|
}, e.prototype.getLength = function() {
|
|
2331
2383
|
return this.data.length;
|
|
2332
2384
|
}, e.prototype.getBitsLength = function() {
|
|
2333
2385
|
return e.getBitsLength(this.data.length);
|
|
2334
|
-
}, e.prototype.write = function(
|
|
2335
|
-
for (let
|
|
2336
|
-
|
|
2337
|
-
},
|
|
2386
|
+
}, e.prototype.write = function(r) {
|
|
2387
|
+
for (let n = 0, o = this.data.length; n < o; n++)
|
|
2388
|
+
r.put(this.data[n], 8);
|
|
2389
|
+
}, Pe = e, Pe;
|
|
2338
2390
|
}
|
|
2339
|
-
var qe,
|
|
2340
|
-
function
|
|
2341
|
-
if (
|
|
2342
|
-
|
|
2391
|
+
var qe, Rt;
|
|
2392
|
+
function cr() {
|
|
2393
|
+
if (Rt) return qe;
|
|
2394
|
+
Rt = 1;
|
|
2343
2395
|
const t = J(), e = O();
|
|
2344
|
-
function n
|
|
2345
|
-
this.mode = t.KANJI, this.data =
|
|
2396
|
+
function r(n) {
|
|
2397
|
+
this.mode = t.KANJI, this.data = n;
|
|
2346
2398
|
}
|
|
2347
|
-
return
|
|
2399
|
+
return r.getBitsLength = function(o) {
|
|
2348
2400
|
return o * 13;
|
|
2349
|
-
},
|
|
2401
|
+
}, r.prototype.getLength = function() {
|
|
2350
2402
|
return this.data.length;
|
|
2351
|
-
},
|
|
2352
|
-
return
|
|
2353
|
-
},
|
|
2403
|
+
}, r.prototype.getBitsLength = function() {
|
|
2404
|
+
return r.getBitsLength(this.data.length);
|
|
2405
|
+
}, r.prototype.write = function(n) {
|
|
2354
2406
|
let o;
|
|
2355
2407
|
for (o = 0; o < this.data.length; o++) {
|
|
2356
2408
|
let s = e.toSJIS(this.data[o]);
|
|
@@ -2363,37 +2415,37 @@ function er() {
|
|
|
2363
2415
|
"Invalid SJIS character: " + this.data[o] + `
|
|
2364
2416
|
Make sure your charset is UTF-8`
|
|
2365
2417
|
);
|
|
2366
|
-
s = (s >>> 8 & 255) * 192 + (s & 255),
|
|
2418
|
+
s = (s >>> 8 & 255) * 192 + (s & 255), n.put(s, 13);
|
|
2367
2419
|
}
|
|
2368
|
-
}, qe =
|
|
2420
|
+
}, qe = r, qe;
|
|
2369
2421
|
}
|
|
2370
|
-
var De = { exports: {} },
|
|
2371
|
-
function
|
|
2372
|
-
return
|
|
2422
|
+
var De = { exports: {} }, St;
|
|
2423
|
+
function lr() {
|
|
2424
|
+
return St || (St = 1, (function(t) {
|
|
2373
2425
|
var e = {
|
|
2374
|
-
single_source_shortest_paths: function(
|
|
2426
|
+
single_source_shortest_paths: function(r, n, o) {
|
|
2375
2427
|
var s = {}, i = {};
|
|
2376
|
-
i[
|
|
2428
|
+
i[n] = 0;
|
|
2377
2429
|
var c = e.PriorityQueue.make();
|
|
2378
|
-
c.push(
|
|
2379
|
-
for (var a,
|
|
2380
|
-
a = c.pop(),
|
|
2381
|
-
for (
|
|
2382
|
-
f.hasOwnProperty(
|
|
2430
|
+
c.push(n, 0);
|
|
2431
|
+
for (var a, l, u, h, f, d, w, p, B; !c.empty(); ) {
|
|
2432
|
+
a = c.pop(), l = a.value, h = a.cost, f = r[l] || {};
|
|
2433
|
+
for (u in f)
|
|
2434
|
+
f.hasOwnProperty(u) && (d = f[u], w = h + d, p = i[u], B = typeof i[u] > "u", (B || p > w) && (i[u] = w, c.push(u, w), s[u] = l));
|
|
2383
2435
|
}
|
|
2384
2436
|
if (typeof o < "u" && typeof i[o] > "u") {
|
|
2385
|
-
var
|
|
2386
|
-
throw new Error(
|
|
2437
|
+
var A = ["Could not find a path from ", n, " to ", o, "."].join("");
|
|
2438
|
+
throw new Error(A);
|
|
2387
2439
|
}
|
|
2388
2440
|
return s;
|
|
2389
2441
|
},
|
|
2390
|
-
extract_shortest_path_from_predecessor_list: function(
|
|
2391
|
-
for (var o = [], s =
|
|
2392
|
-
o.push(s),
|
|
2442
|
+
extract_shortest_path_from_predecessor_list: function(r, n) {
|
|
2443
|
+
for (var o = [], s = n; s; )
|
|
2444
|
+
o.push(s), r[s], s = r[s];
|
|
2393
2445
|
return o.reverse(), o;
|
|
2394
2446
|
},
|
|
2395
|
-
find_path: function(
|
|
2396
|
-
var s = e.single_source_shortest_paths(
|
|
2447
|
+
find_path: function(r, n, o) {
|
|
2448
|
+
var s = e.single_source_shortest_paths(r, n, o);
|
|
2397
2449
|
return e.extract_shortest_path_from_predecessor_list(
|
|
2398
2450
|
s,
|
|
2399
2451
|
o
|
|
@@ -2403,22 +2455,22 @@ function tr() {
|
|
|
2403
2455
|
* A very naive priority queue implementation.
|
|
2404
2456
|
*/
|
|
2405
2457
|
PriorityQueue: {
|
|
2406
|
-
make: function(
|
|
2407
|
-
var
|
|
2408
|
-
|
|
2409
|
-
for (s in
|
|
2410
|
-
|
|
2411
|
-
return o.queue = [], o.sorter =
|
|
2458
|
+
make: function(r) {
|
|
2459
|
+
var n = e.PriorityQueue, o = {}, s;
|
|
2460
|
+
r = r || {};
|
|
2461
|
+
for (s in n)
|
|
2462
|
+
n.hasOwnProperty(s) && (o[s] = n[s]);
|
|
2463
|
+
return o.queue = [], o.sorter = r.sorter || n.default_sorter, o;
|
|
2412
2464
|
},
|
|
2413
|
-
default_sorter: function(
|
|
2414
|
-
return
|
|
2465
|
+
default_sorter: function(r, n) {
|
|
2466
|
+
return r.cost - n.cost;
|
|
2415
2467
|
},
|
|
2416
2468
|
/**
|
|
2417
2469
|
* Add a new item to the queue and ensure the highest priority element
|
|
2418
2470
|
* is at the front of the queue.
|
|
2419
2471
|
*/
|
|
2420
|
-
push: function(
|
|
2421
|
-
var o = { value:
|
|
2472
|
+
push: function(r, n) {
|
|
2473
|
+
var o = { value: r, cost: n };
|
|
2422
2474
|
this.queue.push(o), this.queue.sort(this.sorter);
|
|
2423
2475
|
},
|
|
2424
2476
|
/**
|
|
@@ -2435,339 +2487,339 @@ function tr() {
|
|
|
2435
2487
|
t.exports = e;
|
|
2436
2488
|
})(De)), De.exports;
|
|
2437
2489
|
}
|
|
2438
|
-
var
|
|
2439
|
-
function
|
|
2440
|
-
return
|
|
2441
|
-
const e = J(),
|
|
2442
|
-
function
|
|
2443
|
-
return unescape(encodeURIComponent(
|
|
2490
|
+
var Bt;
|
|
2491
|
+
function ur() {
|
|
2492
|
+
return Bt || (Bt = 1, (function(t) {
|
|
2493
|
+
const e = J(), r = sr(), n = ir(), o = ar(), s = cr(), i = Gt(), c = O(), a = lr();
|
|
2494
|
+
function l(A) {
|
|
2495
|
+
return unescape(encodeURIComponent(A)).length;
|
|
2444
2496
|
}
|
|
2445
|
-
function
|
|
2497
|
+
function u(A, S, k) {
|
|
2446
2498
|
const E = [];
|
|
2447
|
-
let
|
|
2448
|
-
for (; (
|
|
2499
|
+
let x;
|
|
2500
|
+
for (; (x = A.exec(k)) !== null; )
|
|
2449
2501
|
E.push({
|
|
2450
|
-
data:
|
|
2451
|
-
index:
|
|
2452
|
-
mode:
|
|
2453
|
-
length:
|
|
2502
|
+
data: x[0],
|
|
2503
|
+
index: x.index,
|
|
2504
|
+
mode: S,
|
|
2505
|
+
length: x[0].length
|
|
2454
2506
|
});
|
|
2455
2507
|
return E;
|
|
2456
2508
|
}
|
|
2457
|
-
function h(
|
|
2458
|
-
const
|
|
2459
|
-
let E,
|
|
2460
|
-
return c.isKanjiModeEnabled() ? (E =
|
|
2461
|
-
return
|
|
2462
|
-
}).map(function(
|
|
2509
|
+
function h(A) {
|
|
2510
|
+
const S = u(i.NUMERIC, e.NUMERIC, A), k = u(i.ALPHANUMERIC, e.ALPHANUMERIC, A);
|
|
2511
|
+
let E, x;
|
|
2512
|
+
return c.isKanjiModeEnabled() ? (E = u(i.BYTE, e.BYTE, A), x = u(i.KANJI, e.KANJI, A)) : (E = u(i.BYTE_KANJI, e.BYTE, A), x = []), S.concat(k, E, x).sort(function(C, v) {
|
|
2513
|
+
return C.index - v.index;
|
|
2514
|
+
}).map(function(C) {
|
|
2463
2515
|
return {
|
|
2464
|
-
data:
|
|
2465
|
-
mode:
|
|
2466
|
-
length:
|
|
2516
|
+
data: C.data,
|
|
2517
|
+
mode: C.mode,
|
|
2518
|
+
length: C.length
|
|
2467
2519
|
};
|
|
2468
2520
|
});
|
|
2469
2521
|
}
|
|
2470
|
-
function f(
|
|
2471
|
-
switch (
|
|
2522
|
+
function f(A, S) {
|
|
2523
|
+
switch (S) {
|
|
2472
2524
|
case e.NUMERIC:
|
|
2473
|
-
return
|
|
2525
|
+
return r.getBitsLength(A);
|
|
2474
2526
|
case e.ALPHANUMERIC:
|
|
2475
|
-
return
|
|
2527
|
+
return n.getBitsLength(A);
|
|
2476
2528
|
case e.KANJI:
|
|
2477
|
-
return s.getBitsLength(
|
|
2529
|
+
return s.getBitsLength(A);
|
|
2478
2530
|
case e.BYTE:
|
|
2479
|
-
return o.getBitsLength(
|
|
2531
|
+
return o.getBitsLength(A);
|
|
2480
2532
|
}
|
|
2481
2533
|
}
|
|
2482
|
-
function d(
|
|
2483
|
-
return
|
|
2484
|
-
const E =
|
|
2485
|
-
return E && E.mode === k.mode ? (
|
|
2534
|
+
function d(A) {
|
|
2535
|
+
return A.reduce(function(S, k) {
|
|
2536
|
+
const E = S.length - 1 >= 0 ? S[S.length - 1] : null;
|
|
2537
|
+
return E && E.mode === k.mode ? (S[S.length - 1].data += k.data, S) : (S.push(k), S);
|
|
2486
2538
|
}, []);
|
|
2487
2539
|
}
|
|
2488
|
-
function w(
|
|
2489
|
-
const
|
|
2490
|
-
for (let k = 0; k <
|
|
2491
|
-
const E =
|
|
2540
|
+
function w(A) {
|
|
2541
|
+
const S = [];
|
|
2542
|
+
for (let k = 0; k < A.length; k++) {
|
|
2543
|
+
const E = A[k];
|
|
2492
2544
|
switch (E.mode) {
|
|
2493
2545
|
case e.NUMERIC:
|
|
2494
|
-
|
|
2546
|
+
S.push([
|
|
2495
2547
|
E,
|
|
2496
2548
|
{ data: E.data, mode: e.ALPHANUMERIC, length: E.length },
|
|
2497
2549
|
{ data: E.data, mode: e.BYTE, length: E.length }
|
|
2498
2550
|
]);
|
|
2499
2551
|
break;
|
|
2500
2552
|
case e.ALPHANUMERIC:
|
|
2501
|
-
|
|
2553
|
+
S.push([
|
|
2502
2554
|
E,
|
|
2503
2555
|
{ data: E.data, mode: e.BYTE, length: E.length }
|
|
2504
2556
|
]);
|
|
2505
2557
|
break;
|
|
2506
2558
|
case e.KANJI:
|
|
2507
|
-
|
|
2559
|
+
S.push([
|
|
2508
2560
|
E,
|
|
2509
|
-
{ data: E.data, mode: e.BYTE, length:
|
|
2561
|
+
{ data: E.data, mode: e.BYTE, length: l(E.data) }
|
|
2510
2562
|
]);
|
|
2511
2563
|
break;
|
|
2512
2564
|
case e.BYTE:
|
|
2513
|
-
|
|
2514
|
-
{ data: E.data, mode: e.BYTE, length:
|
|
2565
|
+
S.push([
|
|
2566
|
+
{ data: E.data, mode: e.BYTE, length: l(E.data) }
|
|
2515
2567
|
]);
|
|
2516
2568
|
}
|
|
2517
2569
|
}
|
|
2518
|
-
return
|
|
2570
|
+
return S;
|
|
2519
2571
|
}
|
|
2520
|
-
function
|
|
2572
|
+
function p(A, S) {
|
|
2521
2573
|
const k = {}, E = { start: {} };
|
|
2522
|
-
let
|
|
2523
|
-
for (let
|
|
2524
|
-
const
|
|
2525
|
-
for (let g = 0; g <
|
|
2526
|
-
const _ =
|
|
2527
|
-
|
|
2528
|
-
for (let
|
|
2529
|
-
const b =
|
|
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,
|
|
2574
|
+
let x = ["start"];
|
|
2575
|
+
for (let m = 0; m < A.length; m++) {
|
|
2576
|
+
const C = A[m], v = [];
|
|
2577
|
+
for (let g = 0; g < C.length; g++) {
|
|
2578
|
+
const _ = C[g], y = "" + m + g;
|
|
2579
|
+
v.push(y), k[y] = { node: _, lastCount: 0 }, E[y] = {};
|
|
2580
|
+
for (let T = 0; T < x.length; T++) {
|
|
2581
|
+
const b = x[T];
|
|
2582
|
+
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, S));
|
|
2531
2583
|
}
|
|
2532
2584
|
}
|
|
2533
|
-
|
|
2585
|
+
x = v;
|
|
2534
2586
|
}
|
|
2535
|
-
for (let
|
|
2536
|
-
E[
|
|
2587
|
+
for (let m = 0; m < x.length; m++)
|
|
2588
|
+
E[x[m]].end = 0;
|
|
2537
2589
|
return { map: E, table: k };
|
|
2538
2590
|
}
|
|
2539
|
-
function
|
|
2591
|
+
function B(A, S) {
|
|
2540
2592
|
let k;
|
|
2541
|
-
const E = e.getBestModeForData(
|
|
2542
|
-
if (k = e.from(
|
|
2543
|
-
throw new Error('"' +
|
|
2593
|
+
const E = e.getBestModeForData(A);
|
|
2594
|
+
if (k = e.from(S, E), k !== e.BYTE && k.bit < E.bit)
|
|
2595
|
+
throw new Error('"' + A + '" cannot be encoded with mode ' + e.toString(k) + `.
|
|
2544
2596
|
Suggested mode is: ` + e.toString(E));
|
|
2545
2597
|
switch (k === e.KANJI && !c.isKanjiModeEnabled() && (k = e.BYTE), k) {
|
|
2546
2598
|
case e.NUMERIC:
|
|
2547
|
-
return new
|
|
2599
|
+
return new r(A);
|
|
2548
2600
|
case e.ALPHANUMERIC:
|
|
2549
|
-
return new
|
|
2601
|
+
return new n(A);
|
|
2550
2602
|
case e.KANJI:
|
|
2551
|
-
return new s(
|
|
2603
|
+
return new s(A);
|
|
2552
2604
|
case e.BYTE:
|
|
2553
|
-
return new o(
|
|
2605
|
+
return new o(A);
|
|
2554
2606
|
}
|
|
2555
2607
|
}
|
|
2556
|
-
t.fromArray = function(
|
|
2557
|
-
return
|
|
2558
|
-
return typeof E == "string" ? k.push(
|
|
2608
|
+
t.fromArray = function(S) {
|
|
2609
|
+
return S.reduce(function(k, E) {
|
|
2610
|
+
return typeof E == "string" ? k.push(B(E, null)) : E.data && k.push(B(E.data, E.mode)), k;
|
|
2559
2611
|
}, []);
|
|
2560
|
-
}, t.fromString = function(
|
|
2561
|
-
const E = h(
|
|
2562
|
-
for (let g = 1; g <
|
|
2563
|
-
|
|
2564
|
-
return t.fromArray(d(
|
|
2565
|
-
}, t.rawSplit = function(
|
|
2612
|
+
}, t.fromString = function(S, k) {
|
|
2613
|
+
const E = h(S, c.isKanjiModeEnabled()), x = w(E), m = p(x, k), C = a.find_path(m.map, "start", "end"), v = [];
|
|
2614
|
+
for (let g = 1; g < C.length - 1; g++)
|
|
2615
|
+
v.push(m.table[C[g]].node);
|
|
2616
|
+
return t.fromArray(d(v));
|
|
2617
|
+
}, t.rawSplit = function(S) {
|
|
2566
2618
|
return t.fromArray(
|
|
2567
|
-
h(
|
|
2619
|
+
h(S, c.isKanjiModeEnabled())
|
|
2568
2620
|
);
|
|
2569
2621
|
};
|
|
2570
|
-
})(
|
|
2622
|
+
})($e)), $e;
|
|
2571
2623
|
}
|
|
2572
|
-
var
|
|
2573
|
-
function
|
|
2574
|
-
if (
|
|
2575
|
-
|
|
2576
|
-
const t = O(), e =
|
|
2577
|
-
function d(
|
|
2578
|
-
const
|
|
2624
|
+
var Mt;
|
|
2625
|
+
function hr() {
|
|
2626
|
+
if (Mt) return be;
|
|
2627
|
+
Mt = 1;
|
|
2628
|
+
const t = O(), e = Oe(), r = Qn(), n = Gn(), o = Yn(), s = Xn(), i = Zn(), c = Kt(), a = nr(), l = rr(), u = or(), h = J(), f = ur();
|
|
2629
|
+
function d(m, C) {
|
|
2630
|
+
const v = m.size, g = s.getPositions(C);
|
|
2579
2631
|
for (let _ = 0; _ < g.length; _++) {
|
|
2580
|
-
const y = g[_][0],
|
|
2632
|
+
const y = g[_][0], T = g[_][1];
|
|
2581
2633
|
for (let b = -1; b <= 7; b++)
|
|
2582
|
-
if (!(y + b <= -1 ||
|
|
2634
|
+
if (!(y + b <= -1 || v <= y + b))
|
|
2583
2635
|
for (let R = -1; R <= 7; R++)
|
|
2584
|
-
|
|
2636
|
+
T + R <= -1 || v <= T + 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 ? m.set(y + b, T + R, !0, !0) : m.set(y + b, T + R, !1, !0));
|
|
2585
2637
|
}
|
|
2586
2638
|
}
|
|
2587
|
-
function w(
|
|
2588
|
-
const
|
|
2589
|
-
for (let
|
|
2590
|
-
const g =
|
|
2591
|
-
|
|
2639
|
+
function w(m) {
|
|
2640
|
+
const C = m.size;
|
|
2641
|
+
for (let v = 8; v < C - 8; v++) {
|
|
2642
|
+
const g = v % 2 === 0;
|
|
2643
|
+
m.set(v, 6, g, !0), m.set(6, v, g, !0);
|
|
2592
2644
|
}
|
|
2593
2645
|
}
|
|
2594
|
-
function m
|
|
2595
|
-
const
|
|
2596
|
-
for (let g = 0; g <
|
|
2597
|
-
const _ =
|
|
2598
|
-
for (let
|
|
2646
|
+
function p(m, C) {
|
|
2647
|
+
const v = o.getPositions(C);
|
|
2648
|
+
for (let g = 0; g < v.length; g++) {
|
|
2649
|
+
const _ = v[g][0], y = v[g][1];
|
|
2650
|
+
for (let T = -2; T <= 2; T++)
|
|
2599
2651
|
for (let b = -2; b <= 2; b++)
|
|
2600
|
-
|
|
2652
|
+
T === -2 || T === 2 || b === -2 || b === 2 || T === 0 && b === 0 ? m.set(_ + T, y + b, !0, !0) : m.set(_ + T, y + b, !1, !0);
|
|
2601
2653
|
}
|
|
2602
2654
|
}
|
|
2603
|
-
function
|
|
2604
|
-
const
|
|
2605
|
-
let _, y,
|
|
2655
|
+
function B(m, C) {
|
|
2656
|
+
const v = m.size, g = l.getEncodedBits(C);
|
|
2657
|
+
let _, y, T;
|
|
2606
2658
|
for (let b = 0; b < 18; b++)
|
|
2607
|
-
_ = Math.floor(b / 3), y = b % 3 +
|
|
2659
|
+
_ = Math.floor(b / 3), y = b % 3 + v - 8 - 3, T = (g >> b & 1) === 1, m.set(_, y, T, !0), m.set(y, _, T, !0);
|
|
2608
2660
|
}
|
|
2609
|
-
function
|
|
2610
|
-
const g =
|
|
2611
|
-
let y,
|
|
2661
|
+
function A(m, C, v) {
|
|
2662
|
+
const g = m.size, _ = u.getEncodedBits(C, v);
|
|
2663
|
+
let y, T;
|
|
2612
2664
|
for (y = 0; y < 15; y++)
|
|
2613
|
-
|
|
2614
|
-
|
|
2665
|
+
T = (_ >> y & 1) === 1, y < 6 ? m.set(y, 8, T, !0) : y < 8 ? m.set(y + 1, 8, T, !0) : m.set(g - 15 + y, 8, T, !0), y < 8 ? m.set(8, g - y - 1, T, !0) : y < 9 ? m.set(8, 15 - y - 1 + 1, T, !0) : m.set(8, 15 - y - 1, T, !0);
|
|
2666
|
+
m.set(g - 8, 8, 1, !0);
|
|
2615
2667
|
}
|
|
2616
|
-
function
|
|
2617
|
-
const
|
|
2618
|
-
let g = -1, _ =
|
|
2619
|
-
for (let b =
|
|
2668
|
+
function S(m, C) {
|
|
2669
|
+
const v = m.size;
|
|
2670
|
+
let g = -1, _ = v - 1, y = 7, T = 0;
|
|
2671
|
+
for (let b = v - 1; b > 0; b -= 2)
|
|
2620
2672
|
for (b === 6 && b--; ; ) {
|
|
2621
2673
|
for (let R = 0; R < 2; R++)
|
|
2622
|
-
if (!
|
|
2623
|
-
let
|
|
2624
|
-
|
|
2674
|
+
if (!m.isReserved(_, b - R)) {
|
|
2675
|
+
let F = !1;
|
|
2676
|
+
T < C.length && (F = (C[T] >>> y & 1) === 1), m.set(_, b - R, F), y--, y === -1 && (T++, y = 7);
|
|
2625
2677
|
}
|
|
2626
|
-
if (_ += g, _ < 0 ||
|
|
2678
|
+
if (_ += g, _ < 0 || v <= _) {
|
|
2627
2679
|
_ -= g, g = -g;
|
|
2628
2680
|
break;
|
|
2629
2681
|
}
|
|
2630
2682
|
}
|
|
2631
2683
|
}
|
|
2632
|
-
function k(
|
|
2633
|
-
const g = new
|
|
2634
|
-
|
|
2635
|
-
g.put(R.mode.bit, 4), g.put(R.getLength(), h.getCharCountIndicator(R.mode,
|
|
2684
|
+
function k(m, C, v) {
|
|
2685
|
+
const g = new r();
|
|
2686
|
+
v.forEach(function(R) {
|
|
2687
|
+
g.put(R.mode.bit, 4), g.put(R.getLength(), h.getCharCountIndicator(R.mode, m)), R.write(g);
|
|
2636
2688
|
});
|
|
2637
|
-
const _ = t.getSymbolTotalCodewords(
|
|
2638
|
-
for (g.getLengthInBits() + 4 <=
|
|
2689
|
+
const _ = t.getSymbolTotalCodewords(m), y = c.getTotalCodewordsCount(m, C), T = (_ - y) * 8;
|
|
2690
|
+
for (g.getLengthInBits() + 4 <= T && g.put(0, 4); g.getLengthInBits() % 8 !== 0; )
|
|
2639
2691
|
g.putBit(0);
|
|
2640
|
-
const b = (
|
|
2692
|
+
const b = (T - g.getLengthInBits()) / 8;
|
|
2641
2693
|
for (let R = 0; R < b; R++)
|
|
2642
2694
|
g.put(R % 2 ? 17 : 236, 8);
|
|
2643
|
-
return E(g,
|
|
2695
|
+
return E(g, m, C);
|
|
2644
2696
|
}
|
|
2645
|
-
function E(
|
|
2646
|
-
const g = t.getSymbolTotalCodewords(
|
|
2697
|
+
function E(m, C, v) {
|
|
2698
|
+
const g = t.getSymbolTotalCodewords(C), _ = c.getTotalCodewordsCount(C, v), y = g - _, T = c.getBlocksCount(C, v), b = g % T, R = T - b, F = Math.floor(g / T), Z = Math.floor(y / T), en = Z + 1, Je = F - Z, tn = new a(Je);
|
|
2647
2699
|
let he = 0;
|
|
2648
|
-
const
|
|
2700
|
+
const ae = new Array(T), Ke = new Array(T);
|
|
2649
2701
|
let de = 0;
|
|
2650
|
-
const
|
|
2651
|
-
for (let K = 0; K <
|
|
2652
|
-
const ge = K < R ?
|
|
2653
|
-
|
|
2702
|
+
const nn = new Uint8Array(m.buffer);
|
|
2703
|
+
for (let K = 0; K < T; K++) {
|
|
2704
|
+
const ge = K < R ? Z : en;
|
|
2705
|
+
ae[K] = nn.slice(he, he + ge), Ke[K] = tn.encode(ae[K]), he += ge, de = Math.max(de, ge);
|
|
2654
2706
|
}
|
|
2655
2707
|
const fe = new Uint8Array(g);
|
|
2656
|
-
let
|
|
2657
|
-
for (
|
|
2658
|
-
for (
|
|
2659
|
-
|
|
2660
|
-
for (
|
|
2661
|
-
for (
|
|
2662
|
-
fe[
|
|
2708
|
+
let Qe = 0, q, D;
|
|
2709
|
+
for (q = 0; q < de; q++)
|
|
2710
|
+
for (D = 0; D < T; D++)
|
|
2711
|
+
q < ae[D].length && (fe[Qe++] = ae[D][q]);
|
|
2712
|
+
for (q = 0; q < Je; q++)
|
|
2713
|
+
for (D = 0; D < T; D++)
|
|
2714
|
+
fe[Qe++] = Ke[D][q];
|
|
2663
2715
|
return fe;
|
|
2664
2716
|
}
|
|
2665
|
-
function
|
|
2717
|
+
function x(m, C, v, g) {
|
|
2666
2718
|
let _;
|
|
2667
|
-
if (Array.isArray(
|
|
2668
|
-
_ = f.fromArray(
|
|
2669
|
-
else if (typeof
|
|
2670
|
-
let
|
|
2671
|
-
if (!
|
|
2672
|
-
const
|
|
2673
|
-
|
|
2719
|
+
if (Array.isArray(m))
|
|
2720
|
+
_ = f.fromArray(m);
|
|
2721
|
+
else if (typeof m == "string") {
|
|
2722
|
+
let F = C;
|
|
2723
|
+
if (!F) {
|
|
2724
|
+
const Z = f.rawSplit(m);
|
|
2725
|
+
F = l.getBestVersionForData(Z, v);
|
|
2674
2726
|
}
|
|
2675
|
-
_ = f.fromString(
|
|
2727
|
+
_ = f.fromString(m, F || 40);
|
|
2676
2728
|
} else
|
|
2677
2729
|
throw new Error("Invalid data");
|
|
2678
|
-
const y =
|
|
2730
|
+
const y = l.getBestVersionForData(_, v);
|
|
2679
2731
|
if (!y)
|
|
2680
2732
|
throw new Error("The amount of data is too big to be stored in a QR Code");
|
|
2681
|
-
if (!
|
|
2682
|
-
|
|
2683
|
-
else if (
|
|
2733
|
+
if (!C)
|
|
2734
|
+
C = y;
|
|
2735
|
+
else if (C < y)
|
|
2684
2736
|
throw new Error(
|
|
2685
2737
|
`
|
|
2686
2738
|
The chosen QR Code version cannot contain this amount of data.
|
|
2687
2739
|
Minimum version required to store current data is: ` + y + `.
|
|
2688
2740
|
`
|
|
2689
2741
|
);
|
|
2690
|
-
const
|
|
2691
|
-
return d(R,
|
|
2742
|
+
const T = k(C, v, _), b = t.getSymbolSize(C), R = new n(b);
|
|
2743
|
+
return d(R, C), w(R), p(R, C), A(R, v, 0), C >= 7 && B(R, C), S(R, T), isNaN(g) && (g = i.getBestMask(
|
|
2692
2744
|
R,
|
|
2693
|
-
|
|
2694
|
-
)), i.applyMask(g, R),
|
|
2745
|
+
A.bind(null, R, v)
|
|
2746
|
+
)), i.applyMask(g, R), A(R, v, g), {
|
|
2695
2747
|
modules: R,
|
|
2696
|
-
version:
|
|
2697
|
-
errorCorrectionLevel:
|
|
2748
|
+
version: C,
|
|
2749
|
+
errorCorrectionLevel: v,
|
|
2698
2750
|
maskPattern: g,
|
|
2699
2751
|
segments: _
|
|
2700
2752
|
};
|
|
2701
2753
|
}
|
|
2702
|
-
return be.create = function(
|
|
2703
|
-
if (typeof
|
|
2754
|
+
return be.create = function(C, v) {
|
|
2755
|
+
if (typeof C > "u" || C === "")
|
|
2704
2756
|
throw new Error("No input text");
|
|
2705
2757
|
let g = e.M, _, y;
|
|
2706
|
-
return typeof
|
|
2758
|
+
return typeof v < "u" && (g = e.from(v.errorCorrectionLevel, e.M), _ = l.from(v.version), y = i.from(v.maskPattern), v.toSJISFunc && t.setToSJISFunction(v.toSJISFunc)), x(C, _, g, y);
|
|
2707
2759
|
}, be;
|
|
2708
2760
|
}
|
|
2709
|
-
var Ne = {}, Ue = {},
|
|
2710
|
-
function
|
|
2711
|
-
return
|
|
2712
|
-
function e(
|
|
2713
|
-
if (typeof
|
|
2761
|
+
var Ne = {}, Ue = {}, xt;
|
|
2762
|
+
function Yt() {
|
|
2763
|
+
return xt || (xt = 1, (function(t) {
|
|
2764
|
+
function e(r) {
|
|
2765
|
+
if (typeof r == "number" && (r = r.toString()), typeof r != "string")
|
|
2714
2766
|
throw new Error("Color should be defined as hex string");
|
|
2715
|
-
let
|
|
2716
|
-
if (
|
|
2717
|
-
throw new Error("Invalid hex color: " +
|
|
2718
|
-
(
|
|
2767
|
+
let n = r.slice().replace("#", "").split("");
|
|
2768
|
+
if (n.length < 3 || n.length === 5 || n.length > 8)
|
|
2769
|
+
throw new Error("Invalid hex color: " + r);
|
|
2770
|
+
(n.length === 3 || n.length === 4) && (n = Array.prototype.concat.apply([], n.map(function(s) {
|
|
2719
2771
|
return [s, s];
|
|
2720
|
-
}))),
|
|
2721
|
-
const o = parseInt(
|
|
2772
|
+
}))), n.length === 6 && n.push("F", "F");
|
|
2773
|
+
const o = parseInt(n.join(""), 16);
|
|
2722
2774
|
return {
|
|
2723
2775
|
r: o >> 24 & 255,
|
|
2724
2776
|
g: o >> 16 & 255,
|
|
2725
2777
|
b: o >> 8 & 255,
|
|
2726
2778
|
a: o & 255,
|
|
2727
|
-
hex: "#" +
|
|
2779
|
+
hex: "#" + n.slice(0, 6).join("")
|
|
2728
2780
|
};
|
|
2729
2781
|
}
|
|
2730
|
-
t.getOptions = function(
|
|
2731
|
-
|
|
2732
|
-
const o = typeof
|
|
2782
|
+
t.getOptions = function(n) {
|
|
2783
|
+
n || (n = {}), n.color || (n.color = {});
|
|
2784
|
+
const o = typeof n.margin > "u" || n.margin === null || n.margin < 0 ? 4 : n.margin, s = n.width && n.width >= 21 ? n.width : void 0, i = n.scale || 4;
|
|
2733
2785
|
return {
|
|
2734
2786
|
width: s,
|
|
2735
2787
|
scale: s ? 4 : i,
|
|
2736
2788
|
margin: o,
|
|
2737
2789
|
color: {
|
|
2738
|
-
dark: e(
|
|
2739
|
-
light: e(
|
|
2790
|
+
dark: e(n.color.dark || "#000000ff"),
|
|
2791
|
+
light: e(n.color.light || "#ffffffff")
|
|
2740
2792
|
},
|
|
2741
|
-
type:
|
|
2742
|
-
rendererOpts:
|
|
2793
|
+
type: n.type,
|
|
2794
|
+
rendererOpts: n.rendererOpts || {}
|
|
2743
2795
|
};
|
|
2744
|
-
}, t.getScale = function(
|
|
2745
|
-
return o.width && o.width >=
|
|
2746
|
-
}, t.getImageWidth = function(
|
|
2747
|
-
const s = t.getScale(
|
|
2748
|
-
return Math.floor((
|
|
2749
|
-
}, t.qrToImageData = function(
|
|
2750
|
-
const i = o.modules.size, c = o.modules.data, a = t.getScale(i, s),
|
|
2751
|
-
for (let f = 0; f <
|
|
2752
|
-
for (let d = 0; d <
|
|
2753
|
-
let w = (f *
|
|
2754
|
-
if (f >=
|
|
2755
|
-
const
|
|
2756
|
-
|
|
2796
|
+
}, t.getScale = function(n, o) {
|
|
2797
|
+
return o.width && o.width >= n + o.margin * 2 ? o.width / (n + o.margin * 2) : o.scale;
|
|
2798
|
+
}, t.getImageWidth = function(n, o) {
|
|
2799
|
+
const s = t.getScale(n, o);
|
|
2800
|
+
return Math.floor((n + o.margin * 2) * s);
|
|
2801
|
+
}, t.qrToImageData = function(n, o, s) {
|
|
2802
|
+
const i = o.modules.size, c = o.modules.data, a = t.getScale(i, s), l = Math.floor((i + s.margin * 2) * a), u = s.margin * a, h = [s.color.light, s.color.dark];
|
|
2803
|
+
for (let f = 0; f < l; f++)
|
|
2804
|
+
for (let d = 0; d < l; d++) {
|
|
2805
|
+
let w = (f * l + d) * 4, p = s.color.light;
|
|
2806
|
+
if (f >= u && d >= u && f < l - u && d < l - u) {
|
|
2807
|
+
const B = Math.floor((f - u) / a), A = Math.floor((d - u) / a);
|
|
2808
|
+
p = h[c[B * i + A] ? 1 : 0];
|
|
2757
2809
|
}
|
|
2758
|
-
|
|
2810
|
+
n[w++] = p.r, n[w++] = p.g, n[w++] = p.b, n[w] = p.a;
|
|
2759
2811
|
}
|
|
2760
2812
|
};
|
|
2761
2813
|
})(Ue)), Ue;
|
|
2762
2814
|
}
|
|
2763
|
-
var
|
|
2764
|
-
function
|
|
2765
|
-
return
|
|
2766
|
-
const e =
|
|
2767
|
-
function
|
|
2815
|
+
var $t;
|
|
2816
|
+
function dr() {
|
|
2817
|
+
return $t || ($t = 1, (function(t) {
|
|
2818
|
+
const e = Yt();
|
|
2819
|
+
function r(o, s, i) {
|
|
2768
2820
|
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
2821
|
}
|
|
2770
|
-
function
|
|
2822
|
+
function n() {
|
|
2771
2823
|
try {
|
|
2772
2824
|
return document.createElement("canvas");
|
|
2773
2825
|
} catch {
|
|
@@ -2775,122 +2827,128 @@ function or() {
|
|
|
2775
2827
|
}
|
|
2776
2828
|
}
|
|
2777
2829
|
t.render = function(s, i, c) {
|
|
2778
|
-
let a = c,
|
|
2779
|
-
typeof a > "u" && (!i || !i.getContext) && (a = i, i = void 0), i || (
|
|
2780
|
-
const
|
|
2781
|
-
return e.qrToImageData(f.data, s, a),
|
|
2830
|
+
let a = c, l = i;
|
|
2831
|
+
typeof a > "u" && (!i || !i.getContext) && (a = i, i = void 0), i || (l = n()), a = e.getOptions(a);
|
|
2832
|
+
const u = e.getImageWidth(s.modules.size, a), h = l.getContext("2d"), f = h.createImageData(u, u);
|
|
2833
|
+
return e.qrToImageData(f.data, s, a), r(h, l, u), h.putImageData(f, 0, 0), l;
|
|
2782
2834
|
}, t.renderToDataURL = function(s, i, c) {
|
|
2783
2835
|
let a = c;
|
|
2784
2836
|
typeof a > "u" && (!i || !i.getContext) && (a = i, i = void 0), a || (a = {});
|
|
2785
|
-
const
|
|
2786
|
-
return
|
|
2837
|
+
const l = t.render(s, i, a), u = a.type || "image/png", h = a.rendererOpts || {};
|
|
2838
|
+
return l.toDataURL(u, h.quality);
|
|
2787
2839
|
};
|
|
2788
2840
|
})(Ne)), Ne;
|
|
2789
2841
|
}
|
|
2790
|
-
var Fe = {},
|
|
2791
|
-
function
|
|
2792
|
-
if (
|
|
2793
|
-
|
|
2794
|
-
const t =
|
|
2842
|
+
var Fe = {}, Lt;
|
|
2843
|
+
function fr() {
|
|
2844
|
+
if (Lt) return Fe;
|
|
2845
|
+
Lt = 1;
|
|
2846
|
+
const t = Yt();
|
|
2795
2847
|
function e(o, s) {
|
|
2796
2848
|
const i = o.a / 255, c = s + '="' + o.hex + '"';
|
|
2797
2849
|
return i < 1 ? c + " " + s + '-opacity="' + i.toFixed(2).slice(1) + '"' : c;
|
|
2798
2850
|
}
|
|
2799
|
-
function
|
|
2851
|
+
function r(o, s, i) {
|
|
2800
2852
|
let c = o + s;
|
|
2801
2853
|
return typeof i < "u" && (c += " " + i), c;
|
|
2802
2854
|
}
|
|
2803
|
-
function
|
|
2804
|
-
let c = "", a = 0,
|
|
2855
|
+
function n(o, s, i) {
|
|
2856
|
+
let c = "", a = 0, l = !1, u = 0;
|
|
2805
2857
|
for (let h = 0; h < o.length; h++) {
|
|
2806
2858
|
const f = Math.floor(h % s), d = Math.floor(h / s);
|
|
2807
|
-
!f && !
|
|
2859
|
+
!f && !l && (l = !0), o[h] ? (u++, h > 0 && f > 0 && o[h - 1] || (c += l ? r("M", f + i, 0.5 + d + i) : r("m", a, 0), a = 0, l = !1), f + 1 < s && o[h + 1] || (c += r("h", u), u = 0)) : a++;
|
|
2808
2860
|
}
|
|
2809
2861
|
return c;
|
|
2810
2862
|
}
|
|
2811
2863
|
return Fe.render = function(s, i, c) {
|
|
2812
|
-
const a = t.getOptions(i),
|
|
2864
|
+
const a = t.getOptions(i), l = s.modules.size, u = s.modules.data, h = l + a.margin * 2, f = a.color.light.a ? "<path " + e(a.color.light, "fill") + ' d="M0 0h' + h + "v" + h + 'H0z"/>' : "", d = "<path " + e(a.color.dark, "stroke") + ' d="' + n(u, l, a.margin) + '"/>', w = 'viewBox="0 0 ' + h + " " + h + '"', B = '<svg xmlns="http://www.w3.org/2000/svg" ' + (a.width ? 'width="' + a.width + '" height="' + a.width + '" ' : "") + w + ' shape-rendering="crispEdges">' + f + d + `</svg>
|
|
2813
2865
|
`;
|
|
2814
|
-
return typeof c == "function" && c(null,
|
|
2866
|
+
return typeof c == "function" && c(null, B), B;
|
|
2815
2867
|
}, Fe;
|
|
2816
2868
|
}
|
|
2817
2869
|
var It;
|
|
2818
|
-
function
|
|
2819
|
-
if (It) return
|
|
2870
|
+
function gr() {
|
|
2871
|
+
if (It) return Q;
|
|
2820
2872
|
It = 1;
|
|
2821
|
-
const t =
|
|
2822
|
-
function o(s, i, c, a,
|
|
2823
|
-
const
|
|
2873
|
+
const t = Kn(), e = hr(), r = dr(), n = fr();
|
|
2874
|
+
function o(s, i, c, a, l) {
|
|
2875
|
+
const u = [].slice.call(arguments, 1), h = u.length, f = typeof u[h - 1] == "function";
|
|
2824
2876
|
if (!f && !t())
|
|
2825
2877
|
throw new Error("Callback required as last argument");
|
|
2826
2878
|
if (f) {
|
|
2827
2879
|
if (h < 2)
|
|
2828
2880
|
throw new Error("Too few arguments provided");
|
|
2829
|
-
h === 2 ? (
|
|
2881
|
+
h === 2 ? (l = c, c = i, i = a = void 0) : h === 3 && (i.getContext && typeof l > "u" ? (l = a, a = void 0) : (l = a, a = c, c = i, i = void 0));
|
|
2830
2882
|
} else {
|
|
2831
2883
|
if (h < 1)
|
|
2832
2884
|
throw new Error("Too few arguments provided");
|
|
2833
2885
|
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
2886
|
try {
|
|
2835
|
-
const
|
|
2836
|
-
d(s(
|
|
2837
|
-
} catch (
|
|
2838
|
-
w(
|
|
2887
|
+
const p = e.create(c, a);
|
|
2888
|
+
d(s(p, i, a));
|
|
2889
|
+
} catch (p) {
|
|
2890
|
+
w(p);
|
|
2839
2891
|
}
|
|
2840
2892
|
});
|
|
2841
2893
|
}
|
|
2842
2894
|
try {
|
|
2843
2895
|
const d = e.create(c, a);
|
|
2844
|
-
|
|
2896
|
+
l(null, s(d, i, a));
|
|
2845
2897
|
} catch (d) {
|
|
2846
|
-
|
|
2898
|
+
l(d);
|
|
2847
2899
|
}
|
|
2848
2900
|
}
|
|
2849
|
-
return
|
|
2850
|
-
return
|
|
2851
|
-
}),
|
|
2901
|
+
return Q.create = e.create, Q.toCanvas = o.bind(null, r.render), Q.toDataURL = o.bind(null, r.renderToDataURL), Q.toString = o.bind(null, function(s, i, c) {
|
|
2902
|
+
return n.render(s, c);
|
|
2903
|
+
}), Q;
|
|
2852
2904
|
}
|
|
2853
|
-
var
|
|
2854
|
-
const
|
|
2905
|
+
var pr = gr();
|
|
2906
|
+
const mr = /* @__PURE__ */ Jn(pr), wr = (t) => {
|
|
2855
2907
|
var e = {
|
|
2856
2908
|
errorCorrectionLevel: "H",
|
|
2857
2909
|
type: "image/jpeg",
|
|
2858
2910
|
margin: 1,
|
|
2859
2911
|
width: 300
|
|
2860
2912
|
};
|
|
2861
|
-
let
|
|
2862
|
-
const
|
|
2863
|
-
const
|
|
2864
|
-
|
|
2913
|
+
let r = null;
|
|
2914
|
+
const n = async (a) => {
|
|
2915
|
+
const l = new URL(window.location.href), u = new URL(l.pathname, l.origin);
|
|
2916
|
+
u.searchParams.set("state", "1-" + a), console.log("生成登录二维码链接:", u.toString());
|
|
2865
2917
|
var h = t || document.getElementById("qrcode");
|
|
2866
|
-
await
|
|
2918
|
+
await mr.toDataURL(h, u.toString(), e);
|
|
2867
2919
|
}, o = async (a) => {
|
|
2868
|
-
const
|
|
2869
|
-
if (
|
|
2870
|
-
console.log(
|
|
2871
|
-
const
|
|
2872
|
-
|
|
2873
|
-
|
|
2920
|
+
const l = await fetch(`/api/router?path=wx&key=checkLogin&state=${a}`).then((u) => u.json());
|
|
2921
|
+
if (l.code === 200) {
|
|
2922
|
+
console.log(l);
|
|
2923
|
+
const u = l.data;
|
|
2924
|
+
u && (localStorage.setItem("token", u.accessToken), await N.setLoginToken(u)), c(), setTimeout(() => {
|
|
2925
|
+
se();
|
|
2874
2926
|
}, 1e3);
|
|
2875
2927
|
} else
|
|
2876
|
-
|
|
2928
|
+
r = setTimeout(() => {
|
|
2877
2929
|
o(a), console.log("继续检测登录状态");
|
|
2878
2930
|
}, 2e3);
|
|
2879
2931
|
}, s = Math.random().toString(36).substring(2, 15);
|
|
2880
|
-
|
|
2932
|
+
n(s), o(s);
|
|
2881
2933
|
const i = setInterval(() => {
|
|
2882
2934
|
const a = Math.random().toString(36).substring(2, 15);
|
|
2883
|
-
clearTimeout(
|
|
2935
|
+
clearTimeout(r), n(a), o(a), console.log("更新二维码");
|
|
2884
2936
|
}, 9e4), c = () => {
|
|
2885
|
-
clearTimeout(
|
|
2937
|
+
clearTimeout(r), clearInterval(i), console.log("停止检测登录状态");
|
|
2886
2938
|
};
|
|
2887
|
-
return { createQrcode:
|
|
2888
|
-
},
|
|
2889
|
-
|
|
2890
|
-
|
|
2891
|
-
|
|
2892
|
-
|
|
2893
|
-
|
|
2939
|
+
return { createQrcode: n, clear: c };
|
|
2940
|
+
}, Xt = "wxff97d569b1db16b6", yr = '<svg t="1764510467010" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1958" width="32" height="32"><path d="M615.904 388.48c8.8 0 17.536 0.64 26.176 1.6-23.52-109.536-140.608-190.912-274.272-190.912C218.4 199.2 96 301.056 96 430.4c0 74.656 40.736 135.936 108.768 183.488l-27.2 81.792 95.04-47.648c33.984 6.72 61.28 13.632 95.2 13.632 8.544 0 16.992-0.416 25.376-1.088a202.496 202.496 0 0 1-8.384-56.96c0-118.752 101.984-215.136 231.104-215.136zM469.76 314.784c20.48 0 34.016 13.472 34.016 33.92 0 20.352-13.536 34.016-34.016 34.016-20.384 0-40.832-13.664-40.832-34.016 0-20.448 20.448-33.92 40.832-33.92zM279.52 382.72c-20.384 0-40.928-13.664-40.928-34.016 0-20.448 20.544-33.92 40.928-33.92 20.352 0 33.92 13.472 33.92 33.92 0 20.384-13.568 34.016-33.92 34.016z" fill="" p-id="1959"></path><path d="M864 600.352c0-108.672-108.736-197.28-230.88-197.28-129.344 0-231.2 88.576-231.2 197.28 0 108.864 101.856 197.248 231.2 197.248 27.072 0 54.368-6.816 81.568-13.632l74.56 40.8-20.448-67.904C823.328 715.936 864 661.664 864 600.352z m-305.856-34.016c-13.536 0-27.2-13.44-27.2-27.2 0-13.568 13.664-27.2 27.2-27.2 20.576 0 34.016 13.632 34.016 27.2 0 13.76-13.44 27.2-34.016 27.2z m149.536 0c-13.44 0-27.008-13.44-27.008-27.2 0-13.568 13.568-27.2 27.008-27.2 20.352 0 34.016 13.632 34.016 27.2 0 13.76-13.664 27.2-34.016 27.2z" fill="" p-id="1960"></path></svg>', br = '<svg t="1764511395617" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="3882" width="32" height="32"><path d="M256 259.584c-29.184 0-51.2 14.848-51.2 44.032s29.184 44.032 51.2 44.032c29.184 0 44.032-14.848 44.032-44.032s-22.016-44.032-44.032-44.032zM541.184 303.616c0-29.184-14.848-44.032-44.032-44.032-29.184 0-51.2 14.848-51.2 44.032s29.184 44.032 51.2 44.032c29.696 0 44.032-22.016 44.032-44.032zM614.4 508.416c-14.848 0-36.352 14.848-36.352 36.352 0 14.848 14.848 36.352 36.352 36.352 29.184 0 44.032-14.848 44.032-36.352 0-14.336-14.848-36.352-44.032-36.352z" p-id="3883"></path><path d="M1024 625.152c0-138.752-124.416-256-285.184-270.848-29.184-153.6-189.952-263.168-373.248-263.168C160.768 91.648 0 230.4 0 406.016c0 95.232 44.032 175.616 138.752 241.152L109.568 742.4c0 7.168 0 14.848 7.168 22.016h14.848l117.248-58.368h14.848c36.352 7.168 66.048 14.848 109.568 14.848 14.848 0 44.032-7.168 44.032-7.168C460.8 822.784 578.048 896 716.8 896c36.352 0 73.216-7.168 102.4-14.848l87.552 51.2h14.848c7.168-7.168 7.168-7.168 7.168-14.848l-22.016-87.552c80.896-58.368 117.248-131.584 117.248-204.8z m-621.568 51.2h-36.352c-36.352 0-66.048-7.168-95.232-14.848l-22.016-7.168h-7.168L153.6 698.368l22.016-66.048c0-7.168 0-14.848-7.168-14.848C80.384 559.616 36.352 486.4 36.352 398.848 36.352 245.248 182.784 128 358.4 128c160.768 0 300.032 95.232 329.216 226.816-168.448 0-300.032 117.248-300.032 263.168 7.168 22.016 14.848 44.032 14.848 58.368z m467.968 132.096c-7.168 7.168-7.168 7.168-7.168 14.848l14.848 51.2L819.2 844.8h-14.848c-29.184 7.168-66.048 14.848-95.232 14.848-146.432 0-270.848-102.4-270.848-226.816 0-131.584 124.416-233.984 270.848-233.984s270.848 102.4 270.848 226.816c0 65.536-36.352 123.904-109.568 182.784z" p-id="3884"></path><path d="M804.352 508.416c-14.848 0-36.352 14.848-36.352 36.352 0 14.848 14.848 36.352 36.352 36.352 29.184 0 44.032-14.848 44.032-36.352 0-14.336-14.336-36.352-44.032-36.352z" p-id="3885"></path></svg>', vr = '<svg t="1764511425462" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5097" width="32" height="32"><path d="M820.409449 797.228346q0 25.19685-10.07874 46.866142t-27.716535 38.299213-41.322835 26.204724-50.897638 9.574803l-357.795276 0q-27.212598 0-50.897638-9.574803t-41.322835-26.204724-27.716535-38.299213-10.07874-46.866142l0-675.275591q0-25.19685 10.07874-47.370079t27.716535-38.80315 41.322835-26.204724 50.897638-9.574803l357.795276 0q27.212598 0 50.897638 9.574803t41.322835 26.204724 27.716535 38.80315 10.07874 47.370079l0 675.275591zM738.771654 170.330709l-455.559055 0 0 577.511811 455.559055 0 0-577.511811zM510.992126 776.062992q-21.165354 0-36.787402 15.11811t-15.622047 37.291339q0 21.165354 15.622047 36.787402t36.787402 15.622047q22.173228 0 37.291339-15.622047t15.11811-36.787402q0-22.173228-15.11811-37.291339t-37.291339-15.11811zM591.622047 84.661417q0-8.062992-5.03937-12.598425t-11.086614-4.535433l-128 0q-5.03937 0-10.582677 4.535433t-5.543307 12.598425 5.03937 12.598425 11.086614 4.535433l128 0q6.047244 0 11.086614-4.535433t5.03937-12.598425z" p-id="5098"></path></svg>', Ar = '<svg t="1764511500570" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="10511" width="32" height="32"><path d="M768.9216 422.72768 372.06016 422.72768C378.88 365.21984 329.37984 131.42016 512.2048 125.72672c173.83424-6.59456 146.78016 213.34016 146.78016 213.34016l85.13536 0.57344c0 0 24.73984-294.4-231.91552-295.8336C232.09984 58.01984 297.82016 377.18016 289.28 422.72768c1.98656 0 4.56704 0 7.29088 0-55.88992 0-101.21216 45.34272-101.21216 101.21216l0 337.38752c0 55.88992 45.34272 101.21216 101.21216 101.21216l472.35072 0c55.88992 0 101.21216-45.34272 101.21216-101.21216L870.13376 523.93984C870.13376 468.0704 824.79104 422.72768 768.9216 422.72768zM566.4768 717.02528l0 76.84096c0 18.57536-15.1552 33.73056-33.73056 33.73056-18.57536 0-33.73056-15.1552-33.73056-33.73056l0-76.84096c-20.09088-11.69408-33.73056-33.21856-33.73056-58.12224 0-37.2736 30.208-67.4816 67.4816-67.4816 37.2736 0 67.4816 30.208 67.4816 67.4816C600.22784 683.80672 586.58816 705.3312 566.4768 717.02528z" fill="#272636" p-id="10512"></path></svg>', ze = {
|
|
2941
|
+
pwd: Ar,
|
|
2942
|
+
phone: vr,
|
|
2943
|
+
wxmpSvg: yr,
|
|
2944
|
+
wxOpenSvg: br
|
|
2945
|
+
}, Cr = [
|
|
2946
|
+
{ id: "password", name: "密码登录", icon: "pwd" },
|
|
2947
|
+
{ id: "wechat", name: "微信登录", icon: "wxmpSvg", appid: "wx9378885c8390e09b" },
|
|
2948
|
+
{ id: "wechat-mp", name: "微信公众号", icon: "wxOpenSvg", appid: Xt },
|
|
2949
|
+
{ id: "wechat-mp-ticket", name: "微信公众号", icon: "wxOpenSvg" },
|
|
2950
|
+
{ id: "phone", name: "手机号登录", icon: "phone" }
|
|
2951
|
+
], Zt = () => {
|
|
2894
2952
|
const t = window.location.hostname;
|
|
2895
2953
|
let e = [];
|
|
2896
2954
|
switch (t) {
|
|
@@ -2898,18 +2956,18 @@ const cr = /* @__PURE__ */ Un(ar), ur = (t) => {
|
|
|
2898
2956
|
e = ["password", "wechat-mp"];
|
|
2899
2957
|
break;
|
|
2900
2958
|
case "kevisual.cn":
|
|
2901
|
-
e = ["password", "wechat"];
|
|
2959
|
+
e = ["password", "wechat", "wechat-mp-ticket"];
|
|
2902
2960
|
break;
|
|
2903
2961
|
default:
|
|
2904
|
-
e = ["password", "phone", "wechat", "wechat-mp"];
|
|
2962
|
+
e = ["password", "phone", "wechat", "wechat-mp", "wechat-mp-ticket"];
|
|
2905
2963
|
break;
|
|
2906
2964
|
}
|
|
2907
|
-
return
|
|
2965
|
+
return Cr.filter((r) => e.includes(r.id));
|
|
2908
2966
|
};
|
|
2909
|
-
console.log("可用登录方式:",
|
|
2910
|
-
class
|
|
2967
|
+
console.log("可用登录方式:", Zt().map((t) => t.name).join(", "));
|
|
2968
|
+
class Tr extends HTMLElement {
|
|
2911
2969
|
selectedMethod = "password";
|
|
2912
|
-
loginMethods =
|
|
2970
|
+
loginMethods = Zt();
|
|
2913
2971
|
setLoginMethods(e) {
|
|
2914
2972
|
this.loginMethods = e, this.render();
|
|
2915
2973
|
}
|
|
@@ -2917,30 +2975,30 @@ class hr extends HTMLElement {
|
|
|
2917
2975
|
super();
|
|
2918
2976
|
}
|
|
2919
2977
|
connectedCallback() {
|
|
2920
|
-
this.attachShadow({ mode: "open" }), this.render(), this.bindEvents(),
|
|
2978
|
+
this.attachShadow({ mode: "open" }), this.render(), this.bindEvents(), Fn();
|
|
2921
2979
|
}
|
|
2922
2980
|
#e = null;
|
|
2923
2981
|
selectLoginMethod(e) {
|
|
2924
2982
|
this.selectedMethod = e, this.render(), this.#e && (this.#e(), this.#e = null);
|
|
2925
2983
|
}
|
|
2926
2984
|
getMethodData(e) {
|
|
2927
|
-
return this.loginMethods.find((
|
|
2985
|
+
return this.loginMethods.find((r) => r.id === e);
|
|
2928
2986
|
}
|
|
2929
2987
|
bindEvents() {
|
|
2930
2988
|
this.shadowRoot && (this.shadowRoot.addEventListener("click", (e) => {
|
|
2931
|
-
const
|
|
2932
|
-
if (
|
|
2933
|
-
const o =
|
|
2989
|
+
const n = e.target.closest(".login-method");
|
|
2990
|
+
if (n) {
|
|
2991
|
+
const o = n.getAttribute("data-method");
|
|
2934
2992
|
o && this.selectLoginMethod(o);
|
|
2935
2993
|
}
|
|
2936
2994
|
}), this.shadowRoot.addEventListener("submit", (e) => {
|
|
2937
|
-
const
|
|
2938
|
-
|
|
2995
|
+
const r = e.target;
|
|
2996
|
+
r && r.id === "loginForm" && (e.preventDefault(), this.handleLogin());
|
|
2939
2997
|
}));
|
|
2940
2998
|
}
|
|
2941
2999
|
handleLogin() {
|
|
2942
3000
|
const e = this.getFormData();
|
|
2943
|
-
|
|
3001
|
+
In({
|
|
2944
3002
|
loginMethod: this.selectedMethod,
|
|
2945
3003
|
data: e
|
|
2946
3004
|
}), this.dispatchEvent(new CustomEvent("login", {
|
|
@@ -2955,15 +3013,15 @@ class hr extends HTMLElement {
|
|
|
2955
3013
|
if (!this.shadowRoot) return {};
|
|
2956
3014
|
switch (this.selectedMethod) {
|
|
2957
3015
|
case "password":
|
|
2958
|
-
const e = this.shadowRoot.querySelector("#username"),
|
|
3016
|
+
const e = this.shadowRoot.querySelector("#username"), r = this.shadowRoot.querySelector("#password");
|
|
2959
3017
|
return {
|
|
2960
3018
|
username: e?.value || "",
|
|
2961
|
-
password:
|
|
3019
|
+
password: r?.value || ""
|
|
2962
3020
|
};
|
|
2963
3021
|
case "phone":
|
|
2964
|
-
const
|
|
3022
|
+
const n = this.shadowRoot.querySelector("#phone"), o = this.shadowRoot.querySelector("#code");
|
|
2965
3023
|
return {
|
|
2966
|
-
phone:
|
|
3024
|
+
phone: n?.value || "",
|
|
2967
3025
|
code: o?.value || ""
|
|
2968
3026
|
};
|
|
2969
3027
|
case "wechat":
|
|
@@ -2979,7 +3037,7 @@ class hr extends HTMLElement {
|
|
|
2979
3037
|
}
|
|
2980
3038
|
}
|
|
2981
3039
|
renderPasswordForm() {
|
|
2982
|
-
return
|
|
3040
|
+
return L`
|
|
2983
3041
|
<form id="loginForm" class="login-form">
|
|
2984
3042
|
<div class="form-group">
|
|
2985
3043
|
<input
|
|
@@ -3006,7 +3064,7 @@ class hr extends HTMLElement {
|
|
|
3006
3064
|
`;
|
|
3007
3065
|
}
|
|
3008
3066
|
renderPhoneForm() {
|
|
3009
|
-
return
|
|
3067
|
+
return L`
|
|
3010
3068
|
<form id="loginForm" class="login-form">
|
|
3011
3069
|
<div class="form-group">
|
|
3012
3070
|
<input
|
|
@@ -3035,7 +3093,7 @@ class hr extends HTMLElement {
|
|
|
3035
3093
|
`;
|
|
3036
3094
|
}
|
|
3037
3095
|
renderWechatForm() {
|
|
3038
|
-
return
|
|
3096
|
+
return L`
|
|
3039
3097
|
<div class="wechat-login">
|
|
3040
3098
|
<slot></slot>
|
|
3041
3099
|
</div>
|
|
@@ -3044,9 +3102,9 @@ class hr extends HTMLElement {
|
|
|
3044
3102
|
renderWechatMpForm() {
|
|
3045
3103
|
const e = this;
|
|
3046
3104
|
return setTimeout(() => {
|
|
3047
|
-
const
|
|
3048
|
-
e.#e =
|
|
3049
|
-
}, 0),
|
|
3105
|
+
const r = e.shadowRoot.querySelector("#qrcode"), { clear: n } = wr(r);
|
|
3106
|
+
e.#e = n;
|
|
3107
|
+
}, 0), L`
|
|
3050
3108
|
<div class="wechat-login">
|
|
3051
3109
|
<div class="qr-container">
|
|
3052
3110
|
<div class="qr-placeholder">
|
|
@@ -3057,6 +3115,28 @@ class hr extends HTMLElement {
|
|
|
3057
3115
|
</div>
|
|
3058
3116
|
`;
|
|
3059
3117
|
}
|
|
3118
|
+
renderWechatMpTicketForm() {
|
|
3119
|
+
const e = this;
|
|
3120
|
+
return setTimeout(async () => {
|
|
3121
|
+
const r = await Vn();
|
|
3122
|
+
if (!r) return;
|
|
3123
|
+
const n = e.shadowRoot.querySelector(".qrcode");
|
|
3124
|
+
if (r.url) {
|
|
3125
|
+
n.src = r.url;
|
|
3126
|
+
const o = Wn(r.ticket);
|
|
3127
|
+
e.#e = o;
|
|
3128
|
+
}
|
|
3129
|
+
}, 0), L`
|
|
3130
|
+
<div class="wechat-login">
|
|
3131
|
+
<div class="qr-container">
|
|
3132
|
+
<div class="qr-placeholder">
|
|
3133
|
+
<img class="qrcode" width="300" height="300" data-appid="" data-size="200" data-ticket=""></img>
|
|
3134
|
+
<p class="qr-desc">请使用微信扫描二维码登录</p>
|
|
3135
|
+
</div>
|
|
3136
|
+
</div>
|
|
3137
|
+
</div>
|
|
3138
|
+
`;
|
|
3139
|
+
}
|
|
3060
3140
|
sendVerificationCode() {
|
|
3061
3141
|
console.log("发送验证码");
|
|
3062
3142
|
}
|
|
@@ -3071,16 +3151,18 @@ class hr extends HTMLElement {
|
|
|
3071
3151
|
case "phone":
|
|
3072
3152
|
return this.renderPhoneForm();
|
|
3073
3153
|
case "wechat":
|
|
3074
|
-
return
|
|
3154
|
+
return On({ appid: e?.appid || "" }), this.renderWechatForm();
|
|
3075
3155
|
case "wechat-mp":
|
|
3076
3156
|
return this.renderWechatMpForm();
|
|
3157
|
+
case "wechat-mp-ticket":
|
|
3158
|
+
return this.renderWechatMpTicketForm();
|
|
3077
3159
|
default:
|
|
3078
3160
|
return this.renderPasswordForm();
|
|
3079
3161
|
}
|
|
3080
3162
|
}
|
|
3081
3163
|
render() {
|
|
3082
3164
|
if (!this.shadowRoot) return;
|
|
3083
|
-
const e =
|
|
3165
|
+
const e = (n) => typeof n == "string" && !ze[n] ? L`<span class="method-icon-emoji">${n}</span>` : typeof n == "string" && ze[n] ? L`<span class="method-icon-svg">${nt(ze[n])}</span>` : typeof n == "string" && (n.includes("<svg") || n.includes("<?xml")) ? L`<span class="method-icon-svg">${nt(n)}</span>` : L`<span class="method-icon-emoji">${n}</span>`, r = L`
|
|
3084
3166
|
<style>
|
|
3085
3167
|
:host {
|
|
3086
3168
|
display: block;
|
|
@@ -3122,7 +3204,7 @@ class hr extends HTMLElement {
|
|
|
3122
3204
|
|
|
3123
3205
|
.login-method.active {
|
|
3124
3206
|
background: white;
|
|
3125
|
-
color: #
|
|
3207
|
+
color: #000000;
|
|
3126
3208
|
}
|
|
3127
3209
|
|
|
3128
3210
|
.login-method.active::after {
|
|
@@ -3132,11 +3214,33 @@ class hr extends HTMLElement {
|
|
|
3132
3214
|
left: 0;
|
|
3133
3215
|
right: 0;
|
|
3134
3216
|
height: 2px;
|
|
3135
|
-
background: #
|
|
3217
|
+
background: #000000;
|
|
3136
3218
|
}
|
|
3137
3219
|
|
|
3138
3220
|
.method-icon {
|
|
3139
3221
|
font-size: 20px;
|
|
3222
|
+
display: flex;
|
|
3223
|
+
align-items: center;
|
|
3224
|
+
justify-content: center;
|
|
3225
|
+
width: 24px;
|
|
3226
|
+
height: 24px;
|
|
3227
|
+
}
|
|
3228
|
+
|
|
3229
|
+
.method-icon-emoji {
|
|
3230
|
+
font-size: 20px;
|
|
3231
|
+
line-height: 1;
|
|
3232
|
+
}
|
|
3233
|
+
|
|
3234
|
+
.method-icon-svg {
|
|
3235
|
+
display: flex;
|
|
3236
|
+
align-items: center;
|
|
3237
|
+
justify-content: center;
|
|
3238
|
+
}
|
|
3239
|
+
|
|
3240
|
+
.method-icon-svg svg {
|
|
3241
|
+
width: 32px;
|
|
3242
|
+
height: 32px;
|
|
3243
|
+
display: block;
|
|
3140
3244
|
}
|
|
3141
3245
|
|
|
3142
3246
|
.method-name {
|
|
@@ -3172,7 +3276,7 @@ class hr extends HTMLElement {
|
|
|
3172
3276
|
|
|
3173
3277
|
.form-group input:focus {
|
|
3174
3278
|
outline: none;
|
|
3175
|
-
border-color: #
|
|
3279
|
+
border-color: #000000;
|
|
3176
3280
|
}
|
|
3177
3281
|
|
|
3178
3282
|
.code-group {
|
|
@@ -3202,7 +3306,7 @@ class hr extends HTMLElement {
|
|
|
3202
3306
|
|
|
3203
3307
|
.login-button {
|
|
3204
3308
|
padding: 12px;
|
|
3205
|
-
background: #
|
|
3309
|
+
background: #000000;
|
|
3206
3310
|
color: white;
|
|
3207
3311
|
border: none;
|
|
3208
3312
|
border-radius: 8px;
|
|
@@ -3213,7 +3317,7 @@ class hr extends HTMLElement {
|
|
|
3213
3317
|
}
|
|
3214
3318
|
|
|
3215
3319
|
.login-button:hover {
|
|
3216
|
-
background: #
|
|
3320
|
+
background: #333333;
|
|
3217
3321
|
}
|
|
3218
3322
|
|
|
3219
3323
|
.wechat-login {
|
|
@@ -3224,9 +3328,9 @@ class hr extends HTMLElement {
|
|
|
3224
3328
|
}
|
|
3225
3329
|
|
|
3226
3330
|
.qr-container {
|
|
3227
|
-
width:
|
|
3228
|
-
height:
|
|
3229
|
-
border: 2px dashed #
|
|
3331
|
+
width: 340px;
|
|
3332
|
+
height: 340px;
|
|
3333
|
+
border: 2px dashed #cccccc;
|
|
3230
3334
|
border-radius: 8px;
|
|
3231
3335
|
display: flex;
|
|
3232
3336
|
align-items: center;
|
|
@@ -3262,16 +3366,20 @@ class hr extends HTMLElement {
|
|
|
3262
3366
|
.refresh-button:hover {
|
|
3263
3367
|
background: #5a6268;
|
|
3264
3368
|
}
|
|
3369
|
+
.method-icon svg {
|
|
3370
|
+
width: 24px;
|
|
3371
|
+
height: 24px;
|
|
3372
|
+
}
|
|
3265
3373
|
</style>
|
|
3266
3374
|
|
|
3267
3375
|
<div class="login-sidebar">
|
|
3268
3376
|
<div class="login-methods">
|
|
3269
|
-
${this.loginMethods.map((n) =>
|
|
3377
|
+
${this.loginMethods.map((n) => L`
|
|
3270
3378
|
<button
|
|
3271
3379
|
class="login-method ${this.selectedMethod === n.id ? "active" : ""}"
|
|
3272
3380
|
data-method="${n.id}"
|
|
3273
3381
|
>
|
|
3274
|
-
|
|
3382
|
+
${e(n.icon)}
|
|
3275
3383
|
<span class="method-name">${n.name}</span>
|
|
3276
3384
|
</button>
|
|
3277
3385
|
`)}
|
|
@@ -3282,7 +3390,7 @@ class hr extends HTMLElement {
|
|
|
3282
3390
|
</div>
|
|
3283
3391
|
</div>
|
|
3284
3392
|
`;
|
|
3285
|
-
|
|
3393
|
+
Ut(r, this.shadowRoot);
|
|
3286
3394
|
}
|
|
3287
3395
|
}
|
|
3288
|
-
customElements.define("kv-login",
|
|
3396
|
+
customElements.define("kv-login", Tr);
|