perf(frontend): add api cache layer and reduce report polling pressure
This commit is contained in:
@@ -550,9 +550,17 @@ const mobileModules = computed(() => [
|
||||
},
|
||||
])
|
||||
|
||||
const REPORT_SYNC_STATS_EVERY = 3
|
||||
let reportRefreshTick = 0
|
||||
|
||||
async function refreshAll(options = {}) {
|
||||
const showLoading = options.showLoading ?? true
|
||||
if (refreshing.value) return
|
||||
|
||||
const forceStatsSync = Boolean(options.forceStatsSync)
|
||||
const shouldSyncStats = forceStatsSync || reportRefreshTick % REPORT_SYNC_STATS_EVERY === 0
|
||||
reportRefreshTick += 1
|
||||
|
||||
refreshing.value = true
|
||||
if (showLoading) {
|
||||
loading.value = true
|
||||
@@ -593,7 +601,9 @@ async function refreshAll(options = {}) {
|
||||
if (slowSqlResult.status === 'fulfilled') slowSqlMetrics.value = slowSqlResult.value
|
||||
if (configResult.status === 'fulfilled') systemConfig.value = configResult.value
|
||||
|
||||
await refreshStats?.()
|
||||
if (shouldSyncStats) {
|
||||
await refreshStats?.({ force: forceStatsSync })
|
||||
}
|
||||
recordUpdatedAt()
|
||||
} finally {
|
||||
refreshing.value = false
|
||||
@@ -637,7 +647,7 @@ function onVisibilityChange() {
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
refreshAll({ showLoading: false })
|
||||
refreshAll({ showLoading: false, forceStatsSync: true })
|
||||
.catch(() => {})
|
||||
.finally(() => {
|
||||
scheduleRefreshLoop()
|
||||
|
||||
Reference in New Issue
Block a user