use local API when it's working, even if a custom API URL is provided

This commit is contained in:
josc146 2023-11-17 21:53:29 +08:00
parent c8470e77fd
commit d18218f21a

View File

@ -290,12 +290,15 @@ export function bytesToReadable(size: number) {
}
export function getServerRoot(defaultLocalPort: number) {
const defaultRoot = `http://127.0.0.1:${defaultLocalPort}`;
if (commonStore.status.status !== ModelStatus.Offline)
return defaultRoot;
const customApiUrl = commonStore.settings.apiUrl.trim().replace(/\/$/, '');
if (customApiUrl)
return customApiUrl;
if (commonStore.platform === 'web')
return '';
return `http://127.0.0.1:${defaultLocalPort}`;
return defaultRoot;
}
export function absPathAsset(path: string) {