From 802427073c31a28594978765872a445588246ff7 Mon Sep 17 00:00:00 2001 From: wh_zcy Date: Tue, 20 Sep 2022 22:08:54 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=B5=8B=E8=AF=95=E5=B7=A5?= =?UTF-8?q?=E5=85=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/v2/FyneApp.toml | 4 ++-- cmd/v2/service/connService.go | 7 +++++++ cmd/v2/ui/mainwindow.go | 13 +++++++++++++ cmd/v2/ui/toolwindow.go | 4 ++++ cmd/v2/ui/views/task_activelist.go | 8 ++++---- modules/rtask/updateHandle.go | 7 +++++-- 6 files changed, 35 insertions(+), 8 deletions(-) diff --git a/cmd/v2/FyneApp.toml b/cmd/v2/FyneApp.toml index 4e9b49fc0..a902b31e6 100644 --- a/cmd/v2/FyneApp.toml +++ b/cmd/v2/FyneApp.toml @@ -4,5 +4,5 @@ Website = "http://legu.cc" Icon = "app.png" Name = "RobotGUI" ID = "cc.legu.app" - Version = "1.0.5" - Build = 5 + Version = "1.0.6" + Build = 7 diff --git a/cmd/v2/service/connService.go b/cmd/v2/service/connService.go index 71e305d7d..61aa5fb00 100644 --- a/cmd/v2/service/connService.go +++ b/cmd/v2/service/connService.go @@ -26,6 +26,7 @@ type ConnService interface { SendMsg(msg *pb.UserMessage, rsp proto.Message) (err error) ReceiveMsg() (code pb.ErrorCode, msg *pb.UserMessage) ListenerPush() + Close() } type ConnServiceImpl struct { @@ -173,3 +174,9 @@ func (c *ConnServiceImpl) handleNotify(msg *pb.UserMessage) (code pb.ErrorCode) } return } + +func (c *ConnServiceImpl) Close() { + if err := c.ws.Close(); err != nil { + logrus.Errorf("close ws conn err: %v", err) + } +} diff --git a/cmd/v2/ui/mainwindow.go b/cmd/v2/ui/mainwindow.go index 2f648814e..d47337d46 100644 --- a/cmd/v2/ui/mainwindow.go +++ b/cmd/v2/ui/mainwindow.go @@ -111,7 +111,9 @@ func (ui *MainWindowImpl) SetStatusMsg(msg string) { } func (ui *MainWindowImpl) quiteHandle() { + ui.parent.Show() ui.w.Close() + ui.connService.Close() } // CreateWindow .... @@ -139,6 +141,9 @@ func (ui *MainWindowImpl) CreateWindow(_ string, width, height float32, _ bool) } } }) + w.SetCloseIntercept(func() { + ui.parent.Show() + }) _ = ui.createChooseServerPopUp(w) } @@ -194,6 +199,10 @@ func (ui *MainWindowImpl) createChooseServerWindow( w.SetFixedSize(true) w.Resize(fyne.NewSize(500, 200)) w.Show() + w.SetCloseIntercept(func() { + ui.parent.Show() + w.Close() + }) w.CenterOnScreen() return w } @@ -327,4 +336,8 @@ func (ui *MainWindowImpl) NewWelcomeLabel(data string) { )), )) ui.w.SetContent(c) + ui.w.SetCloseIntercept(func() { + ui.w.Close() + ui.parent.Show() + }) } diff --git a/cmd/v2/ui/toolwindow.go b/cmd/v2/ui/toolwindow.go index a68e8e1a5..04fc85cdd 100644 --- a/cmd/v2/ui/toolwindow.go +++ b/cmd/v2/ui/toolwindow.go @@ -89,5 +89,9 @@ func (ui *ToolWindowImpl) CreateWindow(title string, width, height float32, _ bo } }) w.CenterOnScreen() + w.SetCloseIntercept(func() { + ui.parent.Show() + w.Close() + }) w.Show() } diff --git a/cmd/v2/ui/views/task_activelist.go b/cmd/v2/ui/views/task_activelist.go index 3bf02eb03..d62f02be2 100644 --- a/cmd/v2/ui/views/task_activelist.go +++ b/cmd/v2/ui/views/task_activelist.go @@ -22,7 +22,7 @@ import ( type TaskActiveListView struct { ListBaseView - activeVal int32 + activeVal *widget.Label } func (this *TaskActiveListView) CreateView(t *model.TestCase) fyne.CanvasObject { @@ -46,7 +46,7 @@ func (this *TaskActiveListView) CreateView(t *model.TestCase) fyne.CanvasObject }) //label - activeLabel := widget.NewLabel(fmt.Sprintf("当前活跃度:%d", this.activeVal)) + this.activeVal = widget.NewLabel("") //receive button receiveBtn := widget.NewButtonWithIcon("领取", theme.ConfirmIcon(), func() { @@ -63,7 +63,7 @@ func (this *TaskActiveListView) CreateView(t *model.TestCase) fyne.CanvasObject }) // layout - split := container.NewHSplit(this.dataListWidget, container.NewVBox(activeLabel, this.form, taskListBtn, receiveBtn)) + split := container.NewHSplit(this.dataListWidget, container.NewVBox(this.activeVal, this.form, taskListBtn, receiveBtn)) split.Offset = 1 //data listener for @@ -86,7 +86,7 @@ func (this *TaskActiveListView) dataListener() { logrus.Error("unmarshal err") } - this.activeVal = rsp.Active + this.activeVal.SetText(fmt.Sprintf("当前活跃度:%v", rsp.Active)) this.itemListData = model.NewItemModelList() for _, v := range rsp.List { diff --git a/modules/rtask/updateHandle.go b/modules/rtask/updateHandle.go index 110484b9e..39eb71216 100644 --- a/modules/rtask/updateHandle.go +++ b/modules/rtask/updateHandle.go @@ -71,13 +71,16 @@ func (this *ModelRtaskRecord) overrideUpdate(uid string, cfg *cfg.GameRdtaskCond // 累计更新 - 招募等 func (this *ModelRtaskRecord) addUpdate(uid string, cfg *cfg.GameRdtaskCondiData, vals ...int32) (err error) { - record := &pb.DBRtaskRecord{} + record := &pb.DBRtaskRecord{Uid: uid} err = this.Get(uid, record) if err != nil { - return errors.Wrapf(err, "获取玩家任务记录 err: %v rtype[%v]", uid, cfg.Id) + if err != mongo.ErrNoDocuments { + return errors.Wrapf(err, "获取玩家任务记录 err: %v rtype[%v]", uid, cfg.Id) + } } if record.Vals == nil { + record.Id = primitive.NewObjectID().Hex() data := &pb.RtaskData{ Data: toMap(vals...), Rtype: cfg.Type,