Merge pull request #48 from xtazhangzp/main
This commit is contained in:
commit
456ad78dd2
@ -23,7 +23,7 @@ export async function refreshAccessToken() {
|
||||
}
|
||||
const { time } = tokenItem
|
||||
// token生成或者刷新后30分钟内不执行刷新
|
||||
if (new Date().getTime() - time <= 1000 * 60 * 30) return
|
||||
if (Date.now() - time <= 1000 * 60 * 30) return
|
||||
try {
|
||||
const res = await api.refreshToken()
|
||||
setToken(res.data.token)
|
||||
|
@ -14,7 +14,7 @@ class Storage {
|
||||
const stringData = JSON.stringify({
|
||||
value,
|
||||
time: Date.now(),
|
||||
expire: !isNullOrUndef(expire) ? new Date().getTime() + expire * 1000 : null,
|
||||
expire: !isNullOrUndef(expire) ? Date.now() + expire * 1000 : null,
|
||||
})
|
||||
this.storage.setItem(this.getKey(key), stringData)
|
||||
}
|
||||
@ -30,7 +30,7 @@ class Storage {
|
||||
try {
|
||||
const data = JSON.parse(val)
|
||||
const { value, time, expire } = data
|
||||
if (isNullOrUndef(expire) || expire > new Date().getTime()) {
|
||||
if (isNullOrUndef(expire) || expire > Date.now()) {
|
||||
return { value, time }
|
||||
}
|
||||
this.remove(key)
|
||||
|
Loading…
x
Reference in New Issue
Block a user