mirror of
https://github.com/Kuingsmile/PicList.git
synced 2025-02-11 06:38:13 -05:00
26 lines
876 B
TypeScript
26 lines
876 B
TypeScript
![]() |
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
|
||
|
}
|