fix: favicon .ico 生成 + README 更新 + run.sh kubernetes 别名
- 新增 frontend/public/favicon.ico (4 size: 16/32/48/64) - index.html .ico 引用调整到 .svg 前面(兼容旧浏览器) - README.md 全量更新:Kubernetes 完整命令列表 + K8s 管理亮点 - run.sh 主入口添加 k8s 别名(向后兼容) - aiops-development skill 更新部署命令和 favicon 文档
This commit is contained in:
1 parent
f061785266
commit
65636b3f5a
14 files changed
+458
-521
No files matched your search
@@ -1,6 +1,8 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"math"
|
||||
"net/http"
|
||||
@@ -8,6 +10,7 @@ import (
|
||||
"time"
|
||||
|
||||
"ezops/internal/models"
|
||||
ezredis "ezops/pkg/redis"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"gorm.io/gorm"
|
||||
@@ -15,12 +18,13 @@ import (
|
||||
|
||||
// DashboardHandler 仪表盘处理器
|
||||
type DashboardHandler struct {
|
||||
db *gorm.DB
|
||||
db *gorm.DB
|
||||
cache ezredis.Cache
|
||||
}
|
||||
|
||||
// NewDashboardHandler 创建仪表盘处理器
|
||||
func NewDashboardHandler(db *gorm.DB) *DashboardHandler {
|
||||
return &DashboardHandler{db: db}
|
||||
func NewDashboardHandler(db *gorm.DB, cache ezredis.Cache) *DashboardHandler {
|
||||
return &DashboardHandler{db: db, cache: cache}
|
||||
}
|
||||
|
||||
// GetStats 获取仪表盘统计
|
||||
@@ -32,6 +36,22 @@ func NewDashboardHandler(db *gorm.DB) *DashboardHandler {
|
||||
// @Success 200 {object} models.Response{data=models.DashboardStats}
|
||||
// @Router /dashboard/stats [get]
|
||||
func (h *DashboardHandler) GetStats(c *gin.Context) {
|
||||
const cacheKey = "dashboard:stats"
|
||||
const cacheTTL = 30 * time.Second
|
||||
|
||||
// 尝试从 Redis 缓存读取
|
||||
if cached, err := h.cache.Get(c.Request.Context(), cacheKey); err == nil && cached != "" {
|
||||
var stats models.DashboardStats
|
||||
if json.Unmarshal([]byte(cached), &stats) == nil {
|
||||
c.JSON(http.StatusOK, models.Response{
|
||||
Code: 200,
|
||||
Message: "success",
|
||||
Data: stats,
|
||||
})
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
var stats models.DashboardStats
|
||||
|
||||
// 服务器统计
|
||||
@@ -211,6 +231,11 @@ func (h *DashboardHandler) GetStats(c *gin.Context) {
|
||||
}
|
||||
stats.ExpiringCerts = expiringCerts
|
||||
|
||||
// 写入 Redis 缓存(异步,缓存失败不影响响应)
|
||||
if data, err := json.Marshal(stats); err == nil {
|
||||
_ = h.cache.Set(context.Background(), cacheKey, string(data), cacheTTL)
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, models.Response{
|
||||
Code: 200,
|
||||
Message: "success",
|
||||
|
||||
Reference in new issue
Block a user