|
|
|
@ -22,7 +22,8 @@ export class WindowMain { |
|
|
|
private enableAlwaysOnTop: boolean = false; |
|
|
|
private enableAlwaysOnTop: boolean = false; |
|
|
|
|
|
|
|
|
|
|
|
constructor(private storageService: StorageService, private hideTitleBar = false, |
|
|
|
constructor(private storageService: StorageService, private hideTitleBar = false, |
|
|
|
private defaultWidth = 950, private defaultHeight = 600) { } |
|
|
|
private defaultWidth = 950, private defaultHeight = 600, |
|
|
|
|
|
|
|
private argvCallback: (argv: string[]) => void = null) { } |
|
|
|
|
|
|
|
|
|
|
|
init(): Promise<any> { |
|
|
|
init(): Promise<any> { |
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
@ -33,7 +34,7 @@ export class WindowMain { |
|
|
|
app.quit(); |
|
|
|
app.quit(); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
app.on('second-instance', (event, commandLine, workingDirectory) => { |
|
|
|
app.on('second-instance', (event, argv, workingDirectory) => { |
|
|
|
// Someone tried to run a second instance, we should focus our window.
|
|
|
|
// Someone tried to run a second instance, we should focus our window.
|
|
|
|
if (this.win != null) { |
|
|
|
if (this.win != null) { |
|
|
|
if (this.win.isMinimized() || !this.win.isVisible()) { |
|
|
|
if (this.win.isMinimized() || !this.win.isVisible()) { |
|
|
|
@ -41,6 +42,11 @@ export class WindowMain { |
|
|
|
} |
|
|
|
} |
|
|
|
this.win.focus(); |
|
|
|
this.win.focus(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (process.platform === 'win32' || process.platform === 'linux') { |
|
|
|
|
|
|
|
if (this.argvCallback != null) { |
|
|
|
|
|
|
|
this.argvCallback(argv); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -57,6 +63,9 @@ export class WindowMain { |
|
|
|
app.on('ready', async () => { |
|
|
|
app.on('ready', async () => { |
|
|
|
await this.createWindow(); |
|
|
|
await this.createWindow(); |
|
|
|
resolve(); |
|
|
|
resolve(); |
|
|
|
|
|
|
|
if (this.argvCallback != null) { |
|
|
|
|
|
|
|
this.argvCallback(process.argv); |
|
|
|
|
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
// Quit when all windows are closed.
|
|
|
|
// Quit when all windows are closed.
|
|
|
|
|