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