mirror of
https://gitcode.com/gh_mirrors/re/react-native-pushy.git
synced 2025-11-01 13:53:11 +08:00
v8.5.1
This commit is contained in:
@@ -1,13 +1,21 @@
|
|||||||
import { logger } from './utils';
|
import { logger } from './utils';
|
||||||
|
|
||||||
let currentEndpoint = 'https://update.react-native.cn/api';
|
let currentEndpoint = 'https://update.react-native.cn/api';
|
||||||
let backupEndpoints: string[] = ['https://update.reactnative.cn/api'];
|
let backupEndpoints: string[] = [
|
||||||
let backupEndpointsQueryUrl: string | null = null;
|
'https://pushy-koa-qgbgqmcpis.cn-beijing.fcapp.run',
|
||||||
|
'https://update.reactnative.cn/api',
|
||||||
|
];
|
||||||
|
let backupEndpointsQueryUrls = [
|
||||||
|
'https://gitee.com/sunnylqm/react-native-pushy/raw/master/endpoints.json',
|
||||||
|
'https://cdn.jsdelivr.net/gh/reactnativecn/react-native-pushy@master/endpoints.json',
|
||||||
|
];
|
||||||
|
|
||||||
export async function updateBackupEndpoints() {
|
export async function updateBackupEndpoints() {
|
||||||
if (backupEndpointsQueryUrl) {
|
if (backupEndpointsQueryUrls) {
|
||||||
try {
|
try {
|
||||||
const resp = await fetch(backupEndpointsQueryUrl);
|
const resp = await Promise.race(
|
||||||
|
backupEndpointsQueryUrls.map((queryUrl) => fetch(queryUrl)),
|
||||||
|
);
|
||||||
const remoteEndpoints = await resp.json();
|
const remoteEndpoints = await resp.json();
|
||||||
if (Array.isArray(remoteEndpoints)) {
|
if (Array.isArray(remoteEndpoints)) {
|
||||||
backupEndpoints = Array.from(
|
backupEndpoints = Array.from(
|
||||||
@@ -36,18 +44,17 @@ export function getCheckUrl(APPKEY, endpoint = currentEndpoint) {
|
|||||||
export function setCustomEndpoints({
|
export function setCustomEndpoints({
|
||||||
main,
|
main,
|
||||||
backups,
|
backups,
|
||||||
backupQueryUrl,
|
backupQueryUrls,
|
||||||
}: {
|
}: {
|
||||||
main: string;
|
main: string;
|
||||||
backups?: string[];
|
backups?: string[];
|
||||||
backupQueryUrl?: string;
|
backupQueryUrls?: string[];
|
||||||
}) {
|
}) {
|
||||||
currentEndpoint = main;
|
currentEndpoint = main;
|
||||||
backupEndpointsQueryUrl = null;
|
|
||||||
if (Array.isArray(backups) && backups.length > 0) {
|
if (Array.isArray(backups) && backups.length > 0) {
|
||||||
backupEndpoints = backups;
|
backupEndpoints = backups;
|
||||||
}
|
}
|
||||||
if (typeof backupQueryUrl === 'string') {
|
if (Array.isArray(backupQueryUrls) && backupQueryUrls.length > 0) {
|
||||||
backupEndpointsQueryUrl = backupQueryUrl;
|
backupEndpointsQueryUrls = backupQueryUrls;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "react-native-update",
|
"name": "react-native-update",
|
||||||
"version": "8.5.0",
|
"version": "8.5.1",
|
||||||
"description": "react-native hot update",
|
"description": "react-native hot update",
|
||||||
"main": "lib/index.ts",
|
"main": "lib/index.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
Reference in New Issue
Block a user