feat(frontend): optimize frontend interaction (#8)

Support auto refresh. Change authentication method. Streamline the frontend code.
This commit is contained in:
Li4n0
2021-04-25 22:15:56 +08:00
committed by GitHub
parent 50a6749070
commit 7e99d93e43
21 changed files with 347 additions and 232 deletions
@@ -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
}
})
}
-9
View File
@@ -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