feat: 在线统计增加按年趋势与本年在线

This commit is contained in:
root committed 2026-10-16 16:23:55 +08:00
1 parent 70fda65889
commit 3ff9c41d18
3 files changed
+50 -13

No files matched your search

+18 -5
View File
@@ -2,7 +2,7 @@
<div class="online-stats-page">
<!-- 统计卡片 -->
<el-row :gutter="20" class="stats-row">
<el-col :xs="12" :sm="6" :md="6" :lg="6">
<el-col :xs="12" :sm="8" :md="4" :lg="4">
<div class="stat-card stat-current">
<div class="stat-icon"><el-icon :size="32"><Odometer /></el-icon></div>
<div class="stat-info">
@@ -11,7 +11,7 @@
</div>
</div>
</el-col>
<el-col :xs="12" :sm="6" :md="6" :lg="6">
<el-col :xs="12" :sm="8" :md="4" :lg="4">
<div class="stat-card stat-today">
<div class="stat-icon"><el-icon :size="32"><Sunny /></el-icon></div>
<div class="stat-info">
@@ -20,7 +20,7 @@
</div>
</div>
</el-col>
<el-col :xs="12" :sm="6" :md="6" :lg="6">
<el-col :xs="12" :sm="8" :md="4" :lg="4">
<div class="stat-card stat-week">
<div class="stat-icon"><el-icon :size="32"><Calendar /></el-icon></div>
<div class="stat-info">
@@ -29,7 +29,7 @@
</div>
</div>
</el-col>
<el-col :xs="12" :sm="6" :md="6" :lg="6">
<el-col :xs="12" :sm="8" :md="4" :lg="4">
<div class="stat-card stat-month">
<div class="stat-icon"><el-icon :size="32"><TrendCharts /></el-icon></div>
<div class="stat-info">
@@ -38,6 +38,15 @@
</div>
</div>
</el-col>
<el-col :xs="12" :sm="8" :md="4" :lg="4">
<div class="stat-card stat-year">
<div class="stat-icon"><el-icon :size="32"><Histogram /></el-icon></div>
<div class="stat-info">
<div class="stat-value">{{ stats.year_online }}</div>
<div class="stat-label">本年在线</div>
</div>
</div>
</el-col>
</el-row>
<!-- 趋势图 -->
@@ -52,6 +61,7 @@
<el-radio-button value="day">按日(30天)</el-radio-button>
<el-radio-button value="week">按周(12周)</el-radio-button>
<el-radio-button value="month">按月(12月)</el-radio-button>
<el-radio-button value="year">按年(12年)</el-radio-button>
</el-radio-group>
<el-button :icon="Refresh" circle @click="fetchData" />
</div>
@@ -74,6 +84,7 @@
<el-table-column prop="today_online" label="今日在线" width="110" align="center" />
<el-table-column prop="week_online" label="本周在线" width="110" align="center" />
<el-table-column prop="month_online" label="本月在线" width="110" align="center" />
<el-table-column prop="year_online" label="本年在线" width="110" align="center" />
</el-table>
<div v-if="!stats.projects?.length && !loading" class="empty-tip">暂无在线记录(自上线后随客户端心跳累积)</div>
</el-card>
@@ -82,7 +93,7 @@
<script setup>
import { ref, onMounted, onUnmounted, nextTick } from 'vue'
import { Refresh, Odometer, Sunny, Calendar, TrendCharts } from '@element-plus/icons-vue'
import { Refresh, Odometer, Sunny, Calendar, TrendCharts, Histogram } from '@element-plus/icons-vue'
import * as echarts from 'echarts'
import request from '@/api'
import installationApi from '@/api/installations'
@@ -99,6 +110,7 @@ const stats = ref({
today_online: 0,
week_online: 0,
month_online: 0,
year_online: 0,
trend: [],
projects: []
})
@@ -207,6 +219,7 @@ onUnmounted(() => {
.stat-today .stat-icon { background: #fffbeb; color: #f59e0b; }
.stat-week .stat-icon { background: #eff6ff; color: #3b82f6; }
.stat-month .stat-icon { background: #f5f3ff; color: #8b5cf6; }
.stat-year .stat-icon { background: #fdf2f8; color: #ec4899; }
.stat-info { display: flex; flex-direction: column; min-width: 0; }
.stat-value { font-size: 22px; font-weight: 700; color: #1d1d1f; line-height: 1.1; letter-spacing: -.3px; }
.stat-label { font-size: 12px; color: #9ca3af; margin-top: 2px; font-weight: 500; }