config valid
This commit is contained in:
parent
32fcd9f691
commit
c6c3e4ed14
@ -4,5 +4,5 @@ Website = "http://legu.cc"
|
||||
Icon = "app.png"
|
||||
Name = "RobotGUI"
|
||||
ID = "cc.legu.app"
|
||||
Version = "1.2.9"
|
||||
Build = 39
|
||||
Version = "1.2.10"
|
||||
Build = 40
|
||||
|
@ -98,6 +98,7 @@ const (
|
||||
TOOLBAR_AUTO = "自动化"
|
||||
TOOLBAR_PING = "端口扫描"
|
||||
TOOLBAR_MGODB = "MongoDB"
|
||||
TOOLBAR_VALID = "配置校验"
|
||||
|
||||
TOOLBAR_PERF_TIP = "开始"
|
||||
TOOLBAR_PERF_CONF = "配置"
|
||||
|
@ -40,6 +40,7 @@ type Config struct {
|
||||
Servers []*ServerConfig `json:"servers,omitempty"` //区服配置
|
||||
MgoDB *MgoDB `json:"mgoDB,omitempty"` //MongoDB配置
|
||||
ServiceDBInfo *pb.ServiceDBInfo `json:"serviceDBInfo,omitempty"` //
|
||||
JsonDir string `json:"jsonDir,omitempty"` //json配置目录
|
||||
}
|
||||
|
||||
type MgoDB struct {
|
||||
|
@ -33,7 +33,6 @@ var (
|
||||
logger *logrus.Logger
|
||||
)
|
||||
|
||||
//
|
||||
func init() {
|
||||
_ = os.Setenv("FYNE_SCALE", "0.9")
|
||||
var err error
|
||||
@ -162,7 +161,6 @@ func setupLogger() (err error) {
|
||||
|
||||
// check version
|
||||
func checkVersion(app fyne.App, parent fyne.Window) {
|
||||
logrus.Debug("check version")
|
||||
b, err := connService.HttpConnect("http://10.0.0.9:8080/" + "version")
|
||||
if err != nil {
|
||||
dialog.ShowError(errors.New("版本检查:"+err.Error()), parent)
|
||||
|
File diff suppressed because one or more lines are too long
BIN
cmd/v2/theme/icon/excel.jpg
Normal file
BIN
cmd/v2/theme/icon/excel.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.6 KiB |
BIN
cmd/v2/theme/icon/mongodb.jpg
Normal file
BIN
cmd/v2/theme/icon/mongodb.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.7 KiB |
@ -34,6 +34,7 @@ var (
|
||||
&appTerm{},
|
||||
&appPing{},
|
||||
&appMgo{},
|
||||
&appConfigValid{},
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -431,3 +431,6 @@ func openFile(entry *widget.Entry, w fyne.Window) {
|
||||
func (a *appGen) GetAppName() string {
|
||||
return common.TOOLBAR_GEN
|
||||
}
|
||||
func(a *appGen) Icon() fyne.Resource{
|
||||
return theme.ContentCopyIcon()
|
||||
}
|
@ -11,6 +11,8 @@ import (
|
||||
"go_dreamfactory/pb"
|
||||
"strings"
|
||||
|
||||
mytheme "go_dreamfactory/cmd/v2/theme"
|
||||
|
||||
"fyne.io/fyne/v2"
|
||||
"fyne.io/fyne/v2/container"
|
||||
"fyne.io/fyne/v2/dialog"
|
||||
@ -244,3 +246,6 @@ func (this *appMgo) showConWin() {
|
||||
func (a *appMgo) GetAppName() string {
|
||||
return common.TOOLBAR_MGODB
|
||||
}
|
||||
func (a *appMgo) Icon() fyne.Resource {
|
||||
return mytheme.ResourceMongodbJpg
|
||||
}
|
||||
|
@ -68,3 +68,6 @@ func (this *appLock) LazyInit(ptService service.PttService, obs observer.Observe
|
||||
func (a *appLock) GetAppName() string {
|
||||
return common.TOOLBAR_SEC
|
||||
}
|
||||
func (a *appLock) Icon() fyne.Resource {
|
||||
return theme.DownloadIcon()
|
||||
}
|
||||
|
@ -191,6 +191,9 @@ func (this *appPbGen) LazyInit(ptService service.PttService, obs observer.Observ
|
||||
func (a *appPbGen) GetAppName() string {
|
||||
return common.TOOLBAR_PB
|
||||
}
|
||||
func (a *appPbGen) Icon() fyne.Resource {
|
||||
return theme.ContentAddIcon()
|
||||
}
|
||||
|
||||
type folderList struct {
|
||||
selItemIds []string //选择的ID
|
||||
|
@ -130,3 +130,7 @@ func (this *appPing) ping(targetHost string, ports []string) {
|
||||
func (a *appPing) GetAppName() string {
|
||||
return common.TOOLBAR_PING
|
||||
}
|
||||
|
||||
func (a *appPing) Icon() fyne.Resource {
|
||||
return theme.ComputerIcon()
|
||||
}
|
||||
|
@ -549,6 +549,9 @@ func (app *appTerm) LazyInit(ptService service.PttService, obs observer.Observer
|
||||
func (a *appTerm) GetAppName() string {
|
||||
return common.TOOLBAR_TERM
|
||||
}
|
||||
func (a *appTerm) Icon() fyne.Resource {
|
||||
return theme.MailSendIcon()
|
||||
}
|
||||
|
||||
func OpenExplor(dir string) {
|
||||
if dir == "" {
|
||||
|
122
cmd/v2/ui/tool_valid.go
Normal file
122
cmd/v2/ui/tool_valid.go
Normal file
@ -0,0 +1,122 @@
|
||||
package ui
|
||||
|
||||
import (
|
||||
"go_dreamfactory/cmd/v2/lib/common"
|
||||
os_storage "go_dreamfactory/cmd/v2/lib/storage"
|
||||
"go_dreamfactory/cmd/v2/service"
|
||||
"go_dreamfactory/cmd/v2/service/observer"
|
||||
mytheme "go_dreamfactory/cmd/v2/theme"
|
||||
"io/ioutil"
|
||||
|
||||
"fyne.io/fyne/v2"
|
||||
"fyne.io/fyne/v2/container"
|
||||
"fyne.io/fyne/v2/dialog"
|
||||
fyne_storage "fyne.io/fyne/v2/storage"
|
||||
"fyne.io/fyne/v2/theme"
|
||||
"fyne.io/fyne/v2/widget"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
type jsonFileList struct {
|
||||
selItemId string //选择的文件ID
|
||||
cacheList common.List
|
||||
itemList *widget.List
|
||||
fileTotal int //文件数
|
||||
}
|
||||
|
||||
func newJsonFileList() *jsonFileList {
|
||||
return &jsonFileList{
|
||||
cacheList: common.NewList(""),
|
||||
}
|
||||
}
|
||||
|
||||
type appConfigValid struct {
|
||||
appAdapter
|
||||
jsonFileList
|
||||
}
|
||||
|
||||
func (a *appConfigValid) LazyInit(pt service.PttService, obs observer.Observer) error {
|
||||
a.tabItem = container.NewTabItemWithIcon(common.TOOLBAR_VALID, mytheme.ResourceExcelJpg, nil)
|
||||
a.jsonFileList = *newJsonFileList()
|
||||
|
||||
//load conf
|
||||
storage, _ := os_storage.NewOSStorage()
|
||||
conf, err := storage.LoadConfig()
|
||||
if err != nil {
|
||||
logrus.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
if conf.JsonDir!=""{
|
||||
|
||||
}
|
||||
content := container.NewMax()
|
||||
content.Objects = []fyne.CanvasObject{}
|
||||
|
||||
// 打开目录
|
||||
openFolder := func(entry *widget.Entry) {
|
||||
dConf := dialog.NewFolderOpen(func(lu fyne.ListableURI, err error) {
|
||||
if lu == nil {
|
||||
return
|
||||
}
|
||||
entry.Text = lu.Path()
|
||||
entry.Refresh()
|
||||
}, toolWin.w)
|
||||
luri, _ := fyne_storage.ListerForURI(fyne_storage.NewFileURI("."))
|
||||
dConf.SetLocation(luri)
|
||||
dConf.SetConfirmText("打开")
|
||||
dConf.SetDismissText("取消")
|
||||
dConf.Resize(fyne.NewSize(750, 500))
|
||||
dConf.Show()
|
||||
}
|
||||
//配置json路径
|
||||
jsonDir := widget.NewEntry()
|
||||
jsonDir.PlaceHolder = "json目录"
|
||||
form := widget.NewForm(
|
||||
widget.NewFormItem("json目录", container.NewBorder(nil, nil, nil, widget.NewButtonWithIcon("", theme.FolderIcon(), func() {
|
||||
openFolder(jsonDir)
|
||||
a.jsonFileList.initItem(jsonDir.Text)
|
||||
}), jsonDir)),
|
||||
)
|
||||
|
||||
jsonDir.SetText(conf.JsonDir)
|
||||
|
||||
c := container.NewBorder(form, nil, nil, nil)
|
||||
|
||||
content.Objects = append(content.Objects, c)
|
||||
a.tabItem.Content = content
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *appConfigValid) GetAppName() string {
|
||||
return common.TOOLBAR_VALID
|
||||
}
|
||||
|
||||
func (a *appConfigValid) Icon() fyne.Resource {
|
||||
return mytheme.ResourceExcelJpg
|
||||
}
|
||||
|
||||
func (f *jsonFileList) initItem(dir string) {
|
||||
files, err := ioutil.ReadDir(dir)
|
||||
if err != nil {
|
||||
logrus.Error(err)
|
||||
return
|
||||
}
|
||||
|
||||
for _, file := range files {
|
||||
if file.IsDir() {
|
||||
if file.Name() == ".vscode" {
|
||||
continue
|
||||
}
|
||||
fm := common.Item{
|
||||
Text: file.Name(),
|
||||
Checked: false,
|
||||
}
|
||||
f.cacheList.Items = append(f.cacheList.Items, fm)
|
||||
// f.selItemIds = append(f.selItemIds, fm.Id)
|
||||
f.fileTotal++
|
||||
// logrus.Debugf("%v", fm.Id)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -10,6 +10,8 @@ import (
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
mytheme "go_dreamfactory/cmd/v2/theme"
|
||||
|
||||
"fyne.io/fyne/v2"
|
||||
"fyne.io/fyne/v2/container"
|
||||
"fyne.io/fyne/v2/dialog"
|
||||
@ -64,10 +66,15 @@ func NewToolWindow(ui *UIImpl, parent fyne.Window) ToolWindow {
|
||||
widget.NewToolbarAction(theme.ComputerIcon(), func() {
|
||||
openApp2(mw.at, common.TOOLBAR_PING)
|
||||
}),
|
||||
widget.NewToolbarAction(theme.SettingsIcon(), func() {
|
||||
|
||||
widget.NewToolbarAction(mytheme.ResourceMongodbJpg, func() {
|
||||
openApp2(mw.at, common.TOOLBAR_MGODB)
|
||||
}),
|
||||
|
||||
widget.NewToolbarAction(mytheme.ResourceExcelJpg, func() {
|
||||
openApp2(mw.at, common.TOOLBAR_VALID)
|
||||
}),
|
||||
|
||||
widget.NewToolbarSpacer(),
|
||||
widget.NewToolbarAction(theme.HelpIcon(), func() {
|
||||
showAbout()
|
||||
@ -126,7 +133,7 @@ func (ui *ToolWindowImpl) quiteHandle() {
|
||||
|
||||
func (ui *ToolWindowImpl) syncConfig() {
|
||||
cli := http.Client{Timeout: time.Second * 10}
|
||||
r, err := cli.Get("http://10.0.0.9:8081/prd/config.json")
|
||||
r, err := cli.Get("http://10.0.0.9:8080/prd/config.json")
|
||||
if err != nil {
|
||||
logrus.Error(err)
|
||||
dialog.ShowError(err, ui.w)
|
||||
|
Loading…
Reference in New Issue
Block a user