改包名
This commit is contained in:
parent
03bd4e3efa
commit
05e00e0c0b
231
cmd/v2/lib/common/itemlist.go
Normal file
231
cmd/v2/lib/common/itemlist.go
Normal file
@ -0,0 +1,231 @@
|
|||||||
|
package common
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"go_dreamfactory/utils"
|
||||||
|
"io/ioutil"
|
||||||
|
"sort"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"fyne.io/fyne/v2"
|
||||||
|
"fyne.io/fyne/v2/container"
|
||||||
|
"fyne.io/fyne/v2/layout"
|
||||||
|
"fyne.io/fyne/v2/widget"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ItemList struct {
|
||||||
|
SelItemIds []string //选择的ID
|
||||||
|
ItemTotal int //总数
|
||||||
|
TitleLabel *widget.Label
|
||||||
|
CachedList List
|
||||||
|
ItemList *widget.List
|
||||||
|
SearchItem []Item //用于暂存搜索结果
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewItemList() *ItemList {
|
||||||
|
return &ItemList{
|
||||||
|
TitleLabel: &widget.Label{},
|
||||||
|
CachedList: NewList(""),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 重置
|
||||||
|
func (f *ItemList) Reset() {
|
||||||
|
f.ItemTotal = 0
|
||||||
|
f.SelItemIds = []string{}
|
||||||
|
f.CachedList = NewList("")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *ItemList) CreateList() *widget.List {
|
||||||
|
f.ItemList = widget.NewList(
|
||||||
|
func() int {
|
||||||
|
return len(f.CachedList.Items)
|
||||||
|
},
|
||||||
|
func() fyne.CanvasObject {
|
||||||
|
return widget.NewLabel("Template")
|
||||||
|
},
|
||||||
|
func(id widget.ListItemID, item fyne.CanvasObject) {
|
||||||
|
c, _ := item.(*widget.Label)
|
||||||
|
c.Text = f.CachedList.Items[id].Text
|
||||||
|
c.Refresh()
|
||||||
|
},
|
||||||
|
)
|
||||||
|
f.ItemList.OnSelected = func(id widget.ListItemID) {
|
||||||
|
selId := f.CachedList.Items[id].Id
|
||||||
|
f.SelItemIds = append(f.SelItemIds, selId)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return f.ItemList
|
||||||
|
}
|
||||||
|
|
||||||
|
// 创建默认的列表
|
||||||
|
func (f *ItemList) CreateDefaultCheckList() *widget.List {
|
||||||
|
f.ItemList = widget.NewList(
|
||||||
|
func() int {
|
||||||
|
return len(f.CachedList.Items)
|
||||||
|
},
|
||||||
|
func() fyne.CanvasObject {
|
||||||
|
return widget.NewCheck("Template", func(bool) {})
|
||||||
|
},
|
||||||
|
func(id widget.ListItemID, item fyne.CanvasObject) {
|
||||||
|
c, _ := item.(*widget.Check)
|
||||||
|
c.Text = f.CachedList.Items[id].Text
|
||||||
|
c.Checked = f.CachedList.Items[id].Checked
|
||||||
|
|
||||||
|
c.OnChanged = func(b bool) {
|
||||||
|
if b {
|
||||||
|
f.SelItemIds = append(f.SelItemIds, c.Text)
|
||||||
|
} else {
|
||||||
|
f.SelItemIds = utils.DeleteString(f.SelItemIds, c.Text)
|
||||||
|
}
|
||||||
|
f.TitleLabel.SetText(fmt.Sprintf("(%d/%d)", len(f.SelItemIds), f.ItemTotal))
|
||||||
|
f.CachedList.Items[id].Checked = b
|
||||||
|
// sort.Sort(f.cachedList)
|
||||||
|
f.ItemList.Refresh()
|
||||||
|
}
|
||||||
|
c.Refresh()
|
||||||
|
},
|
||||||
|
)
|
||||||
|
return f.ItemList
|
||||||
|
}
|
||||||
|
|
||||||
|
// 创建下载列表
|
||||||
|
func (f *ItemList) CreateDownloadList() *widget.List {
|
||||||
|
f.ItemList = widget.NewList(
|
||||||
|
func() int {
|
||||||
|
return len(f.CachedList.Items)
|
||||||
|
},
|
||||||
|
func() fyne.CanvasObject {
|
||||||
|
chk := widget.NewCheck("Template", func(bool) {})
|
||||||
|
lb := widget.NewLabel("Template")
|
||||||
|
items := container.NewHBox(chk, &layout.Spacer{}, lb)
|
||||||
|
return items
|
||||||
|
},
|
||||||
|
func(id widget.ListItemID, item fyne.CanvasObject) {
|
||||||
|
c, _ := item.(*fyne.Container)
|
||||||
|
chk := c.Objects[0].(*widget.Check)
|
||||||
|
data := f.CachedList.Items[id]
|
||||||
|
chk.Text = data.Text
|
||||||
|
chk.Checked = data.Checked
|
||||||
|
chk.OnChanged = func(b bool) {
|
||||||
|
if b {
|
||||||
|
f.SelItemIds = append(f.SelItemIds, chk.Text)
|
||||||
|
} else {
|
||||||
|
f.SelItemIds = utils.DeleteString(f.SelItemIds, chk.Text)
|
||||||
|
}
|
||||||
|
f.CachedList.Items[id].Checked = b
|
||||||
|
// sort.Sort(f.cachedList)
|
||||||
|
f.ItemList.Refresh()
|
||||||
|
}
|
||||||
|
|
||||||
|
lb := c.Objects[2].(*widget.Label)
|
||||||
|
lb.Text = ConvertFileSize(data.Size)
|
||||||
|
c.Refresh()
|
||||||
|
},
|
||||||
|
)
|
||||||
|
return f.ItemList
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *ItemList) AddItem(item Item) {
|
||||||
|
f.CachedList.Items = append(f.CachedList.Items, item)
|
||||||
|
// sort.Sort(f.cachedList)
|
||||||
|
f.ItemList.Refresh()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *ItemList) AddItemWithText(val string) {
|
||||||
|
val = strings.TrimSpace(val)
|
||||||
|
if len(val) == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
newItem := Item{
|
||||||
|
Text: val,
|
||||||
|
Quantity: 1,
|
||||||
|
Checked: false, //默认不选中
|
||||||
|
}
|
||||||
|
f.CachedList.Items = append(f.CachedList.Items, newItem)
|
||||||
|
sort.Sort(f.CachedList)
|
||||||
|
f.ItemList.Refresh()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *ItemList) LoadItem(dirPath string) {
|
||||||
|
f.Reset()
|
||||||
|
files, err := ioutil.ReadDir(dirPath)
|
||||||
|
if err != nil {
|
||||||
|
logrus.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, file := range files {
|
||||||
|
if !file.IsDir() {
|
||||||
|
f.AddItemWithText(file.Name())
|
||||||
|
// f.selItemIds = append(f.selItemIds, file.Name())
|
||||||
|
f.ItemTotal++
|
||||||
|
// logrus.Debugf("%v", file.Name())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
f.SearchItem = f.CachedList.Items
|
||||||
|
}
|
||||||
|
|
||||||
|
// 改变列表项目
|
||||||
|
func (f *ItemList) ChangeItem(tmpDir, projectDir string) {
|
||||||
|
f.ItemTotal = 0
|
||||||
|
f.SelItemIds = []string{}
|
||||||
|
f.CachedList = NewList("")
|
||||||
|
tmpFiles, err := ioutil.ReadDir(tmpDir)
|
||||||
|
if err != nil {
|
||||||
|
logrus.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
defer func() {
|
||||||
|
if len(tmpFiles) == 0 || len(f.CachedList.Items) == 0 {
|
||||||
|
ShowTip("没有任何变更的项目")
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
projectFiles, err := ioutil.ReadDir(projectDir)
|
||||||
|
if err != nil {
|
||||||
|
logrus.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
pfMap := make(map[string]int64)
|
||||||
|
for _, v := range projectFiles {
|
||||||
|
if !v.IsDir() {
|
||||||
|
pfMap[v.Name()] = v.ModTime().Unix()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, file := range tmpFiles {
|
||||||
|
if !file.IsDir() {
|
||||||
|
if pfTime, ok := pfMap[file.Name()]; ok {
|
||||||
|
if file.ModTime().Unix() <= pfTime {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
f.AddItemWithText(file.Name())
|
||||||
|
f.SelItemIds = append(f.SelItemIds, file.Name())
|
||||||
|
f.ItemTotal++
|
||||||
|
logrus.Debugf("%v", file.Name())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 刷新文件数
|
||||||
|
func (f *ItemList) ChangeFileCount() {
|
||||||
|
f.TitleLabel.SetText(fmt.Sprintf("(%d/%d)", len(f.SelItemIds), f.ItemTotal))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *ItemList) DeleteItem(name string) {
|
||||||
|
for i, v := range f.CachedList.Items {
|
||||||
|
if v.Text == name {
|
||||||
|
f.SelItemIds = utils.DeleteString(f.SelItemIds, v.Text)
|
||||||
|
f.CachedList.Items = append(f.CachedList.Items[:i], f.CachedList.Items[i+1:]...)
|
||||||
|
if f.ItemTotal > 0 {
|
||||||
|
f.ItemTotal--
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package ui
|
package common
|
||||||
|
|
||||||
import "strings"
|
import "strings"
|
||||||
|
|
||||||
@ -57,6 +57,7 @@ func (l List) Less(i, j int) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Item struct {
|
type Item struct {
|
||||||
|
Id string `json:"id"`
|
||||||
Title string `json:"title"`
|
Title string `json:"title"`
|
||||||
Text string `json:"text"`
|
Text string `json:"text"`
|
||||||
Quantity int `json:"quantity"`
|
Quantity int `json:"quantity"`
|
@ -1,4 +1,4 @@
|
|||||||
package ui
|
package common
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"image/color"
|
"image/color"
|
||||||
@ -11,7 +11,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// 显示Tip
|
// 显示Tip
|
||||||
func showTip(content string) {
|
func ShowTip(content string) {
|
||||||
drv := fyne.CurrentApp().Driver()
|
drv := fyne.CurrentApp().Driver()
|
||||||
if drv, ok := drv.(desktop.Driver); ok {
|
if drv, ok := drv.(desktop.Driver); ok {
|
||||||
w := drv.CreateSplashWindow()
|
w := drv.CreateSplashWindow()
|
||||||
@ -25,7 +25,7 @@ func showTip(content string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func showCanvasTip(content string) {
|
func ShowCanvasTip(content string) {
|
||||||
drv := fyne.CurrentApp().Driver()
|
drv := fyne.CurrentApp().Driver()
|
||||||
if drv, ok := drv.(desktop.Driver); ok {
|
if drv, ok := drv.(desktop.Driver); ok {
|
||||||
w := drv.CreateSplashWindow()
|
w := drv.CreateSplashWindow()
|
@ -78,7 +78,7 @@ func (this *appMonitor) Run() {
|
|||||||
data := d.(*model.PushModel)
|
data := d.(*model.PushModel)
|
||||||
this.monitorData.DataList = append(this.monitorData.DataList, data)
|
this.monitorData.DataList = append(this.monitorData.DataList, data)
|
||||||
this.reloadMonitorData()
|
this.reloadMonitorData()
|
||||||
showCanvasTip("收到新的数据推送,请打开[推送]页面")
|
common.ShowCanvasTip("收到新的数据推送,请打开[推送]页面")
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -7,13 +7,9 @@ import (
|
|||||||
"go_dreamfactory/cmd/v2/model"
|
"go_dreamfactory/cmd/v2/model"
|
||||||
"go_dreamfactory/cmd/v2/service"
|
"go_dreamfactory/cmd/v2/service"
|
||||||
"go_dreamfactory/cmd/v2/service/observer"
|
"go_dreamfactory/cmd/v2/service/observer"
|
||||||
"go_dreamfactory/utils"
|
|
||||||
"io/ioutil"
|
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
"sort"
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
"fyne.io/fyne/v2"
|
"fyne.io/fyne/v2"
|
||||||
"fyne.io/fyne/v2/container"
|
"fyne.io/fyne/v2/container"
|
||||||
@ -29,14 +25,14 @@ type appGen struct {
|
|||||||
appAdapter
|
appAdapter
|
||||||
|
|
||||||
obs observer.Observer
|
obs observer.Observer
|
||||||
goList *fileList
|
goList *common.ItemList
|
||||||
jsonList *fileList
|
jsonList *common.ItemList
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *appGen) LazyInit(obs observer.Observer) error {
|
func (this *appGen) LazyInit(obs observer.Observer) error {
|
||||||
this.obs = obs
|
this.obs = obs
|
||||||
this.goList = NewFileList()
|
this.goList = common.NewItemList()
|
||||||
this.jsonList = NewFileList()
|
this.jsonList = common.NewItemList()
|
||||||
|
|
||||||
this.tabItem = container.NewTabItemWithIcon(common.TOOLBAR_GEN, theme.ContentCopyIcon(), nil)
|
this.tabItem = container.NewTabItemWithIcon(common.TOOLBAR_GEN, theme.ContentCopyIcon(), nil)
|
||||||
|
|
||||||
@ -148,10 +144,10 @@ func (this *appGen) LazyInit(obs observer.Observer) error {
|
|||||||
})
|
})
|
||||||
|
|
||||||
//go
|
//go
|
||||||
this.goList.titleLabel = widget.NewLabel("Go文件")
|
this.goList.TitleLabel = widget.NewLabel("Go文件")
|
||||||
this.goList.titleLabel.Hide()
|
this.goList.TitleLabel.Hide()
|
||||||
// 复选列表
|
// 复选列表
|
||||||
this.goList.itemList = this.goList.CreateDefaultList()
|
this.goList.ItemList = this.goList.CreateDefaultCheckList()
|
||||||
|
|
||||||
// 覆盖 -go
|
// 覆盖 -go
|
||||||
go_allSelBtn := &widget.Button{Icon: theme.CheckButtonIcon()}
|
go_allSelBtn := &widget.Button{Icon: theme.CheckButtonIcon()}
|
||||||
@ -165,9 +161,9 @@ func (this *appGen) LazyInit(obs observer.Observer) error {
|
|||||||
go_overrideBtn.Disable()
|
go_overrideBtn.Disable()
|
||||||
defer func() {
|
defer func() {
|
||||||
go_overrideBtn.Enable()
|
go_overrideBtn.Enable()
|
||||||
this.goList.itemList.Refresh()
|
this.goList.ItemList.Refresh()
|
||||||
}()
|
}()
|
||||||
for _, v := range this.goList.selItemIds {
|
for _, v := range this.goList.SelItemIds {
|
||||||
// logrus.WithField("path1", filepath.Join(tmpDir.Text, "go", v)).Debug("copy go")
|
// logrus.WithField("path1", filepath.Join(tmpDir.Text, "go", v)).Debug("copy go")
|
||||||
// logrus.WithField("path2", filepath.Join(projectDir.Text, outputCodeDir.Text, v)).Debug("copy go")
|
// logrus.WithField("path2", filepath.Join(projectDir.Text, outputCodeDir.Text, v)).Debug("copy go")
|
||||||
_, err := common.Copy(filepath.Join(tmpDir.Text, "go", v),
|
_, err := common.Copy(filepath.Join(tmpDir.Text, "go", v),
|
||||||
@ -176,9 +172,9 @@ func (this *appGen) LazyInit(obs observer.Observer) error {
|
|||||||
logrus.Error(err)
|
logrus.Error(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.goList.deleteItem(v)
|
this.goList.DeleteItem(v)
|
||||||
}
|
}
|
||||||
this.goList.changeFileCount()
|
this.goList.ChangeFileCount()
|
||||||
}
|
}
|
||||||
|
|
||||||
//取消checked
|
//取消checked
|
||||||
@ -187,13 +183,13 @@ func (this *appGen) LazyInit(obs observer.Observer) error {
|
|||||||
go_allCancelBtn.Hide()
|
go_allCancelBtn.Hide()
|
||||||
go_allSelBtn.Show()
|
go_allSelBtn.Show()
|
||||||
}()
|
}()
|
||||||
this.goList.selItemIds = []string{}
|
this.goList.SelItemIds = []string{}
|
||||||
for i, v := range this.goList.cachedList.Items {
|
for i, v := range this.goList.CachedList.Items {
|
||||||
this.goList.cachedList.Items[i].Checked = false
|
this.goList.CachedList.Items[i].Checked = false
|
||||||
this.goList.itemList.UpdateItem(i, widget.NewCheck(v.Text, nil))
|
this.goList.ItemList.UpdateItem(i, widget.NewCheck(v.Text, nil))
|
||||||
}
|
}
|
||||||
this.goList.changeFileCount()
|
this.goList.ChangeFileCount()
|
||||||
this.goList.itemList.Refresh()
|
this.goList.ItemList.Refresh()
|
||||||
}
|
}
|
||||||
|
|
||||||
//选择所有
|
//选择所有
|
||||||
@ -202,21 +198,21 @@ func (this *appGen) LazyInit(obs observer.Observer) error {
|
|||||||
go_allCancelBtn.Show()
|
go_allCancelBtn.Show()
|
||||||
go_allSelBtn.Hide()
|
go_allSelBtn.Hide()
|
||||||
}()
|
}()
|
||||||
for i, v := range this.goList.cachedList.Items {
|
for i, v := range this.goList.CachedList.Items {
|
||||||
this.goList.cachedList.Items[i].Checked = true
|
this.goList.CachedList.Items[i].Checked = true
|
||||||
this.goList.selItemIds = append(this.goList.selItemIds, v.Text)
|
this.goList.SelItemIds = append(this.goList.SelItemIds, v.Text)
|
||||||
this.goList.itemList.UpdateItem(i, widget.NewCheck(v.Text, nil))
|
this.goList.ItemList.UpdateItem(i, widget.NewCheck(v.Text, nil))
|
||||||
}
|
}
|
||||||
this.goList.changeFileCount()
|
this.goList.ChangeFileCount()
|
||||||
// this.goList.titleLabel.SetText(fmt.Sprintf("(%d/%d)", len(this.goList.selItemIds), this.goList.fileTotal))
|
// this.goList.titleLabel.SetText(fmt.Sprintf("(%d/%d)", len(this.goList.selItemIds), this.goList.fileTotal))
|
||||||
this.goList.itemList.Refresh()
|
this.goList.ItemList.Refresh()
|
||||||
}
|
}
|
||||||
|
|
||||||
// json
|
// json
|
||||||
this.jsonList.titleLabel = widget.NewLabel("Json文件")
|
this.jsonList.TitleLabel = widget.NewLabel("Json文件")
|
||||||
this.jsonList.titleLabel.Hide()
|
this.jsonList.TitleLabel.Hide()
|
||||||
// 复选列表
|
// 复选列表
|
||||||
this.jsonList.itemList = this.jsonList.CreateDefaultList()
|
this.jsonList.ItemList = this.jsonList.CreateDefaultCheckList()
|
||||||
|
|
||||||
// 覆盖 -go
|
// 覆盖 -go
|
||||||
json_allSelBtn := &widget.Button{Icon: theme.CheckButtonIcon()}
|
json_allSelBtn := &widget.Button{Icon: theme.CheckButtonIcon()}
|
||||||
@ -228,9 +224,9 @@ func (this *appGen) LazyInit(obs observer.Observer) error {
|
|||||||
json_overrideBtn.Disable()
|
json_overrideBtn.Disable()
|
||||||
defer func() {
|
defer func() {
|
||||||
json_overrideBtn.Enable()
|
json_overrideBtn.Enable()
|
||||||
this.jsonList.itemList.Refresh()
|
this.jsonList.ItemList.Refresh()
|
||||||
}()
|
}()
|
||||||
for _, v := range this.jsonList.selItemIds {
|
for _, v := range this.jsonList.SelItemIds {
|
||||||
// logrus.WithField("path1", filepath.Join(tmpDir.Text, "json", v)).Debug("copy json")
|
// logrus.WithField("path1", filepath.Join(tmpDir.Text, "json", v)).Debug("copy json")
|
||||||
// logrus.WithField("path2", filepath.Join(projectDir.Text, outputJsonDir.Text, v)).Debug("copy json")
|
// logrus.WithField("path2", filepath.Join(projectDir.Text, outputJsonDir.Text, v)).Debug("copy json")
|
||||||
_, err := common.Copy(filepath.Join(tmpDir.Text, "json", v),
|
_, err := common.Copy(filepath.Join(tmpDir.Text, "json", v),
|
||||||
@ -239,9 +235,9 @@ func (this *appGen) LazyInit(obs observer.Observer) error {
|
|||||||
logrus.Error(err)
|
logrus.Error(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.jsonList.deleteItem(v)
|
this.jsonList.DeleteItem(v)
|
||||||
}
|
}
|
||||||
this.jsonList.changeFileCount()
|
this.jsonList.ChangeFileCount()
|
||||||
}
|
}
|
||||||
|
|
||||||
//取消checked
|
//取消checked
|
||||||
@ -251,13 +247,13 @@ func (this *appGen) LazyInit(obs observer.Observer) error {
|
|||||||
json_allSelBtn.Show()
|
json_allSelBtn.Show()
|
||||||
}()
|
}()
|
||||||
list := this.jsonList
|
list := this.jsonList
|
||||||
list.selItemIds = []string{}
|
list.SelItemIds = []string{}
|
||||||
for i, v := range list.cachedList.Items {
|
for i, v := range list.CachedList.Items {
|
||||||
list.cachedList.Items[i].Checked = false
|
list.CachedList.Items[i].Checked = false
|
||||||
list.itemList.UpdateItem(i, widget.NewCheck(v.Text, nil))
|
list.ItemList.UpdateItem(i, widget.NewCheck(v.Text, nil))
|
||||||
}
|
}
|
||||||
this.jsonList.changeFileCount()
|
this.jsonList.ChangeFileCount()
|
||||||
list.itemList.Refresh()
|
list.ItemList.Refresh()
|
||||||
}
|
}
|
||||||
|
|
||||||
//选择所有
|
//选择所有
|
||||||
@ -267,13 +263,13 @@ func (this *appGen) LazyInit(obs observer.Observer) error {
|
|||||||
json_allSelBtn.Hide()
|
json_allSelBtn.Hide()
|
||||||
}()
|
}()
|
||||||
list := this.jsonList
|
list := this.jsonList
|
||||||
for i, v := range list.cachedList.Items {
|
for i, v := range list.CachedList.Items {
|
||||||
list.cachedList.Items[i].Checked = true
|
list.CachedList.Items[i].Checked = true
|
||||||
list.selItemIds = append(list.selItemIds, v.Text)
|
list.SelItemIds = append(list.SelItemIds, v.Text)
|
||||||
list.itemList.UpdateItem(i, widget.NewCheck(v.Text, nil))
|
list.ItemList.UpdateItem(i, widget.NewCheck(v.Text, nil))
|
||||||
}
|
}
|
||||||
list.changeFileCount()
|
list.ChangeFileCount()
|
||||||
list.itemList.Refresh()
|
list.ItemList.Refresh()
|
||||||
}
|
}
|
||||||
|
|
||||||
genBtn := &widget.Button{Text: "生成", Icon: theme.ConfirmIcon()}
|
genBtn := &widget.Button{Text: "生成", Icon: theme.ConfirmIcon()}
|
||||||
@ -316,17 +312,17 @@ func (this *appGen) LazyInit(obs observer.Observer) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
changeGo := func() {
|
changeGo := func() {
|
||||||
this.goList.changeItem(filepath.Join(tmpDir.Text, "go"), filepath.Join(projectDir.Text, outputCodeDir.Text))
|
this.goList.ChangeItem(filepath.Join(tmpDir.Text, "go"), filepath.Join(projectDir.Text, outputCodeDir.Text))
|
||||||
this.goList.titleLabel.SetText(fmt.Sprintf("(%d/%d个)", len(this.goList.selItemIds), this.goList.fileTotal))
|
this.goList.TitleLabel.SetText(fmt.Sprintf("(%d/%d个)", len(this.goList.SelItemIds), this.goList.ItemTotal))
|
||||||
go_overrideBtn.Show()
|
go_overrideBtn.Show()
|
||||||
this.goList.titleLabel.Show()
|
this.goList.TitleLabel.Show()
|
||||||
}
|
}
|
||||||
|
|
||||||
changeJson := func() {
|
changeJson := func() {
|
||||||
this.jsonList.changeItem(filepath.Join(tmpDir.Text, "json"), filepath.Join(projectDir.Text, outputJsonDir.Text))
|
this.jsonList.ChangeItem(filepath.Join(tmpDir.Text, "json"), filepath.Join(projectDir.Text, outputJsonDir.Text))
|
||||||
this.jsonList.titleLabel.SetText(fmt.Sprintf("(%d/%d)", len(this.jsonList.selItemIds), this.jsonList.fileTotal))
|
this.jsonList.TitleLabel.SetText(fmt.Sprintf("(%d/%d)", len(this.jsonList.SelItemIds), this.jsonList.ItemTotal))
|
||||||
json_overrideBtn.Show()
|
json_overrideBtn.Show()
|
||||||
this.jsonList.titleLabel.Show()
|
this.jsonList.TitleLabel.Show()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更新列表
|
// 更新列表
|
||||||
@ -360,13 +356,13 @@ func (this *appGen) LazyInit(obs observer.Observer) error {
|
|||||||
left := container.NewVBox(form, container.NewHBox(&layout.Spacer{}, desBtn, saveBtn, genBtn))
|
left := container.NewVBox(form, container.NewHBox(&layout.Spacer{}, desBtn, saveBtn, genBtn))
|
||||||
right := container.NewGridWithColumns(2,
|
right := container.NewGridWithColumns(2,
|
||||||
container.NewBorder(
|
container.NewBorder(
|
||||||
container.NewHBox(go_allSelBtn, go_allCancelBtn, go_overrideBtn, widget.NewLabel("Go文件"), this.goList.titleLabel),
|
container.NewHBox(go_allSelBtn, go_allCancelBtn, go_overrideBtn, widget.NewLabel("Go文件"), this.goList.TitleLabel),
|
||||||
nil, nil, nil,
|
nil, nil, nil,
|
||||||
this.goList.itemList),
|
this.goList.ItemList),
|
||||||
container.NewBorder(
|
container.NewBorder(
|
||||||
container.NewHBox(json_allSelBtn, json_allCancelBtn, json_overrideBtn, widget.NewLabel("Json文件"), this.jsonList.titleLabel),
|
container.NewHBox(json_allSelBtn, json_allCancelBtn, json_overrideBtn, widget.NewLabel("Json文件"), this.jsonList.TitleLabel),
|
||||||
nil, nil, nil,
|
nil, nil, nil,
|
||||||
this.jsonList.itemList))
|
this.jsonList.ItemList))
|
||||||
|
|
||||||
content.Objects = append(content.Objects, container.NewGridWithColumns(2, left, right))
|
content.Objects = append(content.Objects, container.NewGridWithColumns(2, left, right))
|
||||||
|
|
||||||
@ -406,204 +402,6 @@ func openFile(entry *widget.Entry, w fyne.Window) {
|
|||||||
dConf.Show()
|
dConf.Show()
|
||||||
}
|
}
|
||||||
|
|
||||||
type fileList struct {
|
|
||||||
selItemIds []string //选择的ID
|
|
||||||
fileTotal int //文件总数
|
|
||||||
titleLabel *widget.Label
|
|
||||||
cachedList List
|
|
||||||
itemList *widget.List
|
|
||||||
searchItem []Item //用于暂存搜索结果
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewFileList() *fileList {
|
|
||||||
return &fileList{
|
|
||||||
titleLabel: &widget.Label{},
|
|
||||||
cachedList: NewList(""),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (f *fileList) reset() {
|
|
||||||
f.fileTotal = 0
|
|
||||||
f.selItemIds = []string{}
|
|
||||||
f.cachedList = NewList("")
|
|
||||||
}
|
|
||||||
|
|
||||||
// 创建默认的列表
|
|
||||||
func (f *fileList) CreateDefaultList() *widget.List {
|
|
||||||
f.itemList = widget.NewList(
|
|
||||||
func() int {
|
|
||||||
return len(f.cachedList.Items)
|
|
||||||
},
|
|
||||||
func() fyne.CanvasObject {
|
|
||||||
return widget.NewCheck("Template", func(bool) {})
|
|
||||||
},
|
|
||||||
func(id widget.ListItemID, item fyne.CanvasObject) {
|
|
||||||
c, _ := item.(*widget.Check)
|
|
||||||
c.Text = f.cachedList.Items[id].Text
|
|
||||||
c.Checked = f.cachedList.Items[id].Checked
|
|
||||||
|
|
||||||
c.OnChanged = func(b bool) {
|
|
||||||
if b {
|
|
||||||
f.selItemIds = append(f.selItemIds, c.Text)
|
|
||||||
} else {
|
|
||||||
f.selItemIds = utils.DeleteString(f.selItemIds, c.Text)
|
|
||||||
}
|
|
||||||
f.titleLabel.SetText(fmt.Sprintf("(%d/%d)", len(f.selItemIds), f.fileTotal))
|
|
||||||
f.cachedList.Items[id].Checked = b
|
|
||||||
// sort.Sort(f.cachedList)
|
|
||||||
f.itemList.Refresh()
|
|
||||||
}
|
|
||||||
c.Refresh()
|
|
||||||
},
|
|
||||||
)
|
|
||||||
return f.itemList
|
|
||||||
}
|
|
||||||
|
|
||||||
// 创建可扩展属性的列表
|
|
||||||
func (f *fileList) CreateDownloadList() *widget.List {
|
|
||||||
f.itemList = widget.NewList(
|
|
||||||
func() int {
|
|
||||||
return len(f.cachedList.Items)
|
|
||||||
},
|
|
||||||
func() fyne.CanvasObject {
|
|
||||||
chk := widget.NewCheck("Template", func(bool) {})
|
|
||||||
lb := widget.NewLabel("Template")
|
|
||||||
items := container.NewHBox(chk, &layout.Spacer{}, lb)
|
|
||||||
return items
|
|
||||||
},
|
|
||||||
func(id widget.ListItemID, item fyne.CanvasObject) {
|
|
||||||
c, _ := item.(*fyne.Container)
|
|
||||||
chk := c.Objects[0].(*widget.Check)
|
|
||||||
data := f.cachedList.Items[id]
|
|
||||||
chk.Text = data.Text
|
|
||||||
chk.Checked = data.Checked
|
|
||||||
chk.OnChanged = func(b bool) {
|
|
||||||
if b {
|
|
||||||
f.selItemIds = append(f.selItemIds, chk.Text)
|
|
||||||
} else {
|
|
||||||
f.selItemIds = utils.DeleteString(f.selItemIds, chk.Text)
|
|
||||||
}
|
|
||||||
f.cachedList.Items[id].Checked = b
|
|
||||||
// sort.Sort(f.cachedList)
|
|
||||||
f.itemList.Refresh()
|
|
||||||
}
|
|
||||||
|
|
||||||
lb := c.Objects[2].(*widget.Label)
|
|
||||||
lb.Text = common.ConvertFileSize(data.Size)
|
|
||||||
c.Refresh()
|
|
||||||
},
|
|
||||||
)
|
|
||||||
return f.itemList
|
|
||||||
}
|
|
||||||
|
|
||||||
func (f *fileList) AddItem(item Item) {
|
|
||||||
f.cachedList.Items = append(f.cachedList.Items, item)
|
|
||||||
// sort.Sort(f.cachedList)
|
|
||||||
f.itemList.Refresh()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (f *fileList) AddItemWithText(val string) {
|
|
||||||
val = strings.TrimSpace(val)
|
|
||||||
if len(val) == 0 {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
newItem := Item{
|
|
||||||
Text: val,
|
|
||||||
Quantity: 1,
|
|
||||||
Checked: false, //默认不选中
|
|
||||||
}
|
|
||||||
f.cachedList.Items = append(f.cachedList.Items, newItem)
|
|
||||||
sort.Sort(f.cachedList)
|
|
||||||
f.itemList.Refresh()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (f *fileList) deleteItem(name string) {
|
|
||||||
for i, v := range f.cachedList.Items {
|
|
||||||
if v.Text == name {
|
|
||||||
f.selItemIds = utils.DeleteString(f.selItemIds, v.Text)
|
|
||||||
f.cachedList.Items = append(f.cachedList.Items[:i], f.cachedList.Items[i+1:]...)
|
|
||||||
if f.fileTotal > 0 {
|
|
||||||
f.fileTotal--
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (f *fileList) loadItem(dirPath string) {
|
|
||||||
f.reset()
|
|
||||||
files, err := ioutil.ReadDir(dirPath)
|
|
||||||
if err != nil {
|
|
||||||
logrus.Error(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, file := range files {
|
|
||||||
if !file.IsDir() {
|
|
||||||
f.AddItemWithText(file.Name())
|
|
||||||
// f.selItemIds = append(f.selItemIds, file.Name())
|
|
||||||
f.fileTotal++
|
|
||||||
// logrus.Debugf("%v", file.Name())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
f.searchItem = f.cachedList.Items
|
|
||||||
}
|
|
||||||
|
|
||||||
// 改变列表项目
|
|
||||||
func (f *fileList) changeItem(tmpDir, projectDir string) {
|
|
||||||
f.fileTotal = 0
|
|
||||||
f.selItemIds = []string{}
|
|
||||||
f.cachedList = NewList("")
|
|
||||||
tmpFiles, err := ioutil.ReadDir(tmpDir)
|
|
||||||
if err != nil {
|
|
||||||
logrus.Error(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
defer func() {
|
|
||||||
if len(tmpFiles) == 0 || len(f.cachedList.Items) == 0 {
|
|
||||||
showTip("没有任何变更的文件,请确定SVN拉取最新文件")
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
projectFiles, err := ioutil.ReadDir(projectDir)
|
|
||||||
if err != nil {
|
|
||||||
logrus.Error(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
pfMap := make(map[string]int64)
|
|
||||||
for _, v := range projectFiles {
|
|
||||||
if !v.IsDir() {
|
|
||||||
pfMap[v.Name()] = v.ModTime().Unix()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, file := range tmpFiles {
|
|
||||||
if !file.IsDir() {
|
|
||||||
if pfTime, ok := pfMap[file.Name()]; ok {
|
|
||||||
if file.ModTime().Unix() <= pfTime {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
f.AddItemWithText(file.Name())
|
|
||||||
f.selItemIds = append(f.selItemIds, file.Name())
|
|
||||||
f.fileTotal++
|
|
||||||
logrus.Debugf("%v", file.Name())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 刷新文件数
|
|
||||||
func (f *fileList) changeFileCount() {
|
|
||||||
f.titleLabel.SetText(fmt.Sprintf("(%d/%d)", len(f.selItemIds), f.fileTotal))
|
|
||||||
}
|
|
||||||
|
|
||||||
type CopyFiles struct {
|
|
||||||
Dir string
|
|
||||||
FileName string
|
|
||||||
}
|
|
||||||
|
|
||||||
func (a *appGen) GetAppName() string {
|
func (a *appGen) GetAppName() string {
|
||||||
return common.TOOLBAR_GEN
|
return common.TOOLBAR_GEN
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,7 @@ func (this *appLock) LazyInit(obs observer.Observer) error {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
toolWin.w.Clipboard().SetContent(text.Text)
|
toolWin.w.Clipboard().SetContent(text.Text)
|
||||||
showTip("已复制到剪贴板")
|
common.ShowTip("已复制到剪贴板")
|
||||||
})
|
})
|
||||||
|
|
||||||
c := container.NewVBox(title, input, text, btn, copybtn)
|
c := container.NewVBox(title, input, text, btn, copybtn)
|
||||||
|
@ -175,14 +175,14 @@ func (a *appPbGen) GetAppName() string {
|
|||||||
|
|
||||||
type folderList struct {
|
type folderList struct {
|
||||||
selItemIds []string //选择的ID
|
selItemIds []string //选择的ID
|
||||||
cachedList List
|
cachedList common.List
|
||||||
itemList *widget.List
|
itemList *widget.List
|
||||||
fileTotal int //文件总数
|
fileTotal int //文件总数
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewFolderList() *folderList {
|
func NewFolderList() *folderList {
|
||||||
return &folderList{
|
return &folderList{
|
||||||
cachedList: NewList(""),
|
cachedList: common.NewList(""),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -192,7 +192,7 @@ func (f *folderList) createList() *widget.List {
|
|||||||
return len(f.cachedList.Items)
|
return len(f.cachedList.Items)
|
||||||
},
|
},
|
||||||
func() fyne.CanvasObject {
|
func() fyne.CanvasObject {
|
||||||
return widget.NewCheck("Template", func(b bool) {})
|
return widget.NewCheck("Template", func(b bool) {})
|
||||||
},
|
},
|
||||||
func(id widget.ListItemID, item fyne.CanvasObject) {
|
func(id widget.ListItemID, item fyne.CanvasObject) {
|
||||||
c, _ := item.(*widget.Check)
|
c, _ := item.(*widget.Check)
|
||||||
@ -226,7 +226,7 @@ func (f *folderList) initItem(dir string) {
|
|||||||
if file.Name() == ".vscode" {
|
if file.Name() == ".vscode" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
fm := Item{
|
fm := common.Item{
|
||||||
Text: file.Name(),
|
Text: file.Name(),
|
||||||
Checked: false,
|
Checked: false,
|
||||||
}
|
}
|
||||||
|
@ -32,18 +32,18 @@ type appTerm struct {
|
|||||||
obs observer.Observer
|
obs observer.Observer
|
||||||
sshService *service.SSHService
|
sshService *service.SSHService
|
||||||
|
|
||||||
jsonList *fileList //json列表
|
jsonList *common.ItemList //json列表
|
||||||
cProgress *widget.ProgressBarInfinite //连接进度条进度条
|
cProgress *widget.ProgressBarInfinite //连接进度条进度条
|
||||||
upProgress *widget.ProgressBar //上传进度条
|
upProgress *widget.ProgressBar //上传进度条
|
||||||
endProgress sync.WaitGroup
|
endProgress sync.WaitGroup
|
||||||
|
|
||||||
downloadList *fileList //download列表
|
downloadList *common.ItemList //download列表
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *appTerm) LazyInit(obs observer.Observer) error {
|
func (this *appTerm) LazyInit(obs observer.Observer) error {
|
||||||
this.obs = obs
|
this.obs = obs
|
||||||
this.sshService = &service.SSHService{}
|
this.sshService = &service.SSHService{}
|
||||||
this.jsonList = NewFileList()
|
this.jsonList = common.NewItemList()
|
||||||
|
|
||||||
//progress
|
//progress
|
||||||
this.cProgress = widget.NewProgressBarInfinite()
|
this.cProgress = widget.NewProgressBarInfinite()
|
||||||
@ -238,7 +238,7 @@ func (this *appTerm) LazyInit(obs observer.Observer) error {
|
|||||||
connBtn.Enable()
|
connBtn.Enable()
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
this.jsonList.loadItem(localDir.Text)
|
this.jsonList.LoadItem(localDir.Text)
|
||||||
|
|
||||||
this.cProgress.Stop()
|
this.cProgress.Stop()
|
||||||
this.cProgress.Hide()
|
this.cProgress.Hide()
|
||||||
@ -260,7 +260,7 @@ func (this *appTerm) LazyInit(obs observer.Observer) error {
|
|||||||
allSelBtn.Hide()
|
allSelBtn.Hide()
|
||||||
allCancelBtn.Show()
|
allCancelBtn.Show()
|
||||||
}()
|
}()
|
||||||
this.jsonList.loadItem(localDir.Text)
|
this.jsonList.LoadItem(localDir.Text)
|
||||||
}
|
}
|
||||||
refreshBtn.OnTapped = reloadItem
|
refreshBtn.OnTapped = reloadItem
|
||||||
|
|
||||||
@ -268,7 +268,7 @@ func (this *appTerm) LazyInit(obs observer.Observer) error {
|
|||||||
disConnBtn.Disable()
|
disConnBtn.Disable()
|
||||||
disConnBtn.OnTapped = func() {
|
disConnBtn.OnTapped = func() {
|
||||||
defer func() {
|
defer func() {
|
||||||
this.jsonList.reset()
|
this.jsonList.Reset()
|
||||||
connBtn.Enable()
|
connBtn.Enable()
|
||||||
disConnBtn.Disable()
|
disConnBtn.Disable()
|
||||||
syncBtn.Disable()
|
syncBtn.Disable()
|
||||||
@ -292,7 +292,7 @@ func (this *appTerm) LazyInit(obs observer.Observer) error {
|
|||||||
explorBtn.OnTapped = func() {
|
explorBtn.OnTapped = func() {
|
||||||
// logrus.Debug(localDir.Text)
|
// logrus.Debug(localDir.Text)
|
||||||
if localDir.Text == "" {
|
if localDir.Text == "" {
|
||||||
showTip("Json目录必须填写")
|
common.ShowTip("Json目录必须填写")
|
||||||
} else {
|
} else {
|
||||||
openExplor(localDir.Text)
|
openExplor(localDir.Text)
|
||||||
}
|
}
|
||||||
@ -355,7 +355,7 @@ func (this *appTerm) LazyInit(obs observer.Observer) error {
|
|||||||
this.upProgress.Show()
|
this.upProgress.Show()
|
||||||
this.upProgress.SetValue(0)
|
this.upProgress.SetValue(0)
|
||||||
|
|
||||||
len := len(this.jsonList.selItemIds)
|
len := len(this.jsonList.SelItemIds)
|
||||||
num := 0.0
|
num := 0.0
|
||||||
|
|
||||||
increment := func(wg *sync.WaitGroup) {
|
increment := func(wg *sync.WaitGroup) {
|
||||||
@ -364,18 +364,18 @@ func (this *appTerm) LazyInit(obs observer.Observer) error {
|
|||||||
wg.Done()
|
wg.Done()
|
||||||
}
|
}
|
||||||
|
|
||||||
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())
|
common.ShowTip(err.Error())
|
||||||
}
|
}
|
||||||
increment(&this.endProgress)
|
increment(&this.endProgress)
|
||||||
// 移除已上传的
|
// 移除已上传的
|
||||||
this.jsonList.deleteItem(fn)
|
this.jsonList.DeleteItem(fn)
|
||||||
showTip(fmt.Sprintf("%s 成功上传", fn))
|
common.ShowTip(fmt.Sprintf("%s 成功上传", fn))
|
||||||
}(fileName)
|
}(fileName)
|
||||||
}
|
}
|
||||||
this.endProgress.Wait()
|
this.endProgress.Wait()
|
||||||
@ -390,12 +390,12 @@ func (this *appTerm) LazyInit(obs observer.Observer) error {
|
|||||||
//SVN更新提示
|
//SVN更新提示
|
||||||
dc := dialog.NewConfirm("提示", "是否要进行SVN更新?", func(b bool) {
|
dc := dialog.NewConfirm("提示", "是否要进行SVN更新?", func(b bool) {
|
||||||
if b {
|
if b {
|
||||||
showTip("单击【SVN更新】按钮进行更新")
|
common.ShowTip("单击【SVN更新】按钮进行更新")
|
||||||
svnBtn.FocusGained()
|
svnBtn.FocusGained()
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
if len(this.jsonList.selItemIds) == 0 {
|
if len(this.jsonList.SelItemIds) == 0 {
|
||||||
showTip("没有选择任何文件,或尝试点击【刷新】")
|
common.ShowTip("没有选择任何文件,或尝试点击【刷新】")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
syncNext()
|
syncNext()
|
||||||
@ -409,7 +409,7 @@ func (this *appTerm) LazyInit(obs observer.Observer) error {
|
|||||||
// excel更新
|
// excel更新
|
||||||
excelBtn.OnTapped = func() {
|
excelBtn.OnTapped = func() {
|
||||||
if workDir.Text == "" {
|
if workDir.Text == "" {
|
||||||
showTip("工作目录必须填写")
|
common.ShowTip("工作目录必须填写")
|
||||||
} else {
|
} else {
|
||||||
openExplor(workDir.Text)
|
openExplor(workDir.Text)
|
||||||
}
|
}
|
||||||
@ -464,12 +464,12 @@ func (this *appTerm) LazyInit(obs observer.Observer) error {
|
|||||||
allCancelBtn.Hide()
|
allCancelBtn.Hide()
|
||||||
allSelBtn.Show()
|
allSelBtn.Show()
|
||||||
}()
|
}()
|
||||||
for i, v := range this.jsonList.cachedList.Items {
|
for i, v := range this.jsonList.CachedList.Items {
|
||||||
this.jsonList.cachedList.Items[i].Checked = true
|
this.jsonList.CachedList.Items[i].Checked = true
|
||||||
this.jsonList.selItemIds = append(this.jsonList.selItemIds, v.Text)
|
this.jsonList.SelItemIds = append(this.jsonList.SelItemIds, v.Text)
|
||||||
this.jsonList.itemList.UpdateItem(i, widget.NewCheck(v.Text, nil))
|
this.jsonList.ItemList.UpdateItem(i, widget.NewCheck(v.Text, nil))
|
||||||
}
|
}
|
||||||
this.jsonList.itemList.Refresh()
|
this.jsonList.ItemList.Refresh()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 全选
|
// 全选
|
||||||
@ -478,12 +478,12 @@ func (this *appTerm) LazyInit(obs observer.Observer) error {
|
|||||||
allCancelBtn.Show()
|
allCancelBtn.Show()
|
||||||
allSelBtn.Hide()
|
allSelBtn.Hide()
|
||||||
}()
|
}()
|
||||||
this.jsonList.selItemIds = []string{}
|
this.jsonList.SelItemIds = []string{}
|
||||||
for i, v := range this.jsonList.cachedList.Items {
|
for i, v := range this.jsonList.CachedList.Items {
|
||||||
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.itemList.Refresh()
|
this.jsonList.ItemList.Refresh()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 搜索
|
// 搜索
|
||||||
@ -497,14 +497,14 @@ func (this *appTerm) LazyInit(obs observer.Observer) error {
|
|||||||
reloadItem()
|
reloadItem()
|
||||||
} else {
|
} else {
|
||||||
// go func() {
|
// go func() {
|
||||||
newList := []Item{}
|
newList := []common.Item{}
|
||||||
for _, v := range this.jsonList.searchItem {
|
for _, v := range this.jsonList.SearchItem {
|
||||||
if strings.Contains(v.Text, s) {
|
if strings.Contains(v.Text, s) {
|
||||||
newList = append(newList, v)
|
newList = append(newList, v)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.jsonList.cachedList.Items = newList
|
this.jsonList.CachedList.Items = newList
|
||||||
this.jsonList.itemList.Refresh()
|
this.jsonList.ItemList.Refresh()
|
||||||
// }()
|
// }()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -522,7 +522,7 @@ func (this *appTerm) LazyInit(obs observer.Observer) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 创建json列表
|
// 创建json列表
|
||||||
this.jsonList.itemList = this.jsonList.CreateDefaultList()
|
this.jsonList.ItemList = this.jsonList.CreateDefaultCheckList()
|
||||||
|
|
||||||
btns1 := container.NewHBox(helpBtn1, dlBtn, &layout.Spacer{}, saveBtn1, connBtn, disConnBtn)
|
btns1 := container.NewHBox(helpBtn1, dlBtn, &layout.Spacer{}, saveBtn1, connBtn, disConnBtn)
|
||||||
btns2 := container.NewHBox(helpBtn2, &layout.Spacer{}, saveBtn2, excelBtn, svnBtn)
|
btns2 := container.NewHBox(helpBtn2, &layout.Spacer{}, saveBtn2, excelBtn, svnBtn)
|
||||||
@ -530,7 +530,7 @@ func (this *appTerm) LazyInit(obs observer.Observer) error {
|
|||||||
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(
|
btns1, svnForm, btns2, this.cProgress), container.NewBorder(
|
||||||
container.NewBorder(nil, nil, container.NewHBox(allCancelBtn, allSelBtn, syncBtn, refreshBtn), container.NewHBox(explorBtn), searchEntry),
|
container.NewBorder(nil, nil, container.NewHBox(allCancelBtn, allSelBtn, syncBtn, refreshBtn), container.NewHBox(explorBtn), searchEntry),
|
||||||
nil, nil, nil, this.jsonList.itemList))
|
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))
|
||||||
|
|
||||||
@ -545,7 +545,7 @@ func (a *appTerm) GetAppName() string {
|
|||||||
|
|
||||||
func OpenExplor(dir string) {
|
func OpenExplor(dir string) {
|
||||||
if dir == "" {
|
if dir == "" {
|
||||||
showTip("资源管理器路径错误")
|
common.ShowTip("资源管理器路径错误")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if runtime.GOOS == "windows" {
|
if runtime.GOOS == "windows" {
|
||||||
@ -571,9 +571,9 @@ func (a *appTerm) OnClose() bool {
|
|||||||
func (a *appTerm) createDownloadWindow() fyne.Window {
|
func (a *appTerm) createDownloadWindow() fyne.Window {
|
||||||
w := toolWin.app.NewWindow("日志")
|
w := toolWin.app.NewWindow("日志")
|
||||||
|
|
||||||
a.downloadList = NewFileList()
|
a.downloadList = common.NewItemList()
|
||||||
|
|
||||||
a.downloadList.itemList = a.downloadList.CreateDownloadList()
|
a.downloadList.ItemList = a.downloadList.CreateDownloadList()
|
||||||
|
|
||||||
remoteLogDirEntry := widget.NewEntry()
|
remoteLogDirEntry := widget.NewEntry()
|
||||||
remoteLogDirEntry.PlaceHolder = "下载到"
|
remoteLogDirEntry.PlaceHolder = "下载到"
|
||||||
@ -630,7 +630,7 @@ func (a *appTerm) createDownloadWindow() fyne.Window {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, f := range files {
|
for _, f := range files {
|
||||||
a.downloadList.AddItem(Item{Text: f.FileName, Size: f.Size})
|
a.downloadList.AddItem(common.Item{Text: f.FileName, Size: f.Size})
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
@ -659,15 +659,15 @@ func (a *appTerm) createDownloadWindow() fyne.Window {
|
|||||||
allSelBtn.Show()
|
allSelBtn.Show()
|
||||||
}()
|
}()
|
||||||
dlist := a.downloadList
|
dlist := a.downloadList
|
||||||
for i, v := range dlist.cachedList.Items {
|
for i, v := range dlist.CachedList.Items {
|
||||||
dlist.cachedList.Items[i].Checked = true
|
dlist.CachedList.Items[i].Checked = true
|
||||||
dlist.selItemIds = append(dlist.selItemIds, v.Text)
|
dlist.SelItemIds = append(dlist.SelItemIds, v.Text)
|
||||||
dlist.itemList.UpdateItem(i, container.NewHBox(
|
dlist.ItemList.UpdateItem(i, container.NewHBox(
|
||||||
widget.NewCheck(v.Text, nil),
|
widget.NewCheck(v.Text, nil),
|
||||||
&layout.Spacer{},
|
&layout.Spacer{},
|
||||||
widget.NewLabel(common.ConvertFileSize(v.Size))))
|
widget.NewLabel(common.ConvertFileSize(v.Size))))
|
||||||
}
|
}
|
||||||
dlist.itemList.Refresh()
|
dlist.ItemList.Refresh()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 全选
|
// 全选
|
||||||
@ -677,15 +677,15 @@ func (a *appTerm) createDownloadWindow() fyne.Window {
|
|||||||
allSelBtn.Hide()
|
allSelBtn.Hide()
|
||||||
}()
|
}()
|
||||||
dlist := a.downloadList
|
dlist := a.downloadList
|
||||||
dlist.selItemIds = []string{}
|
dlist.SelItemIds = []string{}
|
||||||
for i, v := range dlist.cachedList.Items {
|
for i, v := range dlist.CachedList.Items {
|
||||||
dlist.cachedList.Items[i].Checked = false
|
dlist.CachedList.Items[i].Checked = false
|
||||||
dlist.itemList.UpdateItem(i, container.NewHBox(
|
dlist.ItemList.UpdateItem(i, container.NewHBox(
|
||||||
widget.NewCheck(v.Text, nil),
|
widget.NewCheck(v.Text, nil),
|
||||||
&layout.Spacer{},
|
&layout.Spacer{},
|
||||||
widget.NewLabel(common.ConvertFileSize(v.Size))))
|
widget.NewLabel(common.ConvertFileSize(v.Size))))
|
||||||
}
|
}
|
||||||
dlist.itemList.Refresh()
|
dlist.ItemList.Refresh()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 打开下载目录
|
// 打开下载目录
|
||||||
@ -695,11 +695,11 @@ func (a *appTerm) createDownloadWindow() fyne.Window {
|
|||||||
|
|
||||||
EditorBtn.OnTapped = func() {
|
EditorBtn.OnTapped = func() {
|
||||||
if editorEntry.Text == "" {
|
if editorEntry.Text == "" {
|
||||||
showTip("请配置编辑器")
|
common.ShowTip("请配置编辑器")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if runtime.GOOS == "windows" {
|
if runtime.GOOS == "windows" {
|
||||||
for _, v := range a.downloadList.selItemIds {
|
for _, v := range a.downloadList.SelItemIds {
|
||||||
if err := exec.Command(editorEntry.Text, filepath.Join(saveDirEntry.Text, v)).Start(); err != nil {
|
if err := exec.Command(editorEntry.Text, filepath.Join(saveDirEntry.Text, v)).Start(); err != nil {
|
||||||
dialog.ShowError(errors.WithMessage(err, "请确认编辑器目录是否填写正确"), toolWin.w)
|
dialog.ShowError(errors.WithMessage(err, "请确认编辑器目录是否填写正确"), toolWin.w)
|
||||||
return
|
return
|
||||||
@ -733,9 +733,9 @@ func (a *appTerm) createDownloadWindow() fyne.Window {
|
|||||||
allDownloadBtn.OnTapped = func() {
|
allDownloadBtn.OnTapped = func() {
|
||||||
downloadProgress.Show()
|
downloadProgress.Show()
|
||||||
downloadProgress.Start()
|
downloadProgress.Start()
|
||||||
selItems := a.downloadList.selItemIds
|
selItems := a.downloadList.SelItemIds
|
||||||
if len(selItems) == 0 {
|
if len(selItems) == 0 {
|
||||||
showTip("请选择下载的文件")
|
common.ShowTip("请选择下载的文件")
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
for _, item := range selItems {
|
for _, item := range selItems {
|
||||||
@ -747,7 +747,7 @@ func (a *appTerm) createDownloadWindow() fyne.Window {
|
|||||||
}()
|
}()
|
||||||
logrus.WithField("filepath", remoteLogDirEntry.Text+name).Debug("下载")
|
logrus.WithField("filepath", remoteLogDirEntry.Text+name).Debug("下载")
|
||||||
if err := a.sshService.ScpDownload(saveDirEntry.Text, remoteLogDirEntry.Text+name); err != nil {
|
if err := a.sshService.ScpDownload(saveDirEntry.Text, remoteLogDirEntry.Text+name); err != nil {
|
||||||
showTip(name + " 下载失败")
|
common.ShowTip(name + " 下载失败")
|
||||||
}
|
}
|
||||||
}(item)
|
}(item)
|
||||||
}
|
}
|
||||||
@ -760,7 +760,7 @@ func (a *appTerm) createDownloadWindow() fyne.Window {
|
|||||||
toolbar := container.NewBorder(nil, btns, nil, saveConfBtn, confForm)
|
toolbar := container.NewBorder(nil, btns, nil, saveConfBtn, confForm)
|
||||||
|
|
||||||
//layout
|
//layout
|
||||||
w.SetContent(container.NewBorder(toolbar, downloadProgress, nil, nil, a.downloadList.itemList))
|
w.SetContent(container.NewBorder(toolbar, downloadProgress, nil, nil, a.downloadList.ItemList))
|
||||||
|
|
||||||
w.Resize(fyne.NewSize(800, 450))
|
w.Resize(fyne.NewSize(800, 450))
|
||||||
w.CenterOnScreen()
|
w.CenterOnScreen()
|
||||||
|
@ -45,7 +45,7 @@ func (this *toyUserInfo) Init(obs observer.Observer) error {
|
|||||||
this.copyBtn = widget.NewButtonWithIcon("", theme.ContentCopyIcon(), func() {
|
this.copyBtn = widget.NewButtonWithIcon("", theme.ContentCopyIcon(), func() {
|
||||||
if this.userInfo != nil && this.userInfo.DbUser != nil {
|
if this.userInfo != nil && this.userInfo.DbUser != nil {
|
||||||
_ = clipboard.WriteAll(this.userInfo.DbUser.Uid)
|
_ = clipboard.WriteAll(this.userInfo.DbUser.Uid)
|
||||||
showTip("已复制UID到剪贴板")
|
common.ShowTip("已复制UID到剪贴板")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
this.copyBtn.Disable()
|
this.copyBtn.Disable()
|
||||||
|
@ -21,15 +21,14 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type TaskListView struct {
|
type TaskListView struct {
|
||||||
ListBaseView
|
BaseformView
|
||||||
|
itemList common.ItemList
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *TaskListView) CreateView(t *model.TestCase) fyne.CanvasObject {
|
func (this *TaskListView) CreateView(t *model.TestCase) fyne.CanvasObject {
|
||||||
// init required
|
this.itemList = *common.NewItemList()
|
||||||
this.initItemList()
|
|
||||||
|
|
||||||
// create friend list view
|
this.itemList.ItemList = this.itemList.CreateList()
|
||||||
this.createItemList()
|
|
||||||
|
|
||||||
// select widget
|
// select widget
|
||||||
tagSelect := getTaskTagSelect()
|
tagSelect := getTaskTagSelect()
|
||||||
@ -46,20 +45,20 @@ func (this *TaskListView) CreateView(t *model.TestCase) fyne.CanvasObject {
|
|||||||
|
|
||||||
// task receive button
|
// task receive button
|
||||||
receiveBtn := widget.NewButtonWithIcon("任务领取", theme.ConfirmIcon(), func() {
|
receiveBtn := widget.NewButtonWithIcon("任务领取", theme.ConfirmIcon(), func() {
|
||||||
if len(this.selItemIds) != 1 {
|
if len(this.itemList.SelItemIds) != 1 {
|
||||||
dialog.ShowError(errors.New("请选择一项"), this.w)
|
dialog.ShowError(errors.New("请选择一项"), this.w)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err := service.GetPttService().SendToClient(
|
if err := service.GetPttService().SendToClient(
|
||||||
t.MainType, "receive",
|
t.MainType, "receive",
|
||||||
&pb.TaskReceiveReq{Id: this.selItemIds[0], TaskTag: cast.ToInt32(tagSelect.Selected)}); err != nil {
|
&pb.TaskReceiveReq{Id: this.itemList.SelItemIds[0], TaskTag: cast.ToInt32(tagSelect.Selected)}); err != nil {
|
||||||
logrus.Error(err)
|
logrus.Error(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// layout
|
// layout
|
||||||
split := container.NewHSplit(this.dataListWidget, container.NewVBox(this.form, taskListBtn, receiveBtn))
|
split := container.NewHSplit(this.itemList.ItemList, container.NewVBox(this.form, taskListBtn, receiveBtn))
|
||||||
split.Offset = 1
|
split.Offset = 1
|
||||||
|
|
||||||
//data listener for
|
//data listener for
|
||||||
@ -83,15 +82,15 @@ func (this *TaskListView) dataListener() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
this.itemListData = model.NewItemModelList()
|
this.itemList.Reset()
|
||||||
|
|
||||||
for _, v := range rsp.List {
|
for _, v := range rsp.List {
|
||||||
fm := &model.ItemModel{
|
item := common.Item{
|
||||||
Id: cast.ToString(v.Id),
|
Id: cast.ToString(v.Id),
|
||||||
Label: fmt.Sprintf("%s S:%d R:%d", cast.ToString(v.TaskId), v.Status, v.Received),
|
Text: fmt.Sprintf("%s 是否完成:%d 是否领奖:%d 进度:%d", cast.ToString(v.TaskId), v.Status, v.Received, v.Progress),
|
||||||
}
|
}
|
||||||
this.itemListData.DataList = append(this.itemListData.DataList, fm)
|
this.itemList.AddItem(item)
|
||||||
}
|
}
|
||||||
this.reloadListData()
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -99,9 +99,10 @@ func (this *ModelRtaskRecord) addUpdate(uid string, cfg *cfg.GameRdtaskCondiData
|
|||||||
} else {
|
} else {
|
||||||
//查找任务数据
|
//查找任务数据
|
||||||
if v, ok := record.Vals[cfg.Id]; ok {
|
if v, ok := record.Vals[cfg.Id]; ok {
|
||||||
|
newCount := make([]int32, len(vals))
|
||||||
srcCount := v.Data[0]
|
srcCount := v.Data[0]
|
||||||
vals[0] = srcCount + vals[0]
|
newCount[0] = srcCount + vals[0]
|
||||||
v.Data = toMap(vals...)
|
v.Data = toMap(newCount...)
|
||||||
v.Timestamp = time.Now().Unix()
|
v.Timestamp = time.Now().Unix()
|
||||||
|
|
||||||
update := map[string]interface{}{
|
update := map[string]interface{}{
|
||||||
|
Loading…
Reference in New Issue
Block a user