Feature: add dist upload to cos & update checkupdate logic

This commit is contained in:
PiEgg
2022-08-14 20:45:16 +08:00
parent dc85123bde
commit c926414839
15 changed files with 252 additions and 50 deletions

View File

@@ -26,7 +26,8 @@ import {
PICGO_REMOVE_BY_ID_DB,
PICGO_OPEN_FILE,
PASTE_TEXT,
OPEN_WINDOW
OPEN_WINDOW,
DEFAULT_LOGO
} from '#/events/constants'
import { GalleryDB } from 'apis/core/datastore'
@@ -366,6 +367,12 @@ const handleOpenWindow = () => {
})
}
const handleDefaultLogo = () => {
ipcMain.on(DEFAULT_LOGO, (event: IpcMainEvent) => {
event.sender.send(DEFAULT_LOGO, path.join(__static, 'roundLogo.png'))
})
}
export default {
listen () {
handleGetPluginList()
@@ -379,6 +386,7 @@ export default {
handleImportLocalPlugin()
handleOpenFile()
handleOpenWindow()
handleDefaultLogo()
},
// TODO: separate to single file
handlePluginUninstall,

View File

@@ -1,12 +1,12 @@
import { dialog, shell } from 'electron'
import db from '~/main/apis/core/datastore'
import axios from 'axios'
import pkg from 'root/package.json'
import { lt } from 'semver'
import { T } from '~/universal/i18n'
import { getLatestVersion } from '#/utils/getLatestVersion'
const version = pkg.version
const releaseUrl = 'https://api.github.com/repos/Molunerfinn/PicGo/releases/latest'
const releaseUrlBackup = 'https://cdn.jsdelivr.net/gh/Molunerfinn/PicGo@latest/package.json'
// const releaseUrl = 'https://api.github.com/repos/Molunerfinn/PicGo/releases'
// const releaseUrlBackup = 'https://picgo-1251750343.cos.ap-chengdu.myqcloud.com'
const downloadUrl = 'https://github.com/Molunerfinn/PicGo/releases/latest'
const checkVersion = async () => {
@@ -16,17 +16,10 @@ const checkVersion = async () => {
showTip = true
}
if (showTip) {
let res: any
try {
res = await axios.get(releaseUrl).catch(async () => {
const result = await axios.get(releaseUrlBackup)
return result
})
} catch (err) {
console.log(err)
}
if (res.status === 200) {
const latest = res.data.version || res.data.name
const isCheckBetaUpdate = db.get('settings.checkBetaUpdate') !== false
const res: string = await getLatestVersion(isCheckBetaUpdate)
if (res !== '') {
const latest = res
const result = compareVersion2Update(version, latest)
if (result) {
dialog.showMessageBox({