刘洋 9 月之前
父节点
当前提交
9084e843b9

+ 5 - 12
build/build.js

@@ -18,7 +18,7 @@ const startMain = () => {
       if (removeErr) {
         throw removeErr;
       }
-      webpackConfig.mode = isDev ? "development" : "production";
+      webpackConfig.mode = "production";
       const compiler = webpack(webpackConfig);
       compiler.watch({}, (err, stats) => {
         if (err) throw err;
@@ -40,10 +40,12 @@ const startMain = () => {
         resolve();
         console.log(
           chalk.cyan(
-            `Build complete in ${stats.endTime - stats.startTime}ms.\n`
+            `Build complete production in ${
+              stats.endTime - stats.startTime
+            }ms.\n`
           )
         );
-
+        console.log("process.env.IS_BUILDER", process.env.IS_BUILDER);
         if (process.env.IS_BUILDER === "builder") process.exit();
       });
     });
@@ -55,15 +57,6 @@ const startElectron = () => {
   var args = ["--inspect=5858", resolve(__dirname, "../dist/main.js")];
   electronProcess = spawn(electron, args);
 
-  if (isDev) {
-    electronProcess.stdout.on("data", (data) => {
-      console.log(chalk.blue(data.toString()));
-    });
-    electronProcess.stderr.on("data", (data) => {
-      console.log(chalk.blue(data.toString()));
-    });
-  }
-
   electronProcess.on("close", () => {
     process.exit();
   });

+ 0 - 53
build/builder.json

@@ -1,53 +0,0 @@
-{
-  "productName": "通用扫描管理端",
-  "appId": "com.electron.qmth.scan-admin",
-  "directories": {
-    "output": "out"
-  },
-  "asar": true,
-  "files": [
-    "**/*",
-    "!src/",
-    "!out/",
-    "!static/",
-    "*.exe",
-    "*.dll"
-  ],
-  "nsis": {
-    "oneClick": false,
-    "allowElevation": true,
-    "allowToChangeInstallationDirectory": true,
-    "installerIcon": "./icons/icon.ico",
-    "uninstallerIcon": "./icons/icon.ico",
-    "installerHeaderIcon": "./icons/icon.ico",
-    "createDesktopShortcut": true,
-    "createStartMenuShortcut": true,
-    "shortcutName": "通用扫描管理端"
-  },
-  "mac": {
-    "icon": "./icons/icon.icns",
-    "artifactName": "${productName}-${os}-${version}-${arch}.${ext}",
-    "darkModeSupport": true,
-    "hardenedRuntime": false
-  },
-  "win": {
-    "icon": "./icons/icon.ico",
-    "artifactName": "${productName}-${os}-${version}-${arch}.${ext}",
-    "target": [
-      {
-        "target": "portable",
-        "arch": [
-          "ia32"
-        ]
-      }
-    ]
-  },
-  "linux": {
-    "icon": "./icons/icon.icns",
-    "artifactName": "${productName}-${os}-${version}-${arch}.${ext}",
-    "target": [
-      "deb"
-    ],
-    "category": "Utility"
-  }
-}

+ 85 - 0
build/dev.js

@@ -0,0 +1,85 @@
+const webpack = require("webpack");
+const { resolve } = require("path");
+const ora = require("ora");
+const { spawn } = require("child_process");
+const rm = require("rimraf");
+const chalk = require("chalk");
+const webpackConfig = require("./webpack.config.main.js");
+const electron = require("electron");
+const spinner = ora("building development electron...");
+spinner.start();
+let electronProcess = null;
+let manualRestart = false;
+
+const startMain = () => {
+  return new Promise((resolve) => {
+    rm("./dist/main.js", (removeErr) => {
+      if (removeErr) {
+        throw removeErr;
+      }
+      webpackConfig.mode = "development";
+      const compiler = webpack(webpackConfig);
+      compiler.watch({}, (err, stats) => {
+        if (err) throw err;
+        spinner.stop();
+        process.stdout.write(
+          stats.toString({
+            colors: true,
+            modules: false,
+            children: false,
+            chunks: false,
+            chunkModules: false,
+          }) + "\n\n"
+        );
+
+        if (stats.hasErrors()) {
+          console.log(chalk.red("Build failed with errors.\n"));
+          process.exit(1);
+        }
+        if (electronProcess && electronProcess.kill) {
+          manualRestart = true;
+          process.kill(electronProcess.pid);
+          electronProcess = null;
+          startElectron();
+
+          setTimeout(() => {
+            manualRestart = false;
+          }, 5000);
+        }
+        resolve();
+        console.log(
+          chalk.cyan(
+            `Build complete development in ${
+              stats.endTime - stats.startTime
+            }ms.\n`
+          )
+        );
+      });
+    });
+  });
+};
+
+const startElectron = () => {
+  var args = ["--inspect=5858", resolve(__dirname, "../dist/main.js")];
+  electronProcess = spawn(electron, args);
+
+  electronProcess.stdout.on("data", (data) => {
+    console.log(chalk.blue(data.toString()));
+  });
+  electronProcess.stderr.on("data", (data) => {
+    console.log(chalk.blue(data.toString()));
+  });
+
+  electronProcess.on("close", () => {
+    if (!manualRestart) process.exit();
+  });
+};
+async function init() {
+  try {
+    await startMain();
+    await startElectron();
+  } catch (error) {
+    console.error(error);
+  }
+}
+init();

+ 49 - 0
builder.json

@@ -0,0 +1,49 @@
+{
+    "productName": "通用扫描管理端",
+    "appId": "com.electron.qmth.scan-admin",
+    "directories": {
+        "output": "out"
+    },
+    "asar": true,
+    "files": [
+        "build/**/*",
+        "dist/**/*"
+    ],
+    "nsis": {
+        "oneClick": false,
+        "allowElevation": true,
+        "allowToChangeInstallationDirectory": true,
+        "installerIcon": "./icons/icon.ico",
+        "uninstallerIcon": "./icons/icon.ico",
+        "installerHeaderIcon": "./icons/icon.ico",
+        "createDesktopShortcut": true,
+        "createStartMenuShortcut": true,
+        "shortcutName": "通用扫描管理端"
+    },
+    "mac": {
+        "icon": "./icons/icon.icns",
+        "artifactName": "${productName}-${os}-${version}-${arch}.${ext}",
+        "darkModeSupport": true,
+        "hardenedRuntime": false
+    },
+    "win": {
+        "icon": "./icons/icon.ico",
+        "artifactName": "${productName}-${os}-${version}-${arch}.${ext}",
+        "target": [
+            {
+                "target": "portable",
+                "arch": [
+                    "ia32"
+                ]
+            }
+        ]
+    },
+    "linux": {
+        "icon": "./icons/icon.icns",
+        "artifactName": "${productName}-${os}-${version}-${arch}.${ext}",
+        "target": [
+            "deb"
+        ],
+        "category": "Utility"
+    }
+}

+ 5 - 3
package.json

@@ -6,11 +6,11 @@
   "scripts": {
     "start": "npm run dev",
     "dev": "node build/start.js",
-    "builder": "npm run build:vite --mode production && cross-env-shell IS_BUILDER=builder npm run build:main && electron-builder --config=./build/builder.json",
-    "dev:main": "node build/build.js",
+    "builder": "npm run build:vite && cross-env-shell IS_BUILDER=builder npm run build:main && electron-builder --config=./builder.json",
+    "dev:main": "node build/dev.js",
     "build:main": "node build/build.js",
     "dev:vite": "vite --mode development",
-    "build:vite": "vue-tsc --noEmit --skipLibCheck && vite build --mode production",
+    "build:vite": "vue-tsc --noEmit --skipLibCheck && vite build",
     "check": "vue-tsc --noEmit --skipLibCheck"
   },
   "main": "dist/main.js",
@@ -39,6 +39,7 @@
     "@babel/plugin-transform-runtime": "^7.11.5",
     "@babel/preset-env": "^7.11.5",
     "@babel/preset-react": "^7.10.4",
+    "@types/crypto-js": "^4.2.2",
     "@types/lodash-es": "^4.17.12",
     "@types/mockjs": "^1.0.10",
     "@types/node": "^20.6.1",
@@ -64,6 +65,7 @@
     "unplugin-vue-components": "^0.27.3",
     "unplugin-vue-setup-extend-plus": "^1.0.1",
     "vite": "^4.4.9",
+    "vue-tsc": "^2.1.4",
     "wait-on": "^7.0.1",
     "webpack": "^5.88.2",
     "webpack-cli": "^5.1.4",

+ 4 - 2
src/main/index.ts

@@ -24,7 +24,9 @@ function createWin() {
     transparent: true,
     webPreferences: {
       preload: path.resolve(__dirname, "preload.js"),
-      nodeIntegration: true,
+      contextIsolation: true,
+      webSecurity: false,
+      sandbox: false,
     },
   });
 
@@ -59,7 +61,7 @@ function createLoadWin() {
     transparent: true,
     skipTaskbar: true,
     resizable: false,
-    webPreferences: { experimentalFeatures: true },
+    // webPreferences: { experimentalFeatures: true },
   });
 
   loadWin.loadFile(path.resolve(__dirname, "static/load/index.html"));

+ 1 - 1
src/render/Layout/index.vue

@@ -2,7 +2,7 @@
   <div class="layout h-full">
     <div class="layout-header flex items-center justify-between">
       <div class="bread-space">
-        <img src="../../assets/imgs/bread_prefix_icon.png" />
+        <img src="../assets/imgs/bread_prefix_icon.png" />
         <div class="my-bread flex items-center">
           <div v-for="(r, i) in matched" :key="r.path">
             <span :class="{ 'cur-page': r.name === route.name }">{{

+ 0 - 5
src/render/components.d.ts

@@ -7,8 +7,6 @@ export {}
 /* prettier-ignore */
 declare module 'vue' {
   export interface GlobalComponents {
-    ABreadcrumb: typeof import('@qmth/ui')['Breadcrumb']
-    AButton: typeof import('@qmth/ui')['Button']
     AInput: typeof import('@qmth/ui')['Input']
     AInputNumber: typeof import('@qmth/ui')['InputNumber']
     ARadio: typeof import('@qmth/ui')['Radio']
@@ -19,10 +17,7 @@ declare module 'vue' {
     ATag: typeof import('@qmth/ui')['Tag']
     QmButton: typeof import('@qmth/ui')['QmButton']
     QmConfigProvider: typeof import('@qmth/ui')['QmConfigProvider']
-    QmDateRangePicker: typeof import('@qmth/ui')['QmDateRangePicker']
-    QmInput: typeof import('@qmth/ui')['QmInput']
     QmLowForm: typeof import('@qmth/ui')['QmLowForm']
-    QmModal: typeof import('@qmth/ui')['QmModal']
     RouterLink: typeof import('vue-router')['RouterLink']
     RouterView: typeof import('vue-router')['RouterView']
   }

+ 30 - 15
src/render/components/MyModal/index.vue

@@ -47,6 +47,7 @@
 <script lang="ts" name="QmModal" setup>
 import { ref, watch, nextTick, onMounted } from "vue";
 import { modalProps } from "ant-design-vue/es/modal/Modal";
+import { ModalProps } from "@qmth/ui";
 import {
   CloseOutlined,
   FullscreenOutlined,
@@ -55,21 +56,35 @@ import {
 import { throttle, omit } from "lodash-es";
 import { Modal, Space } from "ant-design-vue";
 
-const props = defineProps({
-  ...modalProps(),
-  fullscreen: {
-    type: Boolean,
-    default: false,
-  },
-  showFullScreen: {
-    type: Boolean,
-    default: false,
-  },
-  canDrag: {
-    type: Boolean,
-    default: false,
-  },
-});
+// const props = defineProps({
+//   ...modalProps(),
+//   fullscreen: {
+//     type: Boolean,
+//     default: false,
+//   },
+//   showFullScreen: {
+//     type: Boolean,
+//     default: false,
+//   },
+//   canDrag: {
+//     type: Boolean,
+//     default: false,
+//   },
+// });
+const props = withDefaults(
+  defineProps<
+    {
+      fullscreen?: boolean;
+      canDrag?: boolean;
+      showFullScreen?: boolean;
+    } & ModalProps
+  >(),
+  {
+    fullscreen: false,
+    canDrag: false,
+    showFullScreen: false,
+  }
+);
 
 const emit = defineEmits(["update:open", "update:fullscreen", "ok", "cancel"]);
 

+ 1 - 1
src/render/views/Login/IpSet.vue

@@ -48,7 +48,7 @@ import {
   CloseCircleFilled,
   SwapRightOutlined,
 } from "@ant-design/icons-vue";
-import FooterInfo from "@/components/FooterInfo";
+import FooterInfo from "@/components/FooterInfo/index.vue";
 import { local } from "@/utils/tool";
 
 const emit = defineEmits(["next"]);

+ 1 - 1
src/render/views/Login/LoginWays.vue

@@ -43,7 +43,7 @@ import {
   CloseCircleFilled,
   SwapRightOutlined,
 } from "@ant-design/icons-vue";
-import FooterInfo from "@/components/FooterInfo";
+import FooterInfo from "@/components/FooterInfo/index.vue";
 
 const emit = defineEmits(["next"]);
 const activeName = ref("scan");

+ 4 - 0
types/spark-md5.d.ts

@@ -0,0 +1,4 @@
+declare module "spark-md5" {
+  const SparkMD5: any;
+  export default SparkMD5;
+}