From 9ea5ff67655241271bdf04bb50ca3a8d60c4e22a Mon Sep 17 00:00:00 2001
From: yuan <123@>
Date: 星期二, 11 八月 2026 15:07:02 +0800
Subject: [PATCH] fix: 用河南鹤壁代码覆盖山西长治

---
 multiple/multiple-build.js |   25 ++++++++++++++++++++++---
 1 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/multiple/multiple-build.js b/multiple/multiple-build.js
index b1b7f5f..933090c 100644
--- a/multiple/multiple-build.js
+++ b/multiple/multiple-build.js
@@ -60,12 +60,15 @@
     const backupFile = path.join(replacePath, config[key]);
     const replaceFile = path.join(resourcePath, companyMap[key]);
 
-    await copyFileWithOverwrite(originFile, backupFile);
+    if (fsSync.existsSync(originFile)) {
+      await copyFileWithOverwrite(originFile, backupFile);
+    }
     await copyFileWithOverwrite(replaceFile, originFile);
   }
 
   console.log("=====寮�濮嬫墦鍖�=====");
-  execSync("vite build", { stdio: "inherit" });
+  const buildEnv = createBuildEnv(companyMap.env);
+  execSync("vite build", { stdio: "inherit", cwd: rootPath, env: buildEnv });
   console.log("=====鎵撳寘瀹屾垚======");
 } finally {
   console.log("=====鎭㈠璧勬簮======");
@@ -81,7 +84,9 @@
 
       const originFile = path.join(rootPath, config[key]);
       const backupFile = path.join(replacePath, config[key]);
-      await copyFileWithOverwrite(backupFile, originFile);
+      if (fsSync.existsSync(backupFile)) {
+        await copyFileWithOverwrite(backupFile, originFile);
+      }
     }
     await fs.rm(replacePath, { recursive: true, force: true });
     console.log(`馃棏锔� 宸插垹闄� ${replacePath}`);
@@ -135,3 +140,17 @@
   if (!trimmed) return undefined;
   return trimmed.replace(/^["']|["']$/g, "");
 }
+
+function createBuildEnv(companyEnv) {
+  const env = { ...process.env };
+  for (const key of Object.keys(env)) {
+    if (key.startsWith("VITE_")) {
+      delete env[key];
+    }
+  }
+  return {
+    ...env,
+    ...companyEnv,
+    VITE_APP_ENV: "production",
+  };
+}

--
Gitblit v1.9.3