fix: replace default dialog with notification (#98)
Signed-off-by: dxty522 <261609953+dxty522@users.noreply.github.com>
This commit is contained in:
+13
-3
@@ -1,6 +1,6 @@
|
|||||||
import { updateElectronApp } from "update-electron-app";
|
import { IUpdateInfo, updateElectronApp } from "update-electron-app";
|
||||||
|
|
||||||
import { BrowserWindow, app, shell } from "electron";
|
import { BrowserWindow, app, shell, Notification } from "electron";
|
||||||
import started from "electron-squirrel-startup";
|
import started from "electron-squirrel-startup";
|
||||||
|
|
||||||
import { autoLaunch } from "./native/autoLaunch";
|
import { autoLaunch } from "./native/autoLaunch";
|
||||||
@@ -24,9 +24,19 @@ if (!config.hardwareAcceleration) {
|
|||||||
// ensure only one copy of the application can run
|
// ensure only one copy of the application can run
|
||||||
const acquiredLock = app.requestSingleInstanceLock();
|
const acquiredLock = app.requestSingleInstanceLock();
|
||||||
|
|
||||||
|
const onNotifyUser = (_info: IUpdateInfo) => {
|
||||||
|
const notification = new Notification({
|
||||||
|
title: 'Update Available',
|
||||||
|
body: 'Restart the app to install the update.',
|
||||||
|
silent: true
|
||||||
|
})
|
||||||
|
|
||||||
|
notification.show()
|
||||||
|
}
|
||||||
|
|
||||||
if (acquiredLock) {
|
if (acquiredLock) {
|
||||||
// start auto update logic
|
// start auto update logic
|
||||||
updateElectronApp();
|
updateElectronApp({onNotifyUser})
|
||||||
|
|
||||||
// create and configure the app when electron is ready
|
// create and configure the app when electron is ready
|
||||||
app.on("ready", () => {
|
app.on("ready", () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user