mirror of
https://github.com/Eugeny/tabby.git
synced 2025-07-20 02:18:01 +00:00
more electron/web separation
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
import { app, ipcMain, Menu, Tray, shell, screen, globalShortcut, MenuItemConstructorOptions } from 'electron'
|
||||
import * as promiseIpc from 'electron-promise-ipc'
|
||||
import * as remote from '@electron/remote/main'
|
||||
import * as path from 'path'
|
||||
import * as fs from 'fs'
|
||||
|
||||
import { loadConfig } from './config'
|
||||
import { Window, WindowOptions } from './window'
|
||||
@@ -17,6 +19,7 @@ export class Application {
|
||||
private tray?: Tray
|
||||
private ptyManager = new PTYManager()
|
||||
private windows: Window[] = []
|
||||
userPluginsPath: string
|
||||
|
||||
constructor () {
|
||||
remote.initialize()
|
||||
@@ -36,12 +39,12 @@ export class Application {
|
||||
}
|
||||
})
|
||||
|
||||
;(promiseIpc as any).on('plugin-manager:install', (path, name, version) => {
|
||||
return pluginManager.install(path, name, version)
|
||||
;(promiseIpc as any).on('plugin-manager:install', (name, version) => {
|
||||
return pluginManager.install(this.userPluginsPath, name, version)
|
||||
})
|
||||
|
||||
;(promiseIpc as any).on('plugin-manager:uninstall', (path, name) => {
|
||||
return pluginManager.uninstall(path, name)
|
||||
;(promiseIpc as any).on('plugin-manager:uninstall', (name) => {
|
||||
return pluginManager.uninstall(this.userPluginsPath, name)
|
||||
})
|
||||
|
||||
const configData = loadConfig()
|
||||
@@ -53,6 +56,15 @@ export class Application {
|
||||
}
|
||||
}
|
||||
|
||||
this.userPluginsPath = path.join(
|
||||
app.getPath('userData'),
|
||||
'plugins',
|
||||
)
|
||||
|
||||
if (!fs.existsSync(this.userPluginsPath)) {
|
||||
fs.mkdirSync(this.userPluginsPath)
|
||||
}
|
||||
|
||||
app.commandLine.appendSwitch('disable-http-cache')
|
||||
app.commandLine.appendSwitch('max-active-webgl-contexts', '9000')
|
||||
app.commandLine.appendSwitch('lang', 'EN')
|
||||
@@ -70,7 +82,7 @@ export class Application {
|
||||
}
|
||||
|
||||
async newWindow (options?: WindowOptions): Promise<Window> {
|
||||
const window = new Window(options)
|
||||
const window = new Window(this, options)
|
||||
this.windows.push(window)
|
||||
window.visible$.subscribe(visible => {
|
||||
if (visible) {
|
||||
|
@@ -9,6 +9,7 @@ import * as path from 'path'
|
||||
import macOSRelease from 'macos-release'
|
||||
import * as compareVersions from 'compare-versions'
|
||||
|
||||
import type { Application } from './app'
|
||||
import { parseArgs } from './cli'
|
||||
import { loadConfig } from './config'
|
||||
|
||||
@@ -43,7 +44,7 @@ export class Window {
|
||||
get visible$ (): Observable<boolean> { return this.visible }
|
||||
get closed$ (): Observable<void> { return this.closed }
|
||||
|
||||
constructor (options?: WindowOptions) {
|
||||
constructor (private application: Application, options?: WindowOptions) {
|
||||
this.configStore = loadConfig()
|
||||
|
||||
options = options ?? {}
|
||||
@@ -299,16 +300,10 @@ export class Window {
|
||||
executable: app.getPath('exe'),
|
||||
windowID: this.window.id,
|
||||
isFirstWindow: this.window.id === 1,
|
||||
userPluginsPath: this.application.userPluginsPath,
|
||||
})
|
||||
})
|
||||
|
||||
ipcMain.on('window-focus', event => {
|
||||
if (!this.window || event.sender !== this.window.webContents) {
|
||||
return
|
||||
}
|
||||
this.window.focus()
|
||||
})
|
||||
|
||||
ipcMain.on('window-toggle-maximize', event => {
|
||||
if (!this.window || event.sender !== this.window.webContents) {
|
||||
return
|
||||
|
Reference in New Issue
Block a user