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