This commit is contained in:
2026-01-23 02:35:52 +08:00
parent 9849f93b1e
commit 2db3868fcf
39 changed files with 3381 additions and 164 deletions

32
src/modules/query.ts Normal file
View File

@@ -0,0 +1,32 @@
'use client';
import { QueryClient } from '@kevisual/query';
import { QueryLoginBrowser } from '@kevisual/api/login';
import { toast } from 'sonner';
// Only create instances in browser environment
const isBrowser = typeof window !== 'undefined';
export const query = isBrowser ? new QueryClient({}) : {} as QueryClient;
export const queryLogin = isBrowser
? new QueryLoginBrowser({
query: query as any,
})
: {} as QueryLoginBrowser;
if (isBrowser) {
(query as any).afterResponse = async (res, ctx) => {
const newRes = await queryLogin.run401Action(res, ctx, {
afterAlso401: () => {},
afterCheck: (res: any) => {
if (res.code === 200) {
toast.success('刷新登陆信息');
setTimeout(() => {
window.location.reload();
}, 2000);
}
},
});
return newRes as any;
};
}