refactor: refactor api usage
This commit is contained in:
@@ -17,6 +17,8 @@ export function createAxios(options = {}) {
|
||||
|
||||
export const defAxios = createAxios()
|
||||
|
||||
export default createAxios()
|
||||
|
||||
export const testAxios = createAxios({
|
||||
baseURL: import.meta.env.VITE_APP_BASE_API_TEST,
|
||||
})
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import { lStorage } from './cache'
|
||||
import { refreshToken } from '@/api/auth'
|
||||
import api from '@/api'
|
||||
|
||||
const TOKEN_CODE = 'access_token'
|
||||
const DURATION = 6 * 60 * 60
|
||||
@@ -25,7 +25,7 @@ export async function refreshAccessToken() {
|
||||
// token生成或者刷新后30分钟内不执行刷新
|
||||
if (new Date().getTime() - time <= 1000 * 60 * 30) return
|
||||
try {
|
||||
const res = await refreshToken()
|
||||
const res = await api.refreshToken()
|
||||
if (res.code === 0) {
|
||||
setToken(res.data.token)
|
||||
}
|
||||
|
Reference in New Issue
Block a user