diff --git a/backend/internal/router/admin/versions.go b/backend/internal/router/admin/versions.go index 61132f2..5461be6 100644 --- a/backend/internal/router/admin/versions.go +++ b/backend/internal/router/admin/versions.go @@ -98,6 +98,27 @@ func handleGetAllVersions(c *gin.Context) { var forcedCount int64 database.DB.Model(&model.Version{}).Where("application_id IN ? AND update_strategy = ?", appIDs, "forced").Count(&forcedCount) + // 计算总文件大小 + var totalSize int64 + sizeQuery := database.DB.Model(&model.Version{}).Where("application_id IN ?", appIDs) + if applicationIDFilter != "" { + sizeQuery = sizeQuery.Where("application_id = ?", applicationIDFilter) + } + if updateStrategyFilter != "" { + sizeQuery = sizeQuery.Where("update_strategy = ?", updateStrategyFilter) + } + if updateTypeFilter != "" { + sizeQuery = sizeQuery.Where("update_type = ?", updateTypeFilter) + } + if updateMethodFilter != "" { + sizeQuery = sizeQuery.Where("update_method = ?", updateMethodFilter) + } + if searchFilter != "" { + searchLower := strings.ToLower(searchFilter) + sizeQuery = sizeQuery.Where("LOWER(version) LIKE ? OR LOWER(description) LIKE ?", "%"+searchLower+"%", "%"+searchLower+"%") + } + sizeQuery.Select("COALESCE(SUM(file_size), 0)").Scan(&totalSize) + query := database.DB.Where("application_id IN ?", appIDs) if applicationIDFilter != "" { query = query.Where("application_id = ?", applicationIDFilter) @@ -190,6 +211,7 @@ func handleGetAllVersions(c *gin.Context) { "versions": result, "total": total, "forced_count": forcedCount, + "total_size": totalSize, }) } diff --git a/frontend/src/pages/admin/versions/index.vue b/frontend/src/pages/admin/versions/index.vue index c028f72..33f668f 100644 --- a/frontend/src/pages/admin/versions/index.vue +++ b/frontend/src/pages/admin/versions/index.vue @@ -68,9 +68,7 @@ const methodOptions = computed(() => [ { label: t('admin.versions.methods.manual'), value: 'manual' }, ]) -const totalSize = computed(() => { - return versions.value.reduce((sum, v) => sum + (v.file_size || 0), 0) -}) +const totalSize = ref(0) const serverPagination = computed(() => ({ page: currentPage.value, @@ -131,6 +129,7 @@ async function fetchVersions() { versions.value = data?.versions || [] total.value = data?.total || 0 forcedCount.value = data?.forced_count || 0 + totalSize.value = data?.total_size || 0 } catch (error) { console.error('加载版本列表失败:', error)