Pārlūkot izejas kodu

优化登录配置

Michael Wang 2 gadi atpakaļ
vecāks
revīzija
076b06e938
2 mainītis faili ar 17 papildinājumiem un 19 dzēšanām
  1. 13 11
      prebuild.mjs
  2. 4 8
      src/devLogin.ts

+ 13 - 11
prebuild.mjs

@@ -1,4 +1,4 @@
-import { writeFileSync, existsSync } from "fs";
+import { writeFileSync, existsSync, readFileSync } from "fs";
 import { execSync } from "child_process";
 import moment from "moment";
 import packageJson from "./package.json" assert { type: "json" };
@@ -50,19 +50,21 @@ VITE_GIT_REPO_VERSION=${revision}
 );
 
 // 如果不存在则创建,对真正的构建无影响
-if (!existsSync("./src/devLoginParams.ts")) {
+if (
+  !existsSync("./src/devLoginParams.ts") &&
+  !readFileSync("./src/devLoginParams.ts").toString().includes("LOGIN_CONFIG")
+) {
   writeFileSync(
     "./src/devLoginParams.ts",
     `
-    export const isAdmin = false;
-    export let forceChange = false;
-    forceChange = true;
-    
-    // 很多任务,选分组2
-    export const loginName = "";
-    export const password = "";
-    export const examId = "";
-    export const markerId = "";
+    export const LOGIN_CONFIG = {
+      isAdmin: false,
+      forceChange: true,
+      loginName: "1-431-2-1",
+      password: "123456",
+      examId: "1",
+      markerId: "451",
+    };    
     `
   );
 }

+ 4 - 8
src/devLogin.ts

@@ -1,11 +1,7 @@
-import {
-  loginName,
-  password,
-  examId,
-  markerId,
-  isAdmin,
-  forceChange,
-} from "@/devLoginParams";
+import { LOGIN_CONFIG } from "@/devLoginParams";
+
+const { loginName, password, examId, markerId, isAdmin, forceChange } =
+  LOGIN_CONFIG;
 
 export async function initLogin() {
   if (document.cookie.includes("stmms_cookie") && !forceChange) return;