feat: 支持tunnel, 优化server结构。

This commit is contained in:
余泓铮
2025-02-19 20:26:20 +08:00
parent 1c6d12f7bd
commit ef320a3947
21 changed files with 233 additions and 170 deletions

View File

@@ -7,14 +7,13 @@ import (
"github.com/Masterminds/semver"
"github.com/danielpaulus/go-ios/ios"
"github.com/gin-gonic/gin"
"github.com/httprunner/httprunner/v5/internal/builtin"
"github.com/httprunner/httprunner/v5/pkg/gadb"
"github.com/httprunner/httprunner/v5/pkg/uixt"
"github.com/httprunner/httprunner/v5/pkg/uixt/option"
"github.com/rs/zerolog/log"
)
func listDeviceHandler(c *gin.Context) {
func (r *Router) listDeviceHandler(c *gin.Context) {
var deviceList []interface{}
client, err := gadb.NewClient()
if err == nil {
@@ -88,17 +87,17 @@ func listDeviceHandler(c *gin.Context) {
RenderSuccess(c, deviceList)
}
func pushImageHandler(c *gin.Context) {
func (r *Router) pushImageHandler(c *gin.Context) {
var pushMediaReq PushMediaRequest
if err := c.ShouldBindJSON(&pushMediaReq); err != nil {
RenderErrorValidateRequest(c, err)
return
}
driver, err := GetDriver(c)
driver, err := r.GetDriver(c)
if err != nil {
return
}
imagePath, err := builtin.DownloadFileByUrl(pushMediaReq.ImageUrl)
imagePath, err := uixt.DownloadFileByUrl(pushMediaReq.ImageUrl)
if path.Ext(imagePath) == "" {
err = os.Rename(imagePath, imagePath+".png")
if err != nil {
@@ -122,8 +121,8 @@ func pushImageHandler(c *gin.Context) {
RenderSuccess(c, true)
}
func clearImageHandler(c *gin.Context) {
driver, err := GetDriver(c)
func (r *Router) clearImageHandler(c *gin.Context) {
driver, err := r.GetDriver(c)
if err != nil {
return
}
@@ -135,6 +134,6 @@ func clearImageHandler(c *gin.Context) {
RenderSuccess(c, true)
}
func videoHandler(c *gin.Context) {
func (r *Router) videoHandler(c *gin.Context) {
RenderSuccess(c, "")
}