From b1d2d5715d662b4a641533536810433ed673f4f9 Mon Sep 17 00:00:00 2001 From: selfrelease Date: Wed, 29 Jul 2026 11:56:24 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=99=BB=E5=BD=95/=E7=99=BB=E5=87=BA?= =?UTF-8?q?=E6=97=B6=E6=B8=85=E9=99=A4=20React=20Query=20=E7=BC=93?= =?UTF-8?q?=E5=AD=98=EF=BC=8C=E4=BF=AE=E5=A4=8D=E5=88=87=E6=8D=A2=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E9=A1=B5=E9=9D=A2=E4=B8=8D=E5=88=B7=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/main.tsx | 2 +- frontend/src/store/authStore.ts | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/frontend/src/main.tsx b/frontend/src/main.tsx index c63e1f3..f9cd159 100644 --- a/frontend/src/main.tsx +++ b/frontend/src/main.tsx @@ -7,7 +7,7 @@ import ErrorBoundary from './components/ErrorBoundary' import { ConfirmProvider } from './hooks/useConfirm' import './index.css' -const queryClient = new QueryClient({ +export const queryClient = new QueryClient({ defaultOptions: { queries: { staleTime: 1000 * 60 * 5, diff --git a/frontend/src/store/authStore.ts b/frontend/src/store/authStore.ts index 2010929..370b9f4 100644 --- a/frontend/src/store/authStore.ts +++ b/frontend/src/store/authStore.ts @@ -1,5 +1,6 @@ import { create } from 'zustand' import { persist } from 'zustand/middleware' +import { queryClient } from '../main' interface User { id: string @@ -26,11 +27,15 @@ export const useAuthStore = create()( accessToken: null, refreshToken: null, isAuthenticated: false, - setAuth: (user, accessToken, refreshToken) => - set({ user, accessToken, refreshToken, isAuthenticated: true }), + setAuth: (user, accessToken, refreshToken) => { + queryClient.clear() + set({ user, accessToken, refreshToken, isAuthenticated: true }) + }, updateToken: (accessToken) => set({ accessToken }), - logout: () => - set({ user: null, accessToken: null, refreshToken: null, isAuthenticated: false }), + logout: () => { + queryClient.clear() + set({ user: null, accessToken: null, refreshToken: null, isAuthenticated: false }) + }, }), { name: 'auth-storage' }, ),