Quellcode durchsuchen

fix mode test build

Michael Wang vor 3 Jahren
Ursprung
Commit
7ff7698096
2 geänderte Dateien mit 7 neuen und 3 gelöschten Zeilen
  1. 2 1
      .env.test
  2. 5 2
      src/utils/nativeMethods.ts

+ 2 - 1
.env.test

@@ -1,2 +1,3 @@
 VITE_SLS_STORE_NAME=student-client-test
-VITE_CONFIG_FILE_SEVER_URL=https://ecs-test-static.qmth.com.cn
+VITE_CONFIG_FILE_SEVER_URL=https://ecs-test-static.qmth.com.cn
+NODE_ENV=production

+ 5 - 2
src/utils/nativeMethods.ts

@@ -10,7 +10,7 @@ const fs: typeof import("fs") = isElectron() && window.nodeRequire("fs");
 
 /** 执行本地exe文件 */
 export function execLocal(exeName: string): Promise<void> {
-  if (isElectron()) {
+  if (!isElectron()) {
     logger({
       pgu: "AUTO",
       cnl: ["local", "server"],
@@ -18,6 +18,9 @@ export function execLocal(exeName: string): Promise<void> {
     });
     throw new Error("不在Electron中,调用 fs 失败");
   }
+  if (import.meta.env.DEV) {
+    return Promise.resolve();
+  }
   return new Promise<void>((resolve) => {
     // eslint-disable-next-line
     window
@@ -71,7 +74,7 @@ export function execLocal(exeName: string): Promise<void> {
 
 /** 文件路径是否存在 */
 export function fileExists(file: string): boolean {
-  if (typeof window.nodeRequire == "undefined") {
+  if (!isElectron()) {
     logger({
       pgu: "AUTO",
       cnl: ["local", "server"],