Add native frame styles per OS
This commit is contained in:
parent
73997cf6c7
commit
6d092d9ebc
1 changed files with 23 additions and 2 deletions
|
@ -20,6 +20,7 @@ import {
|
||||||
Tray,
|
Tray,
|
||||||
Menu,
|
Menu,
|
||||||
nativeImage,
|
nativeImage,
|
||||||
|
BrowserWindowConstructorOptions,
|
||||||
} from 'electron';
|
} from 'electron';
|
||||||
import electronLocalShortcut from 'electron-localshortcut';
|
import electronLocalShortcut from 'electron-localshortcut';
|
||||||
import log from 'electron-log';
|
import log from 'electron-log';
|
||||||
|
@ -186,9 +187,26 @@ const createWindow = async () => {
|
||||||
const nativeFrame = store.get('window_window_bar_style') === 'linux';
|
const nativeFrame = store.get('window_window_bar_style') === 'linux';
|
||||||
store.set('window_has_frame', nativeFrame);
|
store.set('window_has_frame', nativeFrame);
|
||||||
|
|
||||||
|
const nativeFrameConfig: Record<string, BrowserWindowConstructorOptions> = {
|
||||||
|
linux: {
|
||||||
|
autoHideMenuBar: true,
|
||||||
|
frame: true,
|
||||||
|
},
|
||||||
|
macOS: {
|
||||||
|
autoHideMenuBar: true,
|
||||||
|
frame: false,
|
||||||
|
titleBarStyle: 'hidden',
|
||||||
|
trafficLightPosition: { x: 10, y: 10 },
|
||||||
|
},
|
||||||
|
windows: {
|
||||||
|
autoHideMenuBar: true,
|
||||||
|
frame: true,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
mainWindow = new BrowserWindow({
|
mainWindow = new BrowserWindow({
|
||||||
autoHideMenuBar: nativeFrame,
|
autoHideMenuBar: true,
|
||||||
frame: nativeFrame,
|
frame: false,
|
||||||
height: 900,
|
height: 900,
|
||||||
icon: getAssetPath('icon.png'),
|
icon: getAssetPath('icon.png'),
|
||||||
minHeight: 600,
|
minHeight: 600,
|
||||||
|
@ -206,6 +224,9 @@ const createWindow = async () => {
|
||||||
webSecurity: !store.get('ignore_cors'),
|
webSecurity: !store.get('ignore_cors'),
|
||||||
},
|
},
|
||||||
width: 1440,
|
width: 1440,
|
||||||
|
...(nativeFrame && isLinux() && nativeFrameConfig.linux),
|
||||||
|
...(nativeFrame && isMacOS() && nativeFrameConfig.macOS),
|
||||||
|
...(nativeFrame && isWindows() && nativeFrameConfig.windows),
|
||||||
});
|
});
|
||||||
|
|
||||||
electronLocalShortcut.register(mainWindow, 'Ctrl+Shift+I', () => {
|
electronLocalShortcut.register(mainWindow, 'Ctrl+Shift+I', () => {
|
||||||
|
|
Reference in a new issue