Merge pull request #125 from toriphes/master

MacOS improvements
This commit is contained in:
Fabio Di Stasio 2021-10-24 10:32:46 +02:00 committed by GitHub
commit 3679121c25
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 37 additions and 17 deletions

View File

@ -11,6 +11,7 @@ import ipcHandlers from './ipc-handlers';
Store.initRenderer(); Store.initRenderer();
const isDevelopment = process.env.NODE_ENV !== 'production'; const isDevelopment = process.env.NODE_ENV !== 'production';
const isMacOS = process.platform === 'darwin';
const gotTheLock = app.requestSingleInstanceLock(); const gotTheLock = app.requestSingleInstanceLock();
process.env.ELECTRON_DISABLE_SECURITY_WARNINGS = 'true'; process.env.ELECTRON_DISABLE_SECURITY_WARNINGS = 'true';
@ -35,6 +36,8 @@ async function createMainWindow () {
spellcheck: false spellcheck: false
}, },
frame: false, frame: false,
titleBarStyle: isMacOS ? 'hidden' : 'default',
trafficLightPosition: isMacOS ? { x: 10, y: 8 } : undefined,
backgroundColor: '#1d1d1d' backgroundColor: '#1d1d1d'
}); });
@ -81,7 +84,7 @@ else {
// quit application when all windows are closed // quit application when all windows are closed
app.on('window-all-closed', () => { app.on('window-all-closed', () => {
// on macOS it is common for applications to stay open until the user explicitly quits // on macOS it is common for applications to stay open until the user explicitly quits
if (process.platform !== 'darwin') app.quit(); if (isMacOS) app.quit();
}); });
app.on('activate', async () => { app.on('activate', async () => {
@ -112,19 +115,19 @@ else {
function createAppMenu () { function createAppMenu () {
let menu = null; let menu = null;
if (process.platform === 'darwin') { if (isMacOS) {
menu = Menu.buildFromTemplate([ menu = Menu.buildFromTemplate([
{ {
label: app.name, role: 'appMenu'
submenu: [ },
{ {
role: 'about' role: 'editMenu'
}, },
{ type: 'separator' }, {
{ role: 'viewMenu'
role: 'quit' },
} {
] role: 'windowMenu'
} }
]); ]);
} }

View File

@ -2,7 +2,11 @@
<div id="titlebar"> <div id="titlebar">
<div class="titlebar-resizer" /> <div class="titlebar-resizer" />
<div class="titlebar-elements"> <div class="titlebar-elements">
<img class="titlebar-logo" :src="require('@/images/logo.svg').default"> <img
v-if="!isMacOS"
class="titlebar-logo"
:src="require('@/images/logo.svg').default"
>
</div> </div>
<div class="titlebar-elements titlebar-title"> <div class="titlebar-elements titlebar-title">
{{ windowTitle }} {{ windowTitle }}
@ -22,14 +26,26 @@
> >
<i class="mdi mdi-24px mdi-refresh" /> <i class="mdi mdi-24px mdi-refresh" />
</div> </div>
<div class="titlebar-element" @click="minimizeApp"> <div
v-if="!isMacOS"
class="titlebar-element"
@click="minimizeApp"
>
<i class="mdi mdi-24px mdi-minus" /> <i class="mdi mdi-24px mdi-minus" />
</div> </div>
<div class="titlebar-element" @click="toggleFullScreen"> <div
v-if="!isMacOS"
class="titlebar-element"
@click="toggleFullScreen"
>
<i v-if="isMaximized" class="mdi mdi-24px mdi-fullscreen-exit" /> <i v-if="isMaximized" class="mdi mdi-24px mdi-fullscreen-exit" />
<i v-else class="mdi mdi-24px mdi-fullscreen" /> <i v-else class="mdi mdi-24px mdi-fullscreen" />
</div> </div>
<div class="titlebar-element close-button" @click="closeApp"> <div
v-if="!isMacOS"
class="titlebar-element close-button"
@click="closeApp"
>
<i class="mdi mdi-24px mdi-close" /> <i class="mdi mdi-24px mdi-close" />
</div> </div>
</div> </div>
@ -47,7 +63,8 @@ export default {
return { return {
w: getCurrentWindow(), w: getCurrentWindow(),
isMaximized: getCurrentWindow().isMaximized(), isMaximized: getCurrentWindow().isMaximized(),
isDevelopment: process.env.NODE_ENV === 'development' isDevelopment: process.env.NODE_ENV === 'development',
isMacOS: process.platform === 'darwin'
}; };
}, },
computed: { computed: {