tabby/terminus-core/src/services/electron.service.ts

43 lines
1.2 KiB
TypeScript

import { Injectable } from '@angular/core'
@Injectable()
export class ElectronService {
app: any
ipcRenderer: any
shell: any
dialog: any
clipboard: any
globalShortcut: any
screen: any
remote: any
TouchBar: typeof Electron.TouchBar
private electron: any
constructor () {
this.electron = require('electron')
this.remote = this.electron.remote
this.app = this.remote.app
this.screen = this.remote.screen
this.dialog = this.remote.dialog
this.shell = this.electron.shell
this.clipboard = this.electron.clipboard
this.ipcRenderer = this.electron.ipcRenderer
this.globalShortcut = this.remote.globalShortcut
this.TouchBar = this.remote.TouchBar
}
remoteRequire (name: string): any {
return this.remote.require(name)
}
remoteRequirePluginModule (plugin: string, module: string, globals: any): any {
return this.remoteRequire(globals.require.resolve(`${plugin}/node_modules/${module}`))
}
loseFocus () {
if (process.platform === 'darwin') {
this.remote.Menu.sendActionToFirstResponder('hide:')
}
}
}