Skip to content

Commit

Permalink
fix: base url
Browse files Browse the repository at this point in the history
  • Loading branch information
c121914yu committed Aug 24, 2023
1 parent a99ef9e commit e589350
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions client/src/api/service/request.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import axios, { Method, InternalAxiosRequestConfig, AxiosResponse } from 'axios';
import { baseUrl } from '../../service/ai/openai';

interface ConfigType {
headers?: { [key: string]: string };
Expand Down Expand Up @@ -60,7 +61,6 @@ function responseError(err: any) {

/* 创建请求实例 */
const instance = axios.create({
baseURL: global.systemEnv.pluginBaseUrl,
timeout: 60000, // 超时时间
headers: {
'content-type': 'application/json'
Expand All @@ -73,8 +73,8 @@ instance.interceptors.request.use(requestStart, (err) => Promise.reject(err));
instance.interceptors.response.use(responseSuccess, (err) => Promise.reject(err));

export function request(url: string, data: any, config: ConfigType, method: Method): any {
if (!global.systemEnv.pluginBaseUrl) {
return Promise.reject('请安装商业版插件~');
if (!global.systemEnv?.pluginBaseUrl) {
return Promise.reject('商业版插件加载中...');
}

/* 去空 */
Expand All @@ -86,6 +86,7 @@ export function request(url: string, data: any, config: ConfigType, method: Meth

return instance
.request({
baseURL: global.systemEnv.pluginBaseUrl,
url,
method,
data: ['POST', 'PUT'].includes(method) ? data : null,
Expand Down

0 comments on commit e589350

Please sign in to comment.