diff --git a/src/background.js b/src/background.js index e9d6104..7d71c7e 100644 --- a/src/background.js +++ b/src/background.js @@ -15,6 +15,8 @@ let mini protocol.registerSchemesAsPrivileged([{ scheme: 'app', privileges: { secure: true, standard: true } }]) +autoUpdater.autoDownload = false + function createWindow () { win = new BrowserWindow({ width: 1080, @@ -34,7 +36,6 @@ function createWindow () { } else { createProtocol('app') win.loadURL('app://./index.html') - autoUpdater.checkForUpdatesAndNotify() } win.on('closed', () => { @@ -99,6 +100,16 @@ ipcMain.on('win', () => { win.webContents.send('miniClosed') }) +ipcMain.on('update', async () => { + const checkForUpdates = await autoUpdater.checkForUpdates() + win.webContents.send('update-replay-check', checkForUpdates) + const res = await autoUpdater.downloadUpdate() + win.webContents.send('update-replay-download', res) + autoUpdater.on('update-downloaded', () => { + win.webContents.send('update-replay-downloaded', 'downloaded') + }) +}) + const gotTheLock = app.requestSingleInstanceLock() if (!gotTheLock) { app.quit() diff --git a/src/components/Setting.vue b/src/components/Setting.vue index 7338628..6f73499 100644 --- a/src/components/Setting.vue +++ b/src/components/Setting.vue @@ -7,6 +7,7 @@ Github 当前版本v{{pkg.version}} 反馈 最新版本v{{latestVersion}} + 检查更新