Merge pull request #48 from xtazhangzp/main

This commit is contained in:
Ronnie Zhang 2023-09-01 20:59:38 +08:00 committed by GitHub
commit 456ad78dd2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View File

@ -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)

View File

@ -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)