update queryurls
This commit is contained in:
parent
88bacdfb15
commit
2357a0b78d
@ -17,8 +17,10 @@ import {
|
|||||||
const defaultServer = {
|
const defaultServer = {
|
||||||
main: 'https://update.react-native.cn/api',
|
main: 'https://update.react-native.cn/api',
|
||||||
backups: ['https://update.reactnative.cn/api'],
|
backups: ['https://update.reactnative.cn/api'],
|
||||||
queryUrl:
|
queryUrls: [
|
||||||
|
'https://gitee.com/sunnylqm/react-native-pushy/raw/master/endpoints.json',
|
||||||
'https://cdn.jsdelivr.net/gh/reactnativecn/react-native-pushy@master/endpoints.json',
|
'https://cdn.jsdelivr.net/gh/reactnativecn/react-native-pushy@master/endpoints.json',
|
||||||
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
const empty = {};
|
const empty = {};
|
||||||
@ -233,9 +235,11 @@ export class Pushy {
|
|||||||
if (!server) {
|
if (!server) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
if (server.queryUrl) {
|
if (server.queryUrls) {
|
||||||
try {
|
try {
|
||||||
const resp = await fetch(server.queryUrl);
|
const resp = await Promise.race(
|
||||||
|
server.queryUrls.map(queryUrl => fetch(queryUrl)),
|
||||||
|
);
|
||||||
const remoteEndpoints = await resp.json();
|
const remoteEndpoints = await resp.json();
|
||||||
log('fetch endpoints:', remoteEndpoints);
|
log('fetch endpoints:', remoteEndpoints);
|
||||||
if (Array.isArray(remoteEndpoints)) {
|
if (Array.isArray(remoteEndpoints)) {
|
||||||
@ -244,7 +248,7 @@ export class Pushy {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
log('failed to fetch endpoints from: ', server.queryUrl);
|
log('failed to fetch endpoints from: ', server.queryUrls);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return server.backups;
|
return server.backups;
|
||||||
|
@ -62,7 +62,7 @@ export type UpdateEventsLogger = ({
|
|||||||
export interface PushyServerConfig {
|
export interface PushyServerConfig {
|
||||||
main: string;
|
main: string;
|
||||||
backups?: string[];
|
backups?: string[];
|
||||||
queryUrl?: string;
|
queryUrls?: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PushyOptions {
|
export interface PushyOptions {
|
||||||
|
Loading…
Reference in New Issue
Block a user