From f717f1d48193593b31306d7f3036faff9f59c1f3 Mon Sep 17 00:00:00 2001 From: mengdaoshizhongxinyang Date: Mon, 5 Oct 2026 17:02:58 +0800 Subject: [PATCH] feat: point production host at project57 embed JS [deploy] --- .env.production | 2 ++ .gitea/workflows/ci.yml | 6 +++--- README.md | 5 ++++- src/main.ts | 11 +++++------ 4 files changed, 14 insertions(+), 10 deletions(-) create mode 100644 .env.production diff --git a/.env.production b/.env.production new file mode 100644 index 0000000..08582c5 --- /dev/null +++ b/.env.production @@ -0,0 +1,2 @@ +# A 站(project57)线上源站。构建时写入,B 站用它加载 aurora.js / 图片 / 表单 API。 +VITE_A_ORIGIN=https://swissicapital.net diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 0ae655c..0d1eb2e 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -130,10 +130,10 @@ jobs: VITE_A_ORIGIN: ${{ secrets.VITE_A_ORIGIN }} run: | if [ -z "${VITE_A_ORIGIN}" ]; then - echo "❌ 未配置 Secret VITE_A_ORIGIN(A 站源站,如 https://swissicapital.net)" - exit 1 + echo "ℹ️ Secret VITE_A_ORIGIN 未配置,改用 .env.production" + else + echo "VITE_A_ORIGIN=${VITE_A_ORIGIN}" fi - echo "VITE_A_ORIGIN=${VITE_A_ORIGIN}" pnpm build echo "✅ Build completed" if [ -d "dist" ] && [ -f "dist/index.html" ]; then diff --git a/README.md b/README.md index 0d97163..228de95 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,10 @@ CI 对齐 **project0**(本地 `projectBase`):提交信息带 `[deploy]` - `LFS_PAT` - `KUBECONFIG_BASE64` -- `VITE_A_ORIGIN`:A 站线上源站,如 `https://swissicapital.net` +- `VITE_A_ORIGIN`(可选):覆盖 `.env.production` 里的 A 站地址 +- 默认生产源站:`https://swissicapital.net`(加载 `/embed/aurora.js`) + +A 站需已部署嵌入包(`pnpm build` 会先跑 `build:embed`)。 ## 本地运行 diff --git a/src/main.ts b/src/main.ts index f9c86eb..6d976b5 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,7 +1,6 @@ -const A_ORIGIN = (import.meta.env.VITE_A_ORIGIN || "http://localhost:3000").replace( - /\/$/, - "" -); +const A_ORIGIN = ( + import.meta.env.VITE_A_ORIGIN || "https://swissicapital.net" +).replace(/\/$/, ""); const errorEl = document.getElementById("aurora-error"); @@ -24,7 +23,7 @@ function loadScript(src: string): Promise { async function boot() { try { - await loadScript(`${A_ORIGIN}/embed/aurora.js`); + await loadScript(`${A_ORIGIN}/embed/aurora.js?v=1`); } catch { showError( `无法加载 A 站脚本:${A_ORIGIN}/embed/aurora.js。请先在 project57 执行 pnpm build:embed 并启动 A 站,或修改 .env 中的 VITE_A_ORIGIN。` @@ -41,7 +40,7 @@ async function boot() { api.mount("#aurora-root", { assetBase: A_ORIGIN, apiBase: A_ORIGIN, - cssUrl: `${A_ORIGIN}/embed/aurora.css`, + cssUrl: `${A_ORIGIN}/embed/aurora.css?v=1`, history: "hash", }); }