更新gui
This commit is contained in:
parent
a0b542b20d
commit
5b77f94441
@ -73,6 +73,7 @@ const (
|
||||
APP_NAME = "机器人"
|
||||
// app 子标题 [0.0.1 build-1] 应用名称
|
||||
APP_WIN_TITLE = "%s [%s build-%d] %s"
|
||||
WELCOME_MSG = "欢迎使用工具箱"
|
||||
|
||||
//about
|
||||
APP_ABOUT_TITLE = "关于"
|
||||
@ -89,6 +90,8 @@ const (
|
||||
TOOLBAR_MONITOR = "监控"
|
||||
TOOLBAR_TESTER = "接口测试"
|
||||
TOOLBAR_GEN = "生成代码"
|
||||
TOOLBAR_SEC = "密码器"
|
||||
TOOLBAR_WEL = "欢迎"
|
||||
|
||||
//monitor
|
||||
APP_MONITOR_TITLE_ID = "编号"
|
||||
@ -159,6 +162,7 @@ const (
|
||||
USERINFO_LV = "等级"
|
||||
USERINFO_GOLD = "金币"
|
||||
USERINFO_EXP = "经验"
|
||||
USERINFO_DIAMOND = "钻石"
|
||||
USERINFO_VIP = "贵宾"
|
||||
USERINFO_AVATAR = "头像"
|
||||
USERINFO_FRIENDPOINT = "友情点"
|
||||
|
@ -172,28 +172,3 @@ func (c *ConnServiceImpl) handleNotify(msg *pb.UserMessage) (code pb.ErrorCode)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// response
|
||||
// func (c *ConnServiceImpl) RespHandle(t *model.TestCase) {
|
||||
// for {
|
||||
// if code, msg := c.ReceiveMsg(); code != pb.ErrorCode_Success {
|
||||
// c.obs.Notify(observer.EVENT_APP_LOG, cast.ToString(code))
|
||||
// } else {
|
||||
// if msg.MainType == t.MainType && msg.SubType == t.SubType {
|
||||
// if t.Print == nil {
|
||||
// if a, err := ptypes.MarshalAny(msg.Data); err != nil {
|
||||
// c.obs.Notify(observer.EVENT_APP_LOG, err.Error())
|
||||
// } else {
|
||||
// c.obs.Notify(observer.EVENT_APP_LOG, a.String())
|
||||
// }
|
||||
// } else {
|
||||
// if !comm.ProtoUnmarshal(msg, t.Rsp) {
|
||||
// return
|
||||
// }
|
||||
// c.obs.Notify(observer.EVENT_APP_LOG, t.Print(t.Rsp))
|
||||
// }
|
||||
// break
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
12
cmd/v2/theme/image.go
Normal file
12
cmd/v2/theme/image.go
Normal file
File diff suppressed because one or more lines are too long
@ -21,7 +21,9 @@ var (
|
||||
}
|
||||
|
||||
toolRegister = []appInterface{
|
||||
&appWelcome{},
|
||||
&appGen{},
|
||||
&appLock{},
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -52,7 +52,11 @@ func (a *appTester) LazyInit(obs observer.Observer) error {
|
||||
return
|
||||
}
|
||||
msg := data.(*pb.UserMessage)
|
||||
resLog.SetText(msg.Data.String())
|
||||
if t.Print != nil {
|
||||
resLog.SetText(t.Print(msg))
|
||||
} else {
|
||||
resLog.SetText(msg.Data.String())
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package ui
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"go_dreamfactory/cmd/v2/model"
|
||||
"go_dreamfactory/cmd/v2/service/observer"
|
||||
@ -10,9 +11,11 @@ import (
|
||||
"go_dreamfactory/modules/friend"
|
||||
"go_dreamfactory/modules/hero"
|
||||
"go_dreamfactory/modules/mainline"
|
||||
"go_dreamfactory/modules/rtask"
|
||||
"go_dreamfactory/modules/task"
|
||||
"go_dreamfactory/modules/user"
|
||||
"go_dreamfactory/pb"
|
||||
"strings"
|
||||
|
||||
"fyne.io/fyne/v2"
|
||||
"google.golang.org/protobuf/proto"
|
||||
@ -73,6 +76,11 @@ var (
|
||||
ff(comm.ModuleMainline, mainline.MainlineGetRewardResp): &formview.MainlineRewardView{},
|
||||
// pagoda
|
||||
ff(comm.ModulePagoda, "getlist"): &formview.PagodaListView{},
|
||||
// rtask
|
||||
ff(comm.ModuleRtask, rtask.RtaskSubTypeList): &formview.RtaskListView{},
|
||||
ff(comm.ModuleRtask, rtask.RtaskSubTypeDotask): &formview.RtaskDoitView{},
|
||||
ff(comm.ModuleRtask, rtask.RtaskSubTypeChoose): &formview.RtaskChooseView{},
|
||||
ff(comm.ModuleRtask, rtask.RtaskSubTypeReward): &formview.RtaskRewardView{},
|
||||
}
|
||||
)
|
||||
|
||||
@ -91,6 +99,7 @@ var (
|
||||
string(comm.ModuleShop),
|
||||
string(comm.ModuleMainline),
|
||||
string(comm.ModulePagoda),
|
||||
string(comm.ModuleRtask),
|
||||
},
|
||||
"gm": {ff(comm.ModuleGM, "cmd")},
|
||||
"user": {
|
||||
@ -147,6 +156,12 @@ var (
|
||||
"pagoda": {
|
||||
ff(comm.ModulePagoda, "getlist"),
|
||||
},
|
||||
"rtask": {
|
||||
ff(comm.ModuleRtask, rtask.RtaskSubTypeList),
|
||||
ff(comm.ModuleRtask, rtask.RtaskSubTypeDotask),
|
||||
ff(comm.ModuleRtask, rtask.RtaskSubTypeChoose),
|
||||
ff(comm.ModuleRtask, rtask.RtaskSubTypeReward),
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
@ -308,12 +323,19 @@ var (
|
||||
SubType: hero.HeroSubTypeList,
|
||||
Req: &pb.HeroListReq{},
|
||||
Rsp: &pb.HeroListResp{},
|
||||
// Print: func(rsp proto.Message) string{
|
||||
// out := rsp.(*pb.HeroListResp)
|
||||
// for i, v := range out.List {
|
||||
// fmt.Printf("%d- %v\n", (i + 1), v)
|
||||
// }
|
||||
// },
|
||||
Print: func(rsp proto.Message) string {
|
||||
in := rsp.(*pb.UserMessage)
|
||||
out := &pb.HeroListResp{}
|
||||
if !comm.ProtoUnmarshal(in, out) {
|
||||
return errors.New("unmarshal err").Error()
|
||||
}
|
||||
|
||||
var formatStr strings.Builder
|
||||
for i, v := range out.List {
|
||||
formatStr.WriteString(fmt.Sprintf("%d- %v\n", (i + 1), v))
|
||||
}
|
||||
return formatStr.String()
|
||||
},
|
||||
Enabled: true,
|
||||
},
|
||||
ff(comm.ModuleHero, hero.StrengthenUplv): {
|
||||
@ -504,6 +526,39 @@ var (
|
||||
SubType: "getlist",
|
||||
Enabled: true,
|
||||
},
|
||||
// rtask
|
||||
string(comm.ModuleRtask): {
|
||||
NavLabel: "随机任务",
|
||||
MainType: string(comm.ModuleRtask),
|
||||
Enabled: true,
|
||||
},
|
||||
ff(comm.ModuleRtask, rtask.RtaskSubTypeList): {
|
||||
NavLabel: "任务列表",
|
||||
MainType: string(comm.ModuleRtask),
|
||||
SubType: rtask.RtaskSubTypeList,
|
||||
Enabled: true,
|
||||
},
|
||||
ff(comm.ModuleRtask, rtask.RtaskSubTypeDotask): {
|
||||
NavLabel: "做任务",
|
||||
Desc: "执行随机任务",
|
||||
MainType: string(comm.ModuleRtask),
|
||||
SubType: rtask.RtaskSubTypeDotask,
|
||||
Enabled: true,
|
||||
},
|
||||
ff(comm.ModuleRtask, rtask.RtaskSubTypeChoose): {
|
||||
NavLabel: "情景对答",
|
||||
Desc: "情景对答",
|
||||
MainType: string(comm.ModuleRtask),
|
||||
SubType: rtask.RtaskSubTypeChoose,
|
||||
Enabled: true,
|
||||
},
|
||||
ff(comm.ModuleRtask, rtask.RtaskSubTypeReward): {
|
||||
NavLabel: "领奖",
|
||||
Desc: "领奖",
|
||||
MainType: string(comm.ModuleRtask),
|
||||
SubType: rtask.RtaskSubTypeReward,
|
||||
Enabled: true,
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -135,12 +135,12 @@ func (this *appGen) LazyInit(obs observer.Observer) error {
|
||||
commandStr := `%s -h %s -j cfg -- -d %s --input_data_dir %s --output_code_dir %s --output_data_dir %s --gen_types %s --go:bright_module_name bright -s server`
|
||||
|
||||
arg := fmt.Sprintf(commandStr,
|
||||
workDir.Text+client.Text,
|
||||
fmt.Sprintf("%s\\%s", workDir.Text, client.Text),
|
||||
serverAddr.Text,
|
||||
workDir.Text+define.Text,
|
||||
workDir.Text+inputDir.Text,
|
||||
projectDir.Text+outputCodeDir.Text,
|
||||
projectDir.Text+outputJsonDir.Text,
|
||||
fmt.Sprintf("%s\\%s", workDir.Text, define.Text),
|
||||
fmt.Sprintf("%s\\%s", workDir.Text, inputDir.Text),
|
||||
fmt.Sprintf("%s\\%s", projectDir.Text, outputCodeDir.Text),
|
||||
fmt.Sprintf("%s\\%s", projectDir.Text, outputJsonDir.Text),
|
||||
getType(),
|
||||
)
|
||||
|
||||
@ -159,14 +159,6 @@ func (this *appGen) LazyInit(obs observer.Observer) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *appGen) OpenDefault() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (a *appGen) GetAppName() string {
|
||||
return common.TOOLBAR_GEN
|
||||
}
|
||||
|
||||
func (a appGen) OnClose() bool {
|
||||
return false
|
||||
}
|
62
cmd/v2/ui/tool_newlock.go
Normal file
62
cmd/v2/ui/tool_newlock.go
Normal file
@ -0,0 +1,62 @@
|
||||
package ui
|
||||
|
||||
import (
|
||||
"go_dreamfactory/cmd/v2/lib/common"
|
||||
"go_dreamfactory/cmd/v2/service/observer"
|
||||
"image/color"
|
||||
"strconv"
|
||||
|
||||
"fyne.io/fyne/v2"
|
||||
"fyne.io/fyne/v2/canvas"
|
||||
"fyne.io/fyne/v2/container"
|
||||
"fyne.io/fyne/v2/theme"
|
||||
"fyne.io/fyne/v2/widget"
|
||||
"github.com/sethvargo/go-password/password"
|
||||
)
|
||||
|
||||
type appLock struct {
|
||||
appAdapter
|
||||
}
|
||||
|
||||
func (this *appLock) LazyInit(obs observer.Observer) error {
|
||||
|
||||
this.tabItem = container.NewTabItemWithIcon(common.TOOLBAR_SEC, theme.DownloadIcon(), nil)
|
||||
|
||||
content := container.NewMax()
|
||||
content.Objects = []fyne.CanvasObject{}
|
||||
|
||||
title := canvas.NewText("输入密码长度", color.White)
|
||||
|
||||
input := widget.NewEntry()
|
||||
input.SetPlaceHolder("长度范围10-63")
|
||||
|
||||
text := canvas.NewText("", color.White)
|
||||
text.TextSize = 16
|
||||
|
||||
btn := widget.NewButton("生成", func() {
|
||||
passwordLength, _ := strconv.Atoi(input.Text)
|
||||
|
||||
//Avoids length errors
|
||||
if passwordLength <= 10 || passwordLength >= 63 {
|
||||
passwordLength = 10
|
||||
}
|
||||
|
||||
text.Text = password.MustGenerate(passwordLength, 5, 5, false, false)
|
||||
|
||||
text.Refresh()
|
||||
})
|
||||
|
||||
copybtn := widget.NewButtonWithIcon("复制密码", theme.ContentCopyIcon(), func() {
|
||||
toolWin.w.Clipboard().SetContent(text.Text)
|
||||
})
|
||||
|
||||
c := container.NewVBox(title, input, text, btn, copybtn)
|
||||
content.Objects = append(content.Objects, c)
|
||||
|
||||
this.tabItem.Content = content
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *appLock) GetAppName() string {
|
||||
return common.TOOLBAR_SEC
|
||||
}
|
68
cmd/v2/ui/tool_welcome.go
Normal file
68
cmd/v2/ui/tool_welcome.go
Normal file
@ -0,0 +1,68 @@
|
||||
package ui
|
||||
|
||||
import (
|
||||
"go_dreamfactory/cmd/v2/lib/common"
|
||||
"go_dreamfactory/cmd/v2/service/observer"
|
||||
|
||||
them "go_dreamfactory/cmd/v2/theme"
|
||||
|
||||
"fyne.io/fyne/v2"
|
||||
"fyne.io/fyne/v2/canvas"
|
||||
"fyne.io/fyne/v2/container"
|
||||
"fyne.io/fyne/v2/driver/desktop"
|
||||
"fyne.io/fyne/v2/theme"
|
||||
"fyne.io/fyne/v2/widget"
|
||||
)
|
||||
|
||||
type appWelcome struct {
|
||||
appAdapter
|
||||
}
|
||||
|
||||
func (a *appWelcome) LazyInit(obs observer.Observer) error {
|
||||
logo := canvas.NewImageFromResource(them.ResourceLogoPng)
|
||||
logo.FillMode = canvas.ImageFillContain
|
||||
logo.SetMinSize(fyne.NewSize(362*0.8, 192*0.8))
|
||||
|
||||
a.tabItem = container.NewTabItemWithIcon(common.TOOLBAR_WEL, theme.InfoIcon(), nil)
|
||||
|
||||
wel := widget.NewRichTextFromMarkdown("# " + common.WELCOME_MSG)
|
||||
for i := range wel.Segments {
|
||||
if seg, ok := wel.Segments[i].(*widget.TextSegment); ok {
|
||||
seg.Style.Alignment = fyne.TextAlignCenter
|
||||
}
|
||||
}
|
||||
|
||||
// shortCuts := widget.NewForm()
|
||||
// for _, myApp := range appRegister {
|
||||
// shortCuts.Append(myApp.GetAppName(), widget.NewLabelWithStyle(common.ShortCutName(myApp.ShortCut()), fyne.TextAlignCenter, fyne.TextStyle{}))
|
||||
// }
|
||||
// shortCuts.Append("Show/Hide", widget.NewLabelWithStyle("Ctrl + Shift + Z", fyne.TextAlignCenter, fyne.TextStyle{}))
|
||||
|
||||
a.tabItem.Content = container.NewCenter(
|
||||
container.NewVBox(
|
||||
wel,
|
||||
logo,
|
||||
// shortCuts,
|
||||
))
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *appWelcome) GetAppName() string {
|
||||
return common.TOOLBAR_WEL
|
||||
}
|
||||
|
||||
func (a *appWelcome) OpenDefault() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (a *appWelcome) ShortCut() fyne.Shortcut {
|
||||
return &desktop.CustomShortcut{KeyName: fyne.Key1, Modifier: desktop.AltModifier}
|
||||
}
|
||||
|
||||
func (a *appWelcome) Icon() fyne.Resource {
|
||||
return theme.InfoIcon()
|
||||
}
|
||||
|
||||
func (a *appWelcome) OnClose() bool {
|
||||
return false
|
||||
}
|
@ -36,6 +36,10 @@ func NewToolWindow(ui *UIImpl) ToolWindow {
|
||||
openApp1(common.TOOLBAR_GEN)
|
||||
}),
|
||||
|
||||
widget.NewToolbarAction(theme.DownloadIcon(), func() {
|
||||
openApp1(common.TOOLBAR_SEC)
|
||||
}),
|
||||
|
||||
widget.NewToolbarSpacer(),
|
||||
widget.NewToolbarAction(theme.HelpIcon(), func() {
|
||||
showAbout()
|
||||
|
@ -72,7 +72,7 @@ func (this *toyUserInfo) Init(obs observer.Observer) error {
|
||||
this.widget = widget.NewCard("", "",
|
||||
container.NewBorder(container.NewHBox(this.titleLabel, layout.NewSpacer(), this.refreshBtn, this.copyBtn),
|
||||
nil, nil, nil, container.NewVScroll(this.dataList)))
|
||||
this.widget.Resize(fyne.NewSize(ToyWidth, 600))
|
||||
this.widget.Resize(fyne.NewSize(ToyWidth, 650))
|
||||
|
||||
this.dataListener()
|
||||
return nil
|
||||
@ -103,12 +103,13 @@ func (this *toyUserInfo) dataListener() {
|
||||
_ = this.data.Append(this.getLv()) //5
|
||||
_ = this.data.Append(this.getGold()) //6
|
||||
_ = this.data.Append(this.getExp()) //7
|
||||
_ = this.data.Append(this.getTitle()) //8
|
||||
_ = this.data.Append(this.getActiveDay()) //9
|
||||
_ = this.data.Append(this.getActiveWeek()) //10
|
||||
_ = this.data.Append(this.getFriendPoint()) //11
|
||||
_ = this.data.Append(this.getModiNameCount()) //12
|
||||
_ = this.data.Append(this.getSign()) //13
|
||||
_ = this.data.Append(this.getDiamond()) //8
|
||||
_ = this.data.Append(this.getTitle()) //9
|
||||
_ = this.data.Append(this.getActiveDay()) //10
|
||||
_ = this.data.Append(this.getActiveWeek()) //11
|
||||
_ = this.data.Append(this.getFriendPoint()) //12
|
||||
_ = this.data.Append(this.getModiNameCount()) //13
|
||||
_ = this.data.Append(this.getSign()) //14
|
||||
},
|
||||
})
|
||||
|
||||
@ -141,12 +142,13 @@ func (this *toyUserInfo) dataListener() {
|
||||
this.setProp(5, common.USERINFO_LV, rsp.Data.Lv)
|
||||
this.setProp(6, common.USERINFO_GOLD, rsp.Data.Gold)
|
||||
this.setProp(7, common.USERINFO_EXP, rsp.Data.Exp)
|
||||
this.setProp(8, common.USERINFO_TITLE, rsp.Data.Title)
|
||||
this.setProp(9, common.USERINFO_ACTIVE_DAY, rsp.Ex.Activeday)
|
||||
this.setProp(10, common.USERINFO_ACTIVE_WEEK, rsp.Ex.Activeweek)
|
||||
this.setProp(11, common.USERINFO_FRIENDPOINT, rsp.Ex.FriendPoint)
|
||||
this.setProp(12, common.USERINFO_MODINAME, rsp.Ex.ModifynameCount)
|
||||
this.setProp(13, common.USERINFO_SIGN, rsp.Ex.Sign)
|
||||
this.setProp(8, common.USERINFO_DIAMOND, rsp.Data.Diamond)
|
||||
this.setProp(9, common.USERINFO_TITLE, rsp.Data.Title)
|
||||
this.setProp(10, common.USERINFO_ACTIVE_DAY, rsp.Ex.Activeday)
|
||||
this.setProp(11, common.USERINFO_ACTIVE_WEEK, rsp.Ex.Activeweek)
|
||||
this.setProp(12, common.USERINFO_FRIENDPOINT, rsp.Ex.FriendPoint)
|
||||
this.setProp(13, common.USERINFO_MODINAME, rsp.Ex.ModifynameCount)
|
||||
this.setProp(14, common.USERINFO_SIGN, rsp.Ex.Sign)
|
||||
}
|
||||
},
|
||||
})
|
||||
@ -211,6 +213,10 @@ func (this *toyUserInfo) getExp() string {
|
||||
return fmt.Sprintf("%-3s\t: %s", common.USERINFO_EXP, cast.ToString(this.userInfo.DbUser.Exp))
|
||||
}
|
||||
|
||||
func (this *toyUserInfo) getDiamond() string {
|
||||
return fmt.Sprintf("%-3s\t: %s", common.USERINFO_DIAMOND, cast.ToString(this.userInfo.DbUser.Diamond))
|
||||
}
|
||||
|
||||
func (this *toyUserInfo) getTitle() string {
|
||||
return fmt.Sprintf("%-3s\t: %s", common.USERINFO_TITLE, cast.ToString(this.userInfo.DbUser.Exp))
|
||||
}
|
||||
|
47
cmd/v2/ui/views/rtask_choose.go
Normal file
47
cmd/v2/ui/views/rtask_choose.go
Normal file
@ -0,0 +1,47 @@
|
||||
package formview
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"go_dreamfactory/cmd/v2/model"
|
||||
"go_dreamfactory/cmd/v2/service"
|
||||
"go_dreamfactory/pb"
|
||||
|
||||
"fyne.io/fyne/v2"
|
||||
"fyne.io/fyne/v2/dialog"
|
||||
"fyne.io/fyne/v2/widget"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/spf13/cast"
|
||||
)
|
||||
|
||||
type RtaskChooseView struct {
|
||||
BaseformView
|
||||
}
|
||||
|
||||
func (this *RtaskChooseView) CreateView(t *model.TestCase) fyne.CanvasObject {
|
||||
taskId := widget.NewEntry()
|
||||
taskId.PlaceHolder = "任务ID"
|
||||
|
||||
chooseId := widget.NewEntry()
|
||||
chooseId.PlaceHolder = "选项ID"
|
||||
|
||||
this.form.AppendItem(widget.NewFormItem("任务ID", taskId))
|
||||
this.form.AppendItem(widget.NewFormItem("选项ID", chooseId))
|
||||
|
||||
this.form.OnSubmit = func() {
|
||||
if taskId.Text == "" {
|
||||
dialog.ShowError(errors.New("请填写任务ID"), this.w)
|
||||
return
|
||||
}
|
||||
if chooseId.Text == "" {
|
||||
dialog.ShowError(errors.New("请填写选项ID"), this.w)
|
||||
return
|
||||
}
|
||||
if err := service.GetPttService().SendToClient(t.MainType, t.SubType, &pb.RtaskChooseReq{
|
||||
RtaskId: cast.ToInt32(taskId.Text),
|
||||
ChooseId: cast.ToInt32(chooseId.Text),
|
||||
}); err != nil {
|
||||
logrus.Error(err)
|
||||
}
|
||||
}
|
||||
return this.form
|
||||
}
|
39
cmd/v2/ui/views/rtask_doit.go
Normal file
39
cmd/v2/ui/views/rtask_doit.go
Normal file
@ -0,0 +1,39 @@
|
||||
package formview
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"go_dreamfactory/cmd/v2/model"
|
||||
"go_dreamfactory/cmd/v2/service"
|
||||
"go_dreamfactory/pb"
|
||||
|
||||
"fyne.io/fyne/v2"
|
||||
"fyne.io/fyne/v2/dialog"
|
||||
"fyne.io/fyne/v2/widget"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/spf13/cast"
|
||||
)
|
||||
|
||||
type RtaskDoitView struct {
|
||||
BaseformView
|
||||
}
|
||||
|
||||
func (this *RtaskDoitView) CreateView(t *model.TestCase) fyne.CanvasObject {
|
||||
taskId := widget.NewEntry()
|
||||
taskId.PlaceHolder = "任务ID"
|
||||
|
||||
this.form.AppendItem(widget.NewFormItem("任务ID", taskId))
|
||||
|
||||
this.form.OnSubmit = func() {
|
||||
if taskId.Text == "" {
|
||||
dialog.ShowError(errors.New("请填写任务ID"), this.w)
|
||||
return
|
||||
}
|
||||
if err := service.GetPttService().SendToClient(t.MainType, t.SubType, &pb.RtaskApplyReq{
|
||||
RtaskId: cast.ToInt32(taskId.Text),
|
||||
}); err != nil {
|
||||
logrus.Error(err)
|
||||
}
|
||||
}
|
||||
|
||||
return this.form
|
||||
}
|
84
cmd/v2/ui/views/rtask_list.go
Normal file
84
cmd/v2/ui/views/rtask_list.go
Normal file
@ -0,0 +1,84 @@
|
||||
package formview
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"go_dreamfactory/cmd/v2/model"
|
||||
"go_dreamfactory/cmd/v2/service"
|
||||
"go_dreamfactory/cmd/v2/service/observer"
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/modules/rtask"
|
||||
"go_dreamfactory/pb"
|
||||
|
||||
"fyne.io/fyne/v2"
|
||||
"fyne.io/fyne/v2/container"
|
||||
"fyne.io/fyne/v2/dialog"
|
||||
"fyne.io/fyne/v2/theme"
|
||||
"fyne.io/fyne/v2/widget"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/spf13/cast"
|
||||
)
|
||||
|
||||
type RtaskListView struct {
|
||||
ListBaseView
|
||||
}
|
||||
|
||||
func (this *RtaskListView) CreateView(t *model.TestCase) fyne.CanvasObject {
|
||||
// init required
|
||||
this.initItemList()
|
||||
|
||||
// create friend list view
|
||||
this.createItemList()
|
||||
|
||||
input := widget.NewEntry()
|
||||
input.PlaceHolder = "分组编号"
|
||||
this.form.AppendItem(widget.NewFormItem("", input))
|
||||
|
||||
// task list button
|
||||
taskListBtn := widget.NewButtonWithIcon("任务列表", theme.ConfirmIcon(), func() {
|
||||
if input.Text == "" {
|
||||
dialog.ShowError(errors.New("请填写分组编号"), this.w)
|
||||
return
|
||||
}
|
||||
if err := service.GetPttService().SendToClient(t.MainType, t.SubType, &pb.RtasklistReq{
|
||||
GroupId: cast.ToInt32(input.Text),
|
||||
}); err != nil {
|
||||
logrus.Error(err)
|
||||
}
|
||||
})
|
||||
|
||||
// layout
|
||||
split := container.NewHSplit(this.dataListWidget, container.NewVBox(this.form, taskListBtn))
|
||||
split.Offset = 1
|
||||
|
||||
//data listener for
|
||||
this.dataListener()
|
||||
|
||||
return split
|
||||
}
|
||||
|
||||
func (this *RtaskListView) dataListener() {
|
||||
this.obs.AddListener(observer.EVENT_REQ_RSP, observer.Listener{
|
||||
OnNotify: func(d interface{}, args ...interface{}) {
|
||||
data := d.(*pb.UserMessage)
|
||||
if !(data.MainType == string(comm.ModuleRtask) &&
|
||||
data.SubType == rtask.RtaskSubTypeList) {
|
||||
return
|
||||
}
|
||||
|
||||
rsp := &pb.RtasklistResp{}
|
||||
if !comm.ProtoUnmarshal(data, rsp) {
|
||||
logrus.Error("unmarshal err")
|
||||
}
|
||||
|
||||
this.itemListData = model.NewItemModelList()
|
||||
for _, v := range rsp.RtaskIds {
|
||||
fm := &model.ItemModel{
|
||||
Id: cast.ToString(v),
|
||||
Label: cast.ToString(v),
|
||||
}
|
||||
this.itemListData.DataList = append(this.itemListData.DataList, fm)
|
||||
}
|
||||
this.reloadListData()
|
||||
},
|
||||
})
|
||||
}
|
37
cmd/v2/ui/views/rtask_reward.go
Normal file
37
cmd/v2/ui/views/rtask_reward.go
Normal file
@ -0,0 +1,37 @@
|
||||
package formview
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"go_dreamfactory/cmd/v2/model"
|
||||
"go_dreamfactory/cmd/v2/service"
|
||||
"go_dreamfactory/pb"
|
||||
|
||||
"fyne.io/fyne/v2"
|
||||
"fyne.io/fyne/v2/dialog"
|
||||
"fyne.io/fyne/v2/widget"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/spf13/cast"
|
||||
)
|
||||
|
||||
type RtaskRewardView struct {
|
||||
BaseformView
|
||||
}
|
||||
|
||||
func (this *RtaskRewardView) CreateView(t *model.TestCase) fyne.CanvasObject {
|
||||
taskId := widget.NewEntry()
|
||||
taskId.PlaceHolder = "任务ID"
|
||||
|
||||
this.form.AppendItem(widget.NewFormItem("任务ID", taskId))
|
||||
this.form.OnSubmit = func() {
|
||||
if taskId.Text == "" {
|
||||
dialog.ShowError(errors.New("请填写任务ID"), this.w)
|
||||
return
|
||||
}
|
||||
if err := service.GetPttService().SendToClient(t.MainType, t.SubType, &pb.RtaskGetRewardReq{
|
||||
RtaskId: cast.ToInt32(taskId.Text),
|
||||
}); err != nil {
|
||||
logrus.Error(err)
|
||||
}
|
||||
}
|
||||
return this.form
|
||||
}
|
Loading…
Reference in New Issue
Block a user