1cf2d630eS猫头猫import axios from 'axios'; 2cf2d630eS猫头猫import {compare} from 'compare-versions'; 3cf2d630eS猫头猫import DeviceInfo from 'react-native-device-info'; 4cf2d630eS猫头猫 5cf2d630eS猫头猫const updateList = [ 62432f689S猫头猫 'https://gitee.com/maotoumao/MusicFree/raw/master/release/version.json', 7155f7019S猫头猫 'https://raw.githubusercontent.com/maotoumao/MusicFree/master/release/version.json', 8*470618d9S猫头猫 'https://cdn.jsdelivr.net/gh/maotoumao/MusicFree@master/release/version.json', 9cf2d630eS猫头猫]; 10cf2d630eS猫头猫 11cf2d630eS猫头猫interface IUpdateInfo { 12cf2d630eS猫头猫 needUpdate: boolean; 13cf2d630eS猫头猫 data: { 14cf2d630eS猫头猫 version: string; 15cf2d630eS猫头猫 changeLog: string[]; 16cf2d630eS猫头猫 download: string[]; 17cf2d630eS猫头猫 }; 18cf2d630eS猫头猫} 19cf2d630eS猫头猫 20cf2d630eS猫头猫export default async function checkUpdate(): Promise<IUpdateInfo | undefined> { 21cf2d630eS猫头猫 const currentVersion = DeviceInfo.getVersion(); 22cf2d630eS猫头猫 for (let i = 0; i < updateList.length; ++i) { 23cf2d630eS猫头猫 try { 24cf2d630eS猫头猫 const rawInfo = (await axios.get(updateList[i])).data; 25cf2d630eS猫头猫 if (compare(rawInfo.version, currentVersion, '>')) { 26cf2d630eS猫头猫 return { 27cf2d630eS猫头猫 needUpdate: true, 28cf2d630eS猫头猫 data: rawInfo, 29cf2d630eS猫头猫 }; 30cf2d630eS猫头猫 } 31cf2d630eS猫头猫 } catch {} 32cf2d630eS猫头猫 } 33cf2d630eS猫头猫} 34