mirror of
https://github.com/GiriNeko/YesPlayMusic.git
synced 2025-12-16 13:17:46 +00:00
fix: win32 titlebar issue
This commit is contained in:
parent
2ecba8e161
commit
f702c33834
2 changed files with 23 additions and 17 deletions
|
|
@ -12,8 +12,8 @@
|
||||||
class="button max-restore codicon"
|
class="button max-restore codicon"
|
||||||
@click="windowMaxRestore"
|
@click="windowMaxRestore"
|
||||||
:class="{
|
:class="{
|
||||||
'codicon-chrome-restore': windowIsMaximized,
|
'codicon-chrome-restore': !isWindowMaximized,
|
||||||
'codicon-chrome-maximize': !windowIsMaximized,
|
'codicon-chrome-maximize': isWindowMaximized,
|
||||||
}"
|
}"
|
||||||
></div>
|
></div>
|
||||||
<div
|
<div
|
||||||
|
|
@ -98,11 +98,10 @@ import "vscode-codicons/dist/codicon.css";
|
||||||
import ContextMenu from "@/components/ContextMenu.vue";
|
import ContextMenu from "@/components/ContextMenu.vue";
|
||||||
import ButtonIcon from "@/components/ButtonIcon.vue";
|
import ButtonIcon from "@/components/ButtonIcon.vue";
|
||||||
|
|
||||||
let win = undefined;
|
const electron =
|
||||||
if (process.env.IS_ELECTRON === true) {
|
process.env.IS_ELECTRON === true ? window.require("electron") : null;
|
||||||
const electron = require("electron");
|
const ipcRenderer =
|
||||||
win = electron.remote.BrowserWindow.getFocusedWindow();
|
process.env.IS_ELECTRON === true ? electron.ipcRenderer : null;
|
||||||
}
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "Navbar",
|
name: "Navbar",
|
||||||
|
|
@ -115,7 +114,7 @@ export default {
|
||||||
inputFocus: false,
|
inputFocus: false,
|
||||||
langs: ["zh-CN", "en", "tr"],
|
langs: ["zh-CN", "en", "tr"],
|
||||||
keywords: "",
|
keywords: "",
|
||||||
windowIsMaximized: win ? win.isMaximized() : true,
|
isWindowMaximized: false,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
|
@ -129,6 +128,13 @@ export default {
|
||||||
: "http://s4.music.126.net/style/web2/img/default/default_avatar.jpg?param=60y60";
|
: "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: {
|
methods: {
|
||||||
go(where) {
|
go(where) {
|
||||||
if (where === "back") this.$router.go(-1);
|
if (where === "back") this.$router.go(-1);
|
||||||
|
|
@ -165,19 +171,13 @@ export default {
|
||||||
this.$router.push({ name: "login" });
|
this.$router.push({ name: "login" });
|
||||||
},
|
},
|
||||||
windowMinimize() {
|
windowMinimize() {
|
||||||
win.minimize();
|
ipcRenderer.send("minimize");
|
||||||
},
|
},
|
||||||
windowMaxRestore() {
|
windowMaxRestore() {
|
||||||
if (win.isMaximized()) {
|
ipcRenderer.send("maximizeOrUnmaximize");
|
||||||
win.restore();
|
|
||||||
this.windowIsMaximized = false;
|
|
||||||
} else {
|
|
||||||
win.maximize();
|
|
||||||
this.windowIsMaximized = true;
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
windowClose() {
|
windowClose() {
|
||||||
win.close();
|
ipcRenderer.send("close");
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -61,6 +61,12 @@ export function initIpcMain(win, store) {
|
||||||
win.minimize();
|
win.minimize();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
ipcMain.on("maximizeOrUnmaximize", () => {
|
||||||
|
const isMaximized = win.isMaximized();
|
||||||
|
isMaximized ? win.unmaximize() : win.maximize();
|
||||||
|
win.webContents.send("isMaximized", isMaximized);
|
||||||
|
});
|
||||||
|
|
||||||
ipcMain.on("settings", (event, options) => {
|
ipcMain.on("settings", (event, options) => {
|
||||||
store.set("settings", options);
|
store.set("settings", options);
|
||||||
const isRegisterShortcut = globalShortcut.isRegistered(
|
const isRegisterShortcut = globalShortcut.isRegistered(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue