浏览代码

配置相关

zhangjie 2 年之前
父节点
当前提交
d8a00c06af

+ 0 - 1
config.sample.json

@@ -1,4 +1,3 @@
 {
-  "domain": "http://localhost:9000",
   "input": ""
 }

+ 0 - 4
src/config.js

@@ -1,4 +0,0 @@
-export default {
-  domain: process.env.VUE_APP_DOMAIN,
-  input: ""
-};

+ 3 - 7
src/main.js

@@ -62,17 +62,13 @@ axios.interceptors.request.use(
 
     // 为请求地址添加全局domain
     if (config.url.indexOf("http://") < 0) {
-      config.url = GLOBAL.domain + config.url;
+      let domain = Vue.ls.get("domain", "");
+      config.url = domain + config.url;
     }
 
     // 为请求头添加信息
-    let organizationId = Vue.ls.get("organizationId");
-    if (organizationId) {
-      config.headers["organizationId"] = organizationId;
-    }
-    let user = Vue.ls.get("user", { userId: "", examId: "" });
+    let user = Vue.ls.get("user", { userId: "" });
     config.headers["userId"] = user.userId;
-    config.headers["examId"] = user.examId;
 
     // 设置延迟时效
     config.timeout = 10 * 60 * 1000;

+ 8 - 6
src/mixins/initStoreMixin.js

@@ -27,14 +27,16 @@ export default {
     },
     async initStore() {
       const storeDict = await db.getAllDict();
-      const needInitDict = ["startCountTime", "lastLoginUser"];
-      for (let key in needInitDict) {
-        if (
-          !Object.prototype.hasOwnProperty.call(storeDict, needInitDict[key])
-        ) {
-          await db.initDict(needInitDict[key]);
+      const needInitDict = ["startCountTime", "lastLoginUser", "domain"];
+      for (let i = 0; i < needInitDict.length; i++) {
+        if (!Object.prototype.hasOwnProperty.call(storeDict, needInitDict[i])) {
+          await db.initDict(needInitDict[i]);
         }
       }
+
+      const domain = storeDict["domain"] || "";
+      this.$store.commit("setDomain", domain);
+      this.$ls.set("domain", domain);
     }
   }
 };

+ 1 - 0
src/modules/client/components/ScanTaskDialog.vue

@@ -120,6 +120,7 @@ export default {
       this.loading = true;
 
       this.startScan();
+      // TODO:唤起采集程序
     },
     async confirm() {
       await this.addUploadTask();

+ 4 - 1
src/modules/client/views/TaskManage.vue

@@ -155,7 +155,10 @@ export default {
       size: 10,
       total: 0,
       dataList: [],
-      curRow: {}
+      curRow: {},
+      recordList: [],
+      courseList: [],
+      teachingClassList: []
     };
   },
   methods: {

+ 6 - 0
src/modules/login/views/Login.vue

@@ -99,6 +99,12 @@ export default {
       this.$router.push({ name: "Setting" });
     },
     async submit() {
+      let domain = this.$ls.get("domain");
+      if (!domain) {
+        this.$message.error("请先配置域名!");
+        return;
+      }
+
       const valid = await this.$refs.loginForm.validate().catch(() => {});
       if (!valid) return;
 

+ 47 - 0
src/modules/login/views/Setting.vue

@@ -78,6 +78,8 @@
 </template>
 
 <script>
+import db from "@/plugins/db";
+
 export default {
   name: "setting",
   data() {
@@ -106,7 +108,41 @@ export default {
       loading: false
     };
   },
+  computed: {
+    domainEdited() {
+      return `http://${this.setModel.ipCont1}.${this.setModel.ipCont2}.${this.setModel.ipCont3}.${this.setModel.ipCont4}:${this.setModel.port}`;
+    },
+    domain() {
+      return this.$store.state.domain;
+    }
+  },
+  mounted() {
+    this.initData();
+  },
   methods: {
+    initData() {
+      if (!this.domain) {
+        this.setModel = {
+          ipCont1: undefined,
+          ipCont2: undefined,
+          ipCont3: undefined,
+          ipCont4: undefined,
+          port: undefined
+        };
+        return;
+      }
+
+      const [ipCont1, ipCont2, ipCont3, ipCont4, port] = this.domain
+        .replace("http://", "")
+        .split(/(\.|:)/);
+      this.setModel = {
+        ipCont1: Number(ipCont1),
+        ipCont2: Number(ipCont2),
+        ipCont3: Number(ipCont3),
+        ipCont4: Number(ipCont4),
+        port: Number(port)
+      };
+    },
     async submit() {
       if (this.loading) return;
       this.loading = true;
@@ -116,6 +152,17 @@ export default {
         this.loading = false;
         return;
       }
+
+      this.$store.commit("setDomain", this.domainEdited);
+      const res = await db.setDict("domain", this.domainEdited).catch(() => {});
+      if (res) {
+        this.$ls.set("domain", this.domainEdited);
+        this.$store.commit("setDomain", this.domainEdited);
+        this.$message.success("设置成功!");
+        this.$router.go(-1);
+      } else {
+        this.$message.error("保存失败!");
+      }
     }
   }
 };

+ 1 - 1
src/plugins/db.js

@@ -200,7 +200,7 @@ function setDict(key, val) {
     db.run(sql, [val, key], err => {
       if (err) reject(`update dict ${key} fail!`);
 
-      resolve();
+      resolve(true);
     });
   });
 }

+ 4 - 33
src/plugins/env.js

@@ -13,14 +13,7 @@ function initPath() {
     storePath,
     getInputDir(),
     getStoresDir("out"),
-    getOutputDir("formal"),
-    getOutputDir("slice"),
-    getTmpDir(),
-    // cropper
-    getStoresDir("cropper"),
-    path.join(getStoresDir("cropper"), "origin"),
-    path.join(getStoresDir("cropper"), "formal"),
-    path.join(getStoresDir("cropper"), "slice")
+    getOutputDir("origin")
   ];
   paths.forEach(path => {
     if (!fs.existsSync(path)) fs.mkdirSync(path);
@@ -55,23 +48,6 @@ function getDatabaseDir() {
   return getExtraDir("database");
 }
 
-function getImgDecodeTool() {
-  return path.join(getExtraDir("zxingA"), "zxing.exe");
-}
-
-function getFontPath() {
-  // 文件名必须是英文,否则会报错
-  return path.join(getExtraDir("font"), "simhei-subfont.ttf");
-}
-
-function getEncryptPath() {
-  return path.join(getExtraDir("encrypt"), "msyjencrypt.exe");
-}
-
-function getHardwareCheckPath() {
-  return path.join(getExtraDir("artControl"), "ArtControl.exe");
-}
-
 /**
  *
  * @param {String} pathContent 目录路径
@@ -90,9 +66,9 @@ function makeDirSync(pathContent) {
   });
 }
 
-function formatNum(num, [min, max]) {
-  return !num || num > max || num < min ? max : num;
-}
+// function formatNum(num, [min, max]) {
+//   return !num || num > max || num < min ? max : num;
+// }
 
 function initConfigData(data) {
   let configData = { ...data };
@@ -103,7 +79,6 @@ function initConfigData(data) {
   const configPath = path.join(homePath, "config.json");
   if (fs.existsSync(configPath)) {
     configData = JSON.parse(fs.readFileSync(configPath, "utf8"));
-    configData.compressRate = formatNum(configData.compressRate, [0, 100]);
     if (!configData.input) configData.input = getInputDir();
   } else {
     fs.writeFileSync(configPath, JSON.stringify(configData), "utf8");
@@ -122,9 +97,5 @@ export {
   getTmpDir,
   makeDirSync,
   getDatabaseDir,
-  getImgDecodeTool,
-  getFontPath,
-  getEncryptPath,
-  getHardwareCheckPath,
   initConfigData
 };

+ 3 - 1
src/store.js

@@ -9,12 +9,14 @@ import client from "./modules/client/store";
 export default new Vuex.Store({
   state: {
     user: {},
-    input: "",
     domain: ""
   },
   mutations: {
     setUser(state, user) {
       state.user = user;
+    },
+    setDomain(state, domain) {
+      state.domain = domain;
     }
   },
   actions: {},

+ 10 - 5
src/views/Layout.vue

@@ -82,12 +82,17 @@ export default {
       ipcRenderer.send("maximize-window");
     },
     close() {
-      this.$Modal.confirm({
-        content: "请确保当前窗口没有任务正在进行,确认要关闭当前窗口吗?",
-        onOk: () => {
-          ipcRenderer.send("close-window");
+      this.$confirm(
+        "请确保当前窗口没有任务正在进行,确认要关闭当前窗口吗?",
+        "提示",
+        {
+          type: "warning"
         }
-      });
+      )
+        .then(() => {
+          ipcRenderer.send("close-window");
+        })
+        .catch(() => {});
     }
   }
 };