Browse Source

增加最小化快捷键,优化chart大小

Caner 2 years ago
parent
commit
767703c2c9
2 changed files with 13 additions and 4 deletions
  1. 11 2
      electron/main.js
  2. 2 2
      src/App.vue

+ 11 - 2
electron/main.js

@@ -7,6 +7,7 @@ const sleep = (ms) => new Promise(res => setTimeout(res, ms));
 class MainSerivce {
   #mqttChannel = null
   #client = null
+  #isMin = 1
   constructor() {
     Menu.setApplicationMenu(null) // 去掉菜单栏
     app.commandLine.appendSwitch('wm-window-animations-disabled') // 拖动闪屏
@@ -104,6 +105,14 @@ class MainSerivce {
       this.mainWin.webContents.toggleDevTools()
     })
 
+    // 最小化
+    globalShortcut.register('Ctrl+B', () => {
+      if(this.#isMin & 1) {this.mainWin.hide()}else{
+        this.mainWin.show()
+      }
+      this.#isMin++
+    })
+
     // 系统环境
     if (platform === 'win32') {
       // 右键
@@ -132,8 +141,7 @@ class MainSerivce {
         this.#closeMqtt()
         this.mainWin.close()
       } else if (evt === 'maxWin') {
-        const { width, height } = screen.getPrimaryDisplay().size
-        if (data) { this.mainWin.setBounds({ x: 0, y: 0, width, height }) } else {
+        if (data) { this.mainWin.maximize() } else {
           this.mainWin.setBounds({ width: 1300, height: 760 })
           this.mainWin.center()
         }
@@ -177,6 +185,7 @@ class MainSerivce {
     if (this.#client) this.#client.end()
     this.#client = null
     this.#mqttChannel = null
+    this.#isMin = 1
   }
 
   connectLogi() {

+ 2 - 2
src/App.vue

@@ -349,8 +349,8 @@ video {
   transform: translate(-50%, 0);
   width: 30vw;
   height: 15vw;
-  max-width: 480px;
-  max-height: 250px;
+  max-width: 460px;
+  max-height: 230px;
   z-index: 9;
 }