mirror of
https://gitcode.com/gh_mirrors/re/react-native-pushy.git
synced 2025-11-03 06:43:10 +08:00
feat: extra param for checkupdate
This commit is contained in:
@@ -150,7 +150,7 @@ export class Pushy {
|
|||||||
PushyModule.setNeedUpdate({ hash });
|
PushyModule.setNeedUpdate({ hash });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
checkUpdate = async () => {
|
checkUpdate = async (extra?: Record<string, any>) => {
|
||||||
if (__DEV__ && !this.options.debug) {
|
if (__DEV__ && !this.options.debug) {
|
||||||
console.info(
|
console.info(
|
||||||
'您当前处于开发环境且未启用 debug,不会进行热更检查。如需在开发环境中调试热更,请在 client 中设置 debug 为 true',
|
'您当前处于开发环境且未启用 debug,不会进行热更检查。如需在开发环境中调试热更,请在 client 中设置 debug 为 true',
|
||||||
@@ -176,6 +176,7 @@ export class Pushy {
|
|||||||
hash: currentVersion,
|
hash: currentVersion,
|
||||||
buildTime,
|
buildTime,
|
||||||
cInfo,
|
cInfo,
|
||||||
|
...extra,
|
||||||
};
|
};
|
||||||
if (__DEV__) {
|
if (__DEV__) {
|
||||||
delete fetchBody.buildTime;
|
delete fetchBody.buildTime;
|
||||||
|
|||||||
@@ -145,7 +145,8 @@ export const PushyProvider = ({
|
|||||||
[client],
|
[client],
|
||||||
);
|
);
|
||||||
|
|
||||||
const checkUpdate = useCallback(async () => {
|
const checkUpdate = useCallback(
|
||||||
|
async (extra?: Record<string, any>) => {
|
||||||
const now = Date.now();
|
const now = Date.now();
|
||||||
if (lastChecking.current && now - lastChecking.current < 1000) {
|
if (lastChecking.current && now - lastChecking.current < 1000) {
|
||||||
return;
|
return;
|
||||||
@@ -153,7 +154,7 @@ export const PushyProvider = ({
|
|||||||
lastChecking.current = now;
|
lastChecking.current = now;
|
||||||
let info: CheckResult;
|
let info: CheckResult;
|
||||||
try {
|
try {
|
||||||
info = await client.checkUpdate();
|
info = await client.checkUpdate(extra);
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
setLastError(e);
|
setLastError(e);
|
||||||
alertError('更新检查失败', e.message);
|
alertError('更新检查失败', e.message);
|
||||||
@@ -211,7 +212,8 @@ export const PushyProvider = ({
|
|||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}, [
|
},
|
||||||
|
[
|
||||||
client,
|
client,
|
||||||
alertError,
|
alertError,
|
||||||
throwErrorIfEnabled,
|
throwErrorIfEnabled,
|
||||||
@@ -219,7 +221,8 @@ export const PushyProvider = ({
|
|||||||
alertUpdate,
|
alertUpdate,
|
||||||
downloadAndInstallApk,
|
downloadAndInstallApk,
|
||||||
downloadUpdate,
|
downloadUpdate,
|
||||||
]);
|
],
|
||||||
|
);
|
||||||
|
|
||||||
const markSuccess = client.markSuccess;
|
const markSuccess = client.markSuccess;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user