PageSourceSearch

https://roseselsa.com/assets/auth-DAuB8gK0.js

js roseselsa.com collected 2026-10-10 00:59:25 UTC 3,335 bytes, 1 lines download raw bytes

1import{n as e,o as t,r as n,t as r}from"./request-Dm1a10xE.js";import{u as i,ut as a}from"./_plugin-vue_export-helper-CIomflQo.js";import{n as o}from"./pinia-3gKirCGM.js";function s(e,t){return e.reason||e.msg||t}function c(e,t=`请求失败`){if(e.code!==`200`||e.data==null)throw Error(s(e,t));return e.data}function l(e){let t=c(e,`登录失败`);if(!t.token)throw Error(s(e,`登录失败:未返回 Token`));return t}function u(e,t){if(e.code!==`200`)throw Error(s(e,t))}async function d(t,n){return l(await e({url:`/auth/login`,method:`POST`,data:{username:t,password:n}}))}async function f(){let t=c(await e({url:`/auth/getverify`,method:`GET`}),`图片验证码加载失败`);return{uuid:t,imageSrc:c(await e({url:`/auth/getpic`,method:`GET`,params:{uuid:t}}),`图片验证码已过期,请重新获取`)}}async function p(t,n){u(await e({url:t===`sms`?`/auth/verify-code-sms`:`/auth/verify-code-email`,method:`POST`,data:t===`sms`?{phone:n.account,uuid:n.uuid,ans:n.ans}:{email:n.account,uuid:n.uuid,ans:n.ans}}),t===`sms`?`短信验证码发送失败`:`邮箱验证码发送失败`)}async function m(t,n,r){return l(await e({url:t===`sms`?`/auth/login-sms`:`/auth/login-email`,method:`POST`,data:{username:n,context:r}}))}async function h(){return c(await e({url:`/auth/get-user-info`,method:`POST`}),`获取用户信息失败`)}async function g(){let t=c(await e({url:`/auth/refresh`,method:`POST`}),`Token 刷新失败`);if(!t.token)throw Error(`Token 刷新失败:未返回 Token`);return t}async function _(){u(await e({url:`/auth/logout`,method:`GET`}),`服务端退出失败`)}var v=864e5,y=3e5,b=2147e6,x=o(`auth`,()=>{let e=a(null),o=a(t.getToken()),s=a(t.getExpiresAt()),c=a(o.value?`idle`:`anonymous`),l=i(()=>![`idle`,`restoring`].includes(c.value)),u=i(()=>!!o.value),d=null,f=null,p;function m(){p&&window.clearTimeout(p),p=void 0}function x(e=0){if(m(),!u.value)return;let n=t.getExpiresAtMs();if(n===null)return;let r=Math.max(e,n-Date.now()-v);p=window.setTimeout(()=>{p=void 0,O().catch(()=>{o.value&&!t.hasExpired()&&x(y)})},Math.min(Math.max(r,0),b))}function S(r){let i=r.token||o.value;if(!i){C();return}let a=r.updateTime||s.value;t.saveToken(i,a),e.value={...r,token:i,updateTime:a||``},o.value=i,s.value=a,c.value=`authenticated`,n(),x()}function C(){m(),e.value=null,o.value=null,s.value=null,c.value=`anonymous`,t.clear()}function w(t=!1){return!t&&l.value?Promise.resolve():d||(o.value?(c.value=`restoring`,d=(async()=>{try{S(await h())}catch(t){!o.value||r(t)?C():(e.value=null,c.value=`unavailable`)}finally{d=null}})(),d):(C(),Promise.resolve()))}async function T(){try{S(await h())}catch(e){throw(!o.value||r(e))&&C(),e}}function E(i){return f||(o.value?!i&&!t.shouldRefresh(v)?(x(),Promise.resolve()):(f=(async()=>{try{let r=await g();o.value=r.token,s.value=r.updateTime,e.value&&={...e.value,token:r.token,updateTime:r.updateTime},t.saveToken(r.token,r.updateTime),n(),x(y)}catch(e){throw!o.value||r(e)?C():x(y),e}finally{f=null}})(),f):Promise.resolve())}function D(){return E(!0)}function O(){return E(!1)}async function k(){try{o.value&&await _()}finally{C()}}return{clearAuth:C,isLogin:u,logout:k,refreshToken:D,refreshTokenIfNeeded:O,refreshUser:T,restoreSession:w,sessionReady:l,sessionStatus:c,setAuth:S,token:o,updateTime:s,userObj:e}});export{p as a,m as i,f as n,d as r,x as t};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.