From 32fa465cf20ae7d017434b59227d4a6bcfee1918 Mon Sep 17 00:00:00 2001 From: Hunlongyu Date: Fri, 23 Oct 2020 14:40:40 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=A6=BA=20=E5=85=B3=E9=97=AD=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E6=9B=B4=E6=96=B0,=20=E6=89=8B=E5=8A=A8=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E8=BD=AF=E4=BB=B6.=20(=E6=9C=AA=E5=AE=8C=E6=88=90)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/background.js | 13 ++++++++++++- src/components/Setting.vue | 15 ++++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) 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}} + 检查更新
视图
@@ -143,7 +144,7 @@ import { mapMutations } from 'vuex' import pkg from '../../package.json' import { setting, sites, shortcut } from '../lib/dexie' import { sites as defaultSites } from '../lib/dexie/initData' -import { shell, clipboard, remote } from 'electron' +import { shell, clipboard, remote, ipcRenderer } from 'electron' import db from '../lib/dexie/dexie' const _hmt = window._hmt export default { @@ -372,6 +373,18 @@ export default { e.preventDefault() menu.popup(remote.getCurrentWindow()) }) + }, + checkUpdate () { + ipcRenderer.send('update') + ipcRenderer.on('update-replay-check', (e, res) => { + console.log(res, 'update-replay-check') + }) + ipcRenderer.on('update-replay-download', (e, res) => { + console.log(res, 'update-replay-download') + }) + ipcRenderer.on('update-replay-downloaded', (e, res) => { + console.log(res, 'update-replay-downloaded') + }) } }, created () {