1
0
mirror of https://gitcode.com/gh_mirrors/re/react-native-pushy.git synced 2025-09-16 10:21:37 +08:00
Code Issues Packages Projects Releases Wiki Activity GitHub Gitee
This commit is contained in:
sunnylqm
2024-08-24 15:28:27 +08:00
parent 5659c79726
commit d000c40e0f
3 changed files with 17 additions and 1 deletions

View File

@@ -1,6 +1,6 @@
{ {
"name": "react-native-update", "name": "react-native-update",
"version": "10.11.8", "version": "10.12.0",
"description": "react-native hot update", "description": "react-native hot update",
"main": "src/index", "main": "src/index",
"scripts": { "scripts": {

View File

@@ -163,6 +163,13 @@ export class Pushy {
console.warn('web 端不支持热更新检查'); console.warn('web 端不支持热更新检查');
return; return;
} }
if (
this.options.beforeCheckUpdate &&
(await this.options.beforeCheckUpdate()) === false
) {
log('beforeCheckUpdate 返回 false, 忽略检查');
return;
}
const now = Date.now(); const now = Date.now();
if ( if (
this.lastRespJson && this.lastRespJson &&
@@ -275,6 +282,13 @@ export class Pushy {
description, description,
metaInfo, metaInfo,
} = info; } = info;
if (
this.options.beforeDownloadUpdate &&
(await this.options.beforeDownloadUpdate(info)) === false
) {
log('beforeDownloadUpdate 返回 false, 忽略下载');
return;
}
if (!info.update || !hash) { if (!info.update || !hash) {
return; return;
} }

View File

@@ -81,6 +81,8 @@ export interface PushyOptions {
dismissErrorAfter?: number; dismissErrorAfter?: number;
debug?: boolean; debug?: boolean;
throwError?: boolean; throwError?: boolean;
beforeCheckUpdate?: () => Promise<boolean>;
beforeDownloadUpdate?: (info: CheckResult) => Promise<boolean>;
} }
export interface PushyTestPayload { export interface PushyTestPayload {