diff --git a/internal/handler/robot.go b/internal/handler/robot.go index 5623dde..fc6d0c0 100644 --- a/internal/handler/robot.go +++ b/internal/handler/robot.go @@ -25,9 +25,25 @@ func ListRobots(c *fiber.Ctx) error { return fiber.NewError(fiber.StatusInternalServerError, "获取机器人列表失败") } + total := len(robots) + online := 0 + offline := 0 + for _, robot := range robots { + if robot.Status == model.RobotStatusOnline { + online++ + } else { + offline++ + } + } + return c.Render("robot/index", fiber.Map{ "Title": "机器人列表", "Robots": robots, + "Status": map[string]int{ + "Total": total, + "Online": online, + "Offline": offline, + }, }) } diff --git a/internal/view/robot/index.html b/internal/view/robot/index.html index 649c03e..2648c12 100644 --- a/internal/view/robot/index.html +++ b/internal/view/robot/index.html @@ -37,23 +37,23 @@
-
-
- -
-
-

在线机器人

-

{{.OnlineCount}}

-
-
-

总机器人

-

{{len .Robots}}

+

{{.Status.Total}}

+
+
+ +
+
+ +
+
+

在线机器人

+

{{.Status.Online}}

@@ -63,7 +63,7 @@

离线机器人

-

{{.OfflineCount}}

+

{{.Status.Offline}}

@@ -75,7 +75,7 @@
- +
@@ -94,7 +94,7 @@
- +
@@ -107,7 +107,7 @@
- +
微信状态: {{if eq .Status "online"}}在线{{else}}离线{{end}} @@ -115,7 +115,7 @@ - + {{if eq .Status "offline"}} @@ -127,7 +127,7 @@ {{end}} - + @@ -150,55 +150,6 @@
-