diff --git a/src/components/Navbar.vue b/src/components/Navbar.vue index 4c3a8a9..da7ed08 100644 --- a/src/components/Navbar.vue +++ b/src/components/Navbar.vue @@ -12,8 +12,8 @@ class="button max-restore codicon" @click="windowMaxRestore" :class="{ - 'codicon-chrome-restore': windowIsMaximized, - 'codicon-chrome-maximize': !windowIsMaximized, + 'codicon-chrome-restore': !isWindowMaximized, + 'codicon-chrome-maximize': isWindowMaximized, }" >
{ + this.isWindowMaximized = value; + }); + } + }, methods: { go(where) { if (where === "back") this.$router.go(-1); @@ -165,19 +171,13 @@ export default { this.$router.push({ name: "login" }); }, windowMinimize() { - win.minimize(); + ipcRenderer.send("minimize"); }, windowMaxRestore() { - if (win.isMaximized()) { - win.restore(); - this.windowIsMaximized = false; - } else { - win.maximize(); - this.windowIsMaximized = true; - } + ipcRenderer.send("maximizeOrUnmaximize"); }, windowClose() { - win.close(); + ipcRenderer.send("close"); }, }, }; diff --git a/src/electron/ipcMain.js b/src/electron/ipcMain.js index b0dfcec..a16e46a 100644 --- a/src/electron/ipcMain.js +++ b/src/electron/ipcMain.js @@ -61,6 +61,12 @@ export function initIpcMain(win, store) { win.minimize(); }); + ipcMain.on("maximizeOrUnmaximize", () => { + const isMaximized = win.isMaximized(); + isMaximized ? win.unmaximize() : win.maximize(); + win.webContents.send("isMaximized", isMaximized); + }); + ipcMain.on("settings", (event, options) => { store.set("settings", options); const isRegisterShortcut = globalShortcut.isRegistered(