更新测试工具
This commit is contained in:
parent
ff58a55669
commit
1ebdeafda0
@ -1,6 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"go_dreamfactory/cmd/v2/lib/common"
|
||||
"go_dreamfactory/cmd/v2/service"
|
||||
@ -10,12 +11,17 @@ import (
|
||||
"io"
|
||||
"log"
|
||||
"os"
|
||||
"os/exec"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
"fyne.io/fyne/v2"
|
||||
"fyne.io/fyne/v2/app"
|
||||
"fyne.io/fyne/v2/container"
|
||||
"fyne.io/fyne/v2/dialog"
|
||||
"fyne.io/fyne/v2/widget"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/tidwall/gjson"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -68,6 +74,11 @@ func main() {
|
||||
|
||||
//创建enter
|
||||
w := fyne.CurrentApp().NewWindow("传送门")
|
||||
// 检查版本
|
||||
if app.Metadata().Build > 1 {
|
||||
checkVersion(app, w)
|
||||
}
|
||||
|
||||
w.SetContent(container.NewGridWithColumns(2,
|
||||
widget.NewButton("工具", func() {
|
||||
toolWindow := ui.NewToolWindow(appUI)
|
||||
@ -80,7 +91,7 @@ func main() {
|
||||
w.Hide()
|
||||
})))
|
||||
w.SetFixedSize(true)
|
||||
w.Resize(fyne.NewSize(300, 100))
|
||||
w.Resize(fyne.NewSize(400, 200))
|
||||
w.CenterOnScreen()
|
||||
logrus.WithField("version", app.Metadata().Version).Info("app starting")
|
||||
w.Show()
|
||||
@ -153,3 +164,45 @@ func setupLogger() (err error) {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// check version
|
||||
func checkVersion(app fyne.App, parent fyne.Window) {
|
||||
logrus.Debug("check version")
|
||||
b, err := connService.HttpConnect(configService.GetConfig().UpgradeUrl + "version")
|
||||
if err != nil {
|
||||
dialog.ShowError(errors.New("版本检查:"+err.Error()), parent)
|
||||
return
|
||||
}
|
||||
|
||||
oldVer := app.Metadata().Version
|
||||
parent.SetTitle(fmt.Sprintf("传送门[%v]", oldVer))
|
||||
ver := gjson.Get(string(b), "version").String()
|
||||
if strings.HasSuffix(ver, ".zip") {
|
||||
ver = strings.TrimSuffix(ver, ".zip")
|
||||
}
|
||||
logrus.WithField("version", ver).Debug("server version")
|
||||
if common.IsUpgrade(ver, oldVer) {
|
||||
chkDialog := dialog.NewConfirm("版本检查", "检查到新版本:"+ver+" 请升级后使用", func(b bool) {
|
||||
var commands = map[string]string{
|
||||
"windows": "explorer",
|
||||
"darwin": "open",
|
||||
"linux": "xdg-open",
|
||||
}
|
||||
//open browser
|
||||
open := func(uri string) error {
|
||||
// runtime.GOOS获取当前平台
|
||||
run, ok := commands[runtime.GOOS]
|
||||
if !ok {
|
||||
logrus.Errorf("don't know how to open things on %s platform", runtime.GOOS)
|
||||
}
|
||||
|
||||
cmd := exec.Command(run, uri)
|
||||
return cmd.Run()
|
||||
}
|
||||
_ = open(configService.GetConfig().UpgradeUrl)
|
||||
defer parent.Close()
|
||||
}, parent)
|
||||
chkDialog.SetConfirmText(common.BUTTON_OK)
|
||||
chkDialog.Show()
|
||||
}
|
||||
}
|
||||
|
@ -78,6 +78,7 @@ func (this *appMonitor) Run() {
|
||||
data := d.(*model.PushModel)
|
||||
this.monitorData.DataList = append(this.monitorData.DataList, data)
|
||||
this.reloadMonitorData()
|
||||
showTip("收到新的数据推送,请打开[监控]页面")
|
||||
},
|
||||
})
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ func (a *appTester) LazyInit(obs observer.Observer) error {
|
||||
|
||||
setNav := func(t *model.TestCase) {
|
||||
viewKey := fmt.Sprintf("%s.%s", t.MainType, t.SubType)
|
||||
title.SetText(fmt.Sprintf("%s : %s", common.APP_TESTCASE_LABEL_PATH, viewKey))
|
||||
title.SetText(fmt.Sprintf("> %s", viewKey))
|
||||
intro.SetText(t.Desc)
|
||||
content.Objects = []fyne.CanvasObject{}
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
package ui
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"go_dreamfactory/cmd/v2/lib/common"
|
||||
"go_dreamfactory/cmd/v2/service"
|
||||
@ -9,8 +8,6 @@ import (
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/modules/user"
|
||||
"go_dreamfactory/pb"
|
||||
"os/exec"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
"fyne.io/fyne/v2"
|
||||
@ -21,7 +18,6 @@ import (
|
||||
"github.com/BabySid/gobase"
|
||||
"github.com/Pallinder/go-randomdata"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/tidwall/gjson"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -90,7 +86,7 @@ func (ui *MainWindowImpl) createWindowContainer() {
|
||||
}),
|
||||
widget.NewToolbarAction(theme.DocumentIcon(), func() {
|
||||
openApp2(common.TOOLBAR_TESTER)
|
||||
}),
|
||||
}),
|
||||
widget.NewToolbarSpacer(),
|
||||
widget.NewToolbarAction(theme.FileIcon(), func() {
|
||||
newLogViewer().Win.Show()
|
||||
@ -135,54 +131,12 @@ func (ui *MainWindowImpl) CreateWindow(_ string, width, height float32, _ bool)
|
||||
_ = ui.createChooseServerPopUp(w)
|
||||
}
|
||||
|
||||
// check version
|
||||
func (ui *MainWindowImpl) checkVersion(parent fyne.Window) {
|
||||
logrus.Debug("check version")
|
||||
b, err := ui.connService.HttpConnect(ui.configService.GetConfig().UpgradeUrl + "version")
|
||||
if err != nil {
|
||||
dialog.ShowError(errors.New("版本检查:"+err.Error()), parent)
|
||||
return
|
||||
}
|
||||
|
||||
ver := gjson.Get(string(b), "version").String()
|
||||
if strings.HasSuffix(ver, ".zip") {
|
||||
ver = strings.TrimSuffix(ver, ".zip")
|
||||
}
|
||||
logrus.WithField("version", ver).Debug("server version")
|
||||
if common.IsUpgrade(ver, ui.app.Metadata().Version) {
|
||||
chkDialog := dialog.NewConfirm("版本检查", "检查到新版本:"+ver+" 请升级后使用", func(b bool) {
|
||||
var commands = map[string]string{
|
||||
"windows": "explorer",
|
||||
"darwin": "open",
|
||||
"linux": "xdg-open",
|
||||
}
|
||||
//open browser
|
||||
open := func(uri string) error {
|
||||
// runtime.GOOS获取当前平台
|
||||
run, ok := commands[runtime.GOOS]
|
||||
if !ok {
|
||||
logrus.Errorf("don't know how to open things on %s platform", runtime.GOOS)
|
||||
}
|
||||
|
||||
cmd := exec.Command(run, uri)
|
||||
return cmd.Run()
|
||||
}
|
||||
_ = open(ui.configService.GetConfig().UpgradeUrl)
|
||||
defer parent.Close()
|
||||
}, parent)
|
||||
chkDialog.SetConfirmText(common.BUTTON_OK)
|
||||
chkDialog.Show()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// createChooseServerPopUp
|
||||
func (ui *MainWindowImpl) createChooseServerPopUp(w fyne.Window) error {
|
||||
ch := make(chan string)
|
||||
|
||||
title := fmt.Sprintf(common.APP_WIN_TITLE, "选服", ui.app.Metadata().Version, ui.app.Metadata().Build, common.APP_NAME)
|
||||
selServerWin := ui.createChooseServerWindow(title, ch)
|
||||
ui.checkVersion(selServerWin)
|
||||
|
||||
go func() {
|
||||
data := <-ch
|
||||
|
@ -6,13 +6,11 @@ import (
|
||||
"go_dreamfactory/cmd/v2/service/observer"
|
||||
"image/color"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"fyne.io/fyne/v2"
|
||||
"fyne.io/fyne/v2/canvas"
|
||||
"fyne.io/fyne/v2/container"
|
||||
"fyne.io/fyne/v2/dialog"
|
||||
"fyne.io/fyne/v2/driver/desktop"
|
||||
"fyne.io/fyne/v2/theme"
|
||||
"fyne.io/fyne/v2/widget"
|
||||
"github.com/sethvargo/go-password/password"
|
||||
@ -56,18 +54,7 @@ func (this *appLock) LazyInit(obs observer.Observer) error {
|
||||
return
|
||||
}
|
||||
toolWin.w.Clipboard().SetContent(text.Text)
|
||||
drv := fyne.CurrentApp().Driver()
|
||||
if drv, ok := drv.(desktop.Driver); ok {
|
||||
w := drv.CreateSplashWindow()
|
||||
w.SetContent(widget.NewLabelWithStyle("已复制到剪贴板", fyne.TextAlignCenter, fyne.TextStyle{}))
|
||||
w.Show()
|
||||
|
||||
go func() {
|
||||
time.Sleep(time.Second * 1)
|
||||
w.Close()
|
||||
}()
|
||||
}
|
||||
|
||||
showTip("已复制到剪贴板")
|
||||
})
|
||||
|
||||
c := container.NewVBox(title, input, text, btn, copybtn)
|
||||
|
@ -45,6 +45,7 @@ func (this *toyUserInfo) Init(obs observer.Observer) error {
|
||||
this.copyBtn = widget.NewButtonWithIcon("", theme.ContentCopyIcon(), func() {
|
||||
if this.userInfo != nil && this.userInfo.DbUser != nil {
|
||||
_ = clipboard.WriteAll(this.userInfo.DbUser.Uid)
|
||||
showTip("已复制UID到剪贴板")
|
||||
}
|
||||
})
|
||||
this.copyBtn.Disable()
|
||||
@ -61,6 +62,7 @@ func (this *toyUserInfo) Init(obs observer.Observer) error {
|
||||
})
|
||||
this.refreshBtn.Disable()
|
||||
|
||||
// list
|
||||
this.dataList = widget.NewListWithData(this.data,
|
||||
func() fyne.CanvasObject {
|
||||
return widget.NewLabel("template")
|
||||
@ -70,9 +72,15 @@ func (this *toyUserInfo) Init(obs observer.Observer) error {
|
||||
},
|
||||
)
|
||||
|
||||
// md
|
||||
sign := widget.NewRichTextFromMarkdown(`
|
||||
> hello
|
||||
## H
|
||||
`)
|
||||
// layout
|
||||
this.widget = widget.NewCard("", "",
|
||||
container.NewBorder(container.NewHBox(this.titleLabel, layout.NewSpacer(), this.refreshBtn, this.copyBtn),
|
||||
nil, nil, nil, container.NewVScroll(this.dataList)))
|
||||
sign, nil, nil, container.NewVScroll(this.dataList)))
|
||||
this.widget.Resize(fyne.NewSize(ToyWidth, 650))
|
||||
|
||||
this.dataListener()
|
||||
@ -166,7 +174,9 @@ func (this *toyUserInfo) dataListener() {
|
||||
logrus.Error("unmarshal err")
|
||||
return
|
||||
}
|
||||
this.setProp(5, common.USERINFO_GOLD, rsp.Gold)
|
||||
this.setProp(6, common.USERINFO_GOLD, rsp.Gold)
|
||||
this.setProp(7, common.USERINFO_EXP, rsp.Exp)
|
||||
this.setProp(8, common.USERINFO_DIAMOND, rsp.Diamond)
|
||||
}
|
||||
// listener exp
|
||||
// if data.Msg.MainType == string(comm.ModuleUser) &&
|
||||
|
@ -1,12 +1,16 @@
|
||||
package formview
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"go_dreamfactory/cmd/v2/lib/common"
|
||||
"go_dreamfactory/cmd/v2/model"
|
||||
"go_dreamfactory/cmd/v2/service"
|
||||
"go_dreamfactory/pb"
|
||||
|
||||
"fyne.io/fyne/v2"
|
||||
"fyne.io/fyne/v2/container"
|
||||
"fyne.io/fyne/v2/dialog"
|
||||
"fyne.io/fyne/v2/widget"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
@ -16,20 +20,66 @@ type BingoView struct {
|
||||
}
|
||||
|
||||
func (this *BingoView) CreateView(t *model.TestCase) fyne.CanvasObject {
|
||||
bingo := widget.NewEntry()
|
||||
bingo.PlaceHolder = "eg. bingo:item,10001,1"
|
||||
this.form.AppendItem(widget.NewFormItem(common.APP_TESTCASE_FORM_BINGO, bingo))
|
||||
var (
|
||||
gridContainer *fyne.Container
|
||||
ttxt string //T text
|
||||
aSel *widget.Select
|
||||
)
|
||||
|
||||
tEntry := widget.NewEntry()
|
||||
tEntry.PlaceHolder = "配置ID"
|
||||
tEntry.OnChanged = func(s string) {
|
||||
ttxt = s
|
||||
}
|
||||
|
||||
nEntry := widget.NewEntry()
|
||||
nEntry.PlaceHolder = "数量"
|
||||
|
||||
attrSel := &widget.Select{}
|
||||
attrSel.Options = []string{"选择", "gold", "diamond", "exp"}
|
||||
attrSel.SetSelected("选择")
|
||||
attrSel.OnChanged = func(s string) {
|
||||
ttxt = s
|
||||
}
|
||||
|
||||
aSel = &widget.Select{}
|
||||
gridContainer = container.NewGridWithColumns(3, aSel, tEntry, nEntry)
|
||||
|
||||
aSel.Options = []string{"选择", "attr", "item", "hero", "equi"}
|
||||
aSel.SetSelected("选择")
|
||||
aSel.OnChanged = func(s string) {
|
||||
if s == "attr" {
|
||||
gridContainer.Objects[1] = attrSel
|
||||
ttxt = attrSel.Selected
|
||||
} else {
|
||||
gridContainer.Objects[1] = tEntry
|
||||
ttxt = tEntry.Text
|
||||
}
|
||||
}
|
||||
|
||||
this.form.AppendItem(widget.NewFormItem(common.APP_TESTCASE_FORM_BINGO, gridContainer))
|
||||
|
||||
this.form.OnSubmit = func() {
|
||||
bingo := fmt.Sprintf("bingo:%s,%s,%s", aSel.Selected, ttxt, nEntry.Text)
|
||||
logrus.Info(bingo)
|
||||
if aSel.Selected == "选择" || nEntry.Text == "" || ttxt == "" || nEntry.Text == "0" {
|
||||
dialog.ShowError(errors.New("请填写完整且正确的数值"), this.w)
|
||||
return
|
||||
}
|
||||
if err := service.GetPttService().SendToClient(
|
||||
t.MainType,
|
||||
t.SubType,
|
||||
&pb.GMCmdReq{Cmod: bingo.Text},
|
||||
&pb.GMCmdReq{Cmod: bingo},
|
||||
); err != nil {
|
||||
logrus.Error(err)
|
||||
return
|
||||
}
|
||||
|
||||
// go service.GetConnService().RespHandle(t)
|
||||
aSel.SetSelected("")
|
||||
attrSel.SetSelected("")
|
||||
nEntry.SetText("")
|
||||
tEntry.SetText("")
|
||||
|
||||
}
|
||||
return this.form
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user