资源探活
export function probeSourceLive(url: string): Promise<string> { return new Promise((resolve, reject) => { uni.request({ url, method: 'HEAD', success: (res) => { const { statusCode } = res; if (statusCode === 200 || String(statusCode).startsWith('3')) { resolve(url); } else { reject(url); } }, fail: () => { reject(url); }, }); }); } export function probeFirstLive(urls: Array<string>): Promise<string> { const array: Array<Promise<string>> = urls.map((item) => { return probeSourceLive(item); }); return Promise.any(array); }
以自己现在的努力程度,还没有资格和别人拼天赋