From f02ef21fad69f64c8f2c99aad1eac66c26054b8c Mon Sep 17 00:00:00 2001 From: lysign Date: Sat, 13 Aug 2022 11:37:27 +0800 Subject: [PATCH] fix: ahead of 10 minutes refresh token (#94) Signed-off-by: liuying Signed-off-by: liuying --- src/utils/request.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/utils/request.js b/src/utils/request.js index f9db8971..81a45375 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -49,12 +49,12 @@ module.exports = methods.reduce( async function checkToken(callback) { const token = getLocalStorageItem('token') || {}; - const { expires = '', expire = '' } = token; + const { expires = '' } = token; if (expires) { const current = new Date().getTime(); - // eslint-disable-next-line no-mixed-operators - const TIME_DELAY = expire - 10 * 1000; + // ahead of 10 minutes refresh token, aviod time difference between client and server + const TIME_DELAY = 10 * 60 * 1000; if (expires <= current + TIME_DELAY) { const resp = await rootStore.getNewToken(token);