✨ 优化管理页交互与历史同步
This commit is contained in:
1 parent
90321a5ca4
commit
2cde31f822
6 files changed
+131
-76
No files matched your search
@@ -10,11 +10,13 @@
|
||||
{{ t('admin.dashboard.lastUpdated', { time: lastUpdatedText }) }}
|
||||
</p>
|
||||
</div>
|
||||
<BaseButton variant="secondary" :loading="isLoading" @click="fetchDashboardData">
|
||||
<BaseButton variant="secondary" :loading="isDashboardRefreshing" @click="refreshDashboardPage">
|
||||
<template #icon>
|
||||
<RefreshCwIcon class="mr-2 h-4 w-4" />
|
||||
</template>
|
||||
{{ isLoading ? t('admin.dashboard.refreshing') : t('admin.dashboard.refresh') }}
|
||||
{{
|
||||
isDashboardRefreshing ? t('admin.dashboard.refreshing') : t('admin.dashboard.refresh')
|
||||
}}
|
||||
</BaseButton>
|
||||
</div>
|
||||
|
||||
@@ -260,13 +262,28 @@
|
||||
/>
|
||||
</div>
|
||||
<div class="grid grid-cols-3 gap-2 sm:flex sm:justify-end">
|
||||
<BaseButton variant="outline" class="h-11 min-w-20" @click="trendCanvas?.zoom(0.75)">
|
||||
<BaseButton
|
||||
variant="outline"
|
||||
size="sm"
|
||||
class="h-9 min-w-16"
|
||||
@click="trendCanvas?.zoom(0.75)"
|
||||
>
|
||||
放大
|
||||
</BaseButton>
|
||||
<BaseButton variant="outline" class="h-11 min-w-20" @click="trendCanvas?.zoom(1.33)">
|
||||
<BaseButton
|
||||
variant="outline"
|
||||
size="sm"
|
||||
class="h-9 min-w-16"
|
||||
@click="trendCanvas?.zoom(1.33)"
|
||||
>
|
||||
缩小
|
||||
</BaseButton>
|
||||
<BaseButton variant="outline" class="h-11 min-w-20" @click="trendCanvas?.resetWindow()">
|
||||
<BaseButton
|
||||
variant="outline"
|
||||
size="sm"
|
||||
class="h-9 min-w-16"
|
||||
@click="trendCanvas?.resetWindow()"
|
||||
>
|
||||
重置
|
||||
</BaseButton>
|
||||
</div>
|
||||
@@ -476,6 +493,7 @@ const analyticsStart = ref(daysAgo(120))
|
||||
const analyticsEnd = ref(today())
|
||||
const analyticsData = ref<AnalyticsData | null>(null)
|
||||
const analyticsError = ref('')
|
||||
const isAnalyticsLoading = ref(false)
|
||||
const analyticsWindowText = ref('无数据')
|
||||
const analyticsDailyRows = computed(() => analyticsData.value?.daily || [])
|
||||
const analyticsTopFiles = computed<AnalyticsFileRow[]>(() => analyticsData.value?.topFiles || [])
|
||||
@@ -497,12 +515,19 @@ const formatBytes = (value: number | string | undefined) => formatFileSize(Numbe
|
||||
|
||||
const fetchAnalyticsData = async () => {
|
||||
analyticsError.value = ''
|
||||
isAnalyticsLoading.value = true
|
||||
try {
|
||||
analyticsData.value = await fetchAnalytics(analyticsStart.value, analyticsEnd.value)
|
||||
} catch (error) {
|
||||
analyticsError.value = error instanceof Error ? error.message : '统计加载失败'
|
||||
} finally {
|
||||
isAnalyticsLoading.value = false
|
||||
}
|
||||
}
|
||||
const isDashboardRefreshing = computed(() => isLoading.value || isAnalyticsLoading.value)
|
||||
const refreshDashboardPage = async () => {
|
||||
await Promise.all([fetchDashboardData(), fetchAnalyticsData()])
|
||||
}
|
||||
|
||||
const healthActions = computed<DashboardHealthAction[]>(() => [
|
||||
{
|
||||
@@ -648,6 +673,6 @@ const PolicyRow = defineComponent({
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
void Promise.all([fetchDashboardData(), fetchAnalyticsData()])
|
||||
void refreshDashboardPage()
|
||||
})
|
||||
</script>
|
||||
Reference in new issue
Block a user