2022-08-14 08:45:16 -04:00
|
|
|
import axios from 'axios'
|
|
|
|
import { RELEASE_URL, RELEASE_URL_BACKUP } from './static'
|
|
|
|
import yaml from 'js-yaml'
|
|
|
|
|
2023-02-15 10:36:47 -05:00
|
|
|
export const getLatestVersion = async () => {
|
2022-08-14 08:45:16 -04:00
|
|
|
let res: string = ''
|
|
|
|
try {
|
|
|
|
res = await axios.get(RELEASE_URL).then(r => {
|
|
|
|
const list = r.data as IStringKeyMap[]
|
|
|
|
const normalList = list.filter(item => !item.name.includes('beta'))
|
|
|
|
return normalList[0].name
|
|
|
|
}).catch(async () => {
|
2023-02-15 10:36:47 -05:00
|
|
|
const result = await axios.get(`${RELEASE_URL_BACKUP}/latest.yml`)
|
2022-08-14 08:45:16 -04:00
|
|
|
const r = yaml.load(result.data) as IStringKeyMap
|
|
|
|
return r.version
|
|
|
|
})
|
|
|
|
} catch (err) {
|
|
|
|
console.log(err)
|
|
|
|
}
|
|
|
|
return res
|
|
|
|
}
|