diff --git a/CHANGELOG.md b/CHANGELOG.md index ac3e91a..1ea7161 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ * 新增最小化至系統匣的設定 (https://github.com/ExpTechTW/TREM-tauri/pull/30) * 新增啟動參數 `--quiet` 在開啟程式時隱藏視窗 (https://github.com/ExpTechTW/TREM-tauri/pull/30) * 停用瀏覽器內建快捷鍵 (https://github.com/ExpTechTW/TREM-tauri/pull/31) +* 自動抓取並更新地震報告 (https://github.com/ExpTechTW/TREM-tauri/pull/32) **完整變更紀錄**: https://github.com/ExpTechTW/TREM-tauri/compare/v0.0.0-alpha.2...v0.0.0-alpha.3 diff --git a/src/main.ts b/src/main.ts index 1152895..e247cd2 100644 --- a/src/main.ts +++ b/src/main.ts @@ -69,7 +69,7 @@ const instance = app.mount("#app") as InstanceType; api.setApiKey(await setting.get("api.key")); - props.reports.push(...(await api.getReports(50))); + props.reports.push(...(await api.getReports())); props.stations.value = await api.getStations(); await browserWindow.setAlwaysOnTop(setting.settings.behavior.alwaysOnTop); @@ -79,6 +79,14 @@ const instance = app.mount("#app") as InstanceType; } else { disableAutoStart(); } + + timer.reportFetchTimer = window.setInterval(async () => { + const ids = props.reports.map((r) => r.id); + const reports = (await api.getReports()).filter((r) => !ids.includes(r.id)); + + props.reports.push(...reports); + props.reports.sort((a, b) => b.time - a.time); + }, 60_000); })(); let replayMode: boolean = false;