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.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
import * as api from '@/api/api.js'
import { encryptionLogin } from '../util/Login.js'
let promise
export async function refreshToken ( ) {
if ( promise ) {
return promise
}
promise = new Promise ( async resolve => {
const loginFrom = encryptionLogin ( )
console . log ( '重新换token' , loginFrom )
let res = await api . login ( loginFrom , { _ _isRefreshToken : true } )
localStorage . setItem ( 'mudu_token' , res . access _token ) //存token
resolve ( res . code === 200 )
} )
promise . finally ( ( ) => {
promise = null
} )
return promise
}
export function isRefreshRequest ( config ) {
// console.log(config.__isRefreshToken)
return ! ! config . _ _isRefreshToken //两个取反, 变成boolean
}