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

@@ -0,0 +1,25 @@
import axios from 'axios'
import { RELEASE_URL, RELEASE_URL_BACKUP } from './static'
import yaml from 'js-yaml'
export const getLatestVersion = async (isCheckBetaUpdate: boolean = false) => {
let res: string = ''
try {
res = await axios.get(RELEASE_URL).then(r => {
const list = r.data as IStringKeyMap[]
if (isCheckBetaUpdate) {
const betaList = list.filter(item => item.name.includes('beta'))
return betaList[0].name
}
const normalList = list.filter(item => !item.name.includes('beta'))
return normalList[0].name
}).catch(async () => {
const result = await axios.get(isCheckBetaUpdate ? `${RELEASE_URL_BACKUP}/latest.beta.yml` : `${RELEASE_URL_BACKUP}/latest.yml`)
const r = yaml.load(result.data) as IStringKeyMap
return r.version
})
} catch (err) {
console.log(err)
}
return res
}

View File

@@ -1 +1,5 @@
export const CLIPBOARD_IMAGE_FOLDER = 'picgo-clipboard-images'
export const RELEASE_URL = 'https://api.github.com/repos/Molunerfinn/PicGo/releases'
export const RELEASE_URL_BACKUP = 'https://picgo-1251750343.cos.ap-chengdu.myqcloud.com'
export const STABLE_RELEASE_URL = 'https://github.com/Molunerfinn/PicGo/releases/latest'
export const BETA_RELEASE_URL = 'https://github.com/Molunerfinn/PicGo/releases'