From 04ddf2762df2eab2491d308038141e33aebc835c Mon Sep 17 00:00:00 2001 From: Hermes Date: Wed, 22 Jul 2026 11:21:23 +0800 Subject: [PATCH] =?UTF-8?q?feat(portal):=20replace=20hardcoded=20'24/7=20?= =?UTF-8?q?=E5=86=85=E7=BD=91'=20stat=20with=20live=20resource=20count?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Backend: bootstrap() now returns stats.total_resources (count of is_active=True resources). Frontend: stats adds 'resources' computed from bootstrapStats; third hero-stat shows '{{ stats.resources }} 资源数量' instead of the static '24/7 内网' placeholder. --- backend/routes/portal.py | 3 +++ frontend/src/views/Portal.vue | 8 ++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/backend/routes/portal.py b/backend/routes/portal.py index d4cb899..e73232f 100644 --- a/backend/routes/portal.py +++ b/backend/routes/portal.py @@ -22,6 +22,9 @@ def bootstrap(): ) return jsonify({ "settings": settings, + "stats": { + "total_resources": Resource.query.filter_by(is_active=True).count(), + }, "categories": [c.to_dict() for c in categories], "links": [l.to_dict() for l in links], }) diff --git a/frontend/src/views/Portal.vue b/frontend/src/views/Portal.vue index 565239a..9226e9d 100644 --- a/frontend/src/views/Portal.vue +++ b/frontend/src/views/Portal.vue @@ -57,14 +57,18 @@ const activeCat = computed(() => categories.value.find(c => c.id === activeCatId const stats = computed(() => ({ categories: categories.value.length, - links: links.value.length + links: links.value.length, + resources: bootstrapStats.value.total_resources || 0 })) +const bootstrapStats = ref({ total_resources: 0 }) + async function loadBootstrap() { loading.value = true try { const { data } = await portalApi.bootstrap() settings.value = data.settings || {} + bootstrapStats.value = data.stats || { total_resources: 0 } categories.value = data.categories || [] links.value = data.links || [] document.title = settings.value.site_name || 'OPS 资源中心' @@ -183,7 +187,7 @@ onMounted(() => {
{{ stats.categories }}资源分类
{{ stats.links }}快捷入口
-
内网访问入口
+
{{ stats.resources }}资源数量