mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-06-07 14:26:03 +00:00
feat: set cloud_service_url
This commit is contained in:
@@ -151,6 +151,7 @@ export interface PluginReorderElement {
|
||||
export interface ApiRespSystemInfo {
|
||||
debug: boolean;
|
||||
version: string;
|
||||
cloud_service_url: string;
|
||||
}
|
||||
|
||||
export interface ApiRespAsyncTasks {
|
||||
|
||||
@@ -53,7 +53,11 @@ export interface RequestConfig extends AxiosRequestConfig {
|
||||
retry?: number; // 重试次数
|
||||
}
|
||||
|
||||
export let systemInfo: ApiRespSystemInfo | null = null;
|
||||
export let systemInfo: ApiRespSystemInfo = {
|
||||
debug: false,
|
||||
version: '',
|
||||
cloud_service_url: '',
|
||||
};
|
||||
|
||||
class HttpClient {
|
||||
private instance: AxiosInstance;
|
||||
@@ -74,7 +78,10 @@ class HttpClient {
|
||||
this.disableToken = disableToken || false;
|
||||
this.initInterceptors();
|
||||
|
||||
if (systemInfo === null && baseURL != 'https://space.langbot.app') {
|
||||
if (
|
||||
systemInfo.cloud_service_url === '' &&
|
||||
baseURL != 'https://space.langbot.app'
|
||||
) {
|
||||
this.getSystemInfo().then((res) => {
|
||||
systemInfo = res;
|
||||
});
|
||||
@@ -86,12 +93,6 @@ class HttpClient {
|
||||
return this.baseURL;
|
||||
}
|
||||
|
||||
// 获取Session
|
||||
private async getSession() {
|
||||
// NOT IMPLEMENT
|
||||
return '';
|
||||
}
|
||||
|
||||
// 同步获取Session
|
||||
private getSessionSync() {
|
||||
// NOT IMPLEMENT
|
||||
@@ -505,4 +506,4 @@ const getBaseURL = (): string => {
|
||||
export const httpClient = new HttpClient(getBaseURL());
|
||||
|
||||
// 临时写法,未来两种Client都继承自HttpClient父类,不允许共享方法
|
||||
export const spaceClient = new HttpClient('https://space.langbot.app');
|
||||
export const spaceClient = new HttpClient(systemInfo.cloud_service_url);
|
||||
|
||||
Reference in New Issue
Block a user