mirror of
https://github.com/Li4n0/revsuit.git
synced 2026-09-23 23:21:54 +08:00
feat(frontend): optimize frontend interaction (#8)
Support auto refresh. Change authentication method. Streamline the frontend code.
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
import request from './index'
|
||||
|
||||
export function ping() {
|
||||
export function auth(token) {
|
||||
return request({
|
||||
url: '/ping',
|
||||
url: '/auth',
|
||||
method: 'get',
|
||||
headers: {"Token": token},
|
||||
validateStatus: function (status) {
|
||||
return status >= 200 && status < 300 // 默认的
|
||||
return status >= 200 && status < 300
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -5,13 +5,4 @@ const service = axios.create({
|
||||
timeout: 5000 // request timeout
|
||||
})
|
||||
|
||||
service.interceptors.request.use(function (config) {
|
||||
const token = localStorage.getItem("token")
|
||||
if (token !== null) {
|
||||
config.headers['Token'] = token
|
||||
}
|
||||
// 在发送请求之前做些什么
|
||||
return config
|
||||
})
|
||||
|
||||
export default service
|
||||
Reference in New Issue
Block a user