Skip to content

Commit 96abce7

Browse files
committed
🐛 修复定时器问题
1 parent cc0e0bd commit 96abce7

2 files changed

Lines changed: 14 additions & 6 deletions

File tree

src/app/service/service_worker/index.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,14 @@ export default class ServiceWorkerManager {
9595
break;
9696
}
9797
});
98-
// 8小时检查一次扩展更新
99-
chrome.alarms.create("checkUpdate", {
100-
delayInMinutes: 0,
101-
periodInMinutes: 8 * 60,
98+
// 12小时检查一次扩展更新
99+
chrome.alarms.get("checkUpdate", (alarm) => {
100+
if (!alarm) {
101+
chrome.alarms.create("checkUpdate", {
102+
delayInMinutes: 0,
103+
periodInMinutes: 12 * 60,
104+
});
105+
}
102106
});
103107

104108
// 监听配置变化

src/app/service/service_worker/synchronize.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -604,8 +604,12 @@ export class SynchronizeService {
604604
this.buildFileSystem(value).then(async (fs) => {
605605
await this.syncOnce(value, fs);
606606
// 开启定时器, 一小时一次
607-
chrome.alarms.create("cloudSync", {
608-
periodInMinutes: 60,
607+
chrome.alarms.get("cloudSync", (alarm) => {
608+
if (!alarm) {
609+
chrome.alarms.create("cloudSync", {
610+
periodInMinutes: 60,
611+
});
612+
}
609613
});
610614
});
611615
} else {

0 commit comments

Comments
 (0)