feat: 管理后台仪表盘统计卡片接入真实数据
新增 /api/admin/stats 聚合接口,填充运行时长、活跃设备、今日流量、在线节点四项卡片: - VpnService 记录启动时间,提供 StartedAt/TotalLiveTraffic 方法 - 新增 TrafficStat 模型,客户端断开时 upsert 当日 rx/tx 流量(持久化) - 前端 AdminView 调用 stats 接口并每 30 秒自动刷新
This commit is contained in:
@@ -32,3 +32,15 @@ type VpnReservation struct {
|
||||
func (VpnReservation) TableName() string {
|
||||
return "vpn_reservations"
|
||||
}
|
||||
|
||||
type TrafficStat struct {
|
||||
ID uint `gorm:"primaryKey;autoIncrement"`
|
||||
Date string `gorm:"uniqueIndex;size:10;not null"`
|
||||
RxBytes int64 `gorm:"default:0"`
|
||||
TxBytes int64 `gorm:"default:0"`
|
||||
UpdatedAt time.Time
|
||||
}
|
||||
|
||||
func (TrafficStat) TableName() string {
|
||||
return "traffic_stats"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user