From aa07361813f91b35469cce809a016d07c91299b9 Mon Sep 17 00:00:00 2001 From: FatttSnake Date: Sun, 15 Oct 2023 12:51:59 +0800 Subject: [PATCH] Fix logout bug --- src/pages/ToolsFramework.tsx | 9 +++++---- src/utils/auth.ts | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/pages/ToolsFramework.tsx b/src/pages/ToolsFramework.tsx index 20f62a9..c386c86 100644 --- a/src/pages/ToolsFramework.tsx +++ b/src/pages/ToolsFramework.tsx @@ -52,10 +52,11 @@ const ToolsFramework: React.FC = () => { } const handleLogout = () => { - logout() - setTimeout(() => { - window.location.reload() - }, 1500) + void logout().finally(() => { + setTimeout(() => { + window.location.reload() + }, 1500) + }) } return ( diff --git a/src/utils/auth.ts b/src/utils/auth.ts index a923968..aa3fc82 100644 --- a/src/utils/auth.ts +++ b/src/utils/auth.ts @@ -11,8 +11,8 @@ export const login = async (username: string, password: string) => { }) } -export const logout = () => { - void request.post('/logout').finally(() => { +export const logout = async () => { + return request.post('/logout').finally(() => { removeLocalStorage('userInfo') removeLocalStorage(TOKEN_NAME) }) -- 2.49.1