2024-10-18 02:26:14 +08:00

21 lines
631 B
JavaScript

import { QueryClient } from 'https://kevisual.xiongxiao.me/system/lib';
const env = window.env || {};
const isDev = location.hostname === 'localhost';
const productionUrl = env?.productionUrl || 'https://envision.xiongxiao.me/api/router';
const url = isDev ? 'http://localhost:4002/api/router' : productionUrl;
export const query = new QueryClient({
url,
});
query.after((res) => {
const pathname = window.location.pathname;
if (res.code === 401 && !pathname.includes('login')) {
console.log('401');
if (env?.needLogin) {
window.location.href = env?.needLoginUrl || '/user/login';
}
}
return res;
});