mirror of
https://github.com/Eugeny/tabby.git
synced 2024-12-09 06:20:22 +08:00
fixed event listener order
This commit is contained in:
parent
524ccd06f3
commit
b3df681753
@ -15,35 +15,21 @@ if (!process.env.TABBY_PLUGINS) {
|
|||||||
|
|
||||||
const argv = parseArgs(process.argv, process.cwd())
|
const argv = parseArgs(process.argv, process.cwd())
|
||||||
|
|
||||||
loadConfig().then(configStore => {
|
const application = loadConfig().catch(err => {
|
||||||
const application = new Application(configStore)
|
dialog.showErrorBox('Could not read config', err.message)
|
||||||
|
app.exit(1)
|
||||||
|
}).then(configStore => {
|
||||||
|
const _application = new Application(configStore)
|
||||||
|
|
||||||
ipcMain.on('app:new-window', () => {
|
ipcMain.on('app:new-window', () => {
|
||||||
application.newWindow()
|
_application.newWindow()
|
||||||
})
|
|
||||||
|
|
||||||
app.on('activate', () => {
|
|
||||||
if (!application.hasWindows()) {
|
|
||||||
application.newWindow()
|
|
||||||
} else {
|
|
||||||
application.focus()
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
process.on('uncaughtException' as any, err => {
|
process.on('uncaughtException' as any, err => {
|
||||||
console.log(err)
|
console.log(err)
|
||||||
application.broadcast('uncaughtException', err)
|
_application.broadcast('uncaughtException', err)
|
||||||
})
|
})
|
||||||
|
|
||||||
app.on('second-instance', (_event, newArgv, cwd) => {
|
|
||||||
application.handleSecondInstance(newArgv, cwd)
|
|
||||||
})
|
|
||||||
|
|
||||||
if (!app.requestSingleInstanceLock()) {
|
|
||||||
app.quit()
|
|
||||||
app.exit(0)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (argv.d) {
|
if (argv.d) {
|
||||||
electronDebug({
|
electronDebug({
|
||||||
isEnabled: true,
|
isEnabled: true,
|
||||||
@ -52,24 +38,43 @@ loadConfig().then(configStore => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
app.on('ready', async () => {
|
return _application
|
||||||
if (process.platform === 'darwin') {
|
})
|
||||||
app.dock.setMenu(Menu.buildFromTemplate([
|
|
||||||
{
|
|
||||||
label: 'New window',
|
app.on('activate', async () => {
|
||||||
click () {
|
if (!(await application).hasWindows()) {
|
||||||
this.app.newWindow()
|
(await application).newWindow()
|
||||||
},
|
} else {
|
||||||
},
|
(await application).focus()
|
||||||
]))
|
}
|
||||||
}
|
})
|
||||||
application.init()
|
|
||||||
|
app.on('second-instance', async (_event, newArgv, cwd) => {
|
||||||
const window = await application.newWindow({ hidden: argv.hidden })
|
(await application).handleSecondInstance(newArgv, cwd)
|
||||||
await window.ready
|
})
|
||||||
window.passCliArguments(process.argv, process.cwd(), false)
|
|
||||||
window.focus()
|
if (!app.requestSingleInstanceLock()) {
|
||||||
})
|
app.quit()
|
||||||
}).catch(err => {
|
app.exit(0)
|
||||||
dialog.showErrorBox('Could not read config', err.message)
|
}
|
||||||
|
|
||||||
|
app.on('ready', async () => {
|
||||||
|
if (process.platform === 'darwin') {
|
||||||
|
app.dock.setMenu(Menu.buildFromTemplate([
|
||||||
|
{
|
||||||
|
label: 'New window',
|
||||||
|
click () {
|
||||||
|
this.app.newWindow()
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]))
|
||||||
|
}
|
||||||
|
|
||||||
|
(await application).init()
|
||||||
|
|
||||||
|
const window = await (await application).newWindow({ hidden: argv.hidden })
|
||||||
|
await window.ready
|
||||||
|
window.passCliArguments(process.argv, process.cwd(), false)
|
||||||
|
window.focus()
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user