You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 line
696 B
1 line
696 B
import{n as e,t}from"./axios-CiYFffbI.js";var n=`szkp_admin_token`,r=t.create({baseURL:`https://szkp-map.langye.net/api`,timeout:1e4});function i(){let e=`/admin/`;return`${e.endsWith(`/`)?e:`${e}/`}login`}r.interceptors.request.use(e=>{let t=localStorage.getItem(n);return t&&(e.headers.Authorization=`Bearer ${t}`),e}),r.interceptors.response.use(e=>e,t=>{let r=t.response?.status,a=String(t.config?.url??``).includes(`/auth/login`);if(r===401&&!a){localStorage.removeItem(n),e.warning(`登录已过期,请重新登录`);let t=`${i()}?redirect=${encodeURIComponent(window.location.pathname+window.location.search)}`;window.location.replace(t)}return Promise.reject(t)});export{r as n,n as t}; |