优化配置同步
This commit is contained in:
parent
55c25671d6
commit
58e8c2f7fd
@ -10,6 +10,7 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"path"
|
"path"
|
||||||
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"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{
|
c.JSON(http.StatusOK, gin.H{
|
||||||
"dirs": dirs,
|
"dirs": dirs,
|
||||||
})
|
})
|
||||||
|
@ -4,5 +4,5 @@ Website = "http://legu.cc"
|
|||||||
Icon = "app.png"
|
Icon = "app.png"
|
||||||
Name = "RobotGUI"
|
Name = "RobotGUI"
|
||||||
ID = "cc.legu.app"
|
ID = "cc.legu.app"
|
||||||
Version = "1.0.11"
|
Version = "1.0.12"
|
||||||
Build = 14
|
Build = 15
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
@echo off
|
@echo off
|
||||||
|
|
||||||
rem build desktop
|
set input=%1%
|
||||||
go build -ldflags -H=windowsgui -o robot.exe
|
|
||||||
|
echo build version:%input%
|
||||||
|
|
||||||
|
fyne package --name RobotGUI-%input% -os windows
|
@ -2,7 +2,10 @@ package ui
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"go_dreamfactory/cmd/v2/lib/common"
|
"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/dialog"
|
||||||
"fyne.io/fyne/v2/widget"
|
"fyne.io/fyne/v2/widget"
|
||||||
)
|
)
|
||||||
@ -14,12 +17,15 @@ type about struct {
|
|||||||
func newAbout() *about {
|
func newAbout() *about {
|
||||||
var a about
|
var a about
|
||||||
ver := toolWin.app.Metadata().Version
|
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(
|
content := widget.NewCard("", "", widget.NewRichTextFromMarkdown(
|
||||||
`
|
`
|
||||||
梦工厂项目辅助工具GUI
|
梦工厂项目辅助工具GUI
|
||||||
@v`+ver,
|
@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
|
return &a
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ func showTip(content string) {
|
|||||||
w.Show()
|
w.Show()
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
time.Sleep(time.Second * 2)
|
time.Sleep(time.Millisecond * 1500)
|
||||||
w.Close()
|
w.Close()
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
@ -397,6 +397,7 @@ type fileList struct {
|
|||||||
titleLabel *widget.Label
|
titleLabel *widget.Label
|
||||||
cachedList List
|
cachedList List
|
||||||
itemList *widget.List
|
itemList *widget.List
|
||||||
|
searchItem []Item //用于暂存搜索结果
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewFileList() *fileList {
|
func NewFileList() *fileList {
|
||||||
@ -450,7 +451,7 @@ func (f *fileList) addItem(val string) {
|
|||||||
newItem := Item{
|
newItem := Item{
|
||||||
Text: val,
|
Text: val,
|
||||||
Quantity: 1,
|
Quantity: 1,
|
||||||
Checked: true, //默认选中
|
Checked: false, //默认不选中
|
||||||
}
|
}
|
||||||
f.cachedList.Items = append(f.cachedList.Items, newItem)
|
f.cachedList.Items = append(f.cachedList.Items, newItem)
|
||||||
sort.Sort(f.cachedList)
|
sort.Sort(f.cachedList)
|
||||||
@ -480,11 +481,13 @@ func (f *fileList) loadItem(dirPath string) {
|
|||||||
for _, file := range files {
|
for _, file := range files {
|
||||||
if !file.IsDir() {
|
if !file.IsDir() {
|
||||||
f.addItem(file.Name())
|
f.addItem(file.Name())
|
||||||
f.selItemIds = append(f.selItemIds, file.Name())
|
// f.selItemIds = append(f.selItemIds, file.Name())
|
||||||
f.fileTotal++
|
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"
|
||||||
"go_dreamfactory/cmd/v2/service/observer"
|
"go_dreamfactory/cmd/v2/service/observer"
|
||||||
"image/color"
|
"image/color"
|
||||||
"math/rand"
|
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
|
||||||
|
|
||||||
"fyne.io/fyne/v2"
|
"fyne.io/fyne/v2"
|
||||||
"fyne.io/fyne/v2/canvas"
|
"fyne.io/fyne/v2/canvas"
|
||||||
@ -112,6 +111,16 @@ func (this *appTerm) LazyInit(obs observer.Observer) error {
|
|||||||
jsonDir := widget.NewEntry()
|
jsonDir := widget.NewEntry()
|
||||||
jsonDir.PlaceHolder = "Json目录"
|
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
|
//set input entry
|
||||||
if sshConf != nil {
|
if sshConf != nil {
|
||||||
ip.Text = sshConf.Ip
|
ip.Text = sshConf.Ip
|
||||||
@ -128,18 +137,11 @@ func (this *appTerm) LazyInit(obs observer.Observer) error {
|
|||||||
jsonDir.Text = sshConf.JsonDir
|
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()
|
passwordItem.Widget.Refresh()
|
||||||
|
ip.Refresh()
|
||||||
|
localDir.Refresh()
|
||||||
|
workDir.Refresh()
|
||||||
|
|
||||||
// save func
|
// save func
|
||||||
saveFunc := func() {
|
saveFunc := func() {
|
||||||
@ -171,6 +173,7 @@ func (this *appTerm) LazyInit(obs observer.Observer) error {
|
|||||||
refreshBtn := &widget.Button{Text: "刷新", Icon: theme.ViewRefreshIcon()}
|
refreshBtn := &widget.Button{Text: "刷新", Icon: theme.ViewRefreshIcon()}
|
||||||
svnBtn := &widget.Button{Text: "SVN更新", Icon: theme.ConfirmIcon()}
|
svnBtn := &widget.Button{Text: "SVN更新", Icon: theme.ConfirmIcon()}
|
||||||
explorBtn := &widget.Button{Text: "资源管理器", Icon: theme.FolderIcon()}
|
explorBtn := &widget.Button{Text: "资源管理器", Icon: theme.FolderIcon()}
|
||||||
|
searchEntry := widget.NewEntry()
|
||||||
|
|
||||||
// 全选/全取消
|
// 全选/全取消
|
||||||
allSelBtn := &widget.Button{Icon: theme.CheckButtonCheckedIcon()}
|
allSelBtn := &widget.Button{Icon: theme.CheckButtonCheckedIcon()}
|
||||||
@ -226,25 +229,26 @@ func (this *appTerm) LazyInit(obs observer.Observer) error {
|
|||||||
disConnBtn.Enable()
|
disConnBtn.Enable()
|
||||||
syncBtn.Enable()
|
syncBtn.Enable()
|
||||||
this.upProgress.Hide()
|
this.upProgress.Hide()
|
||||||
allCancelBtn.Hide()
|
allCancelBtn.Show()
|
||||||
allSelBtn.Show()
|
allSelBtn.Hide()
|
||||||
refreshBtn.Enable()
|
refreshBtn.Enable()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 刷新JSON列表
|
// 刷新JSON列表
|
||||||
refreshBtn.Disable()
|
refreshBtn.Disable()
|
||||||
refreshBtn.OnTapped = func() {
|
reloadItem := func() {
|
||||||
defer func() {
|
defer func() {
|
||||||
syncBtn.Enable()
|
syncBtn.Enable()
|
||||||
allSelBtn.Show()
|
allSelBtn.Hide()
|
||||||
allCancelBtn.Hide()
|
allCancelBtn.Show()
|
||||||
}()
|
}()
|
||||||
this.jsonList.loadItem(localDir.Text)
|
this.jsonList.loadItem(localDir.Text)
|
||||||
}
|
}
|
||||||
|
refreshBtn.OnTapped = reloadItem
|
||||||
|
|
||||||
disConnBtn.Disable()
|
|
||||||
// 断开
|
// 断开
|
||||||
|
disConnBtn.Disable()
|
||||||
disConnBtn.OnTapped = func() {
|
disConnBtn.OnTapped = func() {
|
||||||
defer func() {
|
defer func() {
|
||||||
this.jsonList.reset()
|
this.jsonList.reset()
|
||||||
@ -302,7 +306,7 @@ func (this *appTerm) LazyInit(obs observer.Observer) error {
|
|||||||
* 服务地址:10.0.1.11 (保持一致)
|
* 服务地址:10.0.1.11 (保持一致)
|
||||||
* 工作目录:svn下ExcelFile目录全路径
|
* 工作目录:svn下ExcelFile目录全路径
|
||||||
* LubanCli:Luban.Client\Luban.Client.exe (保持一致)
|
* LubanCli:Luban.Client\Luban.Client.exe (保持一致)
|
||||||
* Datas:Datas(保持一致)
|
* Data目录:Datas(保持一致)
|
||||||
* JSON目录:output\json(保持一致)
|
* JSON目录:output\json(保持一致)
|
||||||
* 全部填写完点击【保存配置】
|
* 全部填写完点击【保存配置】
|
||||||
* 点击【SVN更新】生成json文件
|
* 点击【SVN更新】生成json文件
|
||||||
@ -344,7 +348,7 @@ func (this *appTerm) LazyInit(obs observer.Observer) error {
|
|||||||
for _, fileName := range this.jsonList.selItemIds {
|
for _, fileName := range this.jsonList.selItemIds {
|
||||||
this.endProgress.Add(1)
|
this.endProgress.Add(1)
|
||||||
go func(fn string) {
|
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 {
|
if err := this.sshService.ScpCopy(filepath.Join(localDir.Text, fn), remoteDir.Text); err != nil {
|
||||||
logrus.WithField("err", err).Error("同步json")
|
logrus.WithField("err", err).Error("同步json")
|
||||||
showTip(err.Error())
|
showTip(err.Error())
|
||||||
@ -352,6 +356,7 @@ func (this *appTerm) LazyInit(obs observer.Observer) error {
|
|||||||
increment(&this.endProgress)
|
increment(&this.endProgress)
|
||||||
// 移除已上传的
|
// 移除已上传的
|
||||||
this.jsonList.deleteItem(fn)
|
this.jsonList.deleteItem(fn)
|
||||||
|
showTip(fmt.Sprintf("%s 成功上传", fn))
|
||||||
}(fileName)
|
}(fileName)
|
||||||
}
|
}
|
||||||
this.endProgress.Wait()
|
this.endProgress.Wait()
|
||||||
@ -398,6 +403,7 @@ func (this *appTerm) LazyInit(obs observer.Observer) error {
|
|||||||
}
|
}
|
||||||
this.jsonList.itemList.Refresh()
|
this.jsonList.itemList.Refresh()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 全选
|
// 全选
|
||||||
allSelBtn.OnTapped = func() {
|
allSelBtn.OnTapped = func() {
|
||||||
defer func() {
|
defer func() {
|
||||||
@ -409,10 +415,28 @@ func (this *appTerm) LazyInit(obs observer.Observer) error {
|
|||||||
this.jsonList.cachedList.Items[i].Checked = false
|
this.jsonList.cachedList.Items[i].Checked = false
|
||||||
this.jsonList.itemList.UpdateItem(i, widget.NewCheck(v.Text, nil))
|
this.jsonList.itemList.UpdateItem(i, widget.NewCheck(v.Text, nil))
|
||||||
}
|
}
|
||||||
// this.jsonList.changeFileCount()
|
|
||||||
this.jsonList.itemList.Refresh()
|
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列表
|
// 创建json列表
|
||||||
this.jsonList.itemList = this.jsonList.createList()
|
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)
|
btns2 := container.NewHBox(helpBtn2, &layout.Spacer{}, saveBtn2, svnBtn)
|
||||||
|
|
||||||
split := container.NewHSplit(container.NewVBox(canvas.NewText("---只能在非上产环境!!!同步Json的操作仅限于数值热更,非结构热更---", color.RGBA{255, 0, 0, 255}), configForm,
|
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
|
split.Offset = 0.45
|
||||||
content.Objects = append(content.Objects, container.NewBorder(nil, this.upProgress, nil, nil, split))
|
content.Objects = append(content.Objects, container.NewBorder(nil, this.upProgress, nil, nil, split))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user