From f1defd23e6cfdd5cadd2906063c28107e4b1a992 Mon Sep 17 00:00:00 2001 From: Jimmy Liow Date: Fri, 19 Jul 2024 09:54:00 +0800 Subject: [PATCH] =?UTF-8?q?doc:=20=E6=B3=A8=E9=87=8A=20dev=20=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F=E7=83=AD=E6=9B=B4=E6=96=B0=E5=87=BA=E9=94=99=E5=8E=9F?= =?UTF-8?q?=E5=9B=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/stores/Auth.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/stores/Auth.js b/src/stores/Auth.js index d880476..83da003 100644 --- a/src/stores/Auth.js +++ b/src/stores/Auth.js @@ -64,6 +64,8 @@ const useAuthStore = create((set, get) => ({ const { startTokenInterval, loadUserPermission } = get() const { setStorage, loginToken } = usingStorage() + // Dev 模式使用 localStorage,会有 token 失效情况,需要手动删除 + // Prod 环境没有该问题 const userJson = await fetchUserDetail(loginToken) appendRequestParams('token', loginToken) @@ -142,9 +144,9 @@ const useAuthStore = create((set, get) => ({ async function checkTokenTimeout() { // TODO:Token 失效后要跳转到登录页面 const { LastReqDate } = await fetchLastRequet() - const lastReqDate = new Date(LastReqDate) + const lastReqDateTime = new Date(LastReqDate).getTime() const now = new Date() - const diffTime = now.getTime() - lastReqDate.getTime() + const diffTime = now.getTime() - lastReqDateTime const diffHours = diffTime/1000/60/60 if (diffHours > 1) { logout()