mirror of
https://github.com/Eugeny/tabby.git
synced 2025-07-04 18:39:54 +00:00
commit
275791517b
@ -1,5 +1,5 @@
|
|||||||
import { Subject, Observable } from 'rxjs'
|
import { Subject, Observable } from 'rxjs'
|
||||||
import { BrowserWindow, app, ipcMain } from 'electron'
|
import { BrowserWindow, app, ipcMain, Rectangle } from 'electron'
|
||||||
import ElectronConfig = require('electron-config')
|
import ElectronConfig = require('electron-config')
|
||||||
import * as yaml from 'js-yaml'
|
import * as yaml from 'js-yaml'
|
||||||
import * as fs from 'fs'
|
import * as fs from 'fs'
|
||||||
@ -16,6 +16,7 @@ export class Window {
|
|||||||
private window: BrowserWindow
|
private window: BrowserWindow
|
||||||
private vibrancyViewID: number
|
private vibrancyViewID: number
|
||||||
private windowConfig: ElectronConfig
|
private windowConfig: ElectronConfig
|
||||||
|
private windowBounds: Rectangle
|
||||||
|
|
||||||
get visible$ (): Observable<boolean> { return this.visible }
|
get visible$ (): Observable<boolean> { return this.visible }
|
||||||
|
|
||||||
@ -29,7 +30,9 @@ export class Window {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.windowConfig = new ElectronConfig({ name: 'window' })
|
this.windowConfig = new ElectronConfig({ name: 'window' })
|
||||||
|
this.windowBounds = this.windowConfig.get('windowBoundaries')
|
||||||
|
|
||||||
|
let maximized = this.windowConfig.get('maximized')
|
||||||
let options: Electron.BrowserWindowConstructorOptions = {
|
let options: Electron.BrowserWindowConstructorOptions = {
|
||||||
width: 800,
|
width: 800,
|
||||||
height: 600,
|
height: 600,
|
||||||
@ -40,7 +43,7 @@ export class Window {
|
|||||||
frame: false,
|
frame: false,
|
||||||
show: false,
|
show: false,
|
||||||
}
|
}
|
||||||
Object.assign(options, this.windowConfig.get('windowBoundaries'))
|
Object.assign(options, this.windowBounds)
|
||||||
|
|
||||||
if ((configData.appearance || {}).frame === 'native') {
|
if ((configData.appearance || {}).frame === 'native') {
|
||||||
options.frame = true
|
options.frame = true
|
||||||
@ -65,7 +68,11 @@ export class Window {
|
|||||||
} else if (process.platform === 'win32' && (configData.appearance || {}).vibrancy) {
|
} else if (process.platform === 'win32' && (configData.appearance || {}).vibrancy) {
|
||||||
this.setVibrancy(true)
|
this.setVibrancy(true)
|
||||||
}
|
}
|
||||||
this.window.show()
|
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' })
|
this.window.loadURL(`file://${app.getAppPath()}/dist/index.html?${this.window.id}`, { extraHeaders: 'pragma: no-cache\n' })
|
||||||
@ -122,13 +129,24 @@ export class Window {
|
|||||||
this.window.on('leave-full-screen', () => this.window.webContents.send('host:window-leave-full-screen'))
|
this.window.on('leave-full-screen', () => this.window.webContents.send('host:window-leave-full-screen'))
|
||||||
|
|
||||||
this.window.on('close', () => {
|
this.window.on('close', () => {
|
||||||
this.windowConfig.set('windowBoundaries', this.window.getBounds())
|
this.windowConfig.set('windowBoundaries', this.windowBounds)
|
||||||
|
this.windowConfig.set('maximized', this.window.isMaximized())
|
||||||
})
|
})
|
||||||
|
|
||||||
this.window.on('closed', () => {
|
this.window.on('closed', () => {
|
||||||
this.destroy()
|
this.destroy()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
this.window.on('resize', () => {
|
||||||
|
if (!this.window.isMaximized())
|
||||||
|
this.windowBounds = this.window.getBounds()
|
||||||
|
})
|
||||||
|
|
||||||
|
this.window.on('move', () => {
|
||||||
|
if (!this.window.isMaximized())
|
||||||
|
this.windowBounds = this.window.getBounds()
|
||||||
|
})
|
||||||
|
|
||||||
ipcMain.on('window-focus', () => {
|
ipcMain.on('window-focus', () => {
|
||||||
this.window.focus()
|
this.window.focus()
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user