refactor: GetScreenResult

This commit is contained in:
lilong.129
2023-05-31 16:10:24 +08:00
parent 55e6a42b0f
commit 7d7044f332
8 changed files with 72 additions and 60 deletions

View File

@@ -150,7 +150,7 @@ func NewWorldCupLive(device uixt.Device, matchName, bundleID string, duration, i
func (wc *WorldCupLive) getCurrentLiveTime(utcTime time.Time) error {
utcTimeStr := utcTime.Format("15:04:05")
_, ocrTexts, err := wc.driver.GetScreenTextsByOCR()
imageResult, err := wc.driver.GetScreenResult()
if err != nil {
log.Error().Err(err).Msg("get ocr texts failed")
return err
@@ -159,7 +159,7 @@ func (wc *WorldCupLive) getCurrentLiveTime(utcTime time.Time) error {
// filter ocr texts with time format
secondsMap := map[string]int{}
var secondsTexts []string
for _, ocrText := range ocrTexts {
for _, ocrText := range imageResult.OCRResult.ToOCRTexts() {
seconds, err := convertTimeToSeconds(ocrText.Text)
if err == nil {
secondsTexts = append(secondsTexts, ocrText.Text)
@@ -212,8 +212,9 @@ func (wc *WorldCupLive) EnterLive(bundleID string) error {
time.Sleep(5 * time.Second)
// 青少年弹窗处理
if _, ocrTexts, err := wc.driver.GetScreenTextsByOCR(); err == nil {
if points, err := ocrTexts.FindTexts([]string{"青少年模式", "我知道了"}); err == nil {
if imageResult, err := wc.driver.GetScreenResult(); err == nil {
if points, err := imageResult.OCRResult.ToOCRTexts().
FindTexts([]string{"青少年模式", "我知道了"}); err == nil {
point := points[1].Center()
_ = wc.driver.TapAbsXY(point.X, point.Y)
}