mirror of
https://github.com/Kuingsmile/PicList.git
synced 2025-02-10 06:08:14 -05:00
21 lines
624 B
TypeScript
21 lines
624 B
TypeScript
import axios from 'axios'
|
|
import yaml from 'js-yaml'
|
|
import { RELEASE_URL, RELEASE_URL_BACKUP } from './static'
|
|
|
|
export const getLatestVersion = async (): Promise<string> => {
|
|
try {
|
|
const { data: normalList } = await axios.get(RELEASE_URL)
|
|
return normalList[0].name
|
|
} catch (err) {
|
|
console.error('Error fetching latest version: ', err)
|
|
try {
|
|
const { data } = await axios.get(`${RELEASE_URL_BACKUP}/latest.yml`)
|
|
const r = yaml.load(data) as IStringKeyMap
|
|
return r.version
|
|
} catch (err) {
|
|
console.error('Error fetching backup latest version: ', err)
|
|
return ''
|
|
}
|
|
}
|
|
}
|