fix(electron): set appearance during init of electron window (#525)

resolve #512
This commit is contained in:
Map1en_ 2021-04-04 21:00:47 +08:00 committed by GitHub
parent 1e7274e97f
commit 43a293da6a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 0 deletions

View File

@ -6,6 +6,7 @@ import {
shell,
dialog,
globalShortcut,
nativeTheme,
} from "electron";
import { createProtocol } from "vue-cli-plugin-electron-builder/lib";
import { startNeteaseMusicApi } from "./electron/services";
@ -93,6 +94,8 @@ class Background {
createWindow() {
console.log("creating app window");
const appearance = this.store.get("settings.appearance");
this.window = new BrowserWindow({
width: this.store.get("window.width") || 1440,
height: this.store.get("window.height") || 840,
@ -107,6 +110,12 @@ class Background {
enableRemoteModule: true,
contextIsolation: false,
},
backgroundColor:
((appearance === undefined || appearance === "auto") &&
nativeTheme.shouldUseDarkColors) ||
appearance === "dark"
? "#222"
: "#fff",
});
// hide menu bar on Microsoft Windows and Linux

View File

@ -8,6 +8,7 @@ export function getSendSettingsPlugin() {
ipcRenderer.send("settings", {
minimizeToTray: state.settings.minimizeToTray,
enableGlobalShortcut: state.settings.enableGlobalShortcut,
appearance: state.settings.appearance,
});
});
};