From 589b18f9f05154d8d5e4202f11acae9d4fab5391 Mon Sep 17 00:00:00 2001 From: "lilong.129" Date: Tue, 12 Nov 2024 22:29:39 +0800 Subject: [PATCH] change: set closeResult nil to reduce unnecessary summary info --- hrp/internal/version/VERSION | 2 +- hrp/pkg/uixt/action.go | 4 ++-- hrp/pkg/uixt/ai.go | 4 ++++ hrp/pkg/uixt/screenshot.go | 23 ++++++++++++++--------- 4 files changed, 21 insertions(+), 12 deletions(-) diff --git a/hrp/internal/version/VERSION b/hrp/internal/version/VERSION index d71b395b..8bd55382 100644 --- a/hrp/internal/version/VERSION +++ b/hrp/internal/version/VERSION @@ -1 +1 @@ -v5.0.0+2411112311 +v5.0.0+2411122229 diff --git a/hrp/pkg/uixt/action.go b/hrp/pkg/uixt/action.go index 4f3ecd64..5b6a8ebc 100644 --- a/hrp/pkg/uixt/action.go +++ b/hrp/pkg/uixt/action.go @@ -543,7 +543,7 @@ func (dExt *DriverExt) GenAbsScope(x1, y1, x2, y2 float64) AbsScope { } func (dExt *DriverExt) DoAction(action MobileAction) (err error) { - log.Debug(). + log.Info(). Str("method", string(action.Method)). Interface("params", action.Params). Msg("uixt action start") @@ -557,7 +557,7 @@ func (dExt *DriverExt) DoAction(action MobileAction) (err error) { Int64("elapsed(ms)", time.Since(actionStartTime).Milliseconds()). Msg("uixt action end") } else { - log.Debug(). + log.Info(). Str("method", string(action.Method)). Interface("params", action.Params). Int64("elapsed(ms)", time.Since(actionStartTime).Milliseconds()). diff --git a/hrp/pkg/uixt/ai.go b/hrp/pkg/uixt/ai.go index 14898f99..ff63f4c5 100644 --- a/hrp/pkg/uixt/ai.go +++ b/hrp/pkg/uixt/ai.go @@ -283,3 +283,7 @@ type ClosePopupsResult struct { CloseArea Box `json:"closeArea"` Text string `json:"text"` } + +func (c ClosePopupsResult) IsEmpty() bool { + return c.PopupArea.IsEmpty() && c.CloseArea.IsEmpty() +} diff --git a/hrp/pkg/uixt/screenshot.go b/hrp/pkg/uixt/screenshot.go index 063b016d..8528f3c8 100644 --- a/hrp/pkg/uixt/screenshot.go +++ b/hrp/pkg/uixt/screenshot.go @@ -90,23 +90,28 @@ func (dExt *DriverExt) GetScreenResult(options ...ActionOption) (screenResult *S dExt.Driver.GetSession().addScreenResult(screenResult) if imageResult != nil { - screenResult.ImageResult = imageResult screenResult.Texts = imageResult.OCRResult.ToOCRTexts() screenResult.UploadedURL = imageResult.URL screenResult.Icons = imageResult.UIResult if actionOptions.ScreenShotWithClosePopups && imageResult.ClosePopupsResult != nil { - screenResult.Popup = &PopupInfo{ - ClosePopupsResult: imageResult.ClosePopupsResult, - PicName: imagePath, - PicURL: imageResult.URL, - } + if imageResult.ClosePopupsResult.IsEmpty() { + // set nil to reduce unnecessary summary info + imageResult.ClosePopupsResult = nil + } else { + screenResult.Popup = &PopupInfo{ + ClosePopupsResult: imageResult.ClosePopupsResult, + PicName: imagePath, + PicURL: imageResult.URL, + } - closeAreas, _ := imageResult.UIResult.FilterUIResults([]string{"close"}) - for _, closeArea := range closeAreas { - screenResult.Popup.ClosePoints = append(screenResult.Popup.ClosePoints, closeArea.Center()) + closeAreas, _ := imageResult.UIResult.FilterUIResults([]string{"close"}) + for _, closeArea := range closeAreas { + screenResult.Popup.ClosePoints = append(screenResult.Popup.ClosePoints, closeArea.Center()) + } } } + screenResult.ImageResult = imageResult } log.Debug().