import{a as s}from"./index-B8_nURbH.js";import{$ as n}from"./index-BKsb6cIX.js";const o=s.create({baseURL:"/api",timeout:15e3,headers:{"Content-Type":"application/json"}});o.interceptors.request.use(t=>{const e=localStorage.getItem("accessToken");return e&&(t.headers.Authorization=`Bearer ${e}`),t});o.interceptors.response.use(t=>{const{data:e}=t;return e&&e.code!==void 0?e.code===200?e:e.code===401?(localStorage.removeItem("accessToken"),window.location.hash="#/login",Promise.reject(new Error("登录已过期"))):Promise.reject({...e,_handled:!0}):e},t=>{var r;const{response:e}=t;return e&&e.status===409?Promise.reject({code:409,message:"数据已被他人修改，请刷新后重试",conflictVersion:(r=e.data)==null?void 0:r.conflictVersion,_handled:!0}):(t._handled||n.error(t.message||"请求失败"),Promise.reject(t))});export{o as c};
