添加ai请求地址
This commit is contained in:
@@ -45,6 +45,46 @@ export function createServiceConfig(env: Env.ImportMeta) {
|
||||
|
||||
return config;
|
||||
}
|
||||
let aiUrl = '';
|
||||
export function createAiServiceConfig(env: Env.ImportMeta) {
|
||||
const { VITE_SERVICE_BASE_URL, VITE_OTHER_SERVICE_BASE_URL } = env;
|
||||
|
||||
let other = {} as Record<App.Service.OtherBaseURLKey, string>;
|
||||
try {
|
||||
other = json5.parse(VITE_OTHER_SERVICE_BASE_URL);
|
||||
} catch {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error('VITE_OTHER_SERVICE_BASE_URL is not a valid json5 string');
|
||||
}
|
||||
if(env.DEV){
|
||||
aiUrl = 'http://192.168.0.230:8085/proxy-ai';
|
||||
}else{
|
||||
// url = window.location.origin;
|
||||
aiUrl = '/api';
|
||||
}
|
||||
const httpConfig: App.Service.SimpleServiceConfig = {
|
||||
baseURL: aiUrl,
|
||||
other
|
||||
};
|
||||
|
||||
const otherHttpKeys = Object.keys(httpConfig.other) as App.Service.OtherBaseURLKey[];
|
||||
|
||||
const otherConfig: App.Service.OtherServiceConfigItem[] = otherHttpKeys.map(key => {
|
||||
return {
|
||||
key,
|
||||
baseURL: httpConfig.other[key],
|
||||
proxyPattern: createProxyPattern(key)
|
||||
};
|
||||
});
|
||||
|
||||
const config: App.Service.ServiceConfig = {
|
||||
baseURL: httpConfig.baseURL,
|
||||
proxyPattern: createProxyPattern(),
|
||||
other: otherConfig
|
||||
};
|
||||
|
||||
return config;
|
||||
}
|
||||
export function getBaseUrl() {
|
||||
return url;
|
||||
}
|
||||
@@ -69,6 +109,20 @@ export function getServiceBaseURL(env: Env.ImportMeta, isProxy: boolean) {
|
||||
otherBaseURL
|
||||
};
|
||||
}
|
||||
export function getServiceAiURL(env: Env.ImportMeta, isProxy: boolean) {
|
||||
const { baseURL, other } = createAiServiceConfig(env);
|
||||
|
||||
const otherBaseURL = {} as Record<App.Service.OtherBaseURLKey, string>;
|
||||
|
||||
other.forEach(item => {
|
||||
otherBaseURL[item.key] = isProxy ? item.proxyPattern : item.baseURL;
|
||||
});
|
||||
|
||||
return {
|
||||
baseURL: isProxy ? createProxyPattern() : baseURL,
|
||||
otherBaseURL
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Get proxy pattern of backend service base url
|
||||
|
||||
Reference in New Issue
Block a user