mirror of
https://github.com/Eugeny/tabby.git
synced 2025-04-06 16:00:28 +08:00
properly relaunch app in the portable build (fixes #478)
This commit is contained in:
parent
206cf974c0
commit
1a0acad3c2
@ -83,7 +83,7 @@
|
||||
"token": "d993c4faa708a4cba84fa3a8e822457e7298d75c"
|
||||
},
|
||||
{
|
||||
"provider": "github",
|
||||
"provider": "github"
|
||||
}
|
||||
],
|
||||
"portable": {
|
||||
|
@ -28,6 +28,7 @@ export class HostAppService {
|
||||
*/
|
||||
shown = new EventEmitter<any>()
|
||||
isFullScreen = false
|
||||
isPortable = !!process.env.PORTABLE_EXECUTABLE_FILE
|
||||
|
||||
private preferencesMenu = new Subject<void>()
|
||||
private secondInstance = new Subject<void>()
|
||||
@ -251,6 +252,15 @@ export class HostAppService {
|
||||
this.electron.ipcRenderer.send('window-close')
|
||||
}
|
||||
|
||||
relaunch () {
|
||||
if (this.isPortable) {
|
||||
this.electron.app.relaunch({ execPath: process.env.PORTABLE_EXECUTABLE_FILE })
|
||||
} else {
|
||||
this.electron.app.relaunch()
|
||||
}
|
||||
this.electron.app.exit()
|
||||
}
|
||||
|
||||
quit () {
|
||||
this.logger.info('Quitting')
|
||||
this.electron.app.quit()
|
||||
|
@ -59,6 +59,7 @@ export class ShellIntegrationService {
|
||||
}
|
||||
|
||||
async install () {
|
||||
const exe = process.env.PORTABLE_EXECUTABLE_FILE || this.electron.app.getPath('exe')
|
||||
if (this.hostApp.platform === Platform.macOS) {
|
||||
for (let wf of this.automatorWorkflows) {
|
||||
await exec(`cp -r "${this.automatorWorkflowsLocation}/${wf}" "${this.automatorWorkflowsDestination}"`)
|
||||
@ -67,8 +68,8 @@ export class ShellIntegrationService {
|
||||
for (let registryKey of this.registryKeys) {
|
||||
wnr.createRegistryKey(wnr.HK.CU, registryKey.path)
|
||||
wnr.createRegistryKey(wnr.HK.CU, registryKey.path + '\\command')
|
||||
wnr.setRegistryValue(wnr.HK.CU, registryKey.path, 'Icon', wnr.REG.SZ, this.electron.app.getPath('exe'))
|
||||
wnr.setRegistryValue(wnr.HK.CU, registryKey.path + '\\command', '', wnr.REG.SZ, this.electron.app.getPath('exe') + ' ' + registryKey.command)
|
||||
wnr.setRegistryValue(wnr.HK.CU, registryKey.path, 'Icon', wnr.REG.SZ, exe)
|
||||
wnr.setRegistryValue(wnr.HK.CU, registryKey.path + '\\command', '', wnr.REG.SZ, exe + ' ' + registryKey.command)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
import axios from 'axios'
|
||||
import * as os from 'os'
|
||||
|
||||
import { Injectable } from '@angular/core'
|
||||
import { Logger, LogService } from './log.service'
|
||||
@ -14,6 +13,7 @@ export class UpdaterService {
|
||||
private downloaded: Promise<boolean>
|
||||
private electronUpdaterAvailable = true
|
||||
private updateURL: string
|
||||
private autoUpdater
|
||||
|
||||
constructor (
|
||||
log: LogService,
|
||||
@ -21,24 +21,24 @@ export class UpdaterService {
|
||||
) {
|
||||
this.logger = log.create('updater')
|
||||
|
||||
const autoUpdater = electron.remote.require('electron-updater').autoUpdater
|
||||
this.autoUpdater = electron.remote.require('electron-updater').autoUpdater
|
||||
|
||||
autoUpdater.on('update-available', () => {
|
||||
this.autoUpdater.on('update-available', () => {
|
||||
this.logger.info('Update available')
|
||||
})
|
||||
autoUpdater.once('update-not-available', () => {
|
||||
this.autoUpdater.once('update-not-available', () => {
|
||||
this.logger.info('No updates')
|
||||
})
|
||||
|
||||
this.downloaded = new Promise<boolean>(resolve => {
|
||||
autoUpdater.once('update-downloaded', () => resolve(true))
|
||||
this.autoUpdater.once('update-downloaded', () => resolve(true))
|
||||
})
|
||||
|
||||
this.logger.debug('Checking for updates')
|
||||
|
||||
if (this.electronUpdaterAvailable) {
|
||||
try {
|
||||
autoUpdater.checkForUpdates()
|
||||
this.autoUpdater.checkForUpdates()
|
||||
} catch (e) {
|
||||
this.electronUpdaterAvailable = false
|
||||
this.logger.info('Electron updater unavailable, falling back', e)
|
||||
@ -68,7 +68,7 @@ export class UpdaterService {
|
||||
this.electron.shell.openExternal(this.updateURL)
|
||||
} else {
|
||||
await this.downloaded
|
||||
autoUpdater.quitAndInstall()
|
||||
this.autoUpdater.quitAndInstall()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -100,8 +100,7 @@ export class SettingsTabComponent extends BaseTabComponent {
|
||||
}
|
||||
|
||||
restartApp () {
|
||||
this.electron.app.relaunch()
|
||||
this.electron.app.exit()
|
||||
this.hostApp.relaunch()
|
||||
}
|
||||
|
||||
saveConfigFile () {
|
||||
|
Loading…
x
Reference in New Issue
Block a user