PageSourceSearch

https://cief.org.cn/_nuxt/Dcdj5DrC.js

js cief.org.cn collected 2026-09-24 21:39:07 UTC 5,855 bytes, 1 lines download raw bytes

1var v=Object.defineProperty;var w=(s,e,t)=>e in s?v(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var m=(s,e,t)=>w(s,typeof e!="symbol"?e+"":e,t);import{$ as y,a0 as U}from"./cl7XfM0u.js";var h={};const R={dev:{name:"开发环境",apiBaseUrl:"https://cief.org.cn/api",siteUrl:"http://localhost:3000",isDev:!0,isProd:!1,enableDebug:!0,apiTimeout:1e4,enableApiLog:!0},pre:{name:"预发布环境",apiBaseUrl:"https://pre-api.cief.org.cn",siteUrl:"https://pre.cief.org.cn",isDev:!1,isProd:!1,enableDebug:!0,apiTimeout:15e3,enableApiLog:!0},prod:{name:"生产环境",apiBaseUrl:"https://cief.org.cn/api",siteUrl:"https://cief.org.cn",isDev:!1,isProd:!0,enableDebug:!1,apiTimeout:15e3,enableApiLog:!1}};function b(){if(typeof process<"u"){const s=h.APP_ENV;return s&&R[s]?s:"prod"}if(typeof window<"u"){const s=window.location.hostname;return s.includes("localhost")||s.includes("127.0.0.1")?"dev":s.includes("pre.")?"pre":"prod"}return"dev"}function A(s){const e=s||b();return R[e]}function f(){return A(b())}function D(){return f().isDev}function L(){return typeof process<"u"&&h.API_BASE_URL?h.API_BASE_URL:f().apiBaseUrl}function k(){const s=f();s.enableDebug&&typeof console<"u"&&(console.group("🌍 环境配置信息"),console.log("当前环境:",s.name),console.log("API地址:",s.apiBaseUrl),console.log("网站地址:",s.siteUrl),console.log("调试模式:",s.enableDebug),console.log("API日志:",s.enableApiLog),console.groupEnd())}f();typeof window<"u"&&D()&&k();class C{constructor(e={}){m(this,"config");const t=f();this.config={baseURL:L(),timeout:t.apiTimeout,headers:{"Content-Type":"application/json",Accept:"application/json"},retry:3,retryDelay:1e3,enableLogging:t.enableApiLog,enableRetry:!0,requestInterceptors:[],responseInterceptors:[],...e},this.setupInterceptors()}setupInterceptors(){this.addRequestInterceptor({onRequest:async e=>{const t=y("auth-token").value||localStorage.getItem("auth-token");return t&&(e.headers={...e.headers,Authorization:`Bearer ${t}`}),e.headers={...e.headers,"X-Request-ID":this.generateRequestId()},this.config.enableLogging&&console.log("🚀 API Request:",e),e},onRequestError:async e=>{this.config.enableLogging&&console.error("❌ Request Error:",e)}}),this.addResponseInterceptor({onResponse:async e=>(this.config.enableLogging&&console.log("✅ API Response:",e),e=this.processImageUrls(e),e),onResponseError:async e=>{const t=this.transformError(e);throw this.config.enableLogging&&console.error("❌ Response Error:",t),await this.handleError(t),t}})}processImageUrls(e){if(!e)return e;const t=this.config.baseURL,n=r=>{if(!r)return r;try{return r.startsWith("/")?`${t}${r}`:r.startsWith("http://")||r.startsWith("https://")?r:`${t}/${r}`}catch(i){return console.warn("URL解析失败:",r,i),r}},o=r=>{if(!r||typeof r!="object")return r;if(Array.isArray(r))return r.map(a=>o(a));const i={};for(const a in r){const c=r[a];(a==="webCover"||a==="mobileCover"||a==="coverImage")&&typeof c=="string"&&c?i[a]=n(c):typeof c=="object"?i[a]=o(c):i[a]=c}return i};return o(e)}addRequestInterceptor(e){var t;(t=this.config.requestInterceptors)==null||t.push(e)}addResponseInterceptor(e){var t;(t=this.config.responseInterceptors)==null||t.push(e)}generateRequestId(){return`req_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}transformError(e){const t={code:e.status||e.statusCode||"UNKNOWN_ERROR",message:e.message||e.statusMessage||"请求失败",status:e.status||e.statusCode,data:e.data,timestamp:new Date().toISOString()};switch(t.status){case 400:t.message="请求参数错误";break;case 401:t.message="未授权,请重新登录";break;case 403:t.message="权限不足";break;case 404:t.message="请求的资源不存在";break;case 422:t.message="数据验证失败";break;case 429:t.message="请求过于频繁,请稍后再试";break;case 500:t.message="服务器内部错误";break;case 502:t.message="网关错误";break;case 503:t.message="服务暂时不可用";break;default:(!t.message||t.message==="请求失败")&&(t.message="网络连接异常,请检查网络设置")}return t}async handleError(e){if(e.status===401){const t=y("auth-token");t.value=null,localStorage.removeItem("auth-token")}this.config.defaultErrorHandler&&this.config.defaultErrorHandler(e)}async executeRequestInterceptors(e){let t=e;for(const n of this.config.requestInterceptors||[])if(n.onRequest)try{t=await n.onRequest(t)}catch(o){throw n.onRequestError&&await n.onRequestError(o),o}return t}async executeResponseInterceptors(e){let t=e;for(const n of this.config.responseInterceptors||[])if(n.onResponse)try{t=await n.onResponse(t)}catch(o){throw n.onResponseError&&await n.onResponseError(o),o}return t}
1async request(e,t={}){const{method:n="GET",headers:o={},params:r={},body:i,timeout:a=this.config.timeout,retry:c=this.config.retry,retryDelay:E=this.config.retryDelay,cache:I=!1,transform:l}=t,{cache:P,transform:_,...q}=t;let g={baseURL:this.config.baseURL,method:n,headers:{...this.config.headers,...o},params:r,body:i,timeout:a,retry:this.config.enableRetry?c:0,retryDelay:E,server:!I,...q};try{g=await this.executeRequestInterceptors(g);let u=await U(e,g);return u=await this.executeResponseInterceptors(u),l&&typeof l=="function"&&(u=l(u)),u}catch(u){for(const d of this.config.responseInterceptors||[])d.onResponseError&&await d.onResponseError(u);throw u}}async get(e,t={}){return this.request(e,{...t,method:"GET"})}async post(e,t,n={}){return this.request(e,{...n,method:"POST",body:t})}async put(e,t,n={}){return this.request(e,{...n,method:"PUT",body:t})}async delete(e,t={}){return this.request(e,{...t,method:"DELETE"})}async patch(e,t,n={}){return this.request(e,{...n,method:"PATCH",body:t})}}const p=new C,$={get:(s,e)=>p.get(s,e),post:(s,e,t)=>p.post(s,e,t),put:(s,e,t)=>p.put(s,e,t),delete:(s,e)=>p.delete(s,e),patch:(s,e,t)=>p.patch(s,e,t)};export{$ as a};

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.