刘洋 vor 9 Monaten
Ursprung
Commit
0cf209cf87

+ 10 - 3
src/main/index.ts

@@ -15,9 +15,9 @@ function createWin() {
   // Menu.setApplicationMenu(null);
   // 创建浏览器窗口
   win = new BrowserWindow({
-    width: 840,
+    width: 860,
     // width: width,
-    height: 500,
+    height: 520,
     // height: height,
     frame: false,
     resizable: false,
@@ -116,7 +116,10 @@ function startExe(exePath: string) {
     : exePath;
   const fileExists = fs.existsSync(checkPath);
   if (fileExists) {
-    exec(exePath);
+    exec(exePath, (error, stdout, stderr) => {
+      console.log("子进程关闭了!");
+      win?.show();
+    });
   } else {
     dialog.showErrorBox("tip", `${checkPath}不存在!`);
   }
@@ -126,6 +129,10 @@ ipcMain.on("startExe", (event, args: string) => {
   startExe(args);
 });
 
+ipcMain.on("hide-app", () => {
+  win?.hide();
+});
+
 app.on("ready", async () => {
   if (isDev) {
     try {

+ 2 - 0
src/main/preload/index.ts

@@ -80,6 +80,8 @@ contextBridge.exposeInMainWorld("electronApi", {
     const watchStep = (rs: any, rj: any) => {
       isRunning("client.exe", (status: boolean) => {
         if (status) {
+          //说明扫描端已经成功启动,需要隐藏本应用,待监听扫描端关闭时,再显示本登录界面
+          ipcRenderer.send("hide-app");
           rs(true);
         } else {
           if (num == 0) {

+ 8 - 0
src/render/styles/base.less

@@ -61,3 +61,11 @@ body {
 .tips-error {
   color: @error-color;
 }
+.drag {
+  /* 设置该属性表明这是可拖拽区域,用来移动窗口 */
+  -webkit-app-region: drag;
+}
+
+.no-drag {
+  -webkit-app-region: no-drag;
+}

+ 0 - 14
src/render/views/Login/AdminLogin.vue

@@ -15,13 +15,6 @@
         >返回选择登录身份</qm-button
       >
     </div>
-    <qm-button
-      :icon="h(GlobalOutlined)"
-      class="reset-btn"
-      @click="emit('toIndex', 0)"
-    >
-      连接设置</qm-button
-    >
   </div>
 </template>
 <script name="AdminLogin" lang="ts" setup>
@@ -99,13 +92,6 @@ const fields = ref([
 <style lang="less" scoped>
 .admin-login {
   padding: 88px 80px 0 80px;
-  position: relative;
-  :deep(.reset-btn) {
-    position: absolute;
-    top: 25px;
-    right: 65px;
-    z-index: 1;
-  }
   .title {
     color: @text-color1;
     font-weight: bold;

+ 10 - 23
src/render/views/Login/LoginWays.vue

@@ -34,13 +34,6 @@
         <footer-info></footer-info>
       </div>
     </div>
-    <qm-button
-      :icon="h(GlobalOutlined)"
-      class="reset-btn"
-      @click="emit('toIndex', 0)"
-    >
-      连接设置</qm-button
-    >
   </div>
 </template>
 <script name="LoginWays" lang="ts" setup>
@@ -78,19 +71,20 @@ const nextStep = async () => {
       spinning: true,
       tip: "扫描端启动中...",
     };
-    setTimeout(() => {
-      //如果10秒了扫描端还没启动起来,估计有异常情况,于是关掉全屏loading
+    // setTimeout(() => {
+    //   //如果10秒了扫描端还没启动起来,估计有异常情况,于是关掉全屏loading
+    //   appStore.loadingStatus = {
+    //     spinning: false,
+    //     tip: "",
+    //   };
+    // }, 10000);
+    //同时监测进程,如果发现扫描端启动了,立刻关掉全屏loading,且隐藏本项目
+    try {
+      await window.electronApi?.watchScanProcess();
       appStore.loadingStatus = {
         spinning: false,
         tip: "",
       };
-    }, 10000);
-    //同时监测进程,如果发现扫描端启动了,立刻关掉全屏loading,且关掉本项目
-    try {
-      let result = await window.electronApi?.watchScanProcess();
-      if (result) {
-        window.close();
-      }
     } catch (err: any) {
       appStore.loadingStatus = {
         spinning: false,
@@ -106,13 +100,6 @@ const nextStep = async () => {
 <style lang="less" scoped>
 .login-ways {
   padding-top: 120px;
-  position: relative;
-  :deep(.reset-btn) {
-    position: absolute;
-    top: 25px;
-    right: 65px;
-    z-index: 1;
-  }
   .level2 {
     .text-right {
       padding-right: 24px;

+ 27 - 1
src/render/views/Login/index.vue

@@ -1,5 +1,14 @@
 <template>
   <div class="login h-full flex justify-center items-center">
+    <div class="drag"></div>
+    <qm-button
+      v-if="curStepIndex == 2 || curStepIndex == 3"
+      :icon="h(GlobalOutlined)"
+      class="reset-btn"
+      @click="toIndex(0)"
+    >
+      连接设置</qm-button
+    >
     <div class="login-base flex">
       <span class="close" @click="willClose">&times;</span>
       <div class="left-bg-box"></div>
@@ -15,7 +24,7 @@
   </div>
 </template>
 <script name="Login" lang="ts" setup>
-import { ref, onMounted } from "vue";
+import { ref, onMounted, h } from "vue";
 import { closeApp } from "@/utils";
 import EnvCheck from "./EnvCheck.vue";
 import IpSet from "./IpSet.vue";
@@ -24,6 +33,7 @@ import AdminLogin from "./AdminLogin.vue";
 import { local } from "@/utils/tool";
 import { useAppStore } from "@/store";
 import { getServerStatus } from "@/ap/system";
+import { GlobalOutlined } from "@ant-design/icons-vue";
 
 const appStore = useAppStore();
 
@@ -75,6 +85,22 @@ const willClose = () => {
 <style lang="less" scoped>
 .login {
   height: 100%;
+  position: relative;
+  :deep(.reset-btn) {
+    position: absolute;
+    top: 25px;
+    right: 65px;
+    z-index: 2;
+  }
+  & > .drag {
+    position: absolute;
+    z-index: 1;
+    left: 0;
+    top: 0;
+    right: 175px;
+    height: 80px;
+    z-index: 1;
+  }
   .close {
     position: absolute;
     z-index: 10;