qlfy-ecological-login 1.1.1 → 1.1.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 +1 -1
- 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
|
@@ -3080,7 +3080,7 @@ function Pa(e = !0, t, n) {
|
|
|
3080
3080
|
}
|
|
3081
3081
|
function ot() {
|
|
3082
3082
|
const e = G().props;
|
|
3083
|
-
return
|
|
3083
|
+
return !e || !e.isEnabled ? null : le.get(e.tokenName);
|
|
3084
3084
|
}
|
|
3085
3085
|
function tl() {
|
|
3086
3086
|
return G().refreshToken;
|
package/lib/index.mjs.gz
CHANGED
|
Binary file
|
package/lib/index.umd.js
CHANGED
|
@@ -8,4 +8,4 @@ usage: app.provide(ZINDEX_INJECTION_KEY, { current: 0 })`),{initialZIndex:r,curr
|
|
|
8
8
|
`)}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,...n){const r=new this(t);return n.forEach(o=>r.set(o)),r}static accessor(t){const r=(this[ln]=this[ln]={accessors:{}}).accessors,o=this.prototype;function s(i){const l=fe(i);r[l]||(wi(o,i),r[l]=!0)}return c.isArray(t)?t.forEach(s):s(t),this}};A.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),c.reduceDescriptors(A.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),c.freezeMethods(A);function Ze(e,t){const n=this||ue,r=t||n,o=A.from(r.headers);let s=r.data;return c.forEach(e,function(l){s=l.call(n,s,o.normalize(),t?t.status:void 0)}),o.normalize(),s}function cn(e){return!!(e&&e.__CANCEL__)}function ne(e,t,n){y.call(this,e??"canceled",y.ERR_CANCELED,t,n),this.name="CanceledError"}c.inherits(ne,y,{__CANCEL__:!0});function un(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new y("Request failed with status code "+n.status,[y.ERR_BAD_REQUEST,y.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function _i(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function Ei(e,t){e=e||10;const n=new Array(e),r=new Array(e);let o=0,s=0,i;return t=t!==void 0?t:1e3,function(d){const f=Date.now(),u=r[s];i||(i=f),n[o]=d,r[o]=f;let h=s,b=0;for(;h!==o;)b+=n[h++],h=h%e;if(o=(o+1)%e,o===s&&(s=(s+1)%e),f-i<t)return;const E=u&&f-u;return E?Math.round(b*1e3/E):void 0}}function Si(e,t){let n=0,r=1e3/t,o,s;const i=(f,u=Date.now())=>{n=u,o=null,s&&(clearTimeout(s),s=null),e.apply(null,f)};return[(...f)=>{const u=Date.now(),h=u-n;h>=r?i(f,u):(o=f,s||(s=setTimeout(()=>{s=null,i(o)},r-h)))},()=>o&&i(o)]}const xe=(e,t,n=3)=>{let r=0;const o=Ei(50,250);return Si(s=>{const i=s.loaded,l=s.lengthComputable?s.total:void 0,d=i-r,f=o(d),u=i<=l;r=i;const h={loaded:i,total:l,progress:l?i/l:void 0,bytes:d,rate:f||void 0,estimated:f&&l&&u?(l-i)/f:void 0,event:s,lengthComputable:l!=null,[t?"download":"upload"]:!0};e(h)},n)},fn=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},dn=e=>(...t)=>c.asap(()=>e(...t)),Ti=N.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,N.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(N.origin),N.navigator&&/(msie|trident)/i.test(N.navigator.userAgent)):()=>!0,Ci=N.hasStandardBrowserEnv?{write(e,t,n,r,o,s){const i=[e+"="+encodeURIComponent(t)];c.isNumber(n)&&i.push("expires="+new Date(n).toGMTString()),c.isString(r)&&i.push("path="+r),c.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 Oi(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function xi(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function pn(e,t,n){let r=!Oi(t);return e&&(r||n==!1)?xi(e,t):t}const mn=e=>e instanceof A?{...e}:e;function G(e,t){t=t||{};const n={};function r(f,u,h,b){return c.isPlainObject(f)&&c.isPlainObject(u)?c.merge.call({caseless:b},f,u):c.isPlainObject(u)?c.merge({},u):c.isArray(u)?u.slice():u}function o(f,u,h,b){if(c.isUndefined(u)){if(!c.isUndefined(f))return r(void 0,f,h,b)}else return r(f,u,h,b)}function s(f,u){if(!c.isUndefined(u))return r(void 0,u)}function i(f,u){if(c.isUndefined(u)){if(!c.isUndefined(f))return r(void 0,f)}else return r(void 0,u)}function l(f,u,h){if(h in t)return r(f,u);if(h in e)return r(void 0,f)}const d={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:l,headers:(f,u,h)=>o(mn(f),mn(u),h,!0)};return c.forEach(Object.keys(Object.assign({},e,t)),function(u){const h=d[u]||o,b=h(e[u],t[u],u);c.isUndefined(b)&&h!==l||(n[u]=b)}),n}const hn=e=>{const t=G({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:l}=t;t.headers=i=A.from(i),t.url=rn(pn(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),l&&i.set("Authorization","Basic "+btoa((l.username||"")+":"+(l.password?unescape(encodeURIComponent(l.password)):"")));let d;if(c.isFormData(n)){if(N.hasStandardBrowserEnv||N.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if((d=i.getContentType())!==!1){const[f,...u]=d?d.split(";").map(h=>h.trim()).filter(Boolean):[];i.setContentType([f||"multipart/form-data",...u].join("; "))}}if(N.hasStandardBrowserEnv&&(r&&c.isFunction(r)&&(r=r(t)),r||r!==!1&&Ti(t.url))){const f=o&&s&&Ci.read(s);f&&i.set(o,f)}return t},Ri=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){const o=hn(e);let s=o.data;const i=A.from(o.headers).normalize();let{responseType:l,onUploadProgress:d,onDownloadProgress:f}=o,u,h,b,E,g;function p(){E&&E(),g&&g(),o.cancelToken&&o.cancelToken.unsubscribe(u),o.signal&&o.signal.removeEventListener("abort",u)}let m=new XMLHttpRequest;m.open(o.method.toUpperCase(),o.url,!0),m.timeout=o.timeout;function w(){if(!m)return;const O=A.from("getAllResponseHeaders"in m&&m.getAllResponseHeaders()),x={data:!l||l==="text"||l==="json"?m.responseText:m.response,status:m.status,statusText:m.statusText,headers:O,config:e,request:m};un(function(R){n(R),p()},function(R){r(R),p()},x),m=null}"onloadend"in m?m.onloadend=w:m.onreadystatechange=function(){!m||m.readyState!==4||m.status===0&&!(m.responseURL&&m.responseURL.indexOf("file:")===0)||setTimeout(w)},m.onabort=function(){m&&(r(new y("Request aborted",y.ECONNABORTED,e,m)),m=null)},m.onerror=function(){r(new y("Network Error",y.ERR_NETWORK,e,m)),m=null},m.ontimeout=function(){let B=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const x=o.transitional||sn;o.timeoutErrorMessage&&(B=o.timeoutErrorMessage),r(new y(B,x.clarifyTimeoutError?y.ETIMEDOUT:y.ECONNABORTED,e,m)),m=null},s===void 0&&i.setContentType(null),"setRequestHeader"in m&&c.forEach(i.toJSON(),function(B,x){m.setRequestHeader(x,B)}),c.isUndefined(o.withCredentials)||(m.withCredentials=!!o.withCredentials),l&&l!=="json"&&(m.responseType=o.responseType),f&&([b,g]=xe(f,!0),m.addEventListener("progress",b)),d&&m.upload&&([h,E]=xe(d),m.upload.addEventListener("progress",h),m.upload.addEventListener("loadend",E)),(o.cancelToken||o.signal)&&(u=O=>{m&&(r(!O||O.type?new ne(null,e,m):O),m.abort(),m=null)},o.cancelToken&&o.cancelToken.subscribe(u),o.signal&&(o.signal.aborted?u():o.signal.addEventListener("abort",u)));const T=_i(o.url);if(T&&N.protocols.indexOf(T)===-1){r(new y("Unsupported protocol "+T+":",y.ERR_BAD_REQUEST,e));return}m.send(s||null)})},Ni=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let r=new AbortController,o;const s=function(f){if(!o){o=!0,l();const u=f instanceof Error?f:this.reason;r.abort(u instanceof y?u:new ne(u instanceof Error?u.message:u))}};let i=t&&setTimeout(()=>{i=null,s(new y(`timeout ${t} of ms exceeded`,y.ETIMEDOUT))},t);const l=()=>{e&&(i&&clearTimeout(i),i=null,e.forEach(f=>{f.unsubscribe?f.unsubscribe(s):f.removeEventListener("abort",s)}),e=null)};e.forEach(f=>f.addEventListener("abort",s));const{signal:d}=r;return d.unsubscribe=()=>c.asap(l),d}},Pi=function*(e,t){let n=e.byteLength;if(n<t){yield e;return}let r=0,o;for(;r<n;)o=r+t,yield e.slice(r,o),r=o},ki=async function*(e,t){for await(const n of Ai(e))yield*Pi(n,t)},Ai=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}const t=e.getReader();try{for(;;){const{done:n,value:r}=await t.read();if(n)break;yield r}}finally{await t.cancel()}},gn=(e,t,n,r)=>{const o=ki(e,t);let s=0,i,l=d=>{i||(i=!0,r&&r(d))};return new ReadableStream({async pull(d){try{const{done:f,value:u}=await o.next();if(f){l(),d.close();return}let h=u.byteLength;if(n){let b=s+=h;n(b)}d.enqueue(new Uint8Array(u))}catch(f){throw l(f),f}},cancel(d){return l(d),o.return()}},{highWaterMark:2})},Re=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",yn=Re&&typeof ReadableStream=="function",Ii=Re&&(typeof TextEncoder=="function"?(e=>t=>e.encode(t))(new TextEncoder):async e=>new Uint8Array(await new Response(e).arrayBuffer())),bn=(e,...t)=>{try{return!!e(...t)}catch{return!1}},Bi=yn&&bn(()=>{let e=!1;const t=new Request(N.origin,{body:new ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t}),wn=64*1024,Xe=yn&&bn(()=>c.isReadableStream(new Response("").body)),Ne={stream:Xe&&(e=>e.body)};Re&&(e=>{["text","arrayBuffer","blob","formData","stream"].forEach(t=>{!Ne[t]&&(Ne[t]=c.isFunction(e[t])?n=>n[t]():(n,r)=>{throw new y(`Response type '${t}' is not supported`,y.ERR_NOT_SUPPORT,r)})})})(new Response);const Li=async e=>{if(e==null)return 0;if(c.isBlob(e))return e.size;if(c.isSpecCompliantForm(e))return(await new Request(N.origin,{method:"POST",body:e}).arrayBuffer()).byteLength;if(c.isArrayBufferView(e)||c.isArrayBuffer(e))return e.byteLength;if(c.isURLSearchParams(e)&&(e=e+""),c.isString(e))return(await Ii(e)).byteLength},$i=async(e,t)=>{const n=c.toFiniteNumber(e.getContentLength());return n??Li(t)},Qe={http:ni,xhr:Ri,fetch:Re&&(async e=>{let{url:t,method:n,data:r,signal:o,cancelToken:s,timeout:i,onDownloadProgress:l,onUploadProgress:d,responseType:f,headers:u,withCredentials:h="same-origin",fetchOptions:b}=hn(e);f=f?(f+"").toLowerCase():"text";let E=Ni([o,s&&s.toAbortSignal()],i),g;const p=E&&E.unsubscribe&&(()=>{E.unsubscribe()});let m;try{if(d&&Bi&&n!=="get"&&n!=="head"&&(m=await $i(u,r))!==0){let x=new Request(t,{method:"POST",body:r,duplex:"half"}),L;if(c.isFormData(r)&&(L=x.headers.get("content-type"))&&u.setContentType(L),x.body){const[R,q]=fn(m,xe(dn(d)));r=gn(x.body,wn,R,q)}}c.isString(h)||(h=h?"include":"omit");const w="credentials"in Request.prototype;g=new Request(t,{...b,signal:E,method:n.toUpperCase(),headers:u.normalize().toJSON(),body:r,duplex:"half",credentials:w?h:void 0});let T=await fetch(g,b);const O=Xe&&(f==="stream"||f==="response");if(Xe&&(l||O&&p)){const x={};["status","statusText","headers"].forEach(S=>{x[S]=T[S]});const L=c.toFiniteNumber(T.headers.get("content-length")),[R,q]=l&&fn(L,xe(dn(l),!0))||[];T=new Response(gn(T.body,wn,R,()=>{q&&q(),p&&p()}),x)}f=f||"text";let B=await Ne[c.findKey(Ne,f)||"text"](T,e);return!O&&p&&p(),await new Promise((x,L)=>{un(x,L,{data:B,headers:A.from(T.headers),status:T.status,statusText:T.statusText,config:e,request:g})})}catch(w){throw p&&p(),w&&w.name==="TypeError"&&/Load failed|fetch/i.test(w.message)?Object.assign(new y("Network Error",y.ERR_NETWORK,e,g),{cause:w.cause||w}):y.from(w,w&&w.code,e,g)}})};c.forEach(Qe,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const _n=e=>`- ${e}`,vi=e=>c.isFunction(e)||e===null||e===!1,En={getAdapter:e=>{e=c.isArray(e)?e:[e];const{length:t}=e;let n,r;const o={};for(let s=0;s<t;s++){n=e[s];let i;if(r=n,!vi(n)&&(r=Qe[(i=String(n)).toLowerCase()],r===void 0))throw new y(`Unknown adapter '${i}'`);if(r)break;o[i||"#"+s]=r}if(!r){const s=Object.entries(o).map(([l,d])=>`adapter ${l} `+(d===!1?"is not supported by the environment":"is not available in the build"));let i=t?s.length>1?`since :
|
|
9
9
|
`+s.map(_n).join(`
|
|
10
10
|
`):" "+_n(s[0]):"as no adapter specified";throw new y("There is no suitable adapter to dispatch the request "+i,"ERR_NOT_SUPPORT")}return r},adapters:Qe};function Ye(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new ne(null,e)}function Sn(e){return Ye(e),e.headers=A.from(e.headers),e.data=Ze.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),En.getAdapter(e.adapter||ue.adapter)(e).then(function(r){return Ye(e),r.data=Ze.call(e,e.transformResponse,r),r.headers=A.from(r.headers),r},function(r){return cn(r)||(Ye(e),r&&r.response&&(r.response.data=Ze.call(e,e.transformResponse,r.response),r.response.headers=A.from(r.response.headers))),Promise.reject(r)})}const Tn="1.10.0",Pe={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Pe[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const Cn={};Pe.transitional=function(t,n,r){function o(s,i){return"[Axios v"+Tn+"] Transitional option '"+s+"'"+i+(r?". "+r:"")}return(s,i,l)=>{if(t===!1)throw new y(o(i," has been removed"+(n?" in "+n:"")),y.ERR_DEPRECATED);return n&&!Cn[i]&&(Cn[i]=!0,console.warn(o(i," has been deprecated since v"+n+" and will be removed in the near future"))),t?t(s,i,l):!0}},Pe.spelling=function(t){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${t}`),!0)};function Fi(e,t,n){if(typeof e!="object")throw new y("options must be an object",y.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let o=r.length;for(;o-- >0;){const s=r[o],i=t[s];if(i){const l=e[s],d=l===void 0||i(l,s,e);if(d!==!0)throw new y("option "+s+" must be "+d,y.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new y("Unknown option "+s,y.ERR_BAD_OPTION)}}const ke={assertOptions:Fi,validators:Pe},z=ke.validators;let Z=class{constructor(t){this.defaults=t||{},this.interceptors={request:new on,response:new on}}async request(t,n){try{return await this._request(t,n)}catch(r){if(r instanceof Error){let o={};Error.captureStackTrace?Error.captureStackTrace(o):o=new Error;const s=o.stack?o.stack.replace(/^.+\n/,""):"";try{r.stack?s&&!String(r.stack).endsWith(s.replace(/^.+\n.+\n/,""))&&(r.stack+=`
|
|
11
|
-
`+s):r.stack=s}catch{}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=G(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:s}=n;r!==void 0&&ke.assertOptions(r,{silentJSONParsing:z.transitional(z.boolean),forcedJSONParsing:z.transitional(z.boolean),clarifyTimeoutError:z.transitional(z.boolean)},!1),o!=null&&(c.isFunction(o)?n.paramsSerializer={serialize:o}:ke.assertOptions(o,{encode:z.function,serialize:z.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),ke.assertOptions(n,{baseUrl:z.spelling("baseURL"),withXsrfToken:z.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=s&&c.merge(s.common,s[n.method]);s&&c.forEach(["delete","get","head","post","put","patch","common"],g=>{delete s[g]}),n.headers=A.concat(i,s);const l=[];let d=!0;this.interceptors.request.forEach(function(p){typeof p.runWhen=="function"&&p.runWhen(n)===!1||(d=d&&p.synchronous,l.unshift(p.fulfilled,p.rejected))});const f=[];this.interceptors.response.forEach(function(p){f.push(p.fulfilled,p.rejected)});let u,h=0,b;if(!d){const g=[Sn.bind(this),void 0];for(g.unshift.apply(g,l),g.push.apply(g,f),b=g.length,u=Promise.resolve(n);h<b;)u=u.then(g[h++],g[h++]);return u}b=l.length;let E=n;for(h=0;h<b;){const g=l[h++],p=l[h++];try{E=g(E)}catch(m){p.call(this,m);break}}try{u=Sn.call(this,E)}catch(g){return Promise.reject(g)}for(h=0,b=f.length;h<b;)u=u.then(f[h++],f[h++]);return u}getUri(t){t=G(this.defaults,t);const n=pn(t.baseURL,t.url,t.allowAbsoluteUrls);return rn(n,t.params,t.paramsSerializer)}};c.forEach(["delete","get","head","options"],function(t){Z.prototype[t]=function(n,r){return this.request(G(r||{},{method:t,url:n,data:(r||{}).data}))}}),c.forEach(["post","put","patch"],function(t){function n(r){return function(s,i,l){return this.request(G(l||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}Z.prototype[t]=n(),Z.prototype[t+"Form"]=n(!0)});let ji=class Bn{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(s){n=s});const r=this;this.promise.then(o=>{if(!r._listeners)return;let s=r._listeners.length;for(;s-- >0;)r._listeners[s](o);r._listeners=null}),this.promise.then=o=>{let s;const i=new Promise(l=>{r.subscribe(l),s=l}).then(o);return i.cancel=function(){r.unsubscribe(s)},i},t(function(s,i,l){r.reason||(r.reason=new ne(s,i,l),n(r.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 n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const t=new AbortController,n=r=>{t.abort(r)};return this.subscribe(n),t.signal.unsubscribe=()=>this.unsubscribe(n),t.signal}static source(){let t;return{token:new Bn(function(o){t=o}),cancel:t}}};function Di(e){return function(n){return e.apply(null,n)}}function Ui(e){return c.isObject(e)&&e.isAxiosError===!0}const et={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(et).forEach(([e,t])=>{et[t]=e});function On(e){const t=new Z(e),n=Mt(Z.prototype.request,t);return c.extend(n,Z.prototype,t,{allOwnKeys:!0}),c.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return On(G(e,o))},n}const C=On(ue);C.Axios=Z,C.CanceledError=ne,C.CancelToken=ji,C.isCancel=cn,C.VERSION=Tn,C.toFormData=Ce,C.AxiosError=y,C.Cancel=C.CanceledError,C.all=function(t){return Promise.all(t)},C.spread=Di,C.isAxiosError=Ui,C.mergeConfig=G,C.AxiosHeaders=A,C.formToJSON=e=>an(c.isHTMLForm(e)?new FormData(e):e),C.getAdapter=En.getAdapter,C.HttpStatusCode=et,C.default=C;const{Axios:ra,AxiosError:oa,CanceledError:sa,isCancel:ia,CancelToken:aa,VERSION:la,all:ca,Cancel:ua,isAxiosError:fa,spread:da,toFormData:pa,AxiosHeaders:ma,HttpStatusCode:ha,formToJSON:ga,getAdapter:ya,mergeConfig:ba}=C;class xn{set(t,n,r){let o=null;if(typeof r=="number"&&r>0)o=Date.now()+r*1e3;else if(typeof r>"u"){const i=this.getRaw(t);o=i?i.expire:null}const s={value:n,expire:o};localStorage.setItem(t,JSON.stringify(s))}get(t){const n=this.getRaw(t);return n?n.expire&&Date.now()>n.expire?(this.remove(t),null):n.value:null}getRaw(t){try{const n=localStorage.getItem(t);if(!n)return null;const r=JSON.parse(n);return r&&typeof r=="object"&&"value"in r&&"expire"in r?r:{value:n,expire:null}}catch{return{value:localStorage.getItem(t),expire:null}}}remove(t){localStorage.removeItem(t)}clear(){localStorage.clear()}}const re=new xn;function Rn(e=!0,t,n){const r=M().props;if(!r||!r.isEnabled){n&&n(new Error("统一登陆未开启,请检查配置"));return}const o=Ae();if(!o){n&&n(new Error("未登陆或token失效"));return}C({method:"post",url:r.loginServiceBaseAddress+"/admin-api/system/auth/logout",headers:{"tenant-id":M().tenantId,Authorization:"Bearer "+o}}).then(s=>{s.data.code?n&&n(s):(e&&Nn(),t&&t(s),kn())}).catch(s=>{console.log(s),n&&n(s)})}function Ae(){const e=M().props;return console.log(e),!e||!e.isEnabled?null:re.get(e.tokenName)}function zi(){return M().refreshToken}function Nn(){const e=M().props,t=Mi(e.loginPageBaseAddress,e.clientId,e.clientSecret,e.redirectPath);t&&window.open(t,"_self")}function Mi(e,t,n,r){return!t||!n?(console.error("未配置应用id或应用密钥"),""):(r=r||encodeURIComponent(window.location.href),`${e}/#/login?clientId=${t}&clientSecret=${n}&redirectUrl=${r}`)}function Pn(){return M().userPermission}function de(e){re.set("qlfyEcologicalLogin_loginInfo",e)}function qi(){re.remove("qlfyEcologicalLogin_loginInfo")}function M(){const e=re.get("qlfyEcologicalLogin_loginInfo");return e||{tenantId:7,refreshToken:"",props:null,userPermission:null}}function kn(){const e=M().props;e&&e.tokenName?re.remove(e.tokenName):re.remove("access_token"),qi()}const Vi={style:{display:"none"}},An=a.defineComponent({__name:"index",props:{clientId:{},clientSecret:{},loginPageBaseAddress:{},loginServiceBaseAddress:{},useRouter:{},forceMode:{type:Boolean,default:!0},token:{},isEnabled:{type:Boolean,default:!0},listenToken:{type:Boolean,default:!1},redirectPath:{default:""},tokenName:{default:"access_token"},tokenValidity:{default:60*120},dialogConfig:{}},emits:["loggingIn","loginFail","loginSuccess"],setup(e,{expose:t,emit:n}){const r=e,o=r.useRouter,s=r.useRouter.currentRoute,i=n,l=new xn;let d=null,f=null,u=M(),h="";t({logout:Rn,getToken:Ae,getUserPermission:Pn}),a.onBeforeUnmount(()=>{d&&clearInterval(d),de(u)}),a.watch(()=>s.value.path,(_,D)=>{f&&clearTimeout(f),a.nextTick(()=>{f=setTimeout(()=>{r.isEnabled&&b()},300)})},{deep:!0,immediate:!0}),a.watch(()=>r.isEnabled,_=>{setTimeout(()=>{_&&b(),_||(kn(),d&&clearInterval(d))})},{deep:!0}),a.watch(()=>r.token,_=>{},{});function b(){r.isEnabled&&(In(),E())}function E(){if(g()){p();return}if(m()){w();return}const _=T();if(_){x(_);return}O()}function g(){return!!r.token}function p(){r.token&&(l.set(r.tokenName,r.token,r.tokenValidity),x(r.token))}function m(){return!!s.value.query.token}function w(){const _=s.value.query.token,D=s.value.query.refreshToken;i("loggingIn",_),l.set(r.tokenName,_,r.tokenValidity),u.refreshToken=D,de(u),B(),x(_)}function T(){return l.get(r.tokenName)}function O(){!r.forceMode||r.token?i("loginFail",{msg:"未登录或登陆状态失效",data:null}):Nn()}function B(){let _={...s.value.query};delete _.token,delete _.refreshToken,o.replace({path:s.value.path,query:_})}function x(_){let D={token:_};const nt={"tenant-id":7,Authorization:"Basic "+btoa(r.clientId+":"+r.clientSecret)};C.post(r.loginServiceBaseAddress+"/admin-api/system/oauth2/check-token","",{params:D,headers:nt}).then(U=>{if(U.data.code!==0){R("Token验证失败",U);return}u.tenantId=U.data.data.tenant_id,de(u),L(_)}).catch(U=>{R("Token验证请求失败",U)})}function L(_){l.set(r.tokenName,_,r.tokenValidity),(!h||_!=h)&&q(_),tt()}function R(_,D){Ki(_,D),O()}function q(_){let D={clientId:r.clientId};const nt={"tenant-id":u.tenantId,Authorization:_};C.get(r.loginServiceBaseAddress+"/admin-api/system/auth/get-permission-info",{params:D,headers:nt}).then(U=>{if(U.data.code!==0){R("用户配置获取失败",U);return}S(U.data)}).catch(U=>{R("用户配置获取失败",U)})}function S(_){h=Ae(),u.userPermission=_,de(u),i("loginSuccess",_)}function In(){const _={...r};delete _.useRouter,u.props=_,de(u)}function tt(){r.listenToken&&(d&&clearInterval(d),d=setInterval(()=>{l.get(r.tokenName)||(clearInterval(d),ys.warning("登录状态丢失,正在重新获取~"),setTimeout(()=>{E()},2e3))},1e3))}function Ki(_,D){console.error(`[qlfyEcologicalLogin] ${_}:`,D)}return(_,D)=>(a.openBlock(),a.createElementBlock("div",Vi))}}),Hi=An,Ji={install(e){e.component("qlfyEcologicalLogin",An)}};$.default=Ji,$.getRefreshToken=zi,$.getToken=Ae,$.getUserPermission=Pn,$.logout=Rn,$.qlfyEcologicalLogin=Hi,Object.defineProperties($,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
11
|
+
`+s):r.stack=s}catch{}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=G(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:s}=n;r!==void 0&&ke.assertOptions(r,{silentJSONParsing:z.transitional(z.boolean),forcedJSONParsing:z.transitional(z.boolean),clarifyTimeoutError:z.transitional(z.boolean)},!1),o!=null&&(c.isFunction(o)?n.paramsSerializer={serialize:o}:ke.assertOptions(o,{encode:z.function,serialize:z.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),ke.assertOptions(n,{baseUrl:z.spelling("baseURL"),withXsrfToken:z.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=s&&c.merge(s.common,s[n.method]);s&&c.forEach(["delete","get","head","post","put","patch","common"],g=>{delete s[g]}),n.headers=A.concat(i,s);const l=[];let d=!0;this.interceptors.request.forEach(function(p){typeof p.runWhen=="function"&&p.runWhen(n)===!1||(d=d&&p.synchronous,l.unshift(p.fulfilled,p.rejected))});const f=[];this.interceptors.response.forEach(function(p){f.push(p.fulfilled,p.rejected)});let u,h=0,b;if(!d){const g=[Sn.bind(this),void 0];for(g.unshift.apply(g,l),g.push.apply(g,f),b=g.length,u=Promise.resolve(n);h<b;)u=u.then(g[h++],g[h++]);return u}b=l.length;let E=n;for(h=0;h<b;){const g=l[h++],p=l[h++];try{E=g(E)}catch(m){p.call(this,m);break}}try{u=Sn.call(this,E)}catch(g){return Promise.reject(g)}for(h=0,b=f.length;h<b;)u=u.then(f[h++],f[h++]);return u}getUri(t){t=G(this.defaults,t);const n=pn(t.baseURL,t.url,t.allowAbsoluteUrls);return rn(n,t.params,t.paramsSerializer)}};c.forEach(["delete","get","head","options"],function(t){Z.prototype[t]=function(n,r){return this.request(G(r||{},{method:t,url:n,data:(r||{}).data}))}}),c.forEach(["post","put","patch"],function(t){function n(r){return function(s,i,l){return this.request(G(l||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}Z.prototype[t]=n(),Z.prototype[t+"Form"]=n(!0)});let ji=class Bn{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(s){n=s});const r=this;this.promise.then(o=>{if(!r._listeners)return;let s=r._listeners.length;for(;s-- >0;)r._listeners[s](o);r._listeners=null}),this.promise.then=o=>{let s;const i=new Promise(l=>{r.subscribe(l),s=l}).then(o);return i.cancel=function(){r.unsubscribe(s)},i},t(function(s,i,l){r.reason||(r.reason=new ne(s,i,l),n(r.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 n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const t=new AbortController,n=r=>{t.abort(r)};return this.subscribe(n),t.signal.unsubscribe=()=>this.unsubscribe(n),t.signal}static source(){let t;return{token:new Bn(function(o){t=o}),cancel:t}}};function Di(e){return function(n){return e.apply(null,n)}}function Ui(e){return c.isObject(e)&&e.isAxiosError===!0}const et={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(et).forEach(([e,t])=>{et[t]=e});function On(e){const t=new Z(e),n=Mt(Z.prototype.request,t);return c.extend(n,Z.prototype,t,{allOwnKeys:!0}),c.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return On(G(e,o))},n}const C=On(ue);C.Axios=Z,C.CanceledError=ne,C.CancelToken=ji,C.isCancel=cn,C.VERSION=Tn,C.toFormData=Ce,C.AxiosError=y,C.Cancel=C.CanceledError,C.all=function(t){return Promise.all(t)},C.spread=Di,C.isAxiosError=Ui,C.mergeConfig=G,C.AxiosHeaders=A,C.formToJSON=e=>an(c.isHTMLForm(e)?new FormData(e):e),C.getAdapter=En.getAdapter,C.HttpStatusCode=et,C.default=C;const{Axios:ra,AxiosError:oa,CanceledError:sa,isCancel:ia,CancelToken:aa,VERSION:la,all:ca,Cancel:ua,isAxiosError:fa,spread:da,toFormData:pa,AxiosHeaders:ma,HttpStatusCode:ha,formToJSON:ga,getAdapter:ya,mergeConfig:ba}=C;class xn{set(t,n,r){let o=null;if(typeof r=="number"&&r>0)o=Date.now()+r*1e3;else if(typeof r>"u"){const i=this.getRaw(t);o=i?i.expire:null}const s={value:n,expire:o};localStorage.setItem(t,JSON.stringify(s))}get(t){const n=this.getRaw(t);return n?n.expire&&Date.now()>n.expire?(this.remove(t),null):n.value:null}getRaw(t){try{const n=localStorage.getItem(t);if(!n)return null;const r=JSON.parse(n);return r&&typeof r=="object"&&"value"in r&&"expire"in r?r:{value:n,expire:null}}catch{return{value:localStorage.getItem(t),expire:null}}}remove(t){localStorage.removeItem(t)}clear(){localStorage.clear()}}const re=new xn;function Rn(e=!0,t,n){const r=M().props;if(!r||!r.isEnabled){n&&n(new Error("统一登陆未开启,请检查配置"));return}const o=Ae();if(!o){n&&n(new Error("未登陆或token失效"));return}C({method:"post",url:r.loginServiceBaseAddress+"/admin-api/system/auth/logout",headers:{"tenant-id":M().tenantId,Authorization:"Bearer "+o}}).then(s=>{s.data.code?n&&n(s):(e&&Nn(),t&&t(s),kn())}).catch(s=>{console.log(s),n&&n(s)})}function Ae(){const e=M().props;return!e||!e.isEnabled?null:re.get(e.tokenName)}function zi(){return M().refreshToken}function Nn(){const e=M().props,t=Mi(e.loginPageBaseAddress,e.clientId,e.clientSecret,e.redirectPath);t&&window.open(t,"_self")}function Mi(e,t,n,r){return!t||!n?(console.error("未配置应用id或应用密钥"),""):(r=r||encodeURIComponent(window.location.href),`${e}/#/login?clientId=${t}&clientSecret=${n}&redirectUrl=${r}`)}function Pn(){return M().userPermission}function de(e){re.set("qlfyEcologicalLogin_loginInfo",e)}function qi(){re.remove("qlfyEcologicalLogin_loginInfo")}function M(){const e=re.get("qlfyEcologicalLogin_loginInfo");return e||{tenantId:7,refreshToken:"",props:null,userPermission:null}}function kn(){const e=M().props;e&&e.tokenName?re.remove(e.tokenName):re.remove("access_token"),qi()}const Vi={style:{display:"none"}},An=a.defineComponent({__name:"index",props:{clientId:{},clientSecret:{},loginPageBaseAddress:{},loginServiceBaseAddress:{},useRouter:{},forceMode:{type:Boolean,default:!0},token:{},isEnabled:{type:Boolean,default:!0},listenToken:{type:Boolean,default:!1},redirectPath:{default:""},tokenName:{default:"access_token"},tokenValidity:{default:60*120},dialogConfig:{}},emits:["loggingIn","loginFail","loginSuccess"],setup(e,{expose:t,emit:n}){const r=e,o=r.useRouter,s=r.useRouter.currentRoute,i=n,l=new xn;let d=null,f=null,u=M(),h="";t({logout:Rn,getToken:Ae,getUserPermission:Pn}),a.onBeforeUnmount(()=>{d&&clearInterval(d),de(u)}),a.watch(()=>s.value.path,(_,D)=>{f&&clearTimeout(f),a.nextTick(()=>{f=setTimeout(()=>{r.isEnabled&&b()},300)})},{deep:!0,immediate:!0}),a.watch(()=>r.isEnabled,_=>{setTimeout(()=>{_&&b(),_||(kn(),d&&clearInterval(d))})},{deep:!0}),a.watch(()=>r.token,_=>{},{});function b(){r.isEnabled&&(In(),E())}function E(){if(g()){p();return}if(m()){w();return}const _=T();if(_){x(_);return}O()}function g(){return!!r.token}function p(){r.token&&(l.set(r.tokenName,r.token,r.tokenValidity),x(r.token))}function m(){return!!s.value.query.token}function w(){const _=s.value.query.token,D=s.value.query.refreshToken;i("loggingIn",_),l.set(r.tokenName,_,r.tokenValidity),u.refreshToken=D,de(u),B(),x(_)}function T(){return l.get(r.tokenName)}function O(){!r.forceMode||r.token?i("loginFail",{msg:"未登录或登陆状态失效",data:null}):Nn()}function B(){let _={...s.value.query};delete _.token,delete _.refreshToken,o.replace({path:s.value.path,query:_})}function x(_){let D={token:_};const nt={"tenant-id":7,Authorization:"Basic "+btoa(r.clientId+":"+r.clientSecret)};C.post(r.loginServiceBaseAddress+"/admin-api/system/oauth2/check-token","",{params:D,headers:nt}).then(U=>{if(U.data.code!==0){R("Token验证失败",U);return}u.tenantId=U.data.data.tenant_id,de(u),L(_)}).catch(U=>{R("Token验证请求失败",U)})}function L(_){l.set(r.tokenName,_,r.tokenValidity),(!h||_!=h)&&q(_),tt()}function R(_,D){Ki(_,D),O()}function q(_){let D={clientId:r.clientId};const nt={"tenant-id":u.tenantId,Authorization:_};C.get(r.loginServiceBaseAddress+"/admin-api/system/auth/get-permission-info",{params:D,headers:nt}).then(U=>{if(U.data.code!==0){R("用户配置获取失败",U);return}S(U.data)}).catch(U=>{R("用户配置获取失败",U)})}function S(_){h=Ae(),u.userPermission=_,de(u),i("loginSuccess",_)}function In(){const _={...r};delete _.useRouter,u.props=_,de(u)}function tt(){r.listenToken&&(d&&clearInterval(d),d=setInterval(()=>{l.get(r.tokenName)||(clearInterval(d),ys.warning("登录状态丢失,正在重新获取~"),setTimeout(()=>{E()},2e3))},1e3))}function Ki(_,D){console.error(`[qlfyEcologicalLogin] ${_}:`,D)}return(_,D)=>(a.openBlock(),a.createElementBlock("div",Vi))}}),Hi=An,Ji={install(e){e.component("qlfyEcologicalLogin",An)}};$.default=Ji,$.getRefreshToken=zi,$.getToken=Ae,$.getUserPermission=Pn,$.logout=Rn,$.qlfyEcologicalLogin=Hi,Object.defineProperties($,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/lib/index.umd.js.gz
CHANGED
|
Binary file
|