feat: rebuild frontend with react

This commit is contained in:
liumangmang
2026-04-22 09:53:06 +08:00
parent 42836aa4c3
commit 423cca97a6
81 changed files with 2907 additions and 10230 deletions
+35
View File
@@ -0,0 +1,35 @@
import axios from 'axios'
const http = axios.create({
baseURL: '/api',
headers: {
'Content-Type': 'application/json',
},
})
http.interceptors.request.use((config) => {
const token = localStorage.getItem('token')
if (token) {
config.headers.Authorization = `Bearer ${token}`
}
if (typeof FormData !== 'undefined' && config.data instanceof FormData) {
const headers = config.headers as Record<string, string> | undefined
if (headers) {
delete headers['Content-Type']
delete headers['content-type']
}
}
return config
})
http.interceptors.response.use(
(response) => response,
(error) => {
if (error.response?.status === 401) {
localStorage.removeItem('token')
}
return Promise.reject(error)
},
)
export default http