qlfy-ecological-login 1.0.4 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Router } from 'vue-router';
|
|
2
1
|
import { DialogProps } from 'element-plus';
|
|
3
2
|
/** 响应式数据对象 */
|
|
4
3
|
export declare class Data {
|
|
@@ -18,7 +17,7 @@ export interface Prop {
|
|
|
18
17
|
/** 登陆服务的ip地址 */
|
|
19
18
|
loginServiceBaseAddress: string;
|
|
20
19
|
/** 路由对象 */
|
|
21
|
-
useRouter:
|
|
20
|
+
useRouter: any;
|
|
22
21
|
/** 传入token则使用外部token */
|
|
23
22
|
token?: string;
|
|
24
23
|
/** 是否启用组件,支持动态控制,非必填*/
|
package/lib/index.mjs
CHANGED
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[wn]=this[wn]={accessors:{}}).accessors,o=this.prototype;function a(i){const l=me(i);r[l]||(Ia(o,i),r[l]=!0)}return c.isArray(t)?t.forEach(a):a(t),this}};k.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),c.reduceDescriptors(k.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),c.freezeMethods(k);function nt(e,t){const n=this||pe,r=t||n,o=k.from(r.headers);let a=r.data;return c.forEach(e,function(l){a=l.call(n,a,o.normalize(),t?t.status:void 0)}),o.normalize(),a}function _n(e){return!!(e&&e.__CANCEL__)}function ne(e,t,n){S.call(this,e??"canceled",S.ERR_CANCELED,t,n),this.name="CanceledError"}c.inherits(ne,S,{__CANCEL__:!0});function Sn(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new S("Request failed with status code "+n.status,[S.ERR_BAD_REQUEST,S.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function Ba(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function $a(e,t){e=e||10;const n=new Array(e),r=new Array(e);let o=0,a=0,i;return t=t!==void 0?t:1e3,function(f){const d=Date.now(),u=r[a];i||(i=d),n[o]=f,r[o]=d;let p=a,y=0;for(;p!==o;)y+=n[p++],p=p%e;if(o=(o+1)%e,o===a&&(a=(a+1)%e),d-i<t)return;const b=u&&d-u;return b?Math.round(y*1e3/b):void 0}}function La(e,t){let n=0,r=1e3/t,o,a;const i=(d,u=Date.now())=>{n=u,o=null,a&&(clearTimeout(a),a=null),e.apply(null,d)};return[(...d)=>{const u=Date.now(),p=u-n;p>=r?i(d,u):(o=d,a||(a=setTimeout(()=>{a=null,i(o)},r-p)))},()=>o&&i(o)]}const ve=(e,t,n=3)=>{let r=0;const o=$a(50,250);return La(a=>{const i=a.loaded,l=a.lengthComputable?a.total:void 0,f=i-r,d=o(f),u=i<=l;r=i;const p={loaded:i,total:l,progress:l?i/l:void 0,bytes:f,rate:d||void 0,estimated:d&&l&&u?(l-i)/d:void 0,event:a,lengthComputable:l!=null,[t?"download":"upload"]:!0};e(p)},n)},Cn=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},En=e=>(...t)=>c.asap(()=>e(...t)),Da=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,Fa=N.hasStandardBrowserEnv?{write(e,t,n,r,o,a){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),a===!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 ja(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Ua(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function xn(e,t,n){let r=!ja(t);return e&&(r||n==!1)?Ua(e,t):t}const On=e=>e instanceof k?{...e}:e;function G(e,t){t=t||{};const n={};function r(d,u,p,y){return c.isPlainObject(d)&&c.isPlainObject(u)?c.merge.call({caseless:y},d,u):c.isPlainObject(u)?c.merge({},u):c.isArray(u)?u.slice():u}function o(d,u,p,y){if(c.isUndefined(u)){if(!c.isUndefined(d))return r(void 0,d,p,y)}else return r(d,u,p,y)}function a(d,u){if(!c.isUndefined(u))return r(void 0,u)}function i(d,u){if(c.isUndefined(u)){if(!c.isUndefined(d))return r(void 0,d)}else return r(void 0,u)}function l(d,u,p){if(p in t)return r(d,u);if(p in e)return r(void 0,d)}const f={url:a,method:a,data:a,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:(d,u,p)=>o(On(d),On(u),p,!0)};return c.forEach(Object.keys(Object.assign({},e,t)),function(u){const p=f[u]||o,y=p(e[u],t[u],u);c.isUndefined(y)&&p!==l||(n[u]=y)}),n}const Tn=e=>{const t=G({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:a,headers:i,auth:l}=t;t.headers=i=k.from(i),t.url=hn(xn(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 f;if(c.isFormData(n)){if(N.hasStandardBrowserEnv||N.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if((f=i.getContentType())!==!1){const[d,...u]=f?f.split(";").map(p=>p.trim()).filter(Boolean):[];i.setContentType([d||"multipart/form-data",...u].join("; "))}}if(N.hasStandardBrowserEnv&&(r&&c.isFunction(r)&&(r=r(t)),r||r!==!1&&Da(t.url))){const d=o&&a&&Fa.read(a);d&&i.set(o,d)}return t},za=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){const o=Tn(e);let a=o.data;const i=k.from(o.headers).normalize();let{responseType:l,onUploadProgress:f,onDownloadProgress:d}=o,u,p,y,b,g;function m(){b&&b(),g&&g(),o.cancelToken&&o.cancelToken.unsubscribe(u),o.signal&&o.signal.removeEventListener("abort",u)}let h=new XMLHttpRequest;h.open(o.method.toUpperCase(),o.url,!0),h.timeout=o.timeout;function w(){if(!h)return;const C=k.from("getAllResponseHeaders"in h&&h.getAllResponseHeaders()),T={data:!l||l==="text"||l==="json"?h.responseText:h.response,status:h.status,statusText:h.statusText,headers:C,config:e,request:h};Sn(function(I){n(I),m()},function(I){r(I),m()},T),h=null}"onloadend"in h?h.onloadend=w:h.onreadystatechange=function(){!h||h.readyState!==4||h.status===0&&!(h.responseURL&&h.responseURL.indexOf("file:")===0)||setTimeout(w)},h.onabort=function(){h&&(r(new S("Request aborted",S.ECONNABORTED,e,h)),h=null)},h.onerror=function(){r(new S("Network Error",S.ERR_NETWORK,e,h)),h=null},h.ontimeout=function(){let O=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const T=o.transitional||yn;o.timeoutErrorMessage&&(O=o.timeoutErrorMessage),r(new S(O,T.clarifyTimeoutError?S.ETIMEDOUT:S.ECONNABORTED,e,h)),h=null},a===void 0&&i.setContentType(null),"setRequestHeader"in h&&c.forEach(i.toJSON(),function(O,T){h.setRequestHeader(T,O)}),c.isUndefined(o.withCredentials)||(h.withCredentials=!!o.withCredentials),l&&l!=="json"&&(h.responseType=o.responseType),d&&([y,g]=ve(d,!0),h.addEventListener("progress",y)),f&&h.upload&&([p,b]=ve(f),h.upload.addEventListener("progress",p),h.upload.addEventListener("loadend",b)),(o.cancelToken||o.signal)&&(u=C=>{h&&(r(!C||C.type?new ne(null,e,h):C),h.abort(),h=null)},o.cancelToken&&o.cancelToken.subscribe(u),o.signal&&(o.signal.aborted?u():o.signal.addEventListener("abort",u)));const _=Ba(o.url);if(_&&N.protocols.indexOf(_)===-1){r(new S("Unsupported protocol "+_+":",S.ERR_BAD_REQUEST,e));return}h.send(a||null)})},Va=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let r=new AbortController,o;const a=function(d){if(!o){o=!0,l();const u=d instanceof Error?d:this.reason;r.abort(u instanceof S?u:new ne(u instanceof Error?u.message:u))}};let i=t&&setTimeout(()=>{i=null,a(new S(`timeout ${t} of ms exceeded`,S.ETIMEDOUT))},t);const l=()=>{e&&(i&&clearTimeout(i),i=null,e.forEach(d=>{d.unsubscribe?d.unsubscribe(a):d.removeEventListener("abort",a)}),e=null)};e.forEach(d=>d.addEventListener("abort",a));const{signal:f}=r;return f.unsubscribe=()=>c.asap(l),f}},Ma=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},qa=async function*(e,t){for await(const n of Ha(e))yield*Ma(n,t)},Ha=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()}},Nn=(e,t,n,r)=>{const o=qa(e,t);let a=0,i,l=f=>{i||(i=!0,r&&r(f))};return new ReadableStream({async pull(f){try{const{done:d,value:u}=await o.next();if(d){l(),f.close();return}let p=u.byteLength;if(n){let y=a+=p;n(y)}f.enqueue(new Uint8Array(u))}catch(d){throw l(d),d}},cancel(f){return l(f),o.return()}},{highWaterMark:2})},Ie=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",Rn=Ie&&typeof ReadableStream=="function",Ja=Ie&&(typeof TextEncoder=="function"?(e=>t=>e.encode(t))(new TextEncoder):async e=>new Uint8Array(await new Response(e).arrayBuffer())),Pn=(e,...t)=>{try{return!!e(...t)}catch{return!1}},Ka=Rn&&Pn(()=>{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}),An=64*1024,rt=Rn&&Pn(()=>c.isReadableStream(new Response("").body)),Be={stream:rt&&(e=>e.body)};Ie&&(e=>{["text","arrayBuffer","blob","formData","stream"].forEach(t=>{!Be[t]&&(Be[t]=c.isFunction(e[t])?n=>n[t]():(n,r)=>{throw new S(`Response type '${t}' is not supported`,S.ERR_NOT_SUPPORT,r)})})})(new Response);const Wa=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 Ja(e)).byteLength},Ga=async(e,t)=>{const n=c.toFiniteNumber(e.getContentLength());return n??Wa(t)},ot={http:ga,xhr:za,fetch:Ie&&(async e=>{let{url:t,method:n,data:r,signal:o,cancelToken:a,timeout:i,onDownloadProgress:l,onUploadProgress:f,responseType:d,headers:u,withCredentials:p="same-origin",fetchOptions:y}=Tn(e);d=d?(d+"").toLowerCase():"text";let b=Va([o,a&&a.toAbortSignal()],i),g;const m=b&&b.unsubscribe&&(()=>{b.unsubscribe()});let h;try{if(f&&Ka&&n!=="get"&&n!=="head"&&(h=await Ga(u,r))!==0){let T=new Request(t,{method:"POST",body:r,duplex:"half"}),F;if(c.isFormData(r)&&(F=T.headers.get("content-type"))&&u.setContentType(F),T.body){const[I,oe]=Cn(h,ve(En(f)));r=Nn(T.body,An,I,oe)}}c.isString(p)||(p=p?"include":"omit");const w="credentials"in Request.prototype;g=new Request(t,{...y,signal:b,method:n.toUpperCase(),headers:u.normalize().toJSON(),body:r,duplex:"half",credentials:w?p:void 0});let _=await fetch(g,y);const C=rt&&(d==="stream"||d==="response");if(rt&&(l||C&&m)){const T={};["status","statusText","headers"].forEach(E=>{T[E]=_[E]});const F=c.toFiniteNumber(_.headers.get("content-length")),[I,oe]=l&&Cn(F,ve(En(l),!0))||[];_=new Response(Nn(_.body,An,I,()=>{oe&&oe(),m&&m()}),T)}d=d||"text";let O=await Be[c.findKey(Be,d)||"text"](_,e);return!C&&m&&m(),await new Promise((T,F)=>{Sn(T,F,{data:O,headers:k.from(_.headers),status:_.status,statusText:_.statusText,config:e,request:g})})}catch(w){throw m&&m(),w&&w.name==="TypeError"&&/Load failed|fetch/i.test(w.message)?Object.assign(new S("Network Error",S.ERR_NETWORK,e,g),{cause:w.cause||w}):S.from(w,w&&w.code,e,g)}})};c.forEach(ot,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const kn=e=>`- ${e}`,Za=e=>c.isFunction(e)||e===null||e===!1,vn={getAdapter:e=>{e=c.isArray(e)?e:[e];const{length:t}=e;let n,r;const o={};for(let a=0;a<t;a++){n=e[a];let i;if(r=n,!Za(n)&&(r=ot[(i=String(n)).toLowerCase()],r===void 0))throw new S(`Unknown adapter '${i}'`);if(r)break;o[i||"#"+a]=r}if(!r){const a=Object.entries(o).map(([l,f])=>`adapter ${l} `+(f===!1?"is not supported by the environment":"is not available in the build"));let i=t?a.length>1?`since :
|
|
9
9
|
`+a.map(kn).join(`
|
|
10
10
|
`):" "+kn(a[0]):"as no adapter specified";throw new S("There is no suitable adapter to dispatch the request "+i,"ERR_NOT_SUPPORT")}return r},adapters:ot};function st(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new ne(null,e)}function In(e){return st(e),e.headers=k.from(e.headers),e.data=nt.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),vn.getAdapter(e.adapter||pe.adapter)(e).then(function(r){return st(e),r.data=nt.call(e,e.transformResponse,r),r.headers=k.from(r.headers),r},function(r){return _n(r)||(st(e),r&&r.response&&(r.response.data=nt.call(e,e.transformResponse,r.response),r.response.headers=k.from(r.response.headers))),Promise.reject(r)})}const Bn="1.10.0",$e={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{$e[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const $n={};$e.transitional=function(t,n,r){function o(a,i){return"[Axios v"+Bn+"] Transitional option '"+a+"'"+i+(r?". "+r:"")}return(a,i,l)=>{if(t===!1)throw new S(o(i," has been removed"+(n?" in "+n:"")),S.ERR_DEPRECATED);return n&&!$n[i]&&($n[i]=!0,console.warn(o(i," has been deprecated since v"+n+" and will be removed in the near future"))),t?t(a,i,l):!0}},$e.spelling=function(t){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${t}`),!0)};function Xa(e,t,n){if(typeof e!="object")throw new S("options must be an object",S.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let o=r.length;for(;o-- >0;){const a=r[o],i=t[a];if(i){const l=e[a],f=l===void 0||i(l,a,e);if(f!==!0)throw new S("option "+a+" must be "+f,S.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new S("Unknown option "+a,S.ERR_BAD_OPTION)}}const Le={assertOptions:Xa,validators:$e},j=Le.validators;let Z=class{constructor(t){this.defaults=t||{},this.interceptors={request:new gn,response:new gn}}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 a=o.stack?o.stack.replace(/^.+\n/,""):"";try{r.stack?a&&!String(r.stack).endsWith(a.replace(/^.+\n.+\n/,""))&&(r.stack+=`
|
|
11
|
-
`+a):r.stack=a}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:a}=n;r!==void 0&&Le.assertOptions(r,{silentJSONParsing:j.transitional(j.boolean),forcedJSONParsing:j.transitional(j.boolean),clarifyTimeoutError:j.transitional(j.boolean)},!1),o!=null&&(c.isFunction(o)?n.paramsSerializer={serialize:o}:Le.assertOptions(o,{encode:j.function,serialize:j.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),Le.assertOptions(n,{baseUrl:j.spelling("baseURL"),withXsrfToken:j.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=a&&c.merge(a.common,a[n.method]);a&&c.forEach(["delete","get","head","post","put","patch","common"],g=>{delete a[g]}),n.headers=k.concat(i,a);const l=[];let f=!0;this.interceptors.request.forEach(function(m){typeof m.runWhen=="function"&&m.runWhen(n)===!1||(f=f&&m.synchronous,l.unshift(m.fulfilled,m.rejected))});const d=[];this.interceptors.response.forEach(function(m){d.push(m.fulfilled,m.rejected)});let u,p=0,y;if(!f){const g=[In.bind(this),void 0];for(g.unshift.apply(g,l),g.push.apply(g,d),y=g.length,u=Promise.resolve(n);p<y;)u=u.then(g[p++],g[p++]);return u}y=l.length;let b=n;for(p=0;p<y;){const g=l[p++],m=l[p++];try{b=g(b)}catch(h){m.call(this,h);break}}try{u=In.call(this,b)}catch(g){return Promise.reject(g)}for(p=0,y=d.length;p<y;)u=u.then(d[p++],d[p++]);return u}getUri(t){t=G(this.defaults,t);const n=xn(t.baseURL,t.url,t.allowAbsoluteUrls);return hn(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(a,i,l){return this.request(G(l||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:a,data:i}))}}Z.prototype[t]=n(),Z.prototype[t+"Form"]=n(!0)});let Qa=class Un{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(a){n=a});const r=this;this.promise.then(o=>{if(!r._listeners)return;let a=r._listeners.length;for(;a-- >0;)r._listeners[a](o);r._listeners=null}),this.promise.then=o=>{let a;const i=new Promise(l=>{r.subscribe(l),a=l}).then(o);return i.cancel=function(){r.unsubscribe(a)},i},t(function(a,i,l){r.reason||(r.reason=new ne(a,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 Un(function(o){t=o}),cancel:t}}};function Ya(e){return function(n){return e.apply(null,n)}}function ei(e){return c.isObject(e)&&e.isAxiosError===!0}const at={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(at).forEach(([e,t])=>{at[t]=e});function Ln(e){const t=new Z(e),n=Yt(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 Ln(G(e,o))},n}const x=Ln(pe);x.Axios=Z,x.CanceledError=ne,x.CancelToken=Qa,x.isCancel=_n,x.VERSION=Bn,x.toFormData=Ae,x.AxiosError=S,x.Cancel=x.CanceledError,x.all=function(t){return Promise.all(t)},x.spread=Ya,x.isAxiosError=ei,x.mergeConfig=G,x.AxiosHeaders=k,x.formToJSON=e=>bn(c.isHTMLForm(e)?new FormData(e):e),x.getAdapter=vn.getAdapter,x.HttpStatusCode=at,x.default=x;const{Axios:_i,AxiosError:Si,CanceledError:Ci,isCancel:Ei,CancelToken:xi,VERSION:Oi,all:Ti,Cancel:Ni,isAxiosError:Ri,spread:Pi,toFormData:Ai,AxiosHeaders:ki,HttpStatusCode:vi,formToJSON:Ii,getAdapter:Bi,mergeConfig:$i}=x;class De{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 a={value:n,expire:o};localStorage.setItem(t,JSON.stringify(a))}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 ti=Object.freeze(Object.defineProperty({__proto__:null,default:De},Symbol.toStringTag,{value:"Module"})),D={componentId:"",userPermission:null},re=new De;function Dn(){const e=re.get("qlfyEcologicalLogin_"+D.componentId);if(!e||!e.isEnabled)return console.error(new Error("统一登陆未开启,请检查配置")),null;let t=re.get(e.tokenName);console.log(t),x({method:"post",url:e.loginServiceBaseAddress+"/admin-api/system/auth/logout",headers:{"tenant-id":e.tenantId,Authorization:"Bearer "+t}}).then(n=>{n.data.code||(re.remove(e.tokenName),lt())})}function it(){const e=re.get("qlfyEcologicalLogin_"+D.componentId);return console.log(e),!e||!e.isEnabled?null:re.get(e.tokenName)}function lt(){const e=re.get("qlfyEcologicalLogin_"+D.componentId),t=ni(e.loginPageBaseAddress,e.clientId,e.clientSecret,e.tenantId,e.redirectPath);t&&window.open(t,"_self")}function ni(e,t,n,r,o){return!t||!n?(console.error("未配置应用id或应用密钥"),""):r?(o=o||encodeURIComponent(window.location.href),console.log(`${e}/#/login?clientId=${t}&clientSecret=${n}&tenantId=${r}&redirectUrl=${o}`),`${e}/#/login?clientId=${t}&clientSecret=${n}&tenantId=${r}&redirectUrl=${o}`):(console.error("未配置租户id"),"")}function ri(){let e="",t;for(let n=0;n<32;n++)t=Math.random()*16|0,(n===8||n===12||n===16||n===20)&&(e+="-"),e+=(n===12?4:n===16?t&3|8:t).toString(16);return e}function Fn(){return D.userPermission}let U=s.reactive({isShow:!1,elDialogConfig:{}});function oi(){U.isShow=!0,console.log(U)}function si(){U.isShow=!1}function ai(e){U.elDialogConfig=e}const ii=s.defineComponent({__name:"EditForm",props:{dialogConfig:{default:e=>({})}},setup(e){class t{constructor(){this.dialogVisible=!1,this.formData={oldPassword:"",newPassword:"",newPasswordAgain:""}}}const n=s.reactive(new t),r=U,o=new De,a=e,i={oldPassword:[{required:!0,message:"请输入旧密码",trigger:"blur"}],newPassword:[{required:!0,message:"请输入新密码",trigger:"blur"}],newPasswordAgain:[{required:!0,message:"请输入确认密码",trigger:"blur"},{validator:(p,y,b)=>{y!==n.formData.newPassword?b(new Error("两次输入的密码不一致")):b(void 0)}}]};function l(){const p=o.get("qlfyEcologicalLogin_"+D.componentId);if(!p||!p.loginServiceBaseAddress)return xe.error("组件参数获取失败~");let y={oldPassword:n.formData.oldPassword,newPassword:n.formData.newPassword};const b=u(".edit-password-dialog","加载中",!0);x.put(p.loginServiceBaseAddress+"/admin-api/system/user/profile/update-password",y,{headers:{Authorization:it(),"tenant-id":p.tenantId}}).then(g=>{if(b.close(),g.data.code)return xe.warning(g.data.msg);xe.success("修改成功"),r.isShow=!1}).catch(g=>{b.close()})}const f=s.ref();function d(){f.value.validate(p=>{p&&l()})}function u(p,y,b){return ws.service({target:document.querySelector(p),text:y,lock:b,background:"rgba(0, 0, 0, 0.7)"})}return(p,y)=>{const b=s.resolveComponent("el-input"),g=s.resolveComponent("el-form-item"),m=s.resolveComponent("el-form"),h=s.resolveComponent("el-button"),w=s.resolveComponent("el-dialog");return s.openBlock(),s.createBlock(w,s.mergeProps({modelValue:s.unref(U).isShow,"onUpdate:modelValue":y[4]||(y[4]=_=>s.unref(U).isShow=_),title:"修改密码",class:"edit-password-dialog",width:"500px"},{...a.dialogConfig,...s.unref(U).elDialogConfig}),{footer:s.withCtx(()=>[s.createVNode(h,{onClick:y[3]||(y[3]=_=>s.unref(U).isShow=!1)},{default:s.withCtx(()=>y[5]||(y[5]=[s.createTextVNode("取 消")])),_:1,__:[5]}),s.createVNode(h,{type:"primary",onClick:d},{default:s.withCtx(()=>y[6]||(y[6]=[s.createTextVNode("确 定")])),_:1,__:[6]})]),default:s.withCtx(()=>[s.createVNode(m,{ref_key:"formRef",ref:f,model:n.formData,"label-width":"120px",rules:i},{default:s.withCtx(()=>[s.createVNode(g,{label:"旧密码",prop:"oldPassword"},{default:s.withCtx(()=>[s.createVNode(b,{modelValue:n.formData.oldPassword,"onUpdate:modelValue":y[0]||(y[0]=_=>n.formData.oldPassword=_),type:"password"},null,8,["modelValue"])]),_:1}),s.createVNode(g,{label:"新密码",prop:"newPassword"},{default:s.withCtx(()=>[s.createVNode(b,{modelValue:n.formData.newPassword,"onUpdate:modelValue":y[1]||(y[1]=_=>n.formData.newPassword=_),type:"password"},null,8,["modelValue"])]),_:1}),s.createVNode(g,{label:"确认密码",prop:"newPasswordAgain"},{default:s.withCtx(()=>[s.createVNode(b,{modelValue:n.formData.newPasswordAgain,"onUpdate:modelValue":y[2]||(y[2]=_=>n.formData.newPasswordAgain=_),type:"password"},null,8,["modelValue"])]),_:1})]),_:1},8,["model"])]),_:1},16,["modelValue"])}}}),jn=s.defineComponent({__name:"index",props:{clientId:{},clientSecret:{},loginPageBaseAddress:{},loginServiceBaseAddress:{},useRouter:{},token:{},isEnabled:{type:Boolean,default:!0},listenToken:{type:Boolean,default:!1},redirectPath:{default:""},tokenName:{default:"access_token"},tokenValidity:{default:60*30},tenantId:{default:7},dialogConfig:{default:e=>({})}},emits:["loggingIn","loginSuccess"],setup(e,{expose:t,emit:n}){const r=e,o=r.useRouter,a=r.useRouter.currentRoute,i=n,l=new De;let f=null,d=!0;const u=ri(),p=s.ref(!1);t({logout:Dn,getToken:it,getUserPermission:Fn}),D.componentId||(D.componentId=u,p.value=!0),s.onBeforeUnmount(()=>{f&&clearInterval(f);for(let w=0;w<localStorage.length;w++){let _=localStorage.key(w);_&&_.indexOf("qlfyEcologicalLogin_")>=0&&l.remove(_)}}),s.watch(()=>a.value.path,(w,_)=>{setTimeout(()=>{r.isEnabled&&y()})},{deep:!0}),s.watch(()=>r.isEnabled,()=>{setTimeout(()=>{if(y(),!r.isEnabled){l.remove(r.tokenName);for(let w=0;w<localStorage.length;w++){let _=localStorage.key(w);_&&_.indexOf("qlfyEcologicalLogin_")===0&&l.remove(_)}l.remove("loginInfo")}})},{deep:!0}),s.watch(()=>r.token,w=>{},{});function y(){if(!r.isEnabled||u!==D.componentId)return;m(),r.token?(l.set(r.tokenName,r.token,r.tokenValidity),l.set("tokenType",1)):l.get(r.tokenName)&&(l.get("tokenType")==1&&l.remove(r.tokenName),l.set("tokenType",0));const w=l.get(r.tokenName);w&&l.set(r.tokenName,w,r.tokenValidity);const _=!!a.value.query.token;if(D.userPermission=null,!w&&_){i("loggingIn",a.value.query.token),l.set(r.tokenName,a.value.query.token,r.tokenValidity);let C={...a.value.query};delete C.token,o.replace({path:a.value.path,query:C}),g(w)}else w&&d?(b(w),d=!1):lt()}function b(w){let _={token:w};const C={"tenant-id":r.tenantId,Authorization:"Basic "+btoa(r.clientId+":"+r.clientSecret)};x.post(r.loginServiceBaseAddress+"/admin-api/system/oauth2/check-token","",{params:_,headers:C}).then(O=>{if(O.data.code){l.remove(r.tokenName),lt();return}g(w),h()}).catch(O=>{console.log(O)})}function g(w){let _={clientId:r.clientId};const C={"tenant-id":r.tenantId,Authorization:w};x.get(r.loginServiceBaseAddress+"/admin-api/system/auth/get-permission-info",{params:_,headers:C}).then(O=>{D.userPermission=u,i("loginSuccess",O.data)}).catch(O=>{console.log(O)})}function m(){if(u!==D.componentId)return;for(let _=0;_<localStorage.length;_++){let C=localStorage.key(_);C&&C.indexOf("qlfyEcologicalLogin_")===0&&l.remove(C)}const w={...r};delete w.useRouter,l.set("qlfyEcologicalLogin_"+u,w)}function h(){r.listenToken&&(f&&clearInterval(f),f=setInterval(()=>{l.get(r.tokenName)||(clearInterval(f),xe.warning("登录状态丢失,正在重新获取~"),setTimeout(()=>{y()},2e3))},1e3))}return(w,_)=>p.value?(s.openBlock(),s.createBlock(ii,{key:0,"dialog-config":r.dialogConfig},null,8,["dialog-config"])):s.createCommentVNode("",!0)}}),li=jn,ci={install(e){e.component("qlfyEcologicalLogin",jn)}};R.LocalStorageManager=ti,R.closeChangePassword=si,R.default=ci,R.getToken=it,R.getUserPermission=Fn,R.logout=Dn,R.openChangePassword=oi,R.qlfyEcologicalLogin=li,R.setDialogConfig=ai,Object.defineProperties(R,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
11
|
+
`+a):r.stack=a}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:a}=n;r!==void 0&&Le.assertOptions(r,{silentJSONParsing:j.transitional(j.boolean),forcedJSONParsing:j.transitional(j.boolean),clarifyTimeoutError:j.transitional(j.boolean)},!1),o!=null&&(c.isFunction(o)?n.paramsSerializer={serialize:o}:Le.assertOptions(o,{encode:j.function,serialize:j.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),Le.assertOptions(n,{baseUrl:j.spelling("baseURL"),withXsrfToken:j.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=a&&c.merge(a.common,a[n.method]);a&&c.forEach(["delete","get","head","post","put","patch","common"],g=>{delete a[g]}),n.headers=k.concat(i,a);const l=[];let f=!0;this.interceptors.request.forEach(function(m){typeof m.runWhen=="function"&&m.runWhen(n)===!1||(f=f&&m.synchronous,l.unshift(m.fulfilled,m.rejected))});const d=[];this.interceptors.response.forEach(function(m){d.push(m.fulfilled,m.rejected)});let u,p=0,y;if(!f){const g=[In.bind(this),void 0];for(g.unshift.apply(g,l),g.push.apply(g,d),y=g.length,u=Promise.resolve(n);p<y;)u=u.then(g[p++],g[p++]);return u}y=l.length;let b=n;for(p=0;p<y;){const g=l[p++],m=l[p++];try{b=g(b)}catch(h){m.call(this,h);break}}try{u=In.call(this,b)}catch(g){return Promise.reject(g)}for(p=0,y=d.length;p<y;)u=u.then(d[p++],d[p++]);return u}getUri(t){t=G(this.defaults,t);const n=xn(t.baseURL,t.url,t.allowAbsoluteUrls);return hn(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(a,i,l){return this.request(G(l||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:a,data:i}))}}Z.prototype[t]=n(),Z.prototype[t+"Form"]=n(!0)});let Qa=class Un{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(a){n=a});const r=this;this.promise.then(o=>{if(!r._listeners)return;let a=r._listeners.length;for(;a-- >0;)r._listeners[a](o);r._listeners=null}),this.promise.then=o=>{let a;const i=new Promise(l=>{r.subscribe(l),a=l}).then(o);return i.cancel=function(){r.unsubscribe(a)},i},t(function(a,i,l){r.reason||(r.reason=new ne(a,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 Un(function(o){t=o}),cancel:t}}};function Ya(e){return function(n){return e.apply(null,n)}}function ei(e){return c.isObject(e)&&e.isAxiosError===!0}const at={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(at).forEach(([e,t])=>{at[t]=e});function Ln(e){const t=new Z(e),n=Yt(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 Ln(G(e,o))},n}const x=Ln(pe);x.Axios=Z,x.CanceledError=ne,x.CancelToken=Qa,x.isCancel=_n,x.VERSION=Bn,x.toFormData=Ae,x.AxiosError=S,x.Cancel=x.CanceledError,x.all=function(t){return Promise.all(t)},x.spread=Ya,x.isAxiosError=ei,x.mergeConfig=G,x.AxiosHeaders=k,x.formToJSON=e=>bn(c.isHTMLForm(e)?new FormData(e):e),x.getAdapter=vn.getAdapter,x.HttpStatusCode=at,x.default=x;const{Axios:_i,AxiosError:Si,CanceledError:Ci,isCancel:Ei,CancelToken:xi,VERSION:Oi,all:Ti,Cancel:Ni,isAxiosError:Ri,spread:Pi,toFormData:Ai,AxiosHeaders:ki,HttpStatusCode:vi,formToJSON:Ii,getAdapter:Bi,mergeConfig:$i}=x;class De{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 a={value:n,expire:o};localStorage.setItem(t,JSON.stringify(a))}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 ti=Object.freeze(Object.defineProperty({__proto__:null,default:De},Symbol.toStringTag,{value:"Module"})),D={componentId:"",userPermission:null},re=new De;function Dn(){const e=re.get("qlfyEcologicalLogin_"+D.componentId);if(!e||!e.isEnabled)return console.error(new Error("统一登陆未开启,请检查配置")),null;let t=re.get(e.tokenName);console.log(t),x({method:"post",url:e.loginServiceBaseAddress+"/admin-api/system/auth/logout",headers:{"tenant-id":e.tenantId,Authorization:"Bearer "+t}}).then(n=>{n.data.code||(re.remove(e.tokenName),lt())})}function it(){const e=re.get("qlfyEcologicalLogin_"+D.componentId);return console.log(e),!e||!e.isEnabled?null:re.get(e.tokenName)}function lt(){const e=re.get("qlfyEcologicalLogin_"+D.componentId),t=ni(e.loginPageBaseAddress,e.clientId,e.clientSecret,e.tenantId,e.redirectPath);t&&window.open(t,"_self")}function ni(e,t,n,r,o){return!t||!n?(console.error("未配置应用id或应用密钥"),""):r?(o=o||encodeURIComponent(window.location.href),console.log(`${e}/#/login?clientId=${t}&clientSecret=${n}&tenantId=${r}&redirectUrl=${o}`),`${e}/#/login?clientId=${t}&clientSecret=${n}&tenantId=${r}&redirectUrl=${o}`):(console.error("未配置租户id"),"")}function ri(){let e="",t;for(let n=0;n<32;n++)t=Math.random()*16|0,(n===8||n===12||n===16||n===20)&&(e+="-"),e+=(n===12?4:n===16?t&3|8:t).toString(16);return e}function Fn(){return D.userPermission}let U=s.reactive({isShow:!1,elDialogConfig:{}});function oi(){U.isShow=!0,console.log(U)}function si(){U.isShow=!1}function ai(e){U.elDialogConfig=e}const ii=s.defineComponent({__name:"EditForm",props:{dialogConfig:{default:e=>({})}},setup(e){class t{constructor(){this.dialogVisible=!1,this.formData={oldPassword:"",newPassword:"",newPasswordAgain:""}}}const n=s.reactive(new t),r=U,o=new De,a=e,i={oldPassword:[{required:!0,message:"请输入旧密码",trigger:"blur"}],newPassword:[{required:!0,message:"请输入新密码",trigger:"blur"}],newPasswordAgain:[{required:!0,message:"请输入确认密码",trigger:"blur"},{validator:(p,y,b)=>{y!==n.formData.newPassword?b(new Error("两次输入的密码不一致")):b(void 0)}}]};function l(){const p=o.get("qlfyEcologicalLogin_"+D.componentId);if(!p||!p.loginServiceBaseAddress)return xe.error("组件参数获取失败~");let y={oldPassword:n.formData.oldPassword,newPassword:n.formData.newPassword};const b=u(".edit-password-dialog","加载中",!0);x.put(p.loginServiceBaseAddress+"/admin-api/system/user/profile/update-password",y,{headers:{Authorization:it(),"tenant-id":p.tenantId}}).then(g=>{if(b.close(),g.data.code)return xe.warning(g.data.msg);xe.success("修改成功"),r.isShow=!1}).catch(g=>{b.close()})}const f=s.ref();function d(){f.value.validate(p=>{p&&l()})}function u(p,y,b){return ws.service({target:document.querySelector(p),text:y,lock:b,background:"rgba(0, 0, 0, 0.7)"})}return(p,y)=>{const b=s.resolveComponent("el-input"),g=s.resolveComponent("el-form-item"),m=s.resolveComponent("el-form"),h=s.resolveComponent("el-button"),w=s.resolveComponent("el-dialog");return s.openBlock(),s.createBlock(w,s.mergeProps({modelValue:s.unref(U).isShow,"onUpdate:modelValue":y[4]||(y[4]=_=>s.unref(U).isShow=_),title:"修改密码",class:"edit-password-dialog",width:"500px"},{...a.dialogConfig,...s.unref(U).elDialogConfig}),{footer:s.withCtx(()=>[s.createVNode(h,{onClick:y[3]||(y[3]=_=>s.unref(U).isShow=!1)},{default:s.withCtx(()=>y[5]||(y[5]=[s.createTextVNode("取 消")])),_:1,__:[5]}),s.createVNode(h,{type:"primary",onClick:d},{default:s.withCtx(()=>y[6]||(y[6]=[s.createTextVNode("确 定")])),_:1,__:[6]})]),default:s.withCtx(()=>[s.createVNode(m,{ref_key:"formRef",ref:f,model:n.formData,"label-width":"120px",rules:i},{default:s.withCtx(()=>[s.createVNode(g,{label:"旧密码",prop:"oldPassword"},{default:s.withCtx(()=>[s.createVNode(b,{modelValue:n.formData.oldPassword,"onUpdate:modelValue":y[0]||(y[0]=_=>n.formData.oldPassword=_),type:"password"},null,8,["modelValue"])]),_:1}),s.createVNode(g,{label:"新密码",prop:"newPassword"},{default:s.withCtx(()=>[s.createVNode(b,{modelValue:n.formData.newPassword,"onUpdate:modelValue":y[1]||(y[1]=_=>n.formData.newPassword=_),type:"password"},null,8,["modelValue"])]),_:1}),s.createVNode(g,{label:"确认密码",prop:"newPasswordAgain"},{default:s.withCtx(()=>[s.createVNode(b,{modelValue:n.formData.newPasswordAgain,"onUpdate:modelValue":y[2]||(y[2]=_=>n.formData.newPasswordAgain=_),type:"password"},null,8,["modelValue"])]),_:1})]),_:1},8,["model"])]),_:1},16,["modelValue"])}}}),jn=s.defineComponent({__name:"index",props:{clientId:{},clientSecret:{},loginPageBaseAddress:{},loginServiceBaseAddress:{},useRouter:{},token:{},isEnabled:{type:Boolean,default:!0},listenToken:{type:Boolean,default:!1},redirectPath:{default:""},tokenName:{default:"access_token"},tokenValidity:{default:60*30},tenantId:{default:7},dialogConfig:{default:e=>({})}},emits:["loggingIn","loginSuccess"],setup(e,{expose:t,emit:n}){const r=e,o=r.useRouter,a=r.useRouter.currentRoute,i=n,l=new De;let f=null,d=!0;const u=ri(),p=s.ref(!1);t({logout:Dn,getToken:it,getUserPermission:Fn}),D.componentId||(D.componentId=u,p.value=!0),s.onBeforeUnmount(()=>{f&&clearInterval(f);for(let w=0;w<localStorage.length;w++){let _=localStorage.key(w);_&&_.indexOf("qlfyEcologicalLogin_")>=0&&l.remove(_)}}),s.watch(()=>a.value.path,(w,_)=>{setTimeout(()=>{r.isEnabled&&y()})},{deep:!0,immediate:!0}),s.watch(()=>r.isEnabled,()=>{setTimeout(()=>{if(y(),!r.isEnabled){l.remove(r.tokenName);for(let w=0;w<localStorage.length;w++){let _=localStorage.key(w);_&&_.indexOf("qlfyEcologicalLogin_")===0&&l.remove(_)}l.remove("loginInfo")}})},{deep:!0}),s.watch(()=>r.token,w=>{},{});function y(){if(!r.isEnabled||u!==D.componentId)return;m(),r.token?(l.set(r.tokenName,r.token,r.tokenValidity),l.set("tokenType",1)):l.get(r.tokenName)&&(l.get("tokenType")==1&&l.remove(r.tokenName),l.set("tokenType",0));const w=l.get(r.tokenName);w&&l.set(r.tokenName,w,r.tokenValidity);const _=!!a.value.query.token;if(D.userPermission=null,!w&&_){i("loggingIn",a.value.query.token),l.set(r.tokenName,a.value.query.token,r.tokenValidity);let C={...a.value.query};delete C.token,o.replace({path:a.value.path,query:C}),g(w)}else w&&d?(b(w),d=!1):lt()}function b(w){let _={token:w};const C={"tenant-id":r.tenantId,Authorization:"Basic "+btoa(r.clientId+":"+r.clientSecret)};x.post(r.loginServiceBaseAddress+"/admin-api/system/oauth2/check-token","",{params:_,headers:C}).then(O=>{if(O.data.code){l.remove(r.tokenName),lt();return}g(w),h()}).catch(O=>{console.log(O)})}function g(w){let _={clientId:r.clientId};const C={"tenant-id":r.tenantId,Authorization:w};x.get(r.loginServiceBaseAddress+"/admin-api/system/auth/get-permission-info",{params:_,headers:C}).then(O=>{D.userPermission=u,i("loginSuccess",O.data)}).catch(O=>{console.log(O)})}function m(){if(u!==D.componentId)return;for(let _=0;_<localStorage.length;_++){let C=localStorage.key(_);C&&C.indexOf("qlfyEcologicalLogin_")===0&&l.remove(C)}const w={...r};delete w.useRouter,l.set("qlfyEcologicalLogin_"+u,w)}function h(){r.listenToken&&(f&&clearInterval(f),f=setInterval(()=>{l.get(r.tokenName)||(clearInterval(f),xe.warning("登录状态丢失,正在重新获取~"),setTimeout(()=>{y()},2e3))},1e3))}return(w,_)=>p.value?(s.openBlock(),s.createBlock(ii,{key:0,"dialog-config":r.dialogConfig},null,8,["dialog-config"])):s.createCommentVNode("",!0)}}),li=jn,ci={install(e){e.component("qlfyEcologicalLogin",jn)}};R.LocalStorageManager=ti,R.closeChangePassword=si,R.default=ci,R.getToken=it,R.getUserPermission=Fn,R.logout=Dn,R.openChangePassword=oi,R.qlfyEcologicalLogin=li,R.setDialogConfig=ai,Object.defineProperties(R,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/lib/index.umd.js.gz
CHANGED
|
Binary file
|