优化配置同步
This commit is contained in:
parent
55c25671d6
commit
58e8c2f7fd
@ -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,
|
||||
})
|
||||
|
@ -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
|
||||
|
@ -1,4 +1,7 @@
|
||||
@echo off
|
||||
|
||||
rem build desktop
|
||||
go build -ldflags -H=windowsgui -o robot.exe
|
||||
set input=%1%
|
||||
|
||||
echo build version:%input%
|
||||
|
||||
fyne package --name RobotGUI-%input% -os windows
|
@ -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
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ func showTip(content string) {
|
||||
w.Show()
|
||||
|
||||
go func() {
|
||||
time.Sleep(time.Second * 2)
|
||||
time.Sleep(time.Millisecond * 1500)
|
||||
w.Close()
|
||||
}()
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
// 改变列表项目
|
||||
|
@ -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))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user