[优化] ui优化

This commit is contained in:
ryan
2026-03-12 15:43:32 +08:00
parent eb65c38c56
commit ee539d9b67
9 changed files with 79 additions and 66 deletions
-17
View File
@@ -54,7 +54,6 @@ func (c *Client) Heartbeat(ctx context.Context, payload protocol.NodePayload) (*
}
func (c *Client) GetActiveConfig(ctx context.Context) (*protocol.ActiveConfigResponse, error) {
log.Printf("http get active config request")
resp := protocol.APIResponse[protocol.ActiveConfigResponse]{}
if err := c.getJSON(ctx, "/api/agent/config-versions/active", &resp); err != nil {
return nil, err
@@ -100,9 +99,6 @@ func (c *Client) postJSON(ctx context.Context, path string, body any, target any
}
func (c *Client) do(req *http.Request, target any) error {
if !isHeartbeatRequest(req) {
log.Printf("http request start: method=%s path=%s", req.Method, req.URL.Path)
}
res, err := c.httpClient.Do(req)
if err != nil {
log.Printf("http request failed: method=%s path=%s error=%v", req.Method, req.URL.Path, err)
@@ -123,24 +119,11 @@ func (c *Client) do(req *http.Request, target any) error {
log.Printf("http api response failed: method=%s path=%s message=%s", req.Method, req.URL.Path, wrapper.Message)
return errors.New(wrapper.Message)
}
if !isHeartbeatRequest(req) {
log.Printf("http request succeeded: method=%s path=%s", req.Method, req.URL.Path)
}
return nil
}
if err = json.NewDecoder(res.Body).Decode(target); err != nil {
log.Printf("http response decode failed: method=%s path=%s error=%v", req.Method, req.URL.Path, err)
return err
}
if !isHeartbeatRequest(req) {
log.Printf("http request succeeded: method=%s path=%s", req.Method, req.URL.Path)
}
return nil
}
func isHeartbeatRequest(req *http.Request) bool {
if req == nil || req.URL == nil {
return false
}
return req.Method == http.MethodPost && req.URL.Path == "/api/agent/nodes/heartbeat"
}