diff --git a/handler/getNodeNameBadge.go b/handler/getNodeNameBadge.go index a6f6366..31996be 100644 --- a/handler/getNodeNameBadge.go +++ b/handler/getNodeNameBadge.go @@ -11,6 +11,7 @@ import ( "cocoaSyncer/model" subFunction "cocoaSyncer/subfunction" "encoding/json" + "fmt" "net/http" "github.com/gin-gonic/gin" @@ -34,9 +35,20 @@ func GetNodeNameBadge(context *gin.Context) { thisCocoa.Dsn = "*****" thisCocoa.CocoaSecret = "*****" thisCocoa.CloudPlatformInfo = nil - thisCocoa.OtherCocoaSyncer = nil + // thisCocoa.OtherCocoaSyncer = nil thisCocoa.CocoaManagedService = nil + // 在线节点数量显示 + nodesTotalNum := 0 + nodeLiveNum := 0 + for _, node := range thisCocoa.OtherCocoaSyncer { + nodesTotalNum++ + if node.StatusCode == 200 { + nodeLiveNum++ + } + } + thisCocoa.NodeName = thisCocoa.NodeName + " | " + fmt.Sprint(nodeLiveNum) + "/" + fmt.Sprint(nodesTotalNum) + // 转 map[string]interface{} 给前端 thisCocoaJson, _ := json.Marshal(&thisCocoa) var thisCocoaMap map[string]interface{}