添加安装部署脚本

This commit is contained in:
admin
2026-05-11 10:41:36 +08:00
parent eae665d66f
commit ddb8746954
25 changed files with 1043 additions and 1 deletions
+15 -1
View File
@@ -13,7 +13,21 @@ interface RequestOptions extends RequestInit {
timeout?: number
}
const API_BASE_URL = import.meta.env.VITE_API_BASE_URL || ''
// 运行期配置优先(容器启动时由 nginx entrypoint 注入到 /config.js 写入 window.__APP_CONFIG__
// 构建期 VITE_API_BASE_URL 作为本地 dev 的 fallback
function resolveApiBaseUrl(): string {
if (typeof window !== 'undefined') {
const runtime = (window as unknown as { __APP_CONFIG__?: { apiBaseUrl?: string } }).__APP_CONFIG__
const url = runtime?.apiBaseUrl
// 占位符未替换时(如本地直接打开 public/config.js)忽略
if (url && !(url.startsWith('__') && url.endsWith('__'))) {
return url
}
}
return import.meta.env.VITE_API_BASE_URL || ''
}
const API_BASE_URL = resolveApiBaseUrl()
async function request<T = unknown>(url: string, options: RequestOptions = {}): Promise<T> {
url = `${API_BASE_URL}${url}`