Files
vueapp/dist/assets/auth.vuBox8Gk.js
T
2026-06-15 18:04:01 +08:00

2 lines
1.5 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import{C as t,D as e}from"./index-DGiVEDOl.js";const n="/server/api";class r extends Error{constructor(t,e,n){super(t),this.name="ApiRequestError",this.code=e,this.statusCode=n}}function o(t=!1){const n={"Content-Type":"application/json"};if(!t)return n;const r=function(){try{return e("clinical-thinking-access-token")||""}catch{return""}}();return r&&(n.Authorization=`Bearer ${r}`),n}function s(e,n,s="POST",i=!1){return new Promise(((u,a)=>{t({url:`/server/api${e}`,method:s,timeout:1e4,header:o(i),data:n,success:t=>{if(t.statusCode>=200&&t.statusCode<300)return void u(t.data);const e=t.data,n="string"==typeof(null==e?void 0:e.code)?e.code:void 0;a(new r(function(t,e){if(t&&"object"==typeof t){const e=t,n=e.message||e.detail||e.error;if("string"==typeof n&&n.trim())return n}return e}(t.data,`请求失败(${t.statusCode}`),n,t.statusCode))},fail:t=>{a(new r(t.errMsg||"无法连接服务"))}})}))}function i(t,e="login"){return s("/user/auth/send-code/",{phone:t,scene:e})}function u(){return s("/user/institution_list/",null,"GET")}function a(){return s("/user/institution_info/",null,"GET",!0)}function c(){return s("/user/my_departments/",null,"GET",!0)}function f(t){return s("/user/auth/login-code/",t).then((t=>{if(function(t){if(!t||"object"!=typeof t)return!1;const e=t,n=e.tokens;return Boolean(e.tokens&&"string"==typeof(null==n?void 0:n.access)&&"string"==typeof(null==n?void 0:n.refresh))}(t))return t;throw new Error("登录接口返回数据格式异常")}))}export{r as A,n as a,c as b,a as c,u as f,f as l,i as s};