29 lines
814 B
TypeScript
29 lines
814 B
TypeScript
import { toast } from 'sonner';
|
|
import { QueryClient } from '@kevisual/query';
|
|
import { QueryLoginBrowser } from '@kevisual/api/login';
|
|
export const query = new QueryClient({});
|
|
console.log('初始化 query', query);
|
|
export const clientQuery = new QueryClient({});
|
|
|
|
export const queryLogin = new QueryLoginBrowser({
|
|
query: query as any,
|
|
});
|
|
|
|
query.beforeRequest = queryLogin.beforeRequest.bind(queryLogin);
|
|
query.afterResponse = async (res, ctx) => {
|
|
const newRes = await queryLogin.run401Action(res, ctx, {
|
|
afterAlso401: () => {
|
|
},
|
|
afterCheck: (res) => {
|
|
console.log('afterCheck', res);
|
|
if (res.code === 200) {
|
|
toast.success('刷新登陆信息');
|
|
setTimeout(() => {
|
|
window.location.reload();
|
|
}, 1000);
|
|
}
|
|
},
|
|
});
|
|
return newRes as any;
|
|
};
|