From e91c9ec94bc53c26f2dd8332068fc669905e2a45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=AF=BB=E6=AC=A2?= Date: Mon, 7 Apr 2025 16:55:43 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20=E6=9B=B4=E6=96=B0=E6=9C=BA=E5=99=A8?= =?UTF-8?q?=E4=BA=BA=E7=8A=B6=E6=80=81=E7=BB=9F=E8=AE=A1=E9=80=BB=E8=BE=91?= =?UTF-8?q?=EF=BC=8C=E8=B0=83=E6=95=B4=E5=89=8D=E7=AB=AF=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=EF=BC=8C=E4=BC=98=E5=8C=96=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E7=A1=AE=E8=AE=A4=E4=BA=A4=E4=BA=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/handler/robot.go | 16 +++++ internal/view/robot/index.html | 107 +++++++++------------------------ 2 files changed, 45 insertions(+), 78 deletions(-) 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 @@
-