mirror of
https://github.com/Eugeny/tabby.git
synced 2025-10-05 14:34:54 +00:00
moved electron-specific parts of tabby-local into tabby-electron
This commit is contained in:
69
tabby-electron/src/services/dockMenu.service.ts
Normal file
69
tabby-electron/src/services/dockMenu.service.ts
Normal file
@@ -0,0 +1,69 @@
|
||||
import { NgZone, Injectable } from '@angular/core'
|
||||
import { ConfigService, HostAppService, Platform, ProfilesService, TranslateService } from 'tabby-core'
|
||||
import { ElectronService } from './electron.service'
|
||||
|
||||
/** @hidden */
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class DockMenuService {
|
||||
appVersion: string
|
||||
|
||||
private constructor (
|
||||
config: ConfigService,
|
||||
private electron: ElectronService,
|
||||
private hostApp: HostAppService,
|
||||
private zone: NgZone,
|
||||
private profilesService: ProfilesService,
|
||||
private translate: TranslateService,
|
||||
) {
|
||||
config.changed$.subscribe(() => this.update())
|
||||
}
|
||||
|
||||
async update (): Promise<void> {
|
||||
const profiles = await this.profilesService.getProfiles()
|
||||
|
||||
if (this.hostApp.platform === Platform.Windows) {
|
||||
this.electron.app.setJumpList([
|
||||
{
|
||||
type: 'custom',
|
||||
name: this.translate.instant('Recent'),
|
||||
items: this.profilesService.getRecentProfiles().map((profile, index) => ({
|
||||
type: 'task',
|
||||
program: process.execPath,
|
||||
args: `recent ${index}`,
|
||||
title: profile.name,
|
||||
iconPath: process.execPath,
|
||||
iconIndex: 0,
|
||||
})),
|
||||
},
|
||||
{
|
||||
type: 'custom',
|
||||
name: this.translate.instant('Profiles'),
|
||||
items: profiles.map(profile => ({
|
||||
type: 'task',
|
||||
program: process.execPath,
|
||||
args: `profile "${profile.name}"`,
|
||||
title: profile.name,
|
||||
iconPath: process.execPath,
|
||||
iconIndex: 0,
|
||||
})),
|
||||
},
|
||||
])
|
||||
}
|
||||
if (this.hostApp.platform === Platform.macOS) {
|
||||
this.electron.app.dock.setMenu(this.electron.Menu.buildFromTemplate(
|
||||
[
|
||||
...[...this.profilesService.getRecentProfiles(), ...profiles].map(profile => ({
|
||||
label: profile.name,
|
||||
click: () => this.zone.run(async () => {
|
||||
this.profilesService.openNewTabForProfile(profile)
|
||||
}),
|
||||
})),
|
||||
{
|
||||
label: this.translate.instant('New Window'),
|
||||
click: () => this.zone.run(() => this.hostApp.newWindow()),
|
||||
},
|
||||
],
|
||||
))
|
||||
}
|
||||
}
|
||||
}
|
@@ -234,6 +234,15 @@ export class ElectronPlatformService extends PlatformService {
|
||||
handler(err)
|
||||
})
|
||||
}
|
||||
|
||||
async pickDirectory (): Promise<string> {
|
||||
return (await this.electron.dialog.showOpenDialog(
|
||||
this.hostWindow.getWindow(),
|
||||
{
|
||||
properties: ['openDirectory', 'showHiddenFiles'],
|
||||
},
|
||||
)).filePaths[0]
|
||||
}
|
||||
}
|
||||
|
||||
class ElectronFileUpload extends FileUpload {
|
||||
|
39
tabby-electron/src/services/uac.service.ts
Normal file
39
tabby-electron/src/services/uac.service.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import { Injectable } from '@angular/core'
|
||||
import * as path from 'path'
|
||||
import { WIN_BUILD_CONPTY_SUPPORTED, isWindowsBuild } from 'tabby-core'
|
||||
import { SessionOptions, UACService } from 'tabby-local'
|
||||
import { ElectronService } from './electron.service'
|
||||
|
||||
/** @hidden */
|
||||
@Injectable()
|
||||
export class ElectronUACService extends UACService {
|
||||
constructor (
|
||||
private electron: ElectronService,
|
||||
) {
|
||||
super()
|
||||
this.isAvailable = isWindowsBuild(WIN_BUILD_CONPTY_SUPPORTED)
|
||||
}
|
||||
|
||||
patchSessionOptionsForUAC (sessionOptions: SessionOptions): SessionOptions {
|
||||
let helperPath = path.join(
|
||||
path.dirname(this.electron.app.getPath('exe')),
|
||||
'resources',
|
||||
'extras',
|
||||
'UAC.exe',
|
||||
)
|
||||
|
||||
if (process.env.TABBY_DEV) {
|
||||
helperPath = path.join(
|
||||
path.dirname(this.electron.app.getPath('exe')),
|
||||
'..', '..', '..',
|
||||
'extras',
|
||||
'UAC.exe',
|
||||
)
|
||||
}
|
||||
|
||||
const options = { ...sessionOptions }
|
||||
options.args = [options.command, ...options.args ?? []]
|
||||
options.command = helperPath
|
||||
return options
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user