From a6ecd39422bf8c5016c326e6a4a1448e3b1914a3 Mon Sep 17 00:00:00 2001 From: Joe Date: Fri, 31 Oct 2025 14:26:32 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/request.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/utils/request.ts b/src/utils/request.ts index 8798014..1ac21d4 100644 --- a/src/utils/request.ts +++ b/src/utils/request.ts @@ -75,6 +75,14 @@ request.interceptors.response.use(async (response, options) => { await freshTokenUsingPost(param).then((res) => { if (res.retcode) { localStorage.setItem('token', res.data?.accessToken); + } else { + localStorage.clear(); + history.replace({ + pathname: '/user/login', + search: stringify({ + redirect: window.location.href, + }), + }); } }); const url = response.url.replace(`${process.env.BASE_URL}`, ''); @@ -122,6 +130,14 @@ request.interceptors.response.use(async (response, options) => { await freshTokenUsingPost(param).then((res) => { if (res.retcode) { localStorage.setItem('token', res.data?.accessToken); + } else { + localStorage.clear(); + history.replace({ + pathname: '/user/login', + search: stringify({ + redirect: window.location.href, + }), + }); } }); const url = response.url.replace(`${process.env.BASE_URL}`, '');