fix: quick app bugs (#2327)
This commit is contained in:
parent
f4f1888468
commit
b9b421a495
@ -43,6 +43,12 @@ const gotTheLock = app.requestSingleInstanceLock()
|
||||
|
||||
app
|
||||
.whenReady()
|
||||
.then(() => {
|
||||
if (!gotTheLock) {
|
||||
app.quit()
|
||||
throw new Error('Another instance of the app is already running')
|
||||
}
|
||||
})
|
||||
.then(setupReactDevTool)
|
||||
.then(setupCore)
|
||||
.then(createUserSpace)
|
||||
@ -63,22 +69,20 @@ app
|
||||
log(`Version: ${app.getVersion()}`)
|
||||
})
|
||||
.then(() => {
|
||||
if (!gotTheLock) {
|
||||
app.quit()
|
||||
} else {
|
||||
app.on('second-instance', (_event, _commandLine, _workingDirectory) => {
|
||||
// Someone tried to run a second instance, we should focus our window.
|
||||
windowManager.showMainWindow()
|
||||
})
|
||||
}
|
||||
app.on('activate', () => {
|
||||
if (!BrowserWindow.getAllWindows().length) {
|
||||
createMainWindow()
|
||||
} else {
|
||||
windowManager.showMainWindow()
|
||||
}
|
||||
})
|
||||
})
|
||||
.then(() => cleanLogs())
|
||||
|
||||
app.on('second-instance', (_event, _commandLine, _workingDirectory) => {
|
||||
windowManager.showMainWindow()
|
||||
})
|
||||
|
||||
app.on('ready', () => {
|
||||
registerGlobalShortcuts()
|
||||
})
|
||||
|
||||
@ -5,7 +5,7 @@ export const mainWindowConfig: Electron.BrowserWindowConstructorOptions = {
|
||||
width: DEFAULT_WIDTH,
|
||||
minWidth: DEFAULT_WIDTH,
|
||||
height: DEFAULT_HEIGHT,
|
||||
skipTaskbar: true,
|
||||
skipTaskbar: false,
|
||||
show: true,
|
||||
trafficLightPosition: {
|
||||
x: 10,
|
||||
|
||||
@ -13,6 +13,12 @@ class TrayManager {
|
||||
const tray = new Tray(iconPath)
|
||||
tray.setToolTip(app.getName())
|
||||
|
||||
tray.on('click', () => {
|
||||
windowManager.showQuickAskWindow()
|
||||
})
|
||||
|
||||
// Add context menu for windows only
|
||||
if (process.platform === 'win32') {
|
||||
const contextMenu = Menu.buildFromTemplate([
|
||||
{
|
||||
label: 'Open Jan',
|
||||
@ -26,7 +32,9 @@ class TrayManager {
|
||||
},
|
||||
{ label: 'Quit', type: 'normal', click: () => app.quit() },
|
||||
])
|
||||
|
||||
tray.setContextMenu(contextMenu)
|
||||
}
|
||||
this.currentTray = tray
|
||||
}
|
||||
|
||||
|
||||
@ -73,15 +73,11 @@ class WindowManager {
|
||||
hideMainWindow(): void {
|
||||
this.mainWindow?.hide()
|
||||
this._mainWindowVisible = false
|
||||
// Only macos
|
||||
if (process.platform === 'darwin') app.dock.hide()
|
||||
}
|
||||
|
||||
showMainWindow(): void {
|
||||
this.mainWindow?.show()
|
||||
this._mainWindowVisible = true
|
||||
// Only macos
|
||||
if (process.platform === 'darwin') app.dock.show()
|
||||
}
|
||||
|
||||
hideQuickAskWindow(): void {
|
||||
|
||||
@ -24,10 +24,6 @@ export default function KeyListener({ children }: Props) {
|
||||
|
||||
useEffect(() => {
|
||||
const onKeyDown = (e: KeyboardEvent) => {
|
||||
if (e.key === 'Escape') {
|
||||
window.core?.api?.hideMainWindow()
|
||||
}
|
||||
|
||||
const prefixKey = isMac ? e.metaKey : e.ctrlKey
|
||||
|
||||
if (e.key === 'b' && prefixKey) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user