mirror of
https://github.com/Eugeny/tabby.git
synced 2025-07-29 13:44:47 +00:00
Merge branch 'master' of github.com:Eugeny/terminus
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import { app, ipcMain, Menu, Tray, shell } from 'electron'
|
import { app, ipcMain, Menu, Tray, shell } from 'electron'
|
||||||
import { loadConfig } from './config'
|
import { loadConfig } from './config'
|
||||||
import { Window } from './window'
|
import { Window, WindowOptions } from './window'
|
||||||
|
|
||||||
export class Application {
|
export class Application {
|
||||||
private tray: Tray
|
private tray: Tray
|
||||||
@@ -20,8 +20,8 @@ export class Application {
|
|||||||
app.commandLine.appendSwitch('disable-http-cache')
|
app.commandLine.appendSwitch('disable-http-cache')
|
||||||
}
|
}
|
||||||
|
|
||||||
async newWindow (): Promise<Window> {
|
async newWindow (options?: WindowOptions): Promise<Window> {
|
||||||
let window = new Window()
|
let window = new Window(options)
|
||||||
this.windows.push(window)
|
this.windows.push(window)
|
||||||
window.visible$.subscribe(visible => {
|
window.visible$.subscribe(visible => {
|
||||||
if (visible) {
|
if (visible) {
|
||||||
|
@@ -28,6 +28,10 @@ export function parseArgs (argv, cwd) {
|
|||||||
describe: 'Show DevTools on start',
|
describe: 'Show DevTools on start',
|
||||||
type: 'boolean'
|
type: 'boolean'
|
||||||
})
|
})
|
||||||
|
.option('hidden', {
|
||||||
|
describe: 'Start minimized',
|
||||||
|
type: 'boolean'
|
||||||
|
})
|
||||||
.option('version', {
|
.option('version', {
|
||||||
alias: 'v',
|
alias: 'v',
|
||||||
describe: 'Show version and exit',
|
describe: 'Show version and exit',
|
||||||
|
@@ -59,5 +59,5 @@ app.on('ready', () => {
|
|||||||
}
|
}
|
||||||
]))
|
]))
|
||||||
}
|
}
|
||||||
application.newWindow()
|
application.newWindow({ hidden: argv.hidden })
|
||||||
})
|
})
|
||||||
|
@@ -14,6 +14,10 @@ if (process.platform === 'win32') {
|
|||||||
DwmEnableBlurBehindWindow = require('windows-blurbehind').DwmEnableBlurBehindWindow
|
DwmEnableBlurBehindWindow = require('windows-blurbehind').DwmEnableBlurBehindWindow
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface WindowOptions {
|
||||||
|
hidden?: boolean
|
||||||
|
}
|
||||||
|
|
||||||
export class Window {
|
export class Window {
|
||||||
ready: Promise<void>
|
ready: Promise<void>
|
||||||
private visible = new Subject<boolean>()
|
private visible = new Subject<boolean>()
|
||||||
@@ -23,14 +27,16 @@ export class Window {
|
|||||||
|
|
||||||
get visible$ (): Observable<boolean> { return this.visible }
|
get visible$ (): Observable<boolean> { return this.visible }
|
||||||
|
|
||||||
constructor () {
|
constructor (options?: WindowOptions) {
|
||||||
let configData = loadConfig()
|
let configData = loadConfig()
|
||||||
|
|
||||||
|
options = options || {}
|
||||||
|
|
||||||
this.windowConfig = new ElectronConfig({ name: 'window' })
|
this.windowConfig = new ElectronConfig({ name: 'window' })
|
||||||
this.windowBounds = this.windowConfig.get('windowBoundaries')
|
this.windowBounds = this.windowConfig.get('windowBoundaries')
|
||||||
|
|
||||||
let maximized = this.windowConfig.get('maximized')
|
let maximized = this.windowConfig.get('maximized')
|
||||||
let options: Electron.BrowserWindowConstructorOptions = {
|
let bwOptions: Electron.BrowserWindowConstructorOptions = {
|
||||||
width: 800,
|
width: 800,
|
||||||
height: 600,
|
height: 600,
|
||||||
title: 'Terminus',
|
title: 'Terminus',
|
||||||
@@ -41,33 +47,36 @@ export class Window {
|
|||||||
show: false,
|
show: false,
|
||||||
backgroundColor: '#00000000'
|
backgroundColor: '#00000000'
|
||||||
}
|
}
|
||||||
Object.assign(options, this.windowBounds)
|
Object.assign(bwOptions, this.windowBounds)
|
||||||
|
|
||||||
if ((configData.appearance || {}).frame === 'native') {
|
if ((configData.appearance || {}).frame === 'native') {
|
||||||
options.frame = true
|
bwOptions.frame = true
|
||||||
} else {
|
} else {
|
||||||
if (process.platform === 'darwin') {
|
if (process.platform === 'darwin') {
|
||||||
options.titleBarStyle = 'hiddenInset'
|
bwOptions.titleBarStyle = 'hiddenInset'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (process.platform === 'linux') {
|
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', () => {
|
this.window.once('ready-to-show', () => {
|
||||||
if (process.platform === 'darwin') {
|
if (process.platform === 'darwin') {
|
||||||
this.window.setVibrancy('dark')
|
this.window.setVibrancy('dark')
|
||||||
} else if (process.platform === 'win32' && (configData.appearance || {}).vibrancy) {
|
} else if (process.platform === 'win32' && (configData.appearance || {}).vibrancy) {
|
||||||
this.setVibrancy(true)
|
this.setVibrancy(true)
|
||||||
}
|
}
|
||||||
if (maximized) {
|
|
||||||
this.window.maximize()
|
if (!options.hidden) {
|
||||||
} else {
|
if (maximized) {
|
||||||
this.window.show()
|
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' })
|
||||||
|
|
||||||
|
@@ -20,5 +20,4 @@ exports.bundledModules = [
|
|||||||
'@angular',
|
'@angular',
|
||||||
'@ng-bootstrap',
|
'@ng-bootstrap',
|
||||||
]
|
]
|
||||||
exports.nativeModules = ['node-pty-tmp', 'font-manager', 'xkeychain', 'electron-vibrancy']
|
|
||||||
exports.electronVersion = pkgInfo.devDependencies.electron
|
exports.electronVersion = pkgInfo.devDependencies.electron
|
||||||
|
@@ -122,7 +122,7 @@ export class AppRootComponent {
|
|||||||
})
|
})
|
||||||
|
|
||||||
this.hostApp.secondInstance$.subscribe(() => {
|
this.hostApp.secondInstance$.subscribe(() => {
|
||||||
this.onGlobalHotkey()
|
this.presentWindow()
|
||||||
})
|
})
|
||||||
this.hotkeys.globalHotkey.subscribe(() => {
|
this.hotkeys.globalHotkey.subscribe(() => {
|
||||||
this.onGlobalHotkey()
|
this.onGlobalHotkey()
|
||||||
@@ -166,28 +166,35 @@ export class AppRootComponent {
|
|||||||
|
|
||||||
onGlobalHotkey () {
|
onGlobalHotkey () {
|
||||||
if (this.hostApp.getWindow().isFocused()) {
|
if (this.hostApp.getWindow().isFocused()) {
|
||||||
// focused
|
this.hideWindow()
|
||||||
this.electron.loseFocus()
|
} else {
|
||||||
this.hostApp.getWindow().blur()
|
this.presentWindow()
|
||||||
if (this.hostApp.platform !== Platform.macOS) {
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
presentWindow () {
|
||||||
|
if (!this.hostApp.getWindow().isVisible()) {
|
||||||
|
// unfocused, invisible
|
||||||
|
this.hostApp.getWindow().show()
|
||||||
|
this.hostApp.getWindow().focus()
|
||||||
|
} else {
|
||||||
|
if (this.config.store.appearance.dock === 'off') {
|
||||||
|
// not docked, visible
|
||||||
|
setTimeout(() => {
|
||||||
|
this.hostApp.getWindow().focus()
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
// docked, visible
|
||||||
this.hostApp.getWindow().hide()
|
this.hostApp.getWindow().hide()
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
if (!this.hostApp.getWindow().isVisible()) {
|
}
|
||||||
// unfocused, invisible
|
|
||||||
this.hostApp.getWindow().show()
|
hideWindow () {
|
||||||
this.hostApp.getWindow().focus()
|
this.electron.loseFocus()
|
||||||
} else {
|
this.hostApp.getWindow().blur()
|
||||||
if (this.config.store.appearance.dock === 'off') {
|
if (this.hostApp.platform !== Platform.macOS) {
|
||||||
// not docked, visible
|
this.hostApp.getWindow().hide()
|
||||||
setTimeout(() => {
|
|
||||||
this.hostApp.getWindow().focus()
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
// docked, visible
|
|
||||||
this.hostApp.getWindow().hide()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -85,6 +85,8 @@ export class HostAppService {
|
|||||||
text = shellEscape([text])
|
text = shellEscape([text])
|
||||||
}
|
}
|
||||||
this.cliPaste.next(text)
|
this.cliPaste.next(text)
|
||||||
|
} else {
|
||||||
|
this.secondInstance.next()
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
@@ -9,11 +9,13 @@
|
|||||||
)
|
)
|
||||||
|
|
||||||
.list-group.mt-3(*ngIf='lastConnection')
|
.list-group.mt-3(*ngIf='lastConnection')
|
||||||
a.list-group-item.list-group-item-action((click)='connect(lastConnection)')
|
a.list-group-item.list-group-item-action.d-flex.align-items-center((click)='connect(lastConnection)')
|
||||||
i.fa.fa-fw.fa-history
|
i.fa.fa-fw.fa-history
|
||||||
span {{lastConnection.name}}
|
.mr-auto {{lastConnection.name}}
|
||||||
|
button.btn.btn-outline-danger.btn-sm((click)='clearLastConnection(); $event.stopPropagation()')
|
||||||
|
i.fa.fa-trash-o
|
||||||
|
|
||||||
.list-group.mt-3.connections-list
|
.list-group.mt-3.connections-list(*ngIf='childGroups.length')
|
||||||
ng-container(*ngFor='let group of childGroups')
|
ng-container(*ngFor='let group of childGroups')
|
||||||
.list-group-item.list-group-item-action.d-flex.align-items-center(
|
.list-group-item.list-group-item-action.d-flex.align-items-center(
|
||||||
(click)='groupCollapsed[group.name] = !groupCollapsed[group.name]'
|
(click)='groupCollapsed[group.name] = !groupCollapsed[group.name]'
|
||||||
|
@@ -54,6 +54,11 @@ export class SSHModalComponent {
|
|||||||
this.connect(connection)
|
this.connect(connection)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clearLastConnection () {
|
||||||
|
window.localStorage.lastConnection = null
|
||||||
|
this.lastConnection = null
|
||||||
|
}
|
||||||
|
|
||||||
connect (connection: SSHConnection) {
|
connect (connection: SSHConnection) {
|
||||||
this.close()
|
this.close()
|
||||||
this.ssh.connect(connection).catch(error => {
|
this.ssh.connect(connection).catch(error => {
|
||||||
|
@@ -18,9 +18,7 @@ let windowsProcessTree
|
|||||||
try {
|
try {
|
||||||
windowsProcessTree = require('windows-process-tree')
|
windowsProcessTree = require('windows-process-tree')
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e)
|
|
||||||
} // tslint:disable-line
|
} // tslint:disable-line
|
||||||
console.error(windowsProcessTree)
|
|
||||||
|
|
||||||
export interface IChildProcess {
|
export interface IChildProcess {
|
||||||
pid: number
|
pid: number
|
||||||
|
Reference in New Issue
Block a user