fix: icon url incorrect in prod

This commit is contained in:
Junyan Qin
2025-05-10 11:07:00 +08:00
parent 101931a258
commit d4cf6f650d
+13 -2
View File
@@ -69,7 +69,6 @@ class HttpClient {
// 兜底URL,如果使用未配置会走到这里 // 兜底URL,如果使用未配置会走到这里
private getBaseUrl(): string { private getBaseUrl(): string {
return 'http://localhost:5300';
// NOT IMPLEMENT // NOT IMPLEMENT
if (typeof window === 'undefined') { if (typeof window === 'undefined') {
// 服务端环境 // 服务端环境
@@ -228,6 +227,12 @@ class HttpClient {
} }
public getProviderRequesterIconURL(name: string): string { public getProviderRequesterIconURL(name: string): string {
if (this.instance.defaults.baseURL === '/') {
// 获取用户访问的URL
const url = window.location.href;
const baseURL = url.split('/').slice(0, 3).join('/');
return `${baseURL}/api/v1/provider/requesters/${name}/icon`;
}
return ( return (
this.instance.defaults.baseURL + this.instance.defaults.baseURL +
`/api/v1/provider/requesters/${name}/icon` `/api/v1/provider/requesters/${name}/icon`
@@ -289,6 +294,12 @@ class HttpClient {
} }
public getAdapterIconURL(name: string): string { public getAdapterIconURL(name: string): string {
if (this.instance.defaults.baseURL === '/') {
// 获取用户访问的URL
const url = window.location.href;
const baseURL = url.split('/').slice(0, 3).join('/');
return `${baseURL}/api/v1/platform/adapters/${name}/icon`;
}
return ( return (
this.instance.defaults.baseURL + `/api/v1/platform/adapters/${name}/icon` this.instance.defaults.baseURL + `/api/v1/platform/adapters/${name}/icon`
); );
@@ -421,7 +432,7 @@ class HttpClient {
// export const httpClient = new HttpClient("https://version-4.langbot.dev"); // export const httpClient = new HttpClient("https://version-4.langbot.dev");
// export const httpClient = new HttpClient('http://localhost:5300'); // export const httpClient = new HttpClient('http://localhost:5300');
export const httpClient = new HttpClient(''); export const httpClient = new HttpClient('/');
// 临时写法,未来两种Client都继承自HttpClient父类,不允许共享方法 // 临时写法,未来两种Client都继承自HttpClient父类,不允许共享方法
export const spaceClient = new HttpClient('https://space.langbot.app'); export const spaceClient = new HttpClient('https://space.langbot.app');