feat(portal): replace hardcoded '24/7 内网' stat with live resource count
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.
This commit is contained in:
@@ -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],
|
||||
})
|
||||
|
||||
@@ -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(() => {
|
||||
<div class="hero-stats">
|
||||
<div class="hero-stat"><b>{{ stats.categories }}</b><span>资源分类</span></div>
|
||||
<div class="hero-stat"><b>{{ stats.links }}</b><span>快捷入口</span></div>
|
||||
<div class="hero-stat"><b>内网</b><span>访问入口</span></div>
|
||||
<div class="hero-stat"><b>{{ stats.resources }}</b><span>资源数量</span></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user