diff --git a/src/utils/auth/token.js b/src/utils/auth/token.js index 463d54d..348df18 100644 --- a/src/utils/auth/token.js +++ b/src/utils/auth/token.js @@ -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) diff --git a/src/utils/storage/storage.js b/src/utils/storage/storage.js index c59f971..9a15345 100644 --- a/src/utils/storage/storage.js +++ b/src/utils/storage/storage.js @@ -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)