zhangjie 2 年 前
コミット
ebebc6d5dd

+ 18 - 12
src/assets/styles/login.scss

@@ -15,19 +15,25 @@
     top: 50px;
     right: 20px;
     z-index: auto;
-    border: 1px solid #fff;
-    border-radius: 5px;
-    padding: 6px 10px;
-    line-height: 1;
-    color: #fff;
-    cursor: pointer;
-
-    >i {
-      margin-right: 5px;
-    }
 
-    &:hover{
-      opacity: 0.8;
+    &-btn{
+      display: inline-block;
+      vertical-align: top;
+      border: 1px solid #fff;
+      border-radius: 5px;
+      padding: 6px 10px;
+      line-height: 1;
+      color: #fff;
+      margin-left: 10px;
+      cursor: pointer;
+  
+      >i {
+        margin-right: 5px;
+      }
+  
+      &:hover{
+        opacity: 0.8;
+      }
     }
   }
 }

+ 5 - 4
src/background.js

@@ -16,10 +16,11 @@ protocol.registerSchemesAsPrivileged([
   { scheme: "app", privileges: { secure: true, standard: true } }
 ]);
 
-if (process.env.WEBPACK_DEV_SERVER_URL) {
-  // app.commandLine.appendSwitch("enable-logging", true);
-  app.allowRendererProcessReuse = false;
-}
+// if (process.env.WEBPACK_DEV_SERVER_URL) {
+//   // app.commandLine.appendSwitch("enable-logging", true);
+//   app.allowRendererProcessReuse = false;
+// }
+app.allowRendererProcessReuse = false;
 
 function createWindow() {
   // Create the browser window.

+ 24 - 21
src/modules/client/components/ScanTaskProcessDialog.vue

@@ -68,14 +68,12 @@
 import {
   getPreUploadFiles,
   getPreUploadFileCount,
-  saveOutputImage
+  saveOutputImage,
+  clearDir
 } from "../../../plugins/imageOcr";
 import setTimeMixins from "../../../mixins/setTimeMixins";
 import db from "../../../plugins/db";
-const fs = require("fs");
-const childProcess = require("child_process");
-const util = require("util");
-const childProcessExec = util.promisify(childProcess.exec);
+import { evokeScanner } from "../../../plugins/scanner";
 
 export default {
   name: "scan-task-dialog",
@@ -166,25 +164,29 @@ export default {
     },
     async evokeScanExe() {
       console.log("唤起扫描仪");
-      const commandStr = `scan -scan -d ${this.GLOBAL.input}`;
-      const { stdout, stderr } = await childProcessExec(commandStr).catch(
-        error => {
-          console.log(error);
-        }
-      );
-
+      // console.log(commandStr);
+      await evokeScanner(this.GLOBAL.input).catch(error => {
+        console.dir(error);
+      });
       console.log("扫描仪停止");
       this.scanStatus = "PAUSE";
-      console.log(stdout, stderr);
-    },
-    async confirm() {
+
+      // 缓存已扫描的数据
       const res = getPreUploadFiles(this.GLOBAL.input);
       if (!res.succeed) {
         this.$message.error(res.errorMsg);
         return;
       }
+      this.scaningImageList.push(...res.data);
+
+      console.log(this.scaningImageList);
+    },
+    async confirm() {
+      if (!this.scaningImageList.length) {
+        this.$message.error("当前没有需要保存的数据!");
+        return;
+      }
 
-      this.scaningImageList = res.data;
       await this.saveScanImage();
 
       const confirm = await this.$confirm(`是否继续扫描?`, "提示", {
@@ -249,12 +251,13 @@ export default {
       }
     },
     clearScanList() {
-      for (let i = 0; i < this.scaningImageList.length; i++) {
-        const item = this.scaningImageList[i];
-        fs.unlinkSync(item.frontFile);
-        fs.unlinkSync(item.versoFile);
-      }
+      // for (let i = 0; i < this.scaningImageList.length; i++) {
+      //   const item = this.scaningImageList[i];
+      //   fs.unlinkSync(item.frontFile);
+      //   fs.unlinkSync(item.versoFile);
+      // }
       this.scaningImageList = [];
+      clearDir(this.GLOBAL.input);
     }
   }
 };

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

@@ -111,8 +111,8 @@
 
 <script>
 import { taskListPage } from "../api";
-// import ScanTaskProcessDialog from "../components/ScanTaskProcessDialog.vue";
-import ScanTaskProcessDialog from "../components/ScanTaskDialog.vue";
+import ScanTaskProcessDialog from "../components/ScanTaskProcessDialog.vue";
+// import ScanTaskProcessDialog from "../components/ScanTaskDialog.vue";
 
 export default {
   name: "task-manage",
@@ -139,7 +139,8 @@ export default {
       filter: {
         paperArchivesId: "",
         courseName: "",
-        teachClazzName: ""
+        teachClazzName: "",
+        isMine: false
       },
       current: 1,
       size: 10,

+ 14 - 2
src/modules/login/views/Login.vue

@@ -1,7 +1,12 @@
 <template>
   <div class="login" @keyup.enter="submit">
-    <div class="login-action" @click="toSet">
-      <i class="el-icon-s-tools"></i><span>设置</span>
+    <div class="login-action">
+      <div class="login-action-btn" @click="toSet">
+        <i class="el-icon-s-tools"></i><span>设置</span>
+      </div>
+      <div class="login-action-btn" @click="toSetScan">
+        <i class="el-icon-s-tools"></i><span>配置扫描仪</span>
+      </div>
     </div>
     <div class="login-body">
       <div class="login-title">
@@ -53,6 +58,7 @@ import { password } from "@/plugins/formRules";
 import { formatDate } from "../../../plugins/utils";
 import { login } from "../api";
 import { Base64 } from "@/plugins/crypto";
+import { setScanner } from "../../../plugins/scanner";
 
 export default {
   name: "login",
@@ -95,6 +101,12 @@ export default {
     toSet() {
       this.$router.push({ name: "Setting" });
     },
+    async toSetScan() {
+      await setScanner().catch(error => {
+        console.dir(error);
+        this.$message.error("连接扫描仪异常");
+      });
+    },
     async submit() {
       let domain = this.$ls.get("domain");
       if (!domain) {

+ 5 - 0
src/plugins/env.js

@@ -48,6 +48,10 @@ function getDatabaseDir() {
   return getExtraDir("database");
 }
 
+function getScanExePath() {
+  return path.join(extraPath, "scan", "scan.exe");
+}
+
 /**
  *
  * @param {String} pathContent 目录路径
@@ -94,6 +98,7 @@ export {
   getExtraDir,
   getInputDir,
   getOutputDir,
+  getScanExePath,
   getTmpDir,
   makeDirSync,
   getDatabaseDir,

+ 6 - 0
src/plugins/imageOcr.js

@@ -83,6 +83,12 @@ export function getPreUploadFileCount(dir) {
   return Math.ceil(files.length / 2);
 }
 
+export function clearDir(dir) {
+  fs.readdirSync(dir).forEach(file => {
+    fs.unlinkSync(path.join(dir, file));
+  });
+}
+
 export function getPreUploadFiles(dir) {
   const ddir = dir || getInputDir();
   const files = fs

+ 16 - 0
src/plugins/scanner.js

@@ -0,0 +1,16 @@
+import { getScanExePath } from "./env";
+const childProcess = require("child_process");
+const util = require("util");
+const childProcessExec = util.promisify(childProcess.exec);
+
+export function setScanner() {
+  const commandStr = `${getScanExePath()} -settings`;
+  console.log(commandStr);
+  return childProcessExec(commandStr);
+}
+
+export function evokeScanner(inputDir) {
+  const commandStr = `${getScanExePath()} -scan -d${inputDir}`;
+  // console.log(commandStr);
+  return childProcessExec(commandStr);
+}

+ 8 - 8
vue.config.js

@@ -3,24 +3,24 @@
 var config = {
   // publicPath: './',
   devServer: {
-    port: 8066,
+    port: 8066
   },
   pluginOptions: {
     electronBuilder: {
       externals: [],
       builderOptions: {
         extraFiles: [
-          "extra/gather/**",
+          "extra/scan/**",
           "extra/database/org.rdb",
-          "config.sample.json",
+          "config.sample.json"
         ],
         win: {
           target: "portable",
-          signAndEditExecutable: false,
-        },
-      },
-    },
-  },
+          signAndEditExecutable: false
+        }
+      }
+    }
+  }
 };
 
 module.exports = config;