fix: replace default dialog with notification (#98)
Signed-off-by: dxty522 <261609953+dxty522@users.noreply.github.com>
This commit is contained in:
parent
17d6d174ae
commit
7d2f296ca7
1 changed files with 13 additions and 3 deletions
16
src/main.ts
16
src/main.ts
|
|
@ -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", () => {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue