Integrate Chat and Copilot into chat-sdk, and add SQL parse display (#166)

This commit is contained in:
williamhliu
2023-10-02 18:05:12 +08:00
committed by GitHub
parent 741ed4191b
commit 71cb20eb4f
68 changed files with 1353 additions and 882 deletions

View File

@@ -5,7 +5,7 @@ import { getToken } from '../utils/utils';
// 创建axios实例
const axiosInstance: AxiosInstance = axios.create({
// 设置基本URL所有请求都会使用这个URL作为前缀
baseURL: '',
baseURL: localStorage.getItem('SUPERSONIC_CHAT_API_URL') || '',
// 设置请求超时时间(毫秒)
timeout: 120000,
// 设置请求头
@@ -19,7 +19,7 @@ axiosInstance.interceptors.request.use(
(config: any) => {
const token = getToken();
if (token && config?.headers) {
config.headers.Auth = `Bearer ${token}`;
// config.headers.Auth = `Bearer ${token}`;
config.headers.Authorization = `Bearer ${token}`;
}
return config;
@@ -33,18 +33,18 @@ axiosInstance.interceptors.request.use(
// 响应拦截器
axiosInstance.interceptors.response.use(
(response: any) => {
const redirect = response.headers.get('redirect');
const redirect = response.headers['redirect'];
if (redirect === 'REDIRECT') {
let win: any = window;
while (win !== win.top) {
win = win.top;
}
const contextpath = response.headers.get('contextpath');
const contextpath = response.headers['contextpath'];
win.location.href =
contextpath?.substring(0, contextpath?.indexOf('&')) +
`&redirect_uri=${encodeURIComponent(`http://${win.location.host}`)}`;
}
return response;
return response.data;
},
(error) => {
// 对响应错误进行处理