1
0
Code Issues Pull Requests Packages Projects Releases Wiki Activity GitHub Gitee

feat: extra param for checkupdate

This commit is contained in:
sunnylqm 2024-07-25 22:04:52 +08:00
parent 54036c0f16
commit a5893d8022
No known key found for this signature in database
2 changed files with 76 additions and 72 deletions

View File

@ -150,7 +150,7 @@ export class Pushy {
PushyModule.setNeedUpdate({ hash });
}
};
checkUpdate = async () => {
checkUpdate = async (extra?: Record<string, any>) => {
if (__DEV__ && !this.options.debug) {
console.info(
'您当前处于开发环境且未启用 debug不会进行热更检查。如需在开发环境中调试热更请在 client 中设置 debug 为 true',
@ -176,6 +176,7 @@ export class Pushy {
hash: currentVersion,
buildTime,
cInfo,
...extra,
};
if (__DEV__) {
delete fetchBody.buildTime;

View File

@ -145,7 +145,8 @@ export const PushyProvider = ({
[client],
);
const checkUpdate = useCallback(async () => {
const checkUpdate = useCallback(
async (extra?: Record<string, any>) => {
const now = Date.now();
if (lastChecking.current && now - lastChecking.current < 1000) {
return;
@ -153,7 +154,7 @@ export const PushyProvider = ({
lastChecking.current = now;
let info: CheckResult;
try {
info = await client.checkUpdate();
info = await client.checkUpdate(extra);
} catch (e: any) {
setLastError(e);
alertError('更新检查失败', e.message);
@ -211,7 +212,8 @@ export const PushyProvider = ({
],
);
}
}, [
},
[
client,
alertError,
throwErrorIfEnabled,
@ -219,7 +221,8 @@ export const PushyProvider = ({
alertUpdate,
downloadAndInstallApk,
downloadUpdate,
]);
],
);
const markSuccess = client.markSuccess;