From 58e8c2f7fd237f02f1909040330a50baa1b01fd7 Mon Sep 17 00:00:00 2001 From: wh_zcy Date: Thu, 29 Sep 2022 14:57:49 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=85=8D=E7=BD=AE=E5=90=8C?= =?UTF-8?q?=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/upgrade/main.go | 6 ++++ cmd/v2/FyneApp.toml | 4 +-- cmd/v2/build.bat | 7 ++-- cmd/v2/ui/about.go | 8 ++++- cmd/v2/ui/tip.go | 2 +- cmd/v2/ui/tool_gen.go | 9 ++++-- cmd/v2/ui/tool_term.go | 72 ++++++++++++++++++++++++++++-------------- 7 files changed, 76 insertions(+), 32 deletions(-) diff --git a/cmd/upgrade/main.go b/cmd/upgrade/main.go index 687b52f26..4d8eb2ee5 100644 --- a/cmd/upgrade/main.go +++ b/cmd/upgrade/main.go @@ -10,6 +10,7 @@ import ( "log" "net/http" "path" + "sort" "strings" "time" @@ -115,6 +116,11 @@ func main() { // } } + // 排序 + sort.SliceStable(dirs, func(i, j int) bool { + return dirs[i].DateTime > dirs[j].DateTime + }) + c.JSON(http.StatusOK, gin.H{ "dirs": dirs, }) diff --git a/cmd/v2/FyneApp.toml b/cmd/v2/FyneApp.toml index 4c5ddd5c0..5642e3312 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.11" - Build = 14 + Version = "1.0.12" + Build = 15 diff --git a/cmd/v2/build.bat b/cmd/v2/build.bat index a6ba0569f..176f17f9c 100644 --- a/cmd/v2/build.bat +++ b/cmd/v2/build.bat @@ -1,4 +1,7 @@ @echo off -rem build desktop -go build -ldflags -H=windowsgui -o robot.exe \ No newline at end of file +set input=%1% + +echo build version:%input% + +fyne package --name RobotGUI-%input% -os windows \ No newline at end of file diff --git a/cmd/v2/ui/about.go b/cmd/v2/ui/about.go index ee270ea33..09646cdca 100644 --- a/cmd/v2/ui/about.go +++ b/cmd/v2/ui/about.go @@ -2,7 +2,10 @@ package ui import ( "go_dreamfactory/cmd/v2/lib/common" + "net/url" + "fyne.io/fyne/v2" + "fyne.io/fyne/v2/container" "fyne.io/fyne/v2/dialog" "fyne.io/fyne/v2/widget" ) @@ -14,12 +17,15 @@ type about struct { func newAbout() *about { var a about ver := toolWin.app.Metadata().Version + link, _ := url.Parse("http://10.0.0.9:8080") + wlink := widget.NewHyperlinkWithStyle("更新包", link, fyne.TextAlignLeading, fyne.TextStyle{}) content := widget.NewCard("", "", widget.NewRichTextFromMarkdown( ` 梦工厂项目辅助工具GUI @v`+ver, )) - a.aboutDialog = dialog.NewCustom(common.APP_ABOUT_TITLE, common.APP_ABOUT_CONFIRM, content, toolWin.w) + a.aboutDialog = dialog.NewCustom(common.APP_ABOUT_TITLE, common.APP_ABOUT_CONFIRM, + container.NewVBox(content, wlink), toolWin.w) return &a } diff --git a/cmd/v2/ui/tip.go b/cmd/v2/ui/tip.go index 763e0428f..89ad4236c 100644 --- a/cmd/v2/ui/tip.go +++ b/cmd/v2/ui/tip.go @@ -17,7 +17,7 @@ func showTip(content string) { w.Show() go func() { - time.Sleep(time.Second * 2) + time.Sleep(time.Millisecond * 1500) w.Close() }() } diff --git a/cmd/v2/ui/tool_gen.go b/cmd/v2/ui/tool_gen.go index fd007ceaa..fb56b230f 100644 --- a/cmd/v2/ui/tool_gen.go +++ b/cmd/v2/ui/tool_gen.go @@ -397,6 +397,7 @@ type fileList struct { titleLabel *widget.Label cachedList List itemList *widget.List + searchItem []Item //用于暂存搜索结果 } func NewFileList() *fileList { @@ -450,7 +451,7 @@ func (f *fileList) addItem(val string) { newItem := Item{ Text: val, Quantity: 1, - Checked: true, //默认选中 + Checked: false, //默认不选中 } f.cachedList.Items = append(f.cachedList.Items, newItem) sort.Sort(f.cachedList) @@ -480,11 +481,13 @@ func (f *fileList) loadItem(dirPath string) { for _, file := range files { if !file.IsDir() { f.addItem(file.Name()) - f.selItemIds = append(f.selItemIds, file.Name()) + // f.selItemIds = append(f.selItemIds, file.Name()) f.fileTotal++ - logrus.Debugf("%v", file.Name()) + // logrus.Debugf("%v", file.Name()) } } + + f.searchItem = f.cachedList.Items } // 改变列表项目 diff --git a/cmd/v2/ui/tool_term.go b/cmd/v2/ui/tool_term.go index 548520062..d6f22914a 100644 --- a/cmd/v2/ui/tool_term.go +++ b/cmd/v2/ui/tool_term.go @@ -8,12 +8,11 @@ import ( "go_dreamfactory/cmd/v2/service" "go_dreamfactory/cmd/v2/service/observer" "image/color" - "math/rand" "os/exec" "path/filepath" "runtime" + "strings" "sync" - "time" "fyne.io/fyne/v2" "fyne.io/fyne/v2/canvas" @@ -112,6 +111,16 @@ func (this *appTerm) LazyInit(obs observer.Observer) error { jsonDir := widget.NewEntry() jsonDir.PlaceHolder = "Json目录" + svnForm := widget.NewForm( + &widget.FormItem{Text: "服务地址", Widget: lubanAddr}, + &widget.FormItem{Text: "工作目录", Widget: container.NewBorder(nil, nil, nil, widget.NewButtonWithIcon("", theme.FolderIcon(), func() { + openFolder(workDir) + }), workDir)}, + &widget.FormItem{Text: "LubanCli", Widget: lubanCli}, + &widget.FormItem{Text: "Data目录", Widget: dataDir}, + &widget.FormItem{Text: "JSON目录", Widget: jsonDir}, + ) + //set input entry if sshConf != nil { ip.Text = sshConf.Ip @@ -128,18 +137,11 @@ func (this *appTerm) LazyInit(obs observer.Observer) error { jsonDir.Text = sshConf.JsonDir } - svnForm := widget.NewForm( - &widget.FormItem{Text: "服务地址", Widget: lubanAddr}, - &widget.FormItem{Text: "工作目录", Widget: container.NewBorder(nil, nil, nil, widget.NewButtonWithIcon("", theme.FolderIcon(), func() { - openFolder(workDir) - }), workDir)}, - &widget.FormItem{Text: "LubanCli", Widget: lubanCli}, - &widget.FormItem{Text: "Data目录", Widget: dataDir}, - &widget.FormItem{Text: "JSON目录", Widget: jsonDir}, - ) - - // 非明文显示 + // 解决文本没显示的问题 passwordItem.Widget.Refresh() + ip.Refresh() + localDir.Refresh() + workDir.Refresh() // save func saveFunc := func() { @@ -171,6 +173,7 @@ func (this *appTerm) LazyInit(obs observer.Observer) error { refreshBtn := &widget.Button{Text: "刷新", Icon: theme.ViewRefreshIcon()} svnBtn := &widget.Button{Text: "SVN更新", Icon: theme.ConfirmIcon()} explorBtn := &widget.Button{Text: "资源管理器", Icon: theme.FolderIcon()} + searchEntry := widget.NewEntry() // 全选/全取消 allSelBtn := &widget.Button{Icon: theme.CheckButtonCheckedIcon()} @@ -226,25 +229,26 @@ func (this *appTerm) LazyInit(obs observer.Observer) error { disConnBtn.Enable() syncBtn.Enable() this.upProgress.Hide() - allCancelBtn.Hide() - allSelBtn.Show() + allCancelBtn.Show() + allSelBtn.Hide() refreshBtn.Enable() } } // 刷新JSON列表 refreshBtn.Disable() - refreshBtn.OnTapped = func() { + reloadItem := func() { defer func() { syncBtn.Enable() - allSelBtn.Show() - allCancelBtn.Hide() + allSelBtn.Hide() + allCancelBtn.Show() }() this.jsonList.loadItem(localDir.Text) } + refreshBtn.OnTapped = reloadItem - disConnBtn.Disable() // 断开 + disConnBtn.Disable() disConnBtn.OnTapped = func() { defer func() { this.jsonList.reset() @@ -302,7 +306,7 @@ func (this *appTerm) LazyInit(obs observer.Observer) error { * 服务地址:10.0.1.11 (保持一致) * 工作目录:svn下ExcelFile目录全路径 * LubanCli:Luban.Client\Luban.Client.exe (保持一致) - * Datas:Datas(保持一致) + * Data目录:Datas(保持一致) * JSON目录:output\json(保持一致) * 全部填写完点击【保存配置】 * 点击【SVN更新】生成json文件 @@ -344,7 +348,7 @@ func (this *appTerm) LazyInit(obs observer.Observer) error { for _, fileName := range this.jsonList.selItemIds { this.endProgress.Add(1) go func(fn string) { - time.Sleep(time.Second * time.Duration(rand.Intn(3))) + // time.Sleep(time.Second * time.Duration(rand.Intn(3))) if err := this.sshService.ScpCopy(filepath.Join(localDir.Text, fn), remoteDir.Text); err != nil { logrus.WithField("err", err).Error("同步json") showTip(err.Error()) @@ -352,6 +356,7 @@ func (this *appTerm) LazyInit(obs observer.Observer) error { increment(&this.endProgress) // 移除已上传的 this.jsonList.deleteItem(fn) + showTip(fmt.Sprintf("%s 成功上传", fn)) }(fileName) } this.endProgress.Wait() @@ -398,6 +403,7 @@ func (this *appTerm) LazyInit(obs observer.Observer) error { } this.jsonList.itemList.Refresh() } + // 全选 allSelBtn.OnTapped = func() { defer func() { @@ -409,10 +415,28 @@ func (this *appTerm) LazyInit(obs observer.Observer) error { this.jsonList.cachedList.Items[i].Checked = false this.jsonList.itemList.UpdateItem(i, widget.NewCheck(v.Text, nil)) } - // this.jsonList.changeFileCount() this.jsonList.itemList.Refresh() } + // 搜索 + searchEntry.PlaceHolder = "搜索" + searchEntry.OnChanged = func(s string) { + if s == "" { + reloadItem() + } else { + // go func() { + newList := []Item{} + for _, v := range this.jsonList.searchItem { + if strings.Contains(v.Text, s) { + newList = append(newList, v) + } + } + this.jsonList.cachedList.Items = newList + this.jsonList.itemList.Refresh() + // }() + } + } + // 创建json列表 this.jsonList.itemList = this.jsonList.createList() @@ -420,7 +444,9 @@ func (this *appTerm) LazyInit(obs observer.Observer) error { btns2 := container.NewHBox(helpBtn2, &layout.Spacer{}, saveBtn2, svnBtn) split := container.NewHSplit(container.NewVBox(canvas.NewText("---只能在非上产环境!!!同步Json的操作仅限于数值热更,非结构热更---", color.RGBA{255, 0, 0, 255}), configForm, - btns1, svnForm, btns2, this.cProgress), container.NewBorder(container.NewHBox(allCancelBtn, allSelBtn, syncBtn, refreshBtn, explorBtn), nil, nil, nil, this.jsonList.itemList)) + btns1, svnForm, btns2, this.cProgress), container.NewBorder( + container.NewBorder(nil, nil, container.NewHBox(allCancelBtn, allSelBtn, syncBtn, refreshBtn), container.NewHBox(explorBtn), searchEntry), + nil, nil, nil, this.jsonList.itemList)) split.Offset = 0.45 content.Objects = append(content.Objects, container.NewBorder(nil, this.upProgress, nil, nil, split))