mirror of
https://github.com/geekgeekrun/geekgeekrun.git
synced 2026-09-07 08:27:13 +08:00
replace default app menu
This commit is contained in:
@@ -0,0 +1,27 @@
|
|||||||
|
import { app, Menu, MenuItemConstructorOptions, MenuItem } from 'electron'
|
||||||
|
|
||||||
|
const isMac = process.platform === 'darwin'
|
||||||
|
|
||||||
|
const template: (MenuItemConstructorOptions | MenuItem)[] = [
|
||||||
|
// { role: 'appMenu' }
|
||||||
|
...(isMac
|
||||||
|
? [
|
||||||
|
{
|
||||||
|
label: app.name,
|
||||||
|
submenu: [
|
||||||
|
{ role: 'about' },
|
||||||
|
{ type: 'separator' },
|
||||||
|
{ role: 'services' },
|
||||||
|
{ type: 'separator' },
|
||||||
|
{ role: 'hide' },
|
||||||
|
{ role: 'hideOthers' },
|
||||||
|
{ role: 'unhide' },
|
||||||
|
{ type: 'separator' },
|
||||||
|
{ role: 'quit' }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
: [])
|
||||||
|
]
|
||||||
|
const menu = Menu.buildFromTemplate(template)
|
||||||
|
Menu.setApplicationMenu(menu)
|
||||||
+18
-4
@@ -1,7 +1,7 @@
|
|||||||
import { app, BrowserWindow, ipcMain } from 'electron'
|
import { app, BrowserWindow, ipcMain, globalShortcut } from 'electron'
|
||||||
import { electronApp, optimizer } from '@electron-toolkit/utils'
|
import { electronApp, optimizer } from '@electron-toolkit/utils'
|
||||||
import { createMainWindow } from '../window/mainWindow'
|
import { createMainWindow } from '../../window/mainWindow'
|
||||||
|
import './app-menu'
|
||||||
export function openSettingWindow() {
|
export function openSettingWindow() {
|
||||||
// TODO: singleton lock; how can we check if there is another process should run as singleton with arguments?
|
// TODO: singleton lock; how can we check if there is another process should run as singleton with arguments?
|
||||||
if (!app.requestSingleInstanceLock()) {
|
if (!app.requestSingleInstanceLock()) {
|
||||||
@@ -9,10 +9,12 @@ export function openSettingWindow() {
|
|||||||
app.exit(0)
|
app.exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const whenReadyPromise = app.whenReady()
|
||||||
|
|
||||||
// This method will be called when Electron has finished
|
// This method will be called when Electron has finished
|
||||||
// initialization and is ready to create browser windows.
|
// initialization and is ready to create browser windows.
|
||||||
// Some APIs can only be used after this event occurs.
|
// Some APIs can only be used after this event occurs.
|
||||||
app.whenReady().then(() => {
|
whenReadyPromise.then(() => {
|
||||||
// Set app user model id for windows
|
// Set app user model id for windows
|
||||||
electronApp.setAppUserModelId('com.electron')
|
electronApp.setAppUserModelId('com.electron')
|
||||||
|
|
||||||
@@ -44,4 +46,16 @@ export function openSettingWindow() {
|
|||||||
|
|
||||||
// In this file you can include the rest of your app"s specific main process
|
// In this file you can include the rest of your app"s specific main process
|
||||||
// code. You can also put them in separate files and require them here.
|
// code. You can also put them in separate files and require them here.
|
||||||
|
|
||||||
|
// short cut
|
||||||
|
whenReadyPromise.then(() => {
|
||||||
|
// Register a 'Command+Option+Shift+/' shortcut listener.
|
||||||
|
globalShortcut.register('Command+Option+Shift+/', () => {
|
||||||
|
console.log('Command+Option+Shift+/ is pressed')
|
||||||
|
app.exit(0)
|
||||||
|
})
|
||||||
|
app.once('quit', () => {
|
||||||
|
globalShortcut.unregister('Command+Option+Shift+/')
|
||||||
|
})
|
||||||
|
})
|
||||||
}
|
}
|
||||||
@@ -31,7 +31,7 @@ const runMode = process.env.MAIN_BOSSGEEKGO_UI_RUN_MODE
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
const { openSettingWindow } = await import('./flow/OPEN_SETTING_WINDOW')
|
const { openSettingWindow } = await import('./flow/OPEN_SETTING_WINDOW/index')
|
||||||
openSettingWindow()
|
openSettingWindow()
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user