|
|
@@ -14,6 +14,10 @@ if (process.platform === 'win32') {
|
|
|
DwmEnableBlurBehindWindow = require('windows-blurbehind').DwmEnableBlurBehindWindow
|
|
|
}
|
|
|
|
|
|
+export interface WindowOptions {
|
|
|
+ hidden?: boolean
|
|
|
+}
|
|
|
+
|
|
|
export class Window {
|
|
|
ready: Promise<void>
|
|
|
private visible = new Subject<boolean>()
|
|
|
@@ -23,14 +27,16 @@ export class Window {
|
|
|
|
|
|
get visible$ (): Observable<boolean> { return this.visible }
|
|
|
|
|
|
- constructor () {
|
|
|
+ constructor (options?: WindowOptions) {
|
|
|
let configData = loadConfig()
|
|
|
|
|
|
+ options = options || {}
|
|
|
+
|
|
|
this.windowConfig = new ElectronConfig({ name: 'window' })
|
|
|
this.windowBounds = this.windowConfig.get('windowBoundaries')
|
|
|
|
|
|
let maximized = this.windowConfig.get('maximized')
|
|
|
- let options: Electron.BrowserWindowConstructorOptions = {
|
|
|
+ let bwOptions: Electron.BrowserWindowConstructorOptions = {
|
|
|
width: 800,
|
|
|
height: 600,
|
|
|
title: 'Terminus',
|
|
|
@@ -41,33 +47,36 @@ export class Window {
|
|
|
show: false,
|
|
|
backgroundColor: '#00000000'
|
|
|
}
|
|
|
- Object.assign(options, this.windowBounds)
|
|
|
+ Object.assign(bwOptions, this.windowBounds)
|
|
|
|
|
|
if ((configData.appearance || {}).frame === 'native') {
|
|
|
- options.frame = true
|
|
|
+ bwOptions.frame = true
|
|
|
} else {
|
|
|
if (process.platform === 'darwin') {
|
|
|
- options.titleBarStyle = 'hiddenInset'
|
|
|
+ bwOptions.titleBarStyle = 'hiddenInset'
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (process.platform === 'linux') {
|
|
|
- options.backgroundColor = '#131d27'
|
|
|
+ bwOptions.backgroundColor = '#131d27'
|
|
|
}
|
|
|
|
|
|
- this.window = new BrowserWindow(options)
|
|
|
+ this.window = new BrowserWindow(bwOptions)
|
|
|
this.window.once('ready-to-show', () => {
|
|
|
if (process.platform === 'darwin') {
|
|
|
this.window.setVibrancy('dark')
|
|
|
} else if (process.platform === 'win32' && (configData.appearance || {}).vibrancy) {
|
|
|
this.setVibrancy(true)
|
|
|
}
|
|
|
- if (maximized) {
|
|
|
- this.window.maximize()
|
|
|
- } else {
|
|
|
- this.window.show()
|
|
|
+
|
|
|
+ if (!options.hidden) {
|
|
|
+ if (maximized) {
|
|
|
+ this.window.maximize()
|
|
|
+ } else {
|
|
|
+ this.window.show()
|
|
|
+ }
|
|
|
+ this.window.focus()
|
|
|
}
|
|
|
- this.window.focus()
|
|
|
})
|
|
|
this.window.loadURL(`file://${app.getAppPath()}/dist/index.html?${this.window.id}`, { extraHeaders: 'pragma: no-cache\n' })
|
|
|
|