feat: add right clcik and webid

This commit is contained in:
huangbin.beal@163.com
2025-02-25 16:22:31 +08:00
parent 3b509ba6c6
commit e50454512f
6 changed files with 25 additions and 5 deletions

View File

@@ -1 +1 @@
v5.0.0+2502192152
v5.3.4

View File

@@ -223,7 +223,7 @@ func (wd *BrowserWebDriver) tapBySelector(selector string, options ...option.Act
return err
}
func (wd *BrowserWebDriver) RightClick(x, y int) (err error) {
func (wd *BrowserWebDriver) RightClick(x, y float64) (err error) {
data := map[string]interface{}{
"x": x,
"y": y,

View File

@@ -116,7 +116,7 @@ type IXTDriver interface {
type IBrowserWebDriver interface {
IDriver
Hover(x, y float64) (err error)
RightClick(x, y int) (err error)
RightClick(x, y float64) (err error)
Scroll(delta int) (err error)
UploadFile(x, y float64, FileUrl, FileFormat string) (err error)
}

View File

@@ -124,14 +124,15 @@ func (wd *StubBrowserDriver) LoginNoneUI(packageName, phoneNumber string, captch
"url": packageName,
"web_cookie": password,
}
_, err = wd.HttpPOST(data, wd.sessionId, "stub/login")
resp, err := wd.HttpPOST(data, wd.sessionId, "stub/login")
if err != nil {
return info, err
}
respdata := resp.Data.(map[string]interface{})
loginSuccss := AppLoginInfo{
IsLogin: true,
Uid: wd.sessionId,
Uid: respdata["webid"].(string),
Did: password,
}
return loginSuccss, err

View File

@@ -43,6 +43,7 @@ func (r *Router) Init() {
// UI operations
apiV1PlatformSerial.POST("/ui/tap", r.tapHandler)
apiV1PlatformSerial.POST("/ui/right_click", r.rightClickHandler)
apiV1PlatformSerial.POST("/ui/double_tap", r.doubleTapHandler)
apiV1PlatformSerial.POST("/ui/drag", r.dragHandler)
apiV1PlatformSerial.POST("/ui/input", r.inputHandler)

View File

@@ -29,6 +29,24 @@ func (r *Router) tapHandler(c *gin.Context) {
RenderSuccess(c, true)
}
func (r *Router) rightClickHandler(c *gin.Context) {
var rightClickReq TapRequest
if err := c.ShouldBindJSON(&rightClickReq); err != nil {
RenderErrorValidateRequest(c, err)
return
}
driver, err := r.GetDriver(c)
if err != nil {
return
}
err = driver.GetWebDriver().RightClick(rightClickReq.X, rightClickReq.Y)
if err != nil {
RenderError(c, err)
return
}
RenderSuccess(c, true)
}
func (r *Router) uploadHandler(c *gin.Context) {
var uploadRequest uploadRequest
if err := c.ShouldBindJSON(&uploadRequest); err != nil {