macOS Changes

onStartup implemented
This commit is contained in:
Core 2022-03-10 14:56:07 +00:00
parent bab1b0db4d
commit b71a7b22c0
6 changed files with 99 additions and 62 deletions

View file

@ -120,6 +120,8 @@ export class AppEvents {
public ready(plug: any) {
this.plugin = plug
console.log('[AppEvents] App ready');
AppEvents.setLoginSettings()
}
public bwCreated() {
@ -139,7 +141,9 @@ export class AppEvents {
}
this.InstanceHandler()
this.InitTray()
if (process.platform !== "darwin") {
this.InitTray()
}
}
/***********************************************************************************************************************
@ -329,4 +333,23 @@ export class AppEvents {
clipboard.writeText(data)
})
}
/**
* Set login settings
* @private
*/
private static setLoginSettings() {
if (utils.getStoreValue('general.onStartup.enabled')) {
app.setLoginItemSettings({
openAtLogin: true,
path: app.getPath('exe'),
args: [`${utils.getStoreValue('general.onStartup.hidden') ? '--hidden' : ''}`]
})
} else {
app.setLoginItemSettings({
openAtLogin: false,
path: app.getPath('exe')
})
}
}
}

View file

@ -10,7 +10,6 @@ import {networkInterfaces} from "os";
import * as mm from 'music-metadata';
import fetch from 'electron-fetch'
import {wsapi} from "./wsapi";
import {AppImageUpdater, NsisUpdater} from "electron-updater";
import {utils} from './utils';
import {Plugins} from "./plugins";
@ -1130,8 +1129,18 @@ export class BrowserWindow {
isQuiting = true
});
app.on('activate', function(){
BrowserWindow.win.show()
BrowserWindow.win.focus()
});
// Quit when all windows are closed.
app.on('window-all-closed', () => {
app.quit()
// On macOS it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q
if (process.platform !== 'darwin') {
app.quit()
}
})
BrowserWindow.win.on("closed", () => {

View file

@ -7,7 +7,6 @@ export class Store {
private defaults: any = {
"general": {
"close_button_hide": false,
"open_on_startup": false,
"discord_rpc": 1, // 0 = disabled, 1 = enabled as Cider, 2 = enabled as Apple Music
"discord_rpc_clear_on_pause": true,
"language": "en_US", // electron.app.getLocale().replace('-', '_') this can be used in future
@ -23,6 +22,10 @@ export class Store {
"artists": true,
"videos": true,
"podcasts": true
},
"onStartup": {
"enabled": false,
"hidden": false,
}
},
"home": {