From d000c40e0f7f6a64722103fb51efee45532b464d Mon Sep 17 00:00:00 2001 From: sunnylqm Date: Sat, 24 Aug 2024 15:28:27 +0800 Subject: [PATCH] v10.12.0 --- package.json | 2 +- src/client.ts | 14 ++++++++++++++ src/type.ts | 2 ++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index aceb437..2ca371e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-update", - "version": "10.11.8", + "version": "10.12.0", "description": "react-native hot update", "main": "src/index", "scripts": { diff --git a/src/client.ts b/src/client.ts index c311de7..5c91ba3 100644 --- a/src/client.ts +++ b/src/client.ts @@ -163,6 +163,13 @@ export class Pushy { console.warn('web 端不支持热更新检查'); return; } + if ( + this.options.beforeCheckUpdate && + (await this.options.beforeCheckUpdate()) === false + ) { + log('beforeCheckUpdate 返回 false, 忽略检查'); + return; + } const now = Date.now(); if ( this.lastRespJson && @@ -275,6 +282,13 @@ export class Pushy { description, metaInfo, } = info; + if ( + this.options.beforeDownloadUpdate && + (await this.options.beforeDownloadUpdate(info)) === false + ) { + log('beforeDownloadUpdate 返回 false, 忽略下载'); + return; + } if (!info.update || !hash) { return; } diff --git a/src/type.ts b/src/type.ts index 828bb8d..175ee40 100644 --- a/src/type.ts +++ b/src/type.ts @@ -81,6 +81,8 @@ export interface PushyOptions { dismissErrorAfter?: number; debug?: boolean; throwError?: boolean; + beforeCheckUpdate?: () => Promise; + beforeDownloadUpdate?: (info: CheckResult) => Promise; } export interface PushyTestPayload {