qlfy-ecological-login 1.2.1 → 1.2.2
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/lib/index.mjs +37 -38
- package/lib/index.mjs.gz +0 -0
- package/lib/index.umd.js +1 -1
- package/lib/index.umd.js.gz +0 -0
- package/package.json +1 -1
package/lib/index.mjs
CHANGED
|
@@ -75,11 +75,11 @@ const Pt = (e, t, r, { allOwnKeys: n } = {}) => (J(t, (o, s) => {
|
|
|
75
75
|
e = r !== !1 && pe(e);
|
|
76
76
|
} while (e && (!r || r(e, t)) && e !== Object.prototype);
|
|
77
77
|
return t;
|
|
78
|
-
},
|
|
78
|
+
}, Nt = (e, t, r) => {
|
|
79
79
|
e = String(e), (r === void 0 || r > e.length) && (r = e.length), r -= t.length;
|
|
80
80
|
const n = e.indexOf(t, r);
|
|
81
81
|
return n !== -1 && n === r;
|
|
82
|
-
},
|
|
82
|
+
}, Dt = (e) => {
|
|
83
83
|
if (!e) return null;
|
|
84
84
|
if ($(e)) return e;
|
|
85
85
|
let t = e.length;
|
|
@@ -197,8 +197,8 @@ const vt = (e) => {
|
|
|
197
197
|
toFlatObject: Ct,
|
|
198
198
|
kindOf: Y,
|
|
199
199
|
kindOfTest: C,
|
|
200
|
-
endsWith:
|
|
201
|
-
toArray:
|
|
200
|
+
endsWith: Nt,
|
|
201
|
+
toArray: Dt,
|
|
202
202
|
forEachEntry: _t,
|
|
203
203
|
matchAll: Ft,
|
|
204
204
|
isHTMLForm: Ut,
|
|
@@ -1139,13 +1139,13 @@ const Ze = (e) => {
|
|
|
1139
1139
|
}, {
|
|
1140
1140
|
highWaterMark: 2
|
|
1141
1141
|
});
|
|
1142
|
-
}, re = typeof fetch == "function" && typeof Request == "function" && typeof Response == "function", Ye = re && typeof ReadableStream == "function",
|
|
1142
|
+
}, re = typeof fetch == "function" && typeof Request == "function" && typeof Response == "function", Ye = re && typeof ReadableStream == "function", Nn = re && (typeof TextEncoder == "function" ? /* @__PURE__ */ ((e) => (t) => e.encode(t))(new TextEncoder()) : async (e) => new Uint8Array(await new Response(e).arrayBuffer())), et = (e, ...t) => {
|
|
1143
1143
|
try {
|
|
1144
1144
|
return !!e(...t);
|
|
1145
1145
|
} catch {
|
|
1146
1146
|
return !1;
|
|
1147
1147
|
}
|
|
1148
|
-
},
|
|
1148
|
+
}, Dn = Ye && et(() => {
|
|
1149
1149
|
let e = !1;
|
|
1150
1150
|
const t = new Request(P.origin, {
|
|
1151
1151
|
body: new ReadableStream(),
|
|
@@ -1178,7 +1178,7 @@ const Bn = async (e) => {
|
|
|
1178
1178
|
if (a.isArrayBufferView(e) || a.isArrayBuffer(e))
|
|
1179
1179
|
return e.byteLength;
|
|
1180
1180
|
if (a.isURLSearchParams(e) && (e = e + ""), a.isString(e))
|
|
1181
|
-
return (await
|
|
1181
|
+
return (await Nn(e)).byteLength;
|
|
1182
1182
|
}, _n = async (e, t) => {
|
|
1183
1183
|
const r = a.toFiniteNumber(e.getContentLength());
|
|
1184
1184
|
return r ?? Bn(t);
|
|
@@ -1204,7 +1204,7 @@ const Bn = async (e) => {
|
|
|
1204
1204
|
});
|
|
1205
1205
|
let p;
|
|
1206
1206
|
try {
|
|
1207
|
-
if (f &&
|
|
1207
|
+
if (f && Dn && r !== "get" && r !== "head" && (p = await _n(u, n)) !== 0) {
|
|
1208
1208
|
let S = new Request(t, {
|
|
1209
1209
|
method: "POST",
|
|
1210
1210
|
body: n,
|
|
@@ -1281,7 +1281,7 @@ a.forEach(de, (e, t) => {
|
|
|
1281
1281
|
Object.defineProperty(e, "adapterName", { value: t });
|
|
1282
1282
|
}
|
|
1283
1283
|
});
|
|
1284
|
-
const
|
|
1284
|
+
const Ne = (e) => `- ${e}`, Un = (e) => a.isFunction(e) || e === null || e === !1, tt = {
|
|
1285
1285
|
getAdapter: (e) => {
|
|
1286
1286
|
e = a.isArray(e) ? e : [e];
|
|
1287
1287
|
const { length: t } = e;
|
|
@@ -1301,8 +1301,8 @@ const De = (e) => `- ${e}`, Un = (e) => a.isFunction(e) || e === null || e === !
|
|
|
1301
1301
|
([c, f]) => `adapter ${c} ` + (f === !1 ? "is not supported by the environment" : "is not available in the build")
|
|
1302
1302
|
);
|
|
1303
1303
|
let i = t ? s.length > 1 ? `since :
|
|
1304
|
-
` + s.map(
|
|
1305
|
-
`) : " " +
|
|
1304
|
+
` + s.map(Ne).join(`
|
|
1305
|
+
`) : " " + Ne(s[0]) : "as no adapter specified";
|
|
1306
1306
|
throw new g(
|
|
1307
1307
|
"There is no suitable adapter to dispatch the request " + i,
|
|
1308
1308
|
"ERR_NOT_SUPPORT"
|
|
@@ -1316,7 +1316,7 @@ function ae(e) {
|
|
|
1316
1316
|
if (e.cancelToken && e.cancelToken.throwIfRequested(), e.signal && e.signal.aborted)
|
|
1317
1317
|
throw new j(null, e);
|
|
1318
1318
|
}
|
|
1319
|
-
function
|
|
1319
|
+
function De(e) {
|
|
1320
1320
|
return ae(e), e.headers = k.from(e.headers), e.data = ie.call(
|
|
1321
1321
|
e,
|
|
1322
1322
|
e.transformRequest
|
|
@@ -1382,7 +1382,7 @@ function qn(e, t, r) {
|
|
|
1382
1382
|
const X = {
|
|
1383
1383
|
assertOptions: qn,
|
|
1384
1384
|
validators: oe
|
|
1385
|
-
},
|
|
1385
|
+
}, N = X.validators;
|
|
1386
1386
|
let q = class {
|
|
1387
1387
|
constructor(t) {
|
|
1388
1388
|
this.defaults = t || {}, this.interceptors = {
|
|
@@ -1419,17 +1419,17 @@ let q = class {
|
|
|
1419
1419
|
typeof t == "string" ? (r = r || {}, r.url = t) : r = t || {}, r = M(this.defaults, r);
|
|
1420
1420
|
const { transitional: n, paramsSerializer: o, headers: s } = r;
|
|
1421
1421
|
n !== void 0 && X.assertOptions(n, {
|
|
1422
|
-
silentJSONParsing:
|
|
1423
|
-
forcedJSONParsing:
|
|
1424
|
-
clarifyTimeoutError:
|
|
1422
|
+
silentJSONParsing: N.transitional(N.boolean),
|
|
1423
|
+
forcedJSONParsing: N.transitional(N.boolean),
|
|
1424
|
+
clarifyTimeoutError: N.transitional(N.boolean)
|
|
1425
1425
|
}, !1), o != null && (a.isFunction(o) ? r.paramsSerializer = {
|
|
1426
1426
|
serialize: o
|
|
1427
1427
|
} : X.assertOptions(o, {
|
|
1428
|
-
encode:
|
|
1429
|
-
serialize:
|
|
1428
|
+
encode: N.function,
|
|
1429
|
+
serialize: N.function
|
|
1430
1430
|
}, !0)), r.allowAbsoluteUrls !== void 0 || (this.defaults.allowAbsoluteUrls !== void 0 ? r.allowAbsoluteUrls = this.defaults.allowAbsoluteUrls : r.allowAbsoluteUrls = !0), X.assertOptions(r, {
|
|
1431
|
-
baseUrl:
|
|
1432
|
-
withXsrfToken:
|
|
1431
|
+
baseUrl: N.spelling("baseURL"),
|
|
1432
|
+
withXsrfToken: N.spelling("withXSRFToken")
|
|
1433
1433
|
}, !0), r.method = (r.method || this.defaults.method || "get").toLowerCase();
|
|
1434
1434
|
let i = s && a.merge(
|
|
1435
1435
|
s.common,
|
|
@@ -1452,7 +1452,7 @@ let q = class {
|
|
|
1452
1452
|
});
|
|
1453
1453
|
let u, d = 0, y;
|
|
1454
1454
|
if (!f) {
|
|
1455
|
-
const h = [
|
|
1455
|
+
const h = [De.bind(this), void 0];
|
|
1456
1456
|
for (h.unshift.apply(h, c), h.push.apply(h, l), y = h.length, u = Promise.resolve(r); d < y; )
|
|
1457
1457
|
u = u.then(h[d++], h[d++]);
|
|
1458
1458
|
return u;
|
|
@@ -1469,7 +1469,7 @@ let q = class {
|
|
|
1469
1469
|
}
|
|
1470
1470
|
}
|
|
1471
1471
|
try {
|
|
1472
|
-
u =
|
|
1472
|
+
u = De.call(this, b);
|
|
1473
1473
|
} catch (h) {
|
|
1474
1474
|
return Promise.reject(h);
|
|
1475
1475
|
}
|
|
@@ -1984,7 +1984,7 @@ async function ye() {
|
|
|
1984
1984
|
const e = we.remove(I);
|
|
1985
1985
|
e instanceof Promise && await e;
|
|
1986
1986
|
}
|
|
1987
|
-
async function
|
|
1987
|
+
async function D(e) {
|
|
1988
1988
|
e && I.indexOf(e) == -1 && (I += e);
|
|
1989
1989
|
const t = we.get(I), r = t instanceof Promise ? await t : t;
|
|
1990
1990
|
return r || {
|
|
@@ -1999,7 +1999,7 @@ async function N(e) {
|
|
|
1999
1999
|
};
|
|
2000
2000
|
}
|
|
2001
2001
|
async function Wn(e = !0, t, r) {
|
|
2002
|
-
let n = await
|
|
2002
|
+
let n = await D();
|
|
2003
2003
|
const o = n.props;
|
|
2004
2004
|
if (o.openDebugger)
|
|
2005
2005
|
debugger;
|
|
@@ -2026,7 +2026,7 @@ async function Wn(e = !0, t, r) {
|
|
|
2026
2026
|
});
|
|
2027
2027
|
}
|
|
2028
2028
|
async function F() {
|
|
2029
|
-
const t = (await
|
|
2029
|
+
const t = (await D()).props;
|
|
2030
2030
|
if (!t || !t.isEnabled) {
|
|
2031
2031
|
console.error(new Error("统一登陆未开启,请检查配置"));
|
|
2032
2032
|
return;
|
|
@@ -2037,24 +2037,25 @@ async function F() {
|
|
|
2037
2037
|
}), await ye();
|
|
2038
2038
|
}
|
|
2039
2039
|
async function Kn() {
|
|
2040
|
-
const e = await
|
|
2040
|
+
const e = await D(), t = e.props;
|
|
2041
2041
|
return !t || !t.isEnabled ? (console.error(new Error("统一登陆未开启,请检查配置")), "") : e.token;
|
|
2042
2042
|
}
|
|
2043
2043
|
async function Xn() {
|
|
2044
|
-
|
|
2044
|
+
const e = await D(), t = e.props;
|
|
2045
|
+
return !t || !t.isEnabled ? (console.error(new Error("统一登陆未开启,请检查配置")), null) : e.loginInfo;
|
|
2045
2046
|
}
|
|
2046
2047
|
async function yr() {
|
|
2047
|
-
let e = await
|
|
2048
|
+
let e = await D();
|
|
2048
2049
|
const t = e.props;
|
|
2049
2050
|
return !t || !t.isEnabled ? (console.error(new Error("统一登陆未开启,请检查配置")), null) : e.userPermission;
|
|
2050
2051
|
}
|
|
2051
2052
|
async function br() {
|
|
2052
|
-
let e = await
|
|
2053
|
+
let e = await D();
|
|
2053
2054
|
const t = e.props;
|
|
2054
2055
|
return !t || !t.isEnabled ? (console.error(new Error("统一登陆未开启,请检查配置")), null) : e.refreshToken;
|
|
2055
2056
|
}
|
|
2056
2057
|
async function Gn() {
|
|
2057
|
-
const t = (await
|
|
2058
|
+
const t = (await D()).props;
|
|
2058
2059
|
if (!t || !t.isEnabled)
|
|
2059
2060
|
return console.error(new Error("统一登陆未开启,请检查配置")), null;
|
|
2060
2061
|
if (!t.clientId || !t.clientSecret)
|
|
@@ -2073,7 +2074,7 @@ function Qn() {
|
|
|
2073
2074
|
return "history";
|
|
2074
2075
|
}
|
|
2075
2076
|
async function st(e, t = !1, r = window.location.href, n) {
|
|
2076
|
-
if (n || (n = (await
|
|
2077
|
+
if (n || (n = (await D()).routerMode), !["hash", "history"].includes(n))
|
|
2077
2078
|
throw new Error('路由模式必须是 "hash" 或 "history"');
|
|
2078
2079
|
let o, s, i;
|
|
2079
2080
|
if (n === "hash") {
|
|
@@ -2088,13 +2089,11 @@ async function st(e, t = !1, r = window.location.href, n) {
|
|
|
2088
2089
|
const y = i.toString(), b = y ? `${u}?${y}` : u;
|
|
2089
2090
|
o = `${s}${b}`;
|
|
2090
2091
|
} else {
|
|
2091
|
-
o = new URL(r)
|
|
2092
|
-
|
|
2093
|
-
e.forEach((l) => {
|
|
2094
|
-
o.searchParams.delete(l);
|
|
2092
|
+
o = new URL(r), e.forEach((f) => {
|
|
2093
|
+
o.searchParams.delete(f);
|
|
2095
2094
|
});
|
|
2096
|
-
const
|
|
2097
|
-
o =
|
|
2095
|
+
const c = o.searchParams.toString();
|
|
2096
|
+
o = c ? `${o.href}?${c}` : o.href;
|
|
2098
2097
|
}
|
|
2099
2098
|
return t && history.replaceState({}, "", o), o;
|
|
2100
2099
|
}
|
|
@@ -2185,7 +2184,7 @@ const it = /* @__PURE__ */ at({
|
|
|
2185
2184
|
async function y() {
|
|
2186
2185
|
if (n.openDebugger)
|
|
2187
2186
|
debugger;
|
|
2188
|
-
n.isEnabled && (l = await
|
|
2187
|
+
n.isEnabled && (l = await D(n.clientId), await T(), b());
|
|
2189
2188
|
}
|
|
2190
2189
|
async function b() {
|
|
2191
2190
|
if (n.showLog && console.log("【qlfyEcologicalLogin】登陆流程执行..."), n.token) {
|
package/lib/index.mjs.gz
CHANGED
|
Binary file
|
package/lib/index.umd.js
CHANGED
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...r){const n=new this(t);return r.forEach(o=>n.set(o)),n}static accessor(t){const n=(this[$e]=this[$e]={accessors:{}}).accessors,o=this.prototype;function s(i){const c=W(i);n[c]||(hn(o,i),n[c]=!0)}return a.isArray(t)?t.forEach(s):s(t),this}};C.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),a.reduceDescriptors(C.prototype,({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(n){this[r]=n}}}),a.freezeMethods(C);function pe(e,t){const r=this||V,n=t||r,o=C.from(n.headers);let s=n.data;return a.forEach(e,function(c){s=c.call(r,s,o.normalize(),t?t.status:void 0)}),o.normalize(),s}function je(e){return!!(e&&e.__CANCEL__)}function z(e,t,r){g.call(this,e??"canceled",g.ERR_CANCELED,t,r),this.name="CanceledError"}a.inherits(z,g,{__CANCEL__:!0});function He(e,t,r){const n=r.config.validateStatus;!r.status||!n||n(r.status)?e(r):t(new g("Request failed with status code "+r.status,[g.ERR_BAD_REQUEST,g.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function pn(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function mn(e,t){e=e||10;const r=new Array(e),n=new Array(e);let o=0,s=0,i;return t=t!==void 0?t:1e3,function(f){const l=Date.now(),u=n[s];i||(i=l),r[o]=f,n[o]=l;let d=s,y=0;for(;d!==o;)y+=r[d++],d=d%e;if(o=(o+1)%e,o===s&&(s=(s+1)%e),l-i<t)return;const E=u&&l-u;return E?Math.round(y*1e3/E):void 0}}function gn(e,t){let r=0,n=1e3/t,o,s;const i=(l,u=Date.now())=>{r=u,o=null,s&&(clearTimeout(s),s=null),e.apply(null,l)};return[(...l)=>{const u=Date.now(),d=u-r;d>=n?i(l,u):(o=l,s||(s=setTimeout(()=>{s=null,i(o)},n-d)))},()=>o&&i(o)]}const ne=(e,t,r=3)=>{let n=0;const o=mn(50,250);return gn(s=>{const i=s.loaded,c=s.lengthComputable?s.total:void 0,f=i-n,l=o(f),u=i<=c;n=i;const d={loaded:i,total:c,progress:c?i/c:void 0,bytes:f,rate:l||void 0,estimated:l&&c&&u?(c-i)/l:void 0,event:s,lengthComputable:c!=null,[t?"download":"upload"]:!0};e(d)},r)},ze=(e,t)=>{const r=e!=null;return[n=>t[0]({lengthComputable:r,total:e,loaded:n}),t[1]]},ve=e=>(...t)=>a.asap(()=>e(...t)),wn=x.hasStandardBrowserEnv?((e,t)=>r=>(r=new URL(r,x.origin),e.protocol===r.protocol&&e.host===r.host&&(t||e.port===r.port)))(new URL(x.origin),x.navigator&&/(msie|trident)/i.test(x.navigator.userAgent)):()=>!0,yn=x.hasStandardBrowserEnv?{write(e,t,r,n,o,s){const i=[e+"="+encodeURIComponent(t)];a.isNumber(r)&&i.push("expires="+new Date(r).toGMTString()),a.isString(n)&&i.push("path="+n),a.isString(o)&&i.push("domain="+o),s===!0&&i.push("secure"),document.cookie=i.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function bn(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function En(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function Je(e,t,r){let n=!bn(t);return e&&(n||r==!1)?En(e,t):t}const Ve=e=>e instanceof C?{...e}:e;function I(e,t){t=t||{};const r={};function n(l,u,d,y){return a.isPlainObject(l)&&a.isPlainObject(u)?a.merge.call({caseless:y},l,u):a.isPlainObject(u)?a.merge({},u):a.isArray(u)?u.slice():u}function o(l,u,d,y){if(a.isUndefined(u)){if(!a.isUndefined(l))return n(void 0,l,d,y)}else return n(l,u,d,y)}function s(l,u){if(!a.isUndefined(u))return n(void 0,u)}function i(l,u){if(a.isUndefined(u)){if(!a.isUndefined(l))return n(void 0,l)}else return n(void 0,u)}function c(l,u,d){if(d in t)return n(l,u);if(d in e)return n(void 0,l)}const f={url:s,method:s,data:s,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:c,headers:(l,u,d)=>o(Ve(l),Ve(u),d,!0)};return a.forEach(Object.keys(Object.assign({},e,t)),function(u){const d=f[u]||o,y=d(e[u],t[u],u);a.isUndefined(y)&&d!==c||(r[u]=y)}),r}const We=e=>{const t=I({},e);let{data:r,withXSRFToken:n,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:c}=t;t.headers=i=C.from(i),t.url=qe(Je(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),c&&i.set("Authorization","Basic "+btoa((c.username||"")+":"+(c.password?unescape(encodeURIComponent(c.password)):"")));let f;if(a.isFormData(r)){if(x.hasStandardBrowserEnv||x.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if((f=i.getContentType())!==!1){const[l,...u]=f?f.split(";").map(d=>d.trim()).filter(Boolean):[];i.setContentType([l||"multipart/form-data",...u].join("; "))}}if(x.hasStandardBrowserEnv&&(n&&a.isFunction(n)&&(n=n(t)),n||n!==!1&&wn(t.url))){const l=o&&s&&yn.read(s);l&&i.set(o,l)}return t},Sn=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(r,n){const o=We(e);let s=o.data;const i=C.from(o.headers).normalize();let{responseType:c,onUploadProgress:f,onDownloadProgress:l}=o,u,d,y,E,h;function m(){E&&E(),h&&h(),o.cancelToken&&o.cancelToken.unsubscribe(u),o.signal&&o.signal.removeEventListener("abort",u)}let p=new XMLHttpRequest;p.open(o.method.toUpperCase(),o.url,!0),p.timeout=o.timeout;function S(){if(!p)return;const O=C.from("getAllResponseHeaders"in p&&p.getAllResponseHeaders()),R={data:!c||c==="text"||c==="json"?p.responseText:p.response,status:p.status,statusText:p.statusText,headers:O,config:e,request:p};He(function(L){r(L),m()},function(L){n(L),m()},R),p=null}"onloadend"in p?p.onloadend=S:p.onreadystatechange=function(){!p||p.readyState!==4||p.status===0&&!(p.responseURL&&p.responseURL.indexOf("file:")===0)||setTimeout(S)},p.onabort=function(){p&&(n(new g("Request aborted",g.ECONNABORTED,e,p)),p=null)},p.onerror=function(){n(new g("Network Error",g.ERR_NETWORK,e,p)),p=null},p.ontimeout=function(){let w=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const R=o.transitional||Ie;o.timeoutErrorMessage&&(w=o.timeoutErrorMessage),n(new g(w,R.clarifyTimeoutError?g.ETIMEDOUT:g.ECONNABORTED,e,p)),p=null},s===void 0&&i.setContentType(null),"setRequestHeader"in p&&a.forEach(i.toJSON(),function(w,R){p.setRequestHeader(R,w)}),a.isUndefined(o.withCredentials)||(p.withCredentials=!!o.withCredentials),c&&c!=="json"&&(p.responseType=o.responseType),l&&([y,h]=ne(l,!0),p.addEventListener("progress",y)),f&&p.upload&&([d,E]=ne(f),p.upload.addEventListener("progress",d),p.upload.addEventListener("loadend",E)),(o.cancelToken||o.signal)&&(u=O=>{p&&(n(!O||O.type?new z(null,e,p):O),p.abort(),p=null)},o.cancelToken&&o.cancelToken.subscribe(u),o.signal&&(o.signal.aborted?u():o.signal.addEventListener("abort",u)));const T=pn(o.url);if(T&&x.protocols.indexOf(T)===-1){n(new g("Unsupported protocol "+T+":",g.ERR_BAD_REQUEST,e));return}p.send(s||null)})},Rn=(e,t)=>{const{length:r}=e=e?e.filter(Boolean):[];if(t||r){let n=new AbortController,o;const s=function(l){if(!o){o=!0,c();const u=l instanceof Error?l:this.reason;n.abort(u instanceof g?u:new z(u instanceof Error?u.message:u))}};let i=t&&setTimeout(()=>{i=null,s(new g(`timeout ${t} of ms exceeded`,g.ETIMEDOUT))},t);const c=()=>{e&&(i&&clearTimeout(i),i=null,e.forEach(l=>{l.unsubscribe?l.unsubscribe(s):l.removeEventListener("abort",s)}),e=null)};e.forEach(l=>l.addEventListener("abort",s));const{signal:f}=n;return f.unsubscribe=()=>a.asap(c),f}},Tn=function*(e,t){let r=e.byteLength;if(r<t){yield e;return}let n=0,o;for(;n<r;)o=n+t,yield e.slice(n,o),n=o},On=async function*(e,t){for await(const r of An(e))yield*Tn(r,t)},An=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}const t=e.getReader();try{for(;;){const{done:r,value:n}=await t.read();if(r)break;yield n}}finally{await t.cancel()}},Ke=(e,t,r,n)=>{const o=On(e,t);let s=0,i,c=f=>{i||(i=!0,n&&n(f))};return new ReadableStream({async pull(f){try{const{done:l,value:u}=await o.next();if(l){c(),f.close();return}let d=u.byteLength;if(r){let y=s+=d;r(y)}f.enqueue(new Uint8Array(u))}catch(l){throw c(l),l}},cancel(f){return c(f),o.return()}},{highWaterMark:2})},re=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",Xe=re&&typeof ReadableStream=="function",xn=re&&(typeof TextEncoder=="function"?(e=>t=>e.encode(t))(new TextEncoder):async e=>new Uint8Array(await new Response(e).arrayBuffer())),Ge=(e,...t)=>{try{return!!e(...t)}catch{return!1}},Ln=Xe&&Ge(()=>{let e=!1;const t=new Request(x.origin,{body:new ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t}),Qe=64*1024,me=Xe&&Ge(()=>a.isReadableStream(new Response("").body)),oe={stream:me&&(e=>e.body)};re&&(e=>{["text","arrayBuffer","blob","formData","stream"].forEach(t=>{!oe[t]&&(oe[t]=a.isFunction(e[t])?r=>r[t]():(r,n)=>{throw new g(`Response type '${t}' is not supported`,g.ERR_NOT_SUPPORT,n)})})})(new Response);const Pn=async e=>{if(e==null)return 0;if(a.isBlob(e))return e.size;if(a.isSpecCompliantForm(e))return(await new Request(x.origin,{method:"POST",body:e}).arrayBuffer()).byteLength;if(a.isArrayBufferView(e)||a.isArrayBuffer(e))return e.byteLength;if(a.isURLSearchParams(e)&&(e=e+""),a.isString(e))return(await xn(e)).byteLength},kn=async(e,t)=>{const r=a.toFiniteNumber(e.getContentLength());return r??Pn(t)},ge={http:Xt,xhr:Sn,fetch:re&&(async e=>{let{url:t,method:r,data:n,signal:o,cancelToken:s,timeout:i,onDownloadProgress:c,onUploadProgress:f,responseType:l,headers:u,withCredentials:d="same-origin",fetchOptions:y}=We(e);l=l?(l+"").toLowerCase():"text";let E=Rn([o,s&&s.toAbortSignal()],i),h;const m=E&&E.unsubscribe&&(()=>{E.unsubscribe()});let p;try{if(f&&Ln&&r!=="get"&&r!=="head"&&(p=await kn(u,n))!==0){let R=new Request(t,{method:"POST",body:n,duplex:"half"}),A;if(a.isFormData(n)&&(A=R.headers.get("content-type"))&&u.setContentType(A),R.body){const[L,q]=ze(p,ne(ve(f)));n=Ke(R.body,Qe,L,q)}}a.isString(d)||(d=d?"include":"omit");const S="credentials"in Request.prototype;h=new Request(t,{...y,signal:E,method:r.toUpperCase(),headers:u.normalize().toJSON(),body:n,duplex:"half",credentials:S?d:void 0});let T=await fetch(h,y);const O=me&&(l==="stream"||l==="response");if(me&&(c||O&&m)){const R={};["status","statusText","headers"].forEach(lt=>{R[lt]=T[lt]});const A=a.toFiniteNumber(T.headers.get("content-length")),[L,q]=c&&ze(A,ne(ve(c),!0))||[];T=new Response(Ke(T.body,Qe,L,()=>{q&&q(),m&&m()}),R)}l=l||"text";let w=await oe[a.findKey(oe,l)||"text"](T,e);return!O&&m&&m(),await new Promise((R,A)=>{He(R,A,{data:w,headers:C.from(T.headers),status:T.status,statusText:T.statusText,config:e,request:h})})}catch(S){throw m&&m(),S&&S.name==="TypeError"&&/Load failed|fetch/i.test(S.message)?Object.assign(new g("Network Error",g.ERR_NETWORK,e,h),{cause:S.cause||S}):g.from(S,S&&S.code,e,h)}})};a.forEach(ge,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Ze=e=>`- ${e}`,Cn=e=>a.isFunction(e)||e===null||e===!1,Ye={getAdapter:e=>{e=a.isArray(e)?e:[e];const{length:t}=e;let r,n;const o={};for(let s=0;s<t;s++){r=e[s];let i;if(n=r,!Cn(r)&&(n=ge[(i=String(r)).toLowerCase()],n===void 0))throw new g(`Unknown adapter '${i}'`);if(n)break;o[i||"#"+s]=n}if(!n){const s=Object.entries(o).map(([c,f])=>`adapter ${c} `+(f===!1?"is not supported by the environment":"is not available in the build"));let i=t?s.length>1?`since :
|
|
4
4
|
`+s.map(Ze).join(`
|
|
5
5
|
`):" "+Ze(s[0]):"as no adapter specified";throw new g("There is no suitable adapter to dispatch the request "+i,"ERR_NOT_SUPPORT")}return n},adapters:ge};function we(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new z(null,e)}function et(e){return we(e),e.headers=C.from(e.headers),e.data=pe.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),Ye.getAdapter(e.adapter||V.adapter)(e).then(function(n){return we(e),n.data=pe.call(e,e.transformResponse,n),n.headers=C.from(n.headers),n},function(n){return je(n)||(we(e),n&&n.response&&(n.response.data=pe.call(e,e.transformResponse,n.response),n.response.headers=C.from(n.response.headers))),Promise.reject(n)})}const tt="1.10.0",se={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{se[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}});const nt={};se.transitional=function(t,r,n){function o(s,i){return"[Axios v"+tt+"] Transitional option '"+s+"'"+i+(n?". "+n:"")}return(s,i,c)=>{if(t===!1)throw new g(o(i," has been removed"+(r?" in "+r:"")),g.ERR_DEPRECATED);return r&&!nt[i]&&(nt[i]=!0,console.warn(o(i," has been deprecated since v"+r+" and will be removed in the near future"))),t?t(s,i,c):!0}},se.spelling=function(t){return(r,n)=>(console.warn(`${n} is likely a misspelling of ${t}`),!0)};function Dn(e,t,r){if(typeof e!="object")throw new g("options must be an object",g.ERR_BAD_OPTION_VALUE);const n=Object.keys(e);let o=n.length;for(;o-- >0;){const s=n[o],i=t[s];if(i){const c=e[s],f=c===void 0||i(c,s,e);if(f!==!0)throw new g("option "+s+" must be "+f,g.ERR_BAD_OPTION_VALUE);continue}if(r!==!0)throw new g("Unknown option "+s,g.ERR_BAD_OPTION)}}const ie={assertOptions:Dn,validators:se},N=ie.validators;let M=class{constructor(t){this.defaults=t||{},this.interceptors={request:new Ue,response:new Ue}}async request(t,r){try{return await this._request(t,r)}catch(n){if(n instanceof Error){let o={};Error.captureStackTrace?Error.captureStackTrace(o):o=new Error;const s=o.stack?o.stack.replace(/^.+\n/,""):"";try{n.stack?s&&!String(n.stack).endsWith(s.replace(/^.+\n.+\n/,""))&&(n.stack+=`
|
|
6
|
-
`+s):n.stack=s}catch{}}throw n}}_request(t,r){typeof t=="string"?(r=r||{},r.url=t):r=t||{},r=I(this.defaults,r);const{transitional:n,paramsSerializer:o,headers:s}=r;n!==void 0&&ie.assertOptions(n,{silentJSONParsing:N.transitional(N.boolean),forcedJSONParsing:N.transitional(N.boolean),clarifyTimeoutError:N.transitional(N.boolean)},!1),o!=null&&(a.isFunction(o)?r.paramsSerializer={serialize:o}:ie.assertOptions(o,{encode:N.function,serialize:N.function},!0)),r.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?r.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:r.allowAbsoluteUrls=!0),ie.assertOptions(r,{baseUrl:N.spelling("baseURL"),withXsrfToken:N.spelling("withXSRFToken")},!0),r.method=(r.method||this.defaults.method||"get").toLowerCase();let i=s&&a.merge(s.common,s[r.method]);s&&a.forEach(["delete","get","head","post","put","patch","common"],h=>{delete s[h]}),r.headers=C.concat(i,s);const c=[];let f=!0;this.interceptors.request.forEach(function(m){typeof m.runWhen=="function"&&m.runWhen(r)===!1||(f=f&&m.synchronous,c.unshift(m.fulfilled,m.rejected))});const l=[];this.interceptors.response.forEach(function(m){l.push(m.fulfilled,m.rejected)});let u,d=0,y;if(!f){const h=[et.bind(this),void 0];for(h.unshift.apply(h,c),h.push.apply(h,l),y=h.length,u=Promise.resolve(r);d<y;)u=u.then(h[d++],h[d++]);return u}y=c.length;let E=r;for(d=0;d<y;){const h=c[d++],m=c[d++];try{E=h(E)}catch(p){m.call(this,p);break}}try{u=et.call(this,E)}catch(h){return Promise.reject(h)}for(d=0,y=l.length;d<y;)u=u.then(l[d++],l[d++]);return u}getUri(t){t=I(this.defaults,t);const r=Je(t.baseURL,t.url,t.allowAbsoluteUrls);return qe(r,t.params,t.paramsSerializer)}};a.forEach(["delete","get","head","options"],function(t){M.prototype[t]=function(r,n){return this.request(I(n||{},{method:t,url:r,data:(n||{}).data}))}}),a.forEach(["post","put","patch"],function(t){function r(n){return function(s,i,c){return this.request(I(c||{},{method:t,headers:n?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}M.prototype[t]=r(),M.prototype[t+"Form"]=r(!0)});let Nn=class ut{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(s){r=s});const n=this;this.promise.then(o=>{if(!n._listeners)return;let s=n._listeners.length;for(;s-- >0;)n._listeners[s](o);n._listeners=null}),this.promise.then=o=>{let s;const i=new Promise(c=>{n.subscribe(c),s=c}).then(o);return i.cancel=function(){n.unsubscribe(s)},i},t(function(s,i,c){n.reason||(n.reason=new z(s,i,c),r(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const r=this._listeners.indexOf(t);r!==-1&&this._listeners.splice(r,1)}toAbortSignal(){const t=new AbortController,r=n=>{t.abort(n)};return this.subscribe(r),t.signal.unsubscribe=()=>this.unsubscribe(r),t.signal}static source(){let t;return{token:new ut(function(o){t=o}),cancel:t}}};function Bn(e){return function(r){return e.apply(null,r)}}function _n(e){return a.isObject(e)&&e.isAxiosError===!0}const ye={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(ye).forEach(([e,t])=>{ye[t]=e});function rt(e){const t=new M(e),r=Se(M.prototype.request,t);return a.extend(r,M.prototype,t,{allOwnKeys:!0}),a.extend(r,t,null,{allOwnKeys:!0}),r.create=function(o){return rt(I(e,o))},r}const b=rt(V);b.Axios=M,b.CanceledError=z,b.CancelToken=Nn,b.isCancel=je,b.VERSION=tt,b.toFormData=ee,b.AxiosError=g,b.Cancel=b.CanceledError,b.all=function(t){return Promise.all(t)},b.spread=Bn,b.isAxiosError=_n,b.mergeConfig=I,b.AxiosHeaders=C,b.formToJSON=e=>Me(a.isHTMLForm(e)?new FormData(e):e),b.getAdapter=Ye.getAdapter,b.HttpStatusCode=ye,b.default=b;const{Axios:tr,AxiosError:nr,CanceledError:rr,isCancel:or,CancelToken:sr,VERSION:ir,all:ar,Cancel:cr,isAxiosError:lr,spread:ur,toFormData:fr,AxiosHeaders:dr,HttpStatusCode:hr,formToJSON:pr,getAdapter:mr,mergeConfig:gr}=b;class Fn{constructor(t,r,n=1){this.db=null,this.dbName=t,this.storeName=r,this.version=n}open(){return new Promise((t,r)=>{if(this.db){t(this.db);return}const n=indexedDB.open(this.dbName,this.version);n.onupgradeneeded=o=>{const s=o.target.result;s.objectStoreNames.contains(this.storeName)||s.createObjectStore(this.storeName,{keyPath:"id"})},n.onsuccess=o=>{this.db=o.target.result,t(this.db)},n.onerror=o=>{console.error("IndexedDB 打开失败:",o.target.error),r(o.target.error)},n.onblocked=()=>{console.warn("数据库操作被阻塞,请关闭其他连接"),r(new Error("数据库操作被阻塞"))}})}close(){this.db&&(this.db.close(),this.db=null)}put(t){return new Promise((r,n)=>{if(!this.db){n(new Error("数据库未打开,请先调用 open() 方法"));return}const o=this.db.transaction(this.storeName,"readwrite"),i=o.objectStore(this.storeName).put(t);i.onsuccess=()=>{r(t)},i.onerror=()=>{console.error("数据存储失败:",i.error),n(i.error)},o.onerror=()=>{console.error("事务错误:",o.error),n(o.error)}})}update(t){return new Promise(async(r,n)=>{try{if(!await this.get(t.id)){n(new Error(`ID为 ${t.id} 的数据不存在,无法更新`));return}const s=await this.put(t);r(s)}catch(o){console.error("数据更新失败:",o),n(o)}})}partialUpdate(t,r){return new Promise(async(n,o)=>{try{const s=await this.get(t);if(!s){o(new Error(`ID为 ${t} 的数据不存在,无法更新`));return}const i={...s,...r,id:t},c=await this.put(i);n(c)}catch(s){console.error("数据部分更新失败:",s),o(s)}})}get(t){return new Promise((r,n)=>{if(!this.db){n(new Error("数据库未打开,请先调用 open() 方法"));return}const i=this.db.transaction(this.storeName,"readonly").objectStore(this.storeName).get(t);i.onsuccess=()=>{r(i.result)},i.onerror=()=>{console.error("数据读取失败:",i.error),n(i.error)}})}delete(t){return new Promise((r,n)=>{if(!this.db){n(new Error("数据库未打开,请先调用 open() 方法"));return}const i=this.db.transaction(this.storeName,"readwrite").objectStore(this.storeName).delete(t);i.onsuccess=()=>{r()},i.onerror=()=>{console.error("数据删除失败:",i.error),n(i.error)}})}getAll(){return new Promise((t,r)=>{if(!this.db){r(new Error("数据库未打开,请先调用 open() 方法"));return}const s=this.db.transaction(this.storeName,"readonly").objectStore(this.storeName).getAll();s.onsuccess=()=>{t(s.result)},s.onerror=()=>{console.error("获取所有数据失败:",s.error),r(s.error)}})}clear(){return new Promise((t,r)=>{if(!this.db){r(new Error("数据库未打开,请先调用 open() 方法"));return}const s=this.db.transaction(this.storeName,"readwrite").objectStore(this.storeName).clear();s.onsuccess=()=>{t()},s.onerror=()=>{console.error("清空存储失败:",s.error),r(s.error)}})}}class qn{constructor(){}set(t,r,n){let o=null;if(typeof n=="number"&&n>0)o=Date.now()+n*1e3;else if(typeof n>"u"){const i=this.getRaw(t);o=i?i.expire:null}const s={value:r,expire:o};localStorage.setItem(t,JSON.stringify(s))}get(t){const r=this.getRaw(t);return r?r.expire&&Date.now()>r.expire?(this.remove(t),null):r.value:null}getRaw(t){try{const r=localStorage.getItem(t);if(!r)return null;const n=JSON.parse(r);return n&&typeof n=="object"&&"value"in n&&"expire"in n?n:{value:r,expire:null}}catch{return{value:localStorage.getItem(t),expire:null}}}remove(t){localStorage.removeItem(t)}clear(){localStorage.clear()}}function Un(){return typeof window<"u"&&"indexedDB"in window&&indexedDB!==null&&indexedDB!==void 0}class In{constructor(){this.isInitialized=!1,this.indexedDBManager=new Fn("qlfyEcologicalLogin","loginData")}async ensureInitialized(){this.isInitialized||(await this.indexedDBManager.open(),this.isInitialized=!0)}async set(t,r){await this.ensureInitialized(),await this.indexedDBManager.put({id:t,data:r})}async get(t){await this.ensureInitialized();const r=await this.indexedDBManager.get(t);return r?r.data:null}async remove(t){await this.ensureInitialized(),await this.indexedDBManager.delete(t)}}class Mn{constructor(){this.localStorageManager=new qn}set(t,r){this.localStorageManager.set(t,r)}get(t){return this.localStorageManager.get(t)}remove(t){this.localStorageManager.remove(t)}}function $n(){return Un()?new In:new Mn}let $="qlfyEcologicalLogin_";const be=$n();async function j(e){$.indexOf(e.props.clientId)==-1&&($+=e.props.clientId);const t=be.set($,e);t instanceof Promise&&await t}async function Ee(){const e=be.remove($);e instanceof Promise&&await e}async function _(e){e&&$.indexOf(e)==-1&&($+=e);const t=be.get($),r=t instanceof Promise?await t:t;return r||{props:null,loginInfo:null,routerMode:vn(),isOutLogin:!1,token:"",refreshToken:"",tenant_id:168,userPermission:{}}}async function ot(e=!0,t,r){let n=await _();const o=n.props;if(o.openDebugger)debugger;if(!o||!o.isEnabled){console.error(new Error("统一登陆未开启,请检查配置"));return}const s=n.token;if(!s){console.error(new Error("未登陆或token失效"));return}b({method:"post",url:o.loginServiceBaseAddress+"/admin-api/system/auth/logout",headers:{"tenant-id":n.loginInfo.tenant_id,Authorization:"Bearer "+s}}).then(async i=>{i.data.code?r&&r(i):(e&&await F(),t&&t(i),await Ee(),await j(n))}).catch(i=>{console.log(i),r&&r(i)})}async function F(){const t=(await _()).props;if(!t||!t.isEnabled){console.error(new Error("统一登陆未开启,请检查配置"));return}const r=await zn();r&&setTimeout(()=>{window.open(r,"_self")}),await Ee()}async function st(){const e=await _(),t=e.props;return!t||!t.isEnabled?(console.error(new Error("统一登陆未开启,请检查配置")),""):e.token}async function it(){return(await _()).loginInfo}async function jn(){let e=await _();const t=e.props;return!t||!t.isEnabled?(console.error(new Error("统一登陆未开启,请检查配置")),null):e.userPermission}async function Hn(){let e=await _();const t=e.props;return!t||!t.isEnabled?(console.error(new Error("统一登陆未开启,请检查配置")),null):e.refreshToken}async function zn(){const t=(await _()).props;if(!t||!t.isEnabled)return console.error(new Error("统一登陆未开启,请检查配置")),null;if(!t.clientId||!t.clientSecret)return console.error("未配置应用id或应用密钥!"),"";if(!t.loginPageBaseAddress)return console.error("未配置登录页基础地址!"),"";let r=await at(["token","refreshToken"],!1),n=t.redirectUrl||encodeURIComponent(r);return`${t.loginPageBaseAddress}/#/login?clientId=${t.clientId}&clientSecret=${t.clientSecret}&redirectUrl=${n}`}function vn(){if(window.location.href.includes("#")){const t=window.location.href.indexOf("#"),r=window.location.href.substring(t+1);if(r.startsWith("/")||r.includes("?"))return"hash"}return"history"}async function at(e,t=!1,r=window.location.href,n){if(n||(n=(await _()).routerMode),!["hash","history"].includes(n))throw new Error('路由模式必须是 "hash" 或 "history"');let o,s,i;if(n==="hash"){const c=r.indexOf("#");if(c===-1)return r;s=r.substring(0,c+1);const l=r.substring(c+1).split("?"),u=l[0],d=l[1]||"";i=new URLSearchParams(d),e.forEach(h=>{i.delete(h)});const y=i.toString(),E=y?`${u}?${y}`:u;o=`${s}${E}`}else{o=new URL(r);const c=o.pathname;e.forEach(l=>{o.searchParams.delete(l)});const f=o.searchParams.toString();o=f?`${c}?${f}`:c}return t&&history.replaceState({},"",o),o}function K(e){if(e===null)return null;if(typeof e!="object")return e;if(e instanceof Date)return new Date(e);if(e instanceof RegExp)return new RegExp(e);let t=new e.constructor;for(let r in e)e.hasOwnProperty(r)&&(t[r]=K(e[r]));return t}function Jn(e){if(!e)throw new Error("请传入有效的Vue Router实例");return(()=>{var n,o,s,i;if((n=e.options)!=null&&n.history){const c=e.options.history;if((c==null?void 0:c.type)==="hash"||((o=c==null?void 0:c.constructor)==null?void 0:o.name)==="HashHistory")return"hash"}if(typeof e.mode=="string")return e.mode;const r=e.history;if(r){const c=(s=r.constructor)==null?void 0:s.name;if(c!=null&&c.includes("Hash")||c!=null&&c.includes("hash"))return"hash"}return typeof window<"u"&&((i=window.location)!=null&&i.hash)&&window.location.hash!=="#"?"hash":""})().toLowerCase()==="hash"}const ct=B.defineComponent({__name:"index",props:{clientId:{},clientSecret:{},loginPageBaseAddress:{},loginServiceBaseAddress:{},useRouter:{},forceMode:{type:Boolean,default:!0},clientName:{},token:{},isEnabled:{type:Boolean,default:!0},redirectPath:{default:""},tenantId:{default:168},showLog:{type:Boolean,default:!1},openDebugger:{type:Boolean,default:!1}},emits:["loggingIn","loginSuccess","loginFail","tokenRefresh"],setup(e,{expose:t,emit:r}){const n=e,o=n.useRouter,s=n.useRouter.currentRoute,i=r;let c=!0,f=null,l=null,u=!1,d=null;t({logout:async()=>await ot(),getToken:async()=>await st(),getLoginInfo:async()=>await it(),goLogin:async()=>await F()}),o.beforeEach(async(w,R,A)=>{n.forceMode&&!u?(n.showLog&&console.log("【qlfyEcologicalLogin】【路由拦截中】等待登陆放行..."),d=K(w.query),(u||await S())&&(n.showLog&&console.log("【qlfyEcologicalLogin】【路由拦截中】登陆成功路由放行"),d=null,delete w.query.token,delete w.query.refreshToken,A(w))):A()}),B.onBeforeUnmount(()=>{}),B.watch(()=>s.value.path,(w,R)=>{f&&clearTimeout(f),B.nextTick(()=>{f=setTimeout(()=>{n.isEnabled&&y()},300)})},{deep:!0,immediate:!0}),B.watch(()=>n.isEnabled,w=>{setTimeout(async()=>{w&&y(),w||(await Ee(),f&&clearTimeout(f))})},{deep:!0});async function y(){if(n.openDebugger)debugger;n.isEnabled&&(l=await _(n.clientId),await T(),E())}async function E(){if(n.showLog&&console.log("【qlfyEcologicalLogin】登陆流程执行..."),n.token){n.showLog&&console.log("【qlfyEcologicalLogin】读取参数中的token"),l.isOutLogin=!0,l.token=n.token,await j(l),c&&i("loggingIn",l.token),m(n.token,c),c=!1;return}if((s.value.query.token||d!=null&&d.token)&&c){n.showLog&&console.log("【qlfyEcologicalLogin】读取链接中的token"),l.token=s.value.query.token||(d==null?void 0:d.token),l.refreshToken=s.value.query.refreshToken,await j(l),await O(),c&&i("loggingIn",l.token),m(l.token,c),c=!1;return}const w=l.token;if(w){n.showLog&&console.log("【qlfyEcologicalLogin】读取上一次缓存的token"),c&&i("loggingIn",w),m(w,c),c=!1;return}h()}async function h(){n.forceMode?await F():(i("loginFail",{msg:"未登陆",data:null}),u=!1)}function m(w,R){n.showLog&&console.log("【qlfyEcologicalLogin】尝试效验token");let A={token:w};const L={"tenant-id":n.tenantId,Authorization:"Basic "+btoa(n.clientId+":"+n.clientSecret)};b.post(n.loginServiceBaseAddress+"/admin-api/system/oauth2/check-token","",{params:A,headers:L}).then(async q=>{if(q.data.code!==0){if(n.showLog&&console.log("【qlfyEcologicalLogin】token无效, 无refreshToken"),n.forceMode)return await F();i("loginFail",{message:"token失效"}),u=!1;return}n.showLog&&console.log("【qlfyEcologicalLogin】token校验通过"),l.loginInfo=q.data.data,await j(l),R&&p(w)}).catch(async q=>{l.token="",await j(l),n.forceMode&&await F(),!n.forceMode&&(i("loginFail",{message:"token失效"}),u=!1)})}function p(w){n.showLog&&console.log("【qlfyEcologicalLogin】获取用户配置数据");let R={clientId:n.clientId};const A={"tenant-id":l.loginInfo.tenant_id,Authorization:w};b.get(n.loginServiceBaseAddress+"/admin-api/system/auth/get-permission-info",{params:R,headers:A}).then(async L=>{if(L.data.code!==0){if(n.showLog&&console.log("【qlfyEcologicalLogin】获取用户权限数据失败"),n.forceMode)return F();i("loginFail",{message:"用户配置获取失败"}),u=!1;return}n.showLog&&console.log("【qlfyEcologicalLogin】用户配置获取成功"),l.userPermission=L.data,await j(l),await O(),i("loginSuccess",K(l.userPermission)),u=!0}).catch(L=>{if(n.showLog&&console.log("【qlfyEcologicalLogin】用户配置数据获取失败"),n.forceMode)return F();i("loginFail",{message:"用户配置获取失败",data:L}),u=!1})}function S(){return new Promise((w,R)=>{let A=null;u?w(!0):A=setInterval(L=>{u&&(A&&clearInterval(A),w(!0))},50),setTimeout(()=>{A&&clearInterval(A),R(!1)},1e4)})}async function T(){const w={...n};delete w.useRouter,l.props=K(w),l.routerMode=Jn(o)?"hash":"history",await j(l)}async function O(){await at(["token","refreshToken"],!0);let w=K(s.value.query);delete w.token,delete w.refreshToken,o.currentRoute.value.query=w}return(w,R)=>null}}),Vn=ct,Wn={install(e){e.component("qlfyEcologicalLogin",ct)}};P.default=Wn,P.getLoginInfo=it,P.getRefreshToken=Hn,P.getToken=st,P.getUserPermission=jn,P.goLogin=F,P.logout=ot,P.qlfyEcologicalLogin=Vn,Object.defineProperties(P,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
6
|
+
`+s):n.stack=s}catch{}}throw n}}_request(t,r){typeof t=="string"?(r=r||{},r.url=t):r=t||{},r=I(this.defaults,r);const{transitional:n,paramsSerializer:o,headers:s}=r;n!==void 0&&ie.assertOptions(n,{silentJSONParsing:N.transitional(N.boolean),forcedJSONParsing:N.transitional(N.boolean),clarifyTimeoutError:N.transitional(N.boolean)},!1),o!=null&&(a.isFunction(o)?r.paramsSerializer={serialize:o}:ie.assertOptions(o,{encode:N.function,serialize:N.function},!0)),r.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?r.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:r.allowAbsoluteUrls=!0),ie.assertOptions(r,{baseUrl:N.spelling("baseURL"),withXsrfToken:N.spelling("withXSRFToken")},!0),r.method=(r.method||this.defaults.method||"get").toLowerCase();let i=s&&a.merge(s.common,s[r.method]);s&&a.forEach(["delete","get","head","post","put","patch","common"],h=>{delete s[h]}),r.headers=C.concat(i,s);const c=[];let f=!0;this.interceptors.request.forEach(function(m){typeof m.runWhen=="function"&&m.runWhen(r)===!1||(f=f&&m.synchronous,c.unshift(m.fulfilled,m.rejected))});const l=[];this.interceptors.response.forEach(function(m){l.push(m.fulfilled,m.rejected)});let u,d=0,y;if(!f){const h=[et.bind(this),void 0];for(h.unshift.apply(h,c),h.push.apply(h,l),y=h.length,u=Promise.resolve(r);d<y;)u=u.then(h[d++],h[d++]);return u}y=c.length;let E=r;for(d=0;d<y;){const h=c[d++],m=c[d++];try{E=h(E)}catch(p){m.call(this,p);break}}try{u=et.call(this,E)}catch(h){return Promise.reject(h)}for(d=0,y=l.length;d<y;)u=u.then(l[d++],l[d++]);return u}getUri(t){t=I(this.defaults,t);const r=Je(t.baseURL,t.url,t.allowAbsoluteUrls);return qe(r,t.params,t.paramsSerializer)}};a.forEach(["delete","get","head","options"],function(t){M.prototype[t]=function(r,n){return this.request(I(n||{},{method:t,url:r,data:(n||{}).data}))}}),a.forEach(["post","put","patch"],function(t){function r(n){return function(s,i,c){return this.request(I(c||{},{method:t,headers:n?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}M.prototype[t]=r(),M.prototype[t+"Form"]=r(!0)});let Nn=class ut{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(s){r=s});const n=this;this.promise.then(o=>{if(!n._listeners)return;let s=n._listeners.length;for(;s-- >0;)n._listeners[s](o);n._listeners=null}),this.promise.then=o=>{let s;const i=new Promise(c=>{n.subscribe(c),s=c}).then(o);return i.cancel=function(){n.unsubscribe(s)},i},t(function(s,i,c){n.reason||(n.reason=new z(s,i,c),r(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const r=this._listeners.indexOf(t);r!==-1&&this._listeners.splice(r,1)}toAbortSignal(){const t=new AbortController,r=n=>{t.abort(n)};return this.subscribe(r),t.signal.unsubscribe=()=>this.unsubscribe(r),t.signal}static source(){let t;return{token:new ut(function(o){t=o}),cancel:t}}};function Bn(e){return function(r){return e.apply(null,r)}}function _n(e){return a.isObject(e)&&e.isAxiosError===!0}const ye={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(ye).forEach(([e,t])=>{ye[t]=e});function rt(e){const t=new M(e),r=Se(M.prototype.request,t);return a.extend(r,M.prototype,t,{allOwnKeys:!0}),a.extend(r,t,null,{allOwnKeys:!0}),r.create=function(o){return rt(I(e,o))},r}const b=rt(V);b.Axios=M,b.CanceledError=z,b.CancelToken=Nn,b.isCancel=je,b.VERSION=tt,b.toFormData=ee,b.AxiosError=g,b.Cancel=b.CanceledError,b.all=function(t){return Promise.all(t)},b.spread=Bn,b.isAxiosError=_n,b.mergeConfig=I,b.AxiosHeaders=C,b.formToJSON=e=>Me(a.isHTMLForm(e)?new FormData(e):e),b.getAdapter=Ye.getAdapter,b.HttpStatusCode=ye,b.default=b;const{Axios:tr,AxiosError:nr,CanceledError:rr,isCancel:or,CancelToken:sr,VERSION:ir,all:ar,Cancel:cr,isAxiosError:lr,spread:ur,toFormData:fr,AxiosHeaders:dr,HttpStatusCode:hr,formToJSON:pr,getAdapter:mr,mergeConfig:gr}=b;class Fn{constructor(t,r,n=1){this.db=null,this.dbName=t,this.storeName=r,this.version=n}open(){return new Promise((t,r)=>{if(this.db){t(this.db);return}const n=indexedDB.open(this.dbName,this.version);n.onupgradeneeded=o=>{const s=o.target.result;s.objectStoreNames.contains(this.storeName)||s.createObjectStore(this.storeName,{keyPath:"id"})},n.onsuccess=o=>{this.db=o.target.result,t(this.db)},n.onerror=o=>{console.error("IndexedDB 打开失败:",o.target.error),r(o.target.error)},n.onblocked=()=>{console.warn("数据库操作被阻塞,请关闭其他连接"),r(new Error("数据库操作被阻塞"))}})}close(){this.db&&(this.db.close(),this.db=null)}put(t){return new Promise((r,n)=>{if(!this.db){n(new Error("数据库未打开,请先调用 open() 方法"));return}const o=this.db.transaction(this.storeName,"readwrite"),i=o.objectStore(this.storeName).put(t);i.onsuccess=()=>{r(t)},i.onerror=()=>{console.error("数据存储失败:",i.error),n(i.error)},o.onerror=()=>{console.error("事务错误:",o.error),n(o.error)}})}update(t){return new Promise(async(r,n)=>{try{if(!await this.get(t.id)){n(new Error(`ID为 ${t.id} 的数据不存在,无法更新`));return}const s=await this.put(t);r(s)}catch(o){console.error("数据更新失败:",o),n(o)}})}partialUpdate(t,r){return new Promise(async(n,o)=>{try{const s=await this.get(t);if(!s){o(new Error(`ID为 ${t} 的数据不存在,无法更新`));return}const i={...s,...r,id:t},c=await this.put(i);n(c)}catch(s){console.error("数据部分更新失败:",s),o(s)}})}get(t){return new Promise((r,n)=>{if(!this.db){n(new Error("数据库未打开,请先调用 open() 方法"));return}const i=this.db.transaction(this.storeName,"readonly").objectStore(this.storeName).get(t);i.onsuccess=()=>{r(i.result)},i.onerror=()=>{console.error("数据读取失败:",i.error),n(i.error)}})}delete(t){return new Promise((r,n)=>{if(!this.db){n(new Error("数据库未打开,请先调用 open() 方法"));return}const i=this.db.transaction(this.storeName,"readwrite").objectStore(this.storeName).delete(t);i.onsuccess=()=>{r()},i.onerror=()=>{console.error("数据删除失败:",i.error),n(i.error)}})}getAll(){return new Promise((t,r)=>{if(!this.db){r(new Error("数据库未打开,请先调用 open() 方法"));return}const s=this.db.transaction(this.storeName,"readonly").objectStore(this.storeName).getAll();s.onsuccess=()=>{t(s.result)},s.onerror=()=>{console.error("获取所有数据失败:",s.error),r(s.error)}})}clear(){return new Promise((t,r)=>{if(!this.db){r(new Error("数据库未打开,请先调用 open() 方法"));return}const s=this.db.transaction(this.storeName,"readwrite").objectStore(this.storeName).clear();s.onsuccess=()=>{t()},s.onerror=()=>{console.error("清空存储失败:",s.error),r(s.error)}})}}class qn{constructor(){}set(t,r,n){let o=null;if(typeof n=="number"&&n>0)o=Date.now()+n*1e3;else if(typeof n>"u"){const i=this.getRaw(t);o=i?i.expire:null}const s={value:r,expire:o};localStorage.setItem(t,JSON.stringify(s))}get(t){const r=this.getRaw(t);return r?r.expire&&Date.now()>r.expire?(this.remove(t),null):r.value:null}getRaw(t){try{const r=localStorage.getItem(t);if(!r)return null;const n=JSON.parse(r);return n&&typeof n=="object"&&"value"in n&&"expire"in n?n:{value:r,expire:null}}catch{return{value:localStorage.getItem(t),expire:null}}}remove(t){localStorage.removeItem(t)}clear(){localStorage.clear()}}function Un(){return typeof window<"u"&&"indexedDB"in window&&indexedDB!==null&&indexedDB!==void 0}class In{constructor(){this.isInitialized=!1,this.indexedDBManager=new Fn("qlfyEcologicalLogin","loginData")}async ensureInitialized(){this.isInitialized||(await this.indexedDBManager.open(),this.isInitialized=!0)}async set(t,r){await this.ensureInitialized(),await this.indexedDBManager.put({id:t,data:r})}async get(t){await this.ensureInitialized();const r=await this.indexedDBManager.get(t);return r?r.data:null}async remove(t){await this.ensureInitialized(),await this.indexedDBManager.delete(t)}}class Mn{constructor(){this.localStorageManager=new qn}set(t,r){this.localStorageManager.set(t,r)}get(t){return this.localStorageManager.get(t)}remove(t){this.localStorageManager.remove(t)}}function $n(){return Un()?new In:new Mn}let $="qlfyEcologicalLogin_";const be=$n();async function j(e){$.indexOf(e.props.clientId)==-1&&($+=e.props.clientId);const t=be.set($,e);t instanceof Promise&&await t}async function Ee(){const e=be.remove($);e instanceof Promise&&await e}async function _(e){e&&$.indexOf(e)==-1&&($+=e);const t=be.get($),r=t instanceof Promise?await t:t;return r||{props:null,loginInfo:null,routerMode:vn(),isOutLogin:!1,token:"",refreshToken:"",tenant_id:168,userPermission:{}}}async function ot(e=!0,t,r){let n=await _();const o=n.props;if(o.openDebugger)debugger;if(!o||!o.isEnabled){console.error(new Error("统一登陆未开启,请检查配置"));return}const s=n.token;if(!s){console.error(new Error("未登陆或token失效"));return}b({method:"post",url:o.loginServiceBaseAddress+"/admin-api/system/auth/logout",headers:{"tenant-id":n.loginInfo.tenant_id,Authorization:"Bearer "+s}}).then(async i=>{i.data.code?r&&r(i):(e&&await F(),t&&t(i),await Ee(),await j(n))}).catch(i=>{console.log(i),r&&r(i)})}async function F(){const t=(await _()).props;if(!t||!t.isEnabled){console.error(new Error("统一登陆未开启,请检查配置"));return}const r=await zn();r&&setTimeout(()=>{window.open(r,"_self")}),await Ee()}async function st(){const e=await _(),t=e.props;return!t||!t.isEnabled?(console.error(new Error("统一登陆未开启,请检查配置")),""):e.token}async function it(){const e=await _(),t=e.props;return!t||!t.isEnabled?(console.error(new Error("统一登陆未开启,请检查配置")),null):e.loginInfo}async function jn(){let e=await _();const t=e.props;return!t||!t.isEnabled?(console.error(new Error("统一登陆未开启,请检查配置")),null):e.userPermission}async function Hn(){let e=await _();const t=e.props;return!t||!t.isEnabled?(console.error(new Error("统一登陆未开启,请检查配置")),null):e.refreshToken}async function zn(){const t=(await _()).props;if(!t||!t.isEnabled)return console.error(new Error("统一登陆未开启,请检查配置")),null;if(!t.clientId||!t.clientSecret)return console.error("未配置应用id或应用密钥!"),"";if(!t.loginPageBaseAddress)return console.error("未配置登录页基础地址!"),"";let r=await at(["token","refreshToken"],!1),n=t.redirectUrl||encodeURIComponent(r);return`${t.loginPageBaseAddress}/#/login?clientId=${t.clientId}&clientSecret=${t.clientSecret}&redirectUrl=${n}`}function vn(){if(window.location.href.includes("#")){const t=window.location.href.indexOf("#"),r=window.location.href.substring(t+1);if(r.startsWith("/")||r.includes("?"))return"hash"}return"history"}async function at(e,t=!1,r=window.location.href,n){if(n||(n=(await _()).routerMode),!["hash","history"].includes(n))throw new Error('路由模式必须是 "hash" 或 "history"');let o,s,i;if(n==="hash"){const c=r.indexOf("#");if(c===-1)return r;s=r.substring(0,c+1);const l=r.substring(c+1).split("?"),u=l[0],d=l[1]||"";i=new URLSearchParams(d),e.forEach(h=>{i.delete(h)});const y=i.toString(),E=y?`${u}?${y}`:u;o=`${s}${E}`}else{o=new URL(r),e.forEach(f=>{o.searchParams.delete(f)});const c=o.searchParams.toString();o=c?`${o.href}?${c}`:o.href}return t&&history.replaceState({},"",o),o}function K(e){if(e===null)return null;if(typeof e!="object")return e;if(e instanceof Date)return new Date(e);if(e instanceof RegExp)return new RegExp(e);let t=new e.constructor;for(let r in e)e.hasOwnProperty(r)&&(t[r]=K(e[r]));return t}function Jn(e){if(!e)throw new Error("请传入有效的Vue Router实例");return(()=>{var n,o,s,i;if((n=e.options)!=null&&n.history){const c=e.options.history;if((c==null?void 0:c.type)==="hash"||((o=c==null?void 0:c.constructor)==null?void 0:o.name)==="HashHistory")return"hash"}if(typeof e.mode=="string")return e.mode;const r=e.history;if(r){const c=(s=r.constructor)==null?void 0:s.name;if(c!=null&&c.includes("Hash")||c!=null&&c.includes("hash"))return"hash"}return typeof window<"u"&&((i=window.location)!=null&&i.hash)&&window.location.hash!=="#"?"hash":""})().toLowerCase()==="hash"}const ct=B.defineComponent({__name:"index",props:{clientId:{},clientSecret:{},loginPageBaseAddress:{},loginServiceBaseAddress:{},useRouter:{},forceMode:{type:Boolean,default:!0},clientName:{},token:{},isEnabled:{type:Boolean,default:!0},redirectPath:{default:""},tenantId:{default:168},showLog:{type:Boolean,default:!1},openDebugger:{type:Boolean,default:!1}},emits:["loggingIn","loginSuccess","loginFail","tokenRefresh"],setup(e,{expose:t,emit:r}){const n=e,o=n.useRouter,s=n.useRouter.currentRoute,i=r;let c=!0,f=null,l=null,u=!1,d=null;t({logout:async()=>await ot(),getToken:async()=>await st(),getLoginInfo:async()=>await it(),goLogin:async()=>await F()}),o.beforeEach(async(w,R,A)=>{n.forceMode&&!u?(n.showLog&&console.log("【qlfyEcologicalLogin】【路由拦截中】等待登陆放行..."),d=K(w.query),(u||await S())&&(n.showLog&&console.log("【qlfyEcologicalLogin】【路由拦截中】登陆成功路由放行"),d=null,delete w.query.token,delete w.query.refreshToken,A(w))):A()}),B.onBeforeUnmount(()=>{}),B.watch(()=>s.value.path,(w,R)=>{f&&clearTimeout(f),B.nextTick(()=>{f=setTimeout(()=>{n.isEnabled&&y()},300)})},{deep:!0,immediate:!0}),B.watch(()=>n.isEnabled,w=>{setTimeout(async()=>{w&&y(),w||(await Ee(),f&&clearTimeout(f))})},{deep:!0});async function y(){if(n.openDebugger)debugger;n.isEnabled&&(l=await _(n.clientId),await T(),E())}async function E(){if(n.showLog&&console.log("【qlfyEcologicalLogin】登陆流程执行..."),n.token){n.showLog&&console.log("【qlfyEcologicalLogin】读取参数中的token"),l.isOutLogin=!0,l.token=n.token,await j(l),c&&i("loggingIn",l.token),m(n.token,c),c=!1;return}if((s.value.query.token||d!=null&&d.token)&&c){n.showLog&&console.log("【qlfyEcologicalLogin】读取链接中的token"),l.token=s.value.query.token||(d==null?void 0:d.token),l.refreshToken=s.value.query.refreshToken,await j(l),await O(),c&&i("loggingIn",l.token),m(l.token,c),c=!1;return}const w=l.token;if(w){n.showLog&&console.log("【qlfyEcologicalLogin】读取上一次缓存的token"),c&&i("loggingIn",w),m(w,c),c=!1;return}h()}async function h(){n.forceMode?await F():(i("loginFail",{msg:"未登陆",data:null}),u=!1)}function m(w,R){n.showLog&&console.log("【qlfyEcologicalLogin】尝试效验token");let A={token:w};const L={"tenant-id":n.tenantId,Authorization:"Basic "+btoa(n.clientId+":"+n.clientSecret)};b.post(n.loginServiceBaseAddress+"/admin-api/system/oauth2/check-token","",{params:A,headers:L}).then(async q=>{if(q.data.code!==0){if(n.showLog&&console.log("【qlfyEcologicalLogin】token无效, 无refreshToken"),n.forceMode)return await F();i("loginFail",{message:"token失效"}),u=!1;return}n.showLog&&console.log("【qlfyEcologicalLogin】token校验通过"),l.loginInfo=q.data.data,await j(l),R&&p(w)}).catch(async q=>{l.token="",await j(l),n.forceMode&&await F(),!n.forceMode&&(i("loginFail",{message:"token失效"}),u=!1)})}function p(w){n.showLog&&console.log("【qlfyEcologicalLogin】获取用户配置数据");let R={clientId:n.clientId};const A={"tenant-id":l.loginInfo.tenant_id,Authorization:w};b.get(n.loginServiceBaseAddress+"/admin-api/system/auth/get-permission-info",{params:R,headers:A}).then(async L=>{if(L.data.code!==0){if(n.showLog&&console.log("【qlfyEcologicalLogin】获取用户权限数据失败"),n.forceMode)return F();i("loginFail",{message:"用户配置获取失败"}),u=!1;return}n.showLog&&console.log("【qlfyEcologicalLogin】用户配置获取成功"),l.userPermission=L.data,await j(l),await O(),i("loginSuccess",K(l.userPermission)),u=!0}).catch(L=>{if(n.showLog&&console.log("【qlfyEcologicalLogin】用户配置数据获取失败"),n.forceMode)return F();i("loginFail",{message:"用户配置获取失败",data:L}),u=!1})}function S(){return new Promise((w,R)=>{let A=null;u?w(!0):A=setInterval(L=>{u&&(A&&clearInterval(A),w(!0))},50),setTimeout(()=>{A&&clearInterval(A),R(!1)},1e4)})}async function T(){const w={...n};delete w.useRouter,l.props=K(w),l.routerMode=Jn(o)?"hash":"history",await j(l)}async function O(){await at(["token","refreshToken"],!0);let w=K(s.value.query);delete w.token,delete w.refreshToken,o.currentRoute.value.query=w}return(w,R)=>null}}),Vn=ct,Wn={install(e){e.component("qlfyEcologicalLogin",ct)}};P.default=Wn,P.getLoginInfo=it,P.getRefreshToken=Hn,P.getToken=st,P.getUserPermission=jn,P.goLogin=F,P.logout=ot,P.qlfyEcologicalLogin=Vn,Object.defineProperties(P,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/lib/index.umd.js.gz
CHANGED
|
Binary file
|