You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
886 B
21 lines
886 B
import { message } from 'antd'
|
|
import { request } from "@peace/react_client";
|
|
import { clearCompatibleAuthInfo } from "../../../utils/authCompat";
|
|
|
|
export const apiRequest = new request({
|
|
proxy: '/_52', // 代理前缀 与 `config.cjs` 中的 `proxy` 保持一致 才可生效
|
|
userKey: 'user', // session 中的用户键值,用于拼接 token,默认为 `user`,session中没有也不影响使用
|
|
message: message, // 全局提示组件,用于提示请求结果(如果需要)
|
|
timeout: 30000, // 30s
|
|
interceptor: (res, err) => { // 拦截器,用于处理请求结果,两参数互斥出现
|
|
if (err) {
|
|
if (err?.status === 401) {
|
|
clearCompatibleAuthInfo()
|
|
window.location.replace('/chat');
|
|
}
|
|
return err
|
|
}
|
|
return res
|
|
}
|
|
})
|
|
|
|
|