From 7ed4ce8d3a558d34aef142ae6e264b554329119e Mon Sep 17 00:00:00 2001 From: attacker Date: Sun, 28 Jun 2026 10:11:23 +0800 Subject: [PATCH] =?UTF-8?q?fix(log):=20log-datasources=20List=20=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=20{list,total}=20=E6=A0=BC=E5=BC=8F=E5=AF=B9=E9=BD=90?= =?UTF-8?q?=E5=89=8D=E7=AB=AF=E6=9C=9F=E6=9C=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 前端 logCenterApi.listDatasources 期望 res.list 数组,但后端 List handler 返回裸数组导致前端取 res?.list 为 undefined。改为 model.ListResponse 对齐 项目其他列表端点的惯例格式。 --- backend/controller/log_datasource.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/backend/controller/log_datasource.go b/backend/controller/log_datasource.go index 50a80f8..fd44258 100644 --- a/backend/controller/log_datasource.go +++ b/backend/controller/log_datasource.go @@ -40,7 +40,8 @@ func (h *LogDSHandler) List(c *gin.Context) { if sources == nil { sources = []model.LogDataSource{} } - c.JSON(200, model.Response{Code: 200, Data: sources}) + // 按项目惯例返回 {list,total},前端 listDatasources 取 .list // Logan.Li + c.JSON(200, model.Response{Code: 200, Data: model.ListResponse{List: sources, Total: int64(len(sources))}}) } // Get GET /api/v1/log-datasources/:id