mirror of
https://github.com/stardrophere/InsightRadar.git
synced 2026-08-04 21:27:24 +08:00
optimize+注释
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
/**
|
||||
* API 基础配置:自动探测内网/公网后端,失败时回退公网
|
||||
*/
|
||||
const API_PREFIX = '/api/v1'
|
||||
const LAN_BACKEND_ORIGIN = 'http://10.252.130.135:8000'
|
||||
const PUBLIC_BACKEND_ORIGIN = 'http://47.107.130.88:51290'
|
||||
@@ -42,6 +45,7 @@ function isLanHostname(hostname: string): boolean {
|
||||
return isPrivateIpv4(normalized)
|
||||
}
|
||||
|
||||
// 探测内网后端是否可用(请求 openapi.json)
|
||||
async function probeLanBackend(): Promise<boolean> {
|
||||
if (typeof window === 'undefined') return false
|
||||
|
||||
@@ -69,6 +73,7 @@ async function probeLanBackend(): Promise<boolean> {
|
||||
}
|
||||
}
|
||||
|
||||
// 根据当前 hostname 与探测结果选择内网或公网 API 地址
|
||||
async function detectApiBaseUrl(): Promise<string> {
|
||||
if (ENV_API_BASE_URL) return ENV_API_BASE_URL
|
||||
if (typeof window === 'undefined') return PUBLIC_API_BASE_URL
|
||||
|
||||
Reference in New Issue
Block a user