Skip to content

Commit

Permalink
feat(new):新增在线节点显示
Browse files Browse the repository at this point in the history
  • Loading branch information
luckykeeper committed Oct 21, 2023
1 parent 15deef0 commit c883666
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion handler/getNodeNameBadge.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"cocoaSyncer/model"
subFunction "cocoaSyncer/subfunction"
"encoding/json"
"fmt"
"net/http"

"github.com/gin-gonic/gin"
Expand All @@ -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{}
Expand Down

0 comments on commit c883666

Please sign in to comment.