🦺 关闭自动更新, 手动更新软件. (未完成)

This commit is contained in:
Hunlongyu
2020-10-23 14:40:40 +08:00
parent 1fdfada14f
commit 32fa465cf2
2 changed files with 26 additions and 2 deletions

View File

@@ -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()

View File

@@ -7,6 +7,7 @@
<a @click="linkOpen('https://github.com/Hunlongyu/ZY-Player')">Github</a>
<a @click="linkOpen('https://github.com/Hunlongyu/ZY-Player/issues')">当前版本v{{pkg.version}} 反馈</a>
<a style="color:#38dd77" @click="linkOpen('https://github.com/Hunlongyu/ZY-Player/releases/tag/v' + latestVersion)" v-show="latestVersion !== pkg.version" >最新版本v{{latestVersion}}</a>
<a @click="checkUpdate()">检查更新</a>
</div>
<div class="view">
<div class="title">视图</div>
@@ -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 () {