This commit is contained in:
oneao committed 2026-03-18 17:29:39 +08:00
1 parent 68f08d921a
commit 3656d05f62
97 files changed
+17495

No files matched your search

@@ -0,0 +1,28 @@
export function getServerBaseUrl(): string {
const origin = window.location.origin
const publicBase = import.meta.env.VITE_APP_PUBLIC_BASE || '/'
// 拼接时去掉 publicBase 开头和结尾的斜杠(只保留中间路径)
const cleanBase = publicBase.replace(/^\/+|\/+$/g, '')
return cleanBase ? `${origin}/${cleanBase}` : origin
}
export async function getDbConfigs(): Promise<Record<string, any> | null> {
const serverBaseUrl = getServerBaseUrl()
try {
const response = await fetch(`${serverBaseUrl}/static/db.json`)
if (!response.ok) {
console.error('Failed to fetch db.json:', response.status)
return null
}
const data: Record<string, any> = await response.json()
return data
}
catch (error) {
console.error('Error fetching db.json:', error)
return null
}
}