处理service worker的问题
Some checks failed
test / Run tests (push) Failing after 3s
build / Build (push) Failing after 6s

This commit is contained in:
2025-03-31 22:52:52 +08:00
parent 315f5f148c
commit db8c5ec7b5
2 changed files with 16 additions and 8 deletions

View File

@ -217,3 +217,13 @@ export function sleep(time: number) {
setTimeout(resolve, time);
});
}
// 使service_worker长时间存活
export async function waitUntil(promise: Promise<any>) {
const keepAlive = setInterval(chrome.runtime.getPlatformInfo, 25 * 1000);
try {
await promise;
} finally {
clearInterval(keepAlive);
}
}