fix: win32 titlebar issue

master
qier222 4 years ago
parent 2ecba8e161
commit f702c33834
No known key found for this signature in database
GPG Key ID: 9C85007ED905F14D

@ -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,
}"
></div>
<div
@ -98,11 +98,10 @@ import "vscode-codicons/dist/codicon.css";
import ContextMenu from "@/components/ContextMenu.vue";
import ButtonIcon from "@/components/ButtonIcon.vue";
let win = undefined;
if (process.env.IS_ELECTRON === true) {
const electron = require("electron");
win = electron.remote.BrowserWindow.getFocusedWindow();
}
const electron =
process.env.IS_ELECTRON === true ? window.require("electron") : null;
const ipcRenderer =
process.env.IS_ELECTRON === true ? electron.ipcRenderer : null;
export default {
name: "Navbar",
@ -115,7 +114,7 @@ export default {
inputFocus: false,
langs: ["zh-CN", "en", "tr"],
keywords: "",
windowIsMaximized: win ? win.isMaximized() : true,
isWindowMaximized: false,
};
},
computed: {
@ -129,6 +128,13 @@ export default {
: "http://s4.music.126.net/style/web2/img/default/default_avatar.jpg?param=60y60";
},
},
created() {
if (process.env.IS_ELECTRON === true) {
ipcRenderer.on("isMaximized", (event, value) => {
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");
},
},
};

@ -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(

Loading…
Cancel
Save