data sync

This commit is contained in:
Gabe Yuan
2023-07-31 03:10:09 +08:00
parent 497084fe8a
commit 2aef159d9d
12 changed files with 14333 additions and 9971 deletions

View File

@@ -11,6 +11,7 @@ import {
import { fetchData, setFetchLimit } from "./libs/fetch";
import storage from "./libs/storage";
import { getSetting } from "./libs";
import { apiSyncAll } from "./apis/data";
/**
* 插件安装
@@ -26,6 +27,15 @@ browser.runtime.onInstalled.addListener(() => {
*/
browser.runtime.onStartup.addListener(async () => {
console.log("onStartup");
// 同步数据
try {
await apiSyncAll();
} catch (err) {
console.log("[sync all]", err);
}
// 清除缓存
const { clearCache } = await getSetting();
if (clearCache) {
caches.delete(CACHE_NAME);