mirror of
https://github.com/Kuingsmile/PicList.git
synced 2026-05-20 15:50:04 +08:00
✨ Feature: support auto update now
This commit is contained in:
@@ -4,7 +4,8 @@ import {
|
||||
globalShortcut,
|
||||
protocol,
|
||||
Notification,
|
||||
Menu
|
||||
Menu,
|
||||
dialog
|
||||
} from 'electron'
|
||||
import {
|
||||
createProtocol
|
||||
@@ -42,6 +43,7 @@ import { manageIpcList } from '../manage/events/ipcList'
|
||||
import getManageApi from '../manage/Main'
|
||||
import UpDownTaskQueue from '../manage/datastore/upDownTaskQueue'
|
||||
import { T } from '~/main/i18n'
|
||||
import { UpdateInfo, autoUpdater } from 'electron-updater'
|
||||
const isDevelopment = process.env.NODE_ENV !== 'production'
|
||||
|
||||
const handleStartUpFiles = (argv: string[], cwd: string) => {
|
||||
@@ -61,6 +63,46 @@ const handleStartUpFiles = (argv: string[], cwd: string) => {
|
||||
}
|
||||
}
|
||||
|
||||
autoUpdater.setFeedURL({
|
||||
provider: 'generic',
|
||||
url: 'https://release.piclist.cn/latest',
|
||||
channel: 'latest'
|
||||
})
|
||||
|
||||
autoUpdater.autoDownload = false
|
||||
|
||||
autoUpdater.on('update-available', (info: UpdateInfo) => {
|
||||
dialog.showMessageBox({
|
||||
type: 'info',
|
||||
title: T('FIND_NEW_VERSION'),
|
||||
buttons: ['Yes', 'No'],
|
||||
message: T('TIPS_FIND_NEW_VERSION', {
|
||||
v: info.version
|
||||
})
|
||||
}).then((result) => {
|
||||
if (result.response === 0) {
|
||||
autoUpdater.downloadUpdate()
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
autoUpdater.on('update-downloaded', () => {
|
||||
dialog.showMessageBox({
|
||||
type: 'info',
|
||||
title: T('UPDATE_DOWNLOADED'),
|
||||
buttons: ['Yes', 'No'],
|
||||
message: T('TIPS_UPDATE_DOWNLOADED')
|
||||
}).then((result) => {
|
||||
if (result.response === 0) {
|
||||
autoUpdater.quitAndInstall()
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
autoUpdater.on('error', (err) => {
|
||||
dialog.showErrorBox('error', err.message)
|
||||
})
|
||||
|
||||
class LifeCycle {
|
||||
private async beforeReady () {
|
||||
protocol.registerSchemesAsPrivileged([{ scheme: 'picgo', privileges: { secure: true, standard: true } }])
|
||||
@@ -111,6 +153,7 @@ class LifeCycle {
|
||||
createTray()
|
||||
db.set('needReload', false)
|
||||
updateChecker()
|
||||
autoUpdater.checkForUpdatesAndNotify()
|
||||
// 不需要阻塞
|
||||
process.nextTick(() => {
|
||||
shortKeyHandler.init()
|
||||
|
||||
@@ -151,6 +151,7 @@
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
v-if="false"
|
||||
:label="$T('SETTINGS_OPEN_UPDATE_HELPER')"
|
||||
>
|
||||
<el-switch
|
||||
|
||||
2
src/universal/types/i18n.d.ts
vendored
2
src/universal/types/i18n.d.ts
vendored
@@ -730,6 +730,8 @@ interface ILocales {
|
||||
TIPS_SHORTCUT_MODIFIED_CONFLICT: string
|
||||
TIPS_CUSTOM_LINK_STYLE_MODIFIED_SUCCEED: string
|
||||
TIPS_FIND_NEW_VERSION: string
|
||||
UPDATE_DOWNLOADED: string
|
||||
TIPS_UPDATE_DOWNLOADED: string
|
||||
PRIVACY: string
|
||||
PRIVACY_TIPS: string
|
||||
QUIT: string
|
||||
|
||||
Reference in New Issue
Block a user