mirror of
https://github.com/Myxelium/Bridge-Multi.git
synced 2026-04-11 14:19:38 +00:00
Improve update UI
This commit is contained in:
@@ -2,12 +2,13 @@ import { IpcInvokeHandlers, IpcToMainEmitHandlers } from '../src-shared/interfac
|
||||
import { download } from './ipc/DownloadHandler.ipc.js'
|
||||
import { getSettings, setSettings } from './ipc/SettingsHandler.ipc.js'
|
||||
import { downloadUpdate, getCurrentVersion, getUpdateAvailable, quitAndInstall, retryUpdate } from './ipc/UpdateHandler.ipc.js'
|
||||
import { isMaximized, maximize, minimize, openUrl, quit, restore, showFile, showFolder, showOpenDialog, toggleDevTools } from './ipc/UtilHandlers.ipc.js'
|
||||
import { getPlatform, isMaximized, maximize, minimize, openUrl, quit, restore, showFile, showFolder, showOpenDialog, toggleDevTools } from './ipc/UtilHandlers.ipc.js'
|
||||
|
||||
export function getIpcInvokeHandlers(): IpcInvokeHandlers {
|
||||
return {
|
||||
getSettings,
|
||||
getCurrentVersion,
|
||||
getPlatform,
|
||||
getUpdateAvailable,
|
||||
isMaximized,
|
||||
showOpenDialog,
|
||||
|
||||
@@ -4,24 +4,24 @@ import { inspect } from 'util'
|
||||
import { UpdateProgress } from '../../src-shared/interfaces/update.interface.js'
|
||||
import { emitIpcEvent } from '../main.js'
|
||||
|
||||
let updateAvailable: boolean | null = false
|
||||
let updateAvailable: 'yes' | 'no' | 'error' = 'no'
|
||||
let downloading = false
|
||||
|
||||
electronUpdater.autoUpdater.autoDownload = false
|
||||
electronUpdater.autoUpdater.logger = null
|
||||
|
||||
electronUpdater.autoUpdater.on('error', (err: Error) => {
|
||||
updateAvailable = null
|
||||
updateAvailable = 'error'
|
||||
emitIpcEvent('updateError', inspect(err))
|
||||
})
|
||||
|
||||
electronUpdater.autoUpdater.on('update-available', (info: electronUpdater.UpdateInfo) => {
|
||||
updateAvailable = true
|
||||
updateAvailable = 'yes'
|
||||
emitIpcEvent('updateAvailable', info)
|
||||
})
|
||||
|
||||
electronUpdater.autoUpdater.on('update-not-available', () => {
|
||||
updateAvailable = false
|
||||
updateAvailable = 'no'
|
||||
emitIpcEvent('updateAvailable', null)
|
||||
})
|
||||
|
||||
@@ -30,7 +30,7 @@ export async function retryUpdate() {
|
||||
try {
|
||||
await electronUpdater.autoUpdater.checkForUpdates()
|
||||
} catch (err) {
|
||||
updateAvailable = null
|
||||
updateAvailable = 'error'
|
||||
emitIpcEvent('updateError', inspect(err))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,3 +44,7 @@ export function showFolder(folderPath: string) {
|
||||
export function showFile(filePath: string) {
|
||||
shell.showItemInFolder(filePath)
|
||||
}
|
||||
|
||||
export async function getPlatform() {
|
||||
return process.platform
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ const electronApi: ContextBridgeApi = {
|
||||
invoke: {
|
||||
getSettings: getInvoker('getSettings'),
|
||||
getCurrentVersion: getInvoker('getCurrentVersion'),
|
||||
getPlatform: getInvoker('getPlatform'),
|
||||
getUpdateAvailable: getInvoker('getUpdateAvailable'),
|
||||
isMaximized: getInvoker('isMaximized'),
|
||||
showOpenDialog: getInvoker('showOpenDialog'),
|
||||
|
||||
Reference in New Issue
Block a user