feat: 新增日志中心、功能优化与代码重构
- 新增 log_datasource.go / log_proxy.go / user_api_token.go 后端控制器 - 新增 log_datasource.go model - 新增 monitor/log-center.ts API 模块 - 新增 LogCenter 前端组件及页面 - 重构 deployment 相关组件 (HPDA/UpdateImageModal/bundle-yaml 等) - 新增 ResetPasswordDialog / code-snippet-block / copy-button 等 UI 组件 - 重构多个 k8s 相关组件 (TopologyView/ResourceVisualEditor/PodFileBrowser 等) - 更新多个 API 和工具函数 (auth.ts/monitor/index.ts/request.ts 等) - 更新静态资源 (index.html + 新 JS/CSS bundle) - 删除废弃静态资源文件
This commit is contained in:
1 parent
5ca0e6d83a
commit
8d46e8f352
197 files changed
+5014
-815
No files matched your search
@@ -224,10 +224,11 @@ func (h *KubernetesHandler) GetClusterDetail(c *gin.Context) {
|
||||
"description": cluster.Description,
|
||||
"has_token": cluster.Token != "",
|
||||
"has_kube_config": cluster.KubeConfig != "",
|
||||
"node_count": cluster.NodeCount,
|
||||
"pod_count": cluster.PodCount,
|
||||
"service_count": cluster.ServiceCount,
|
||||
"node_count": cluster.NodeCount,
|
||||
"pod_count": cluster.PodCount,
|
||||
"service_count": cluster.ServiceCount,
|
||||
"deployment_count": cluster.DeploymentCount,
|
||||
"ingress_count": cluster.IngressCount,
|
||||
"cpu_usage": cluster.CPUUsage,
|
||||
"memory_usage": cluster.MemoryUsage,
|
||||
"labels": cluster.Labels,
|
||||
@@ -287,7 +288,7 @@ func (h *KubernetesHandler) SyncCluster(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
client, err := k8sclient.NewClient(cluster.KubeConfig)
|
||||
client, err := buildK8sClient(&cluster)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, model.Response{Code: 500, Message: "连接K8s失败: " + err.Error()})
|
||||
return
|
||||
@@ -366,6 +367,7 @@ func (h *KubernetesHandler) SyncCluster(c *gin.Context) {
|
||||
}
|
||||
} else {
|
||||
log.Printf("[K8s] sync nodes error: %v", err)
|
||||
result.Errors = append(result.Errors, "nodes: "+err.Error())
|
||||
}
|
||||
|
||||
// Sync pods
|
||||
@@ -396,6 +398,7 @@ func (h *KubernetesHandler) SyncCluster(c *gin.Context) {
|
||||
}
|
||||
} else {
|
||||
log.Printf("[K8s] sync pods error: %v", err)
|
||||
result.Errors = append(result.Errors, "pods: "+err.Error())
|
||||
}
|
||||
|
||||
// Sync deployments
|
||||
@@ -421,6 +424,7 @@ func (h *KubernetesHandler) SyncCluster(c *gin.Context) {
|
||||
}
|
||||
} else {
|
||||
log.Printf("[K8s] sync deps error: %v", err)
|
||||
result.Errors = append(result.Errors, "deployments: "+err.Error())
|
||||
}
|
||||
|
||||
// Sync services
|
||||
@@ -442,6 +446,9 @@ func (h *KubernetesHandler) SyncCluster(c *gin.Context) {
|
||||
})
|
||||
result.Services++
|
||||
}
|
||||
} else {
|
||||
log.Printf("[K8s] sync services error: %v", err)
|
||||
result.Errors = append(result.Errors, "services: "+err.Error())
|
||||
}
|
||||
|
||||
// Sync ingresses
|
||||
@@ -473,6 +480,9 @@ func (h *KubernetesHandler) SyncCluster(c *gin.Context) {
|
||||
})
|
||||
result.Ingresses++
|
||||
}
|
||||
} else {
|
||||
log.Printf("[K8s] sync ingresses error: %v", err)
|
||||
result.Errors = append(result.Errors, "ingresses: "+err.Error())
|
||||
}
|
||||
|
||||
// Update cluster stats
|
||||
@@ -482,13 +492,18 @@ func (h *KubernetesHandler) SyncCluster(c *gin.Context) {
|
||||
"pod_count": result.Pods,
|
||||
"deployment_count": result.Deployments,
|
||||
"service_count": result.Services,
|
||||
"ingress_count": result.Ingresses,
|
||||
"last_sync_at": &now,
|
||||
})
|
||||
|
||||
msg := fmt.Sprintf("同步完成: %d nodes, %d pods, %d deployments, %d services, %d ingresses",
|
||||
result.Nodes, result.Pods, result.Deployments, result.Services, result.Ingresses)
|
||||
if len(result.Errors) > 0 {
|
||||
msg += " (部分资源同步失败,详见 errors 字段)"
|
||||
}
|
||||
c.JSON(http.StatusOK, model.Response{
|
||||
Code: 200,
|
||||
Message: fmt.Sprintf("同步完成: %d nodes, %d pods, %d deployments, %d services, %d ingresses",
|
||||
result.Nodes, result.Pods, result.Deployments, result.Services, result.Ingresses),
|
||||
Message: msg,
|
||||
Data: result,
|
||||
})
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user