add gui support
添加 ui 支持
This commit is contained in:
@@ -19,6 +19,8 @@ var outDir string
|
||||
var singularTable bool
|
||||
var foreignKey bool
|
||||
var funcKey bool
|
||||
var ui bool
|
||||
var urlTag string
|
||||
|
||||
var rootCmd = &cobra.Command{
|
||||
Use: "main",
|
||||
@@ -64,6 +66,12 @@ func init() {
|
||||
rootCmd.PersistentFlags().BoolVarP(&funcKey, "fun", "F", false, "是否导出函数")
|
||||
rootCmd.MarkFlagRequired("func export")
|
||||
|
||||
rootCmd.PersistentFlags().BoolVarP(&ui, "gui", "g", false, "是否ui显示模式")
|
||||
rootCmd.MarkFlagRequired("show on gui")
|
||||
|
||||
rootCmd.PersistentFlags().StringVarP(&urlTag, "url", "l", "", "url标签(json,url)")
|
||||
rootCmd.MarkFlagRequired("url tag")
|
||||
|
||||
rootCmd.Flags().IntVar(&mysqlInfo.Port, "port", 3306, "端口号")
|
||||
}
|
||||
|
||||
@@ -100,6 +108,9 @@ func MergeMysqlDbInfo() {
|
||||
if len(mysqlInfo.Username) > 0 {
|
||||
tmp.Username = mysqlInfo.Username
|
||||
}
|
||||
if len(urlTag) > 0 {
|
||||
config.SetURLTag(urlTag)
|
||||
}
|
||||
|
||||
config.SetMysqlDbInfo(&tmp)
|
||||
|
||||
@@ -118,4 +129,9 @@ func MergeMysqlDbInfo() {
|
||||
if funcKey {
|
||||
config.SetIsOutFunc(funcKey)
|
||||
}
|
||||
|
||||
if ui {
|
||||
config.SetIsGUI(ui)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,18 +1,24 @@
|
||||
package config
|
||||
|
||||
import "fmt"
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// Config custom config struct
|
||||
type Config struct {
|
||||
CfgBase `yaml:"base"`
|
||||
MySQLInfo MysqlDbInfo `yaml:"mysql_info"`
|
||||
OutDir string `yaml:"out_dir"`
|
||||
URLTag string `yaml:"url_tag"` // url tag
|
||||
Language string `yaml:"language"` // language
|
||||
DbTag string `yaml:"db_tag"` // 数据库标签(gormt,db)
|
||||
Simple bool `yaml:"simple"`
|
||||
IsJSONTag bool `yaml:"is_json_tag"`
|
||||
SingularTable bool `yaml:"singular_table"`
|
||||
IsForeignKey bool `yaml:"is_foreign_key"`
|
||||
IsOutSQL bool `yaml:"is_out_sql"`
|
||||
IsOutFunc bool `yaml:"is_out_func"`
|
||||
IsGUI bool `yaml:"is_gui"` //
|
||||
}
|
||||
|
||||
// MysqlDbInfo mysql database information. mysql 数据库信息
|
||||
@@ -99,3 +105,55 @@ func GetIsOutFunc() bool {
|
||||
func SetIsOutFunc(b bool) {
|
||||
_map.IsOutFunc = b
|
||||
}
|
||||
|
||||
// GetIsGUI if is gui show .
|
||||
func GetIsGUI() bool {
|
||||
return _map.IsGUI
|
||||
}
|
||||
|
||||
// SetIsGUI if is gui show .
|
||||
func SetIsGUI(b bool) {
|
||||
_map.IsGUI = b
|
||||
}
|
||||
|
||||
// GetURLTag get url tag.
|
||||
func GetURLTag() string {
|
||||
if _map.URLTag != "json" && _map.URLTag != "url" {
|
||||
_map.URLTag = "json"
|
||||
}
|
||||
|
||||
return _map.URLTag
|
||||
}
|
||||
|
||||
// SetURLTag set url tag.
|
||||
func SetURLTag(s string) {
|
||||
_map.URLTag = s
|
||||
}
|
||||
|
||||
// GetLG get language tag.
|
||||
func GetLG() string {
|
||||
if _map.Language != "English" && _map.Language != "中 文" {
|
||||
_map.Language = "English"
|
||||
}
|
||||
|
||||
return _map.Language
|
||||
}
|
||||
|
||||
// SetLG set url tag.
|
||||
func SetLG(s string) {
|
||||
_map.Language = s
|
||||
}
|
||||
|
||||
// GetDBTag get database tag.
|
||||
func GetDBTag() string {
|
||||
if _map.DbTag != "gorm" && _map.DbTag != "db" {
|
||||
_map.DbTag = "gorm"
|
||||
}
|
||||
|
||||
return _map.DbTag
|
||||
}
|
||||
|
||||
// SetDBTag get database tag.
|
||||
func SetDBTag(s string) {
|
||||
_map.DbTag = s
|
||||
}
|
||||
|
||||
@@ -55,3 +55,13 @@ func GetServiceConfig() (name, displayName, desc string) {
|
||||
desc = _map.SerciceDesc
|
||||
return
|
||||
}
|
||||
|
||||
// GetIsDev is is dev
|
||||
func GetIsDev() bool {
|
||||
return _map.IsDev
|
||||
}
|
||||
|
||||
// SetIsDev is is dev
|
||||
func SetIsDev(b bool) {
|
||||
_map.IsDev = b
|
||||
}
|
||||
|
||||
7
data/dlg/cmd_darwin.go
Normal file
7
data/dlg/cmd_darwin.go
Normal file
@@ -0,0 +1,7 @@
|
||||
package dlg
|
||||
|
||||
import "os/exec"
|
||||
|
||||
func openURL(url string) {
|
||||
exec.Command(`open`, url).Start()
|
||||
}
|
||||
7
data/dlg/cmd_linux.go
Normal file
7
data/dlg/cmd_linux.go
Normal file
@@ -0,0 +1,7 @@
|
||||
package dlg
|
||||
|
||||
import "os/exec"
|
||||
|
||||
func openURL(url string) {
|
||||
exec.Command(`xdg-open`, url).Start()
|
||||
}
|
||||
7
data/dlg/cmd_windows.go
Normal file
7
data/dlg/cmd_windows.go
Normal file
@@ -0,0 +1,7 @@
|
||||
package dlg
|
||||
|
||||
import "os/exec"
|
||||
|
||||
func openURL(url string) {
|
||||
exec.Command(`cmd`, `/c`, `start`, url).Start() // 有GUI调用
|
||||
}
|
||||
54
data/dlg/common.go
Normal file
54
data/dlg/common.go
Normal file
@@ -0,0 +1,54 @@
|
||||
package dlg
|
||||
|
||||
import "github.com/jroimartin/gocui"
|
||||
|
||||
func division(a int, b float32) int {
|
||||
r := float32(a) / b
|
||||
return (int)(r)
|
||||
}
|
||||
|
||||
func (dlg *menuDetails) nextButton(g *gocui.Gui, v *gocui.View) error {
|
||||
dlg.btnList[dlg.active].UnFocus()
|
||||
dlg.active = (dlg.active + 1) % len(dlg.btnList)
|
||||
menuFocusButton(g)
|
||||
return nil
|
||||
}
|
||||
func menuFocusButton(g *gocui.Gui) {
|
||||
setlog(g, SLocalize(btnLogArr[menuDlg.active]))
|
||||
menuDlg.btnList[menuDlg.active].Focus()
|
||||
}
|
||||
|
||||
func (dlg *menuDetails) prevButton(g *gocui.Gui, v *gocui.View) error {
|
||||
dlg.btnList[dlg.active].UnFocus()
|
||||
if dlg.active == 0 {
|
||||
dlg.active = len(dlg.btnList)
|
||||
}
|
||||
dlg.active--
|
||||
menuFocusButton(g)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (dlg *menuDetails) Draw() {
|
||||
for _, b := range dlg.btnList {
|
||||
b.Draw()
|
||||
}
|
||||
}
|
||||
|
||||
// OnDestroy destroy windows
|
||||
func OnDestroy(g *gocui.Gui, v *gocui.View) error {
|
||||
return gocui.ErrQuit
|
||||
}
|
||||
|
||||
func setCurrentViewOnTop(g *gocui.Gui, name string) (*gocui.View, error) {
|
||||
if _, err := g.SetCurrentView(name); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return g.SetViewOnTop(name)
|
||||
}
|
||||
|
||||
func requireValidator(value string) bool {
|
||||
if value == "" {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
234
data/dlg/cui.go
Normal file
234
data/dlg/cui.go
Normal file
@@ -0,0 +1,234 @@
|
||||
package dlg
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
"github.com/xxjwxc/public/tools"
|
||||
|
||||
"github.com/xxjwxc/gormt/data/config"
|
||||
|
||||
"github.com/jroimartin/gocui"
|
||||
"github.com/xxjwxc/public/mycui"
|
||||
)
|
||||
|
||||
func nextView(g *gocui.Gui, v *gocui.View) error {
|
||||
nextIndex := (mainIndex + 1) % len(mainViewArr)
|
||||
name := mainViewArr[nextIndex]
|
||||
|
||||
err := setlog(g, "Going from view "+v.Name()+" to "+name)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if _, err := g.SetCurrentView(name); err != nil { // 设置选中
|
||||
return err
|
||||
}
|
||||
g.SelFgColor = gocui.ColorGreen // 设置边框颜色
|
||||
g.FgColor = gocui.ColorWhite
|
||||
|
||||
switch name {
|
||||
case _menuDefine:
|
||||
g.Cursor = false // 光标
|
||||
// g.FgColor = gocui.ColorGreen
|
||||
menuDlg.btnList[menuDlg.active].Focus()
|
||||
case _listDefine:
|
||||
g.Cursor = false
|
||||
menuDlg.btnList[menuDlg.active].UnFocus()
|
||||
case _viewDefine:
|
||||
g.Cursor = true
|
||||
menuDlg.btnList[menuDlg.active].UnFocus()
|
||||
}
|
||||
|
||||
mainIndex = nextIndex
|
||||
return nil
|
||||
}
|
||||
|
||||
func mainLayout(g *gocui.Gui) error {
|
||||
maxX, maxY := g.Size()
|
||||
if v, err := g.SetView("main_title", maxX/2-16, -1, maxX/2+16, 1); err != nil {
|
||||
if err != gocui.ErrUnknownView {
|
||||
return err
|
||||
}
|
||||
v.Highlight = true
|
||||
v.SelFgColor = gocui.ColorGreen | gocui.AttrUnderline
|
||||
fmt.Fprintln(v, "https://github.com/xxjwxc/gormt")
|
||||
}
|
||||
|
||||
if v, err := g.SetView(_menuDefine, 0, 1, division(maxX, uiPart[0])-1, division(maxY, uiPart[1])-1); err != nil {
|
||||
if err != gocui.ErrUnknownView {
|
||||
return err
|
||||
}
|
||||
v.Title = SLocalize(_menuDefine)
|
||||
// v.Editable = true // 是否可以编辑
|
||||
v.Wrap = true
|
||||
v.Autoscroll = true
|
||||
// g.FgColor = gocui.ColorGreen
|
||||
}
|
||||
|
||||
if v, err := g.SetView(_listDefine, 0, division(maxY, uiPart[1]), division(maxX, uiPart[0])-1, maxY-1); err != nil {
|
||||
if err != gocui.ErrUnknownView {
|
||||
return err
|
||||
}
|
||||
v.Title = SLocalize(_listDefine)
|
||||
v.Wrap = true
|
||||
v.Autoscroll = true
|
||||
if _, err := g.SetCurrentView(_menuDefine); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if v, err := g.SetView(_viewDefine, division(maxX, uiPart[0]), 1, maxX-1, maxY-1); err != nil {
|
||||
if err != gocui.ErrUnknownView {
|
||||
return err
|
||||
}
|
||||
v.Title = SLocalize(_viewDefine)
|
||||
v.Wrap = true
|
||||
v.Autoscroll = true
|
||||
v.Editable = true
|
||||
}
|
||||
|
||||
nemuLayOut(g) // menuLayOut
|
||||
return nil
|
||||
}
|
||||
|
||||
func nemuLayOut(g *gocui.Gui) {
|
||||
menuDlg = &menuDetails{}
|
||||
menuDlg.btnList = append(menuDlg.btnList,
|
||||
mycui.NewButton(g, _run, SLocalize(_run), 0, 2, 3).SetTextColor(gocui.ColorRed|gocui.AttrReverse, gocui.ColorWhite).
|
||||
AddHandler(gocui.KeyArrowUp, menuDlg.prevButton).AddHandler(gocui.KeyArrowDown, menuDlg.nextButton).
|
||||
AddHandler(gocui.KeyEnter, enterRun).AddHandler(gocui.MouseLeft, enterRun))
|
||||
|
||||
menuDlg.btnList = append(menuDlg.btnList,
|
||||
mycui.NewButton(g, _set, SLocalize(_set), 0, 4, 3).
|
||||
AddHandler(gocui.KeyArrowUp, menuDlg.prevButton).AddHandler(gocui.KeyArrowDown, menuDlg.nextButton).
|
||||
AddHandler(gocui.KeyEnter, enterSet).AddHandler(gocui.MouseLeft, enterSet))
|
||||
|
||||
menuDlg.Draw()
|
||||
menuFocusButton(g)
|
||||
}
|
||||
|
||||
func keybindings(g *gocui.Gui) {
|
||||
if err := g.SetKeybinding("", gocui.KeyCtrlC, gocui.ModNone, OnDestroy); err != nil { // 退出事件
|
||||
log.Panicln(err)
|
||||
}
|
||||
if err := g.SetKeybinding("", gocui.KeyTab, gocui.ModNone, nextView); err != nil { // tab next事件
|
||||
log.Panicln(err)
|
||||
}
|
||||
if err := g.SetKeybinding("main_title", gocui.MouseLeft, gocui.ModNone, about); err != nil {
|
||||
log.Panicln(err)
|
||||
}
|
||||
// if err := g.SetKeybinding(_run, gocui.MouseLeft, gocui.ModNone, about); err != nil {
|
||||
// log.Panicln(err)
|
||||
// }
|
||||
// if err := g.SetKeybinding(_set, gocui.MouseLeft, gocui.ModNone, about); err != nil {
|
||||
// log.Panicln(err)
|
||||
// }
|
||||
}
|
||||
|
||||
///////////////////signal slot ///////////
|
||||
func about(g *gocui.Gui, v *gocui.View) error {
|
||||
openURL("https://github.com/xxjwxc/gormt")
|
||||
return nil
|
||||
}
|
||||
|
||||
func setlog(g *gocui.Gui, str string) error {
|
||||
logView, err := g.View(_viewDefine)
|
||||
if err == nil {
|
||||
logView.Clear()
|
||||
fmt.Fprintln(logView, str)
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
func enterRun(g *gocui.Gui, v *gocui.View) error {
|
||||
setlog(g, "run .... ing")
|
||||
return nil
|
||||
}
|
||||
|
||||
func enterSet(g *gocui.Gui, v *gocui.View) error {
|
||||
maxX, _ := g.Size()
|
||||
setlog(g, "")
|
||||
// new form
|
||||
form = mycui.NewForm(g, "set_ui", "Sign Up", division(maxX, uiPart[0])+3, 3, 0, 0)
|
||||
|
||||
// add input field
|
||||
form.AddInputField("out_dir", SLocalize("out_dir"), formPart[0], formPart[1]).SetText(config.GetOutDir()).
|
||||
AddValidate("required input", requireValidator)
|
||||
form.AddInputField("db_host", SLocalize("db_host"), formPart[0], formPart[1]).SetText(config.GetMysqlDbInfo().Host).
|
||||
AddValidate("required input", requireValidator)
|
||||
form.AddInputField("db_port", SLocalize("db_port"), formPart[0], formPart[1]).SetText(tools.AsString(config.GetMysqlDbInfo().Port)).
|
||||
AddValidate("required input", requireValidator)
|
||||
form.AddInputField("db_usename", SLocalize("db_usename"), formPart[0], formPart[1]).SetText(config.GetMysqlDbInfo().Username).
|
||||
AddValidate("required input", requireValidator)
|
||||
form.AddInputField("db_pwd", SLocalize("db_pwd"), formPart[0], formPart[1]).SetText(config.GetMysqlDbInfo().Password).
|
||||
SetMask().SetMaskKeybinding(gocui.KeyCtrlA).
|
||||
AddValidate("required input", requireValidator)
|
||||
form.AddInputField("db_name", SLocalize("db_name"), formPart[0], formPart[1]).SetText(config.GetMysqlDbInfo().Database).
|
||||
AddValidate("required input", requireValidator)
|
||||
|
||||
// add select
|
||||
form.AddSelect("is_dev", SLocalize("is_dev"), formPart[0], formPart[2]).
|
||||
AddOptions(SLocalize("true"), SLocalize("false")).SetSelected(SLocalize(tools.AsString(config.GetIsDev())))
|
||||
form.AddSelect("is_simple", SLocalize("is_simple"), formPart[0], formPart[2]).
|
||||
AddOptions(SLocalize("true"), SLocalize("false")).SetSelected(SLocalize(tools.AsString(config.GetSimple())))
|
||||
form.AddSelect("is_singular", SLocalize("is_singular"), formPart[0], formPart[2]).
|
||||
AddOptions(SLocalize("true"), SLocalize("false")).SetSelected(SLocalize(tools.AsString(config.GetSingularTable())))
|
||||
form.AddSelect("is_out_sql", SLocalize("is_out_sql"), formPart[0], formPart[2]).
|
||||
AddOptions(SLocalize("true"), SLocalize("false")).SetSelected(SLocalize(tools.AsString(config.GetIsOutSQL())))
|
||||
form.AddSelect("is_out_func", SLocalize("is_out_func"), formPart[0], formPart[2]).
|
||||
AddOptions(SLocalize("true"), SLocalize("false")).SetSelected(SLocalize(tools.AsString(config.GetIsOutFunc())))
|
||||
form.AddSelect("is_foreign_key", SLocalize("is_foreign_key"), formPart[0], formPart[2]).
|
||||
AddOptions(SLocalize("true"), SLocalize("false")).SetSelected(SLocalize(tools.AsString(config.GetIsForeignKey())))
|
||||
form.AddSelect("url_tag", SLocalize("url_tag"), formPart[0], formPart[2]).
|
||||
AddOptions("json", "url").SetSelected(tools.AsString(config.GetURLTag()))
|
||||
form.AddSelect("db_tag", SLocalize("db_tag"), formPart[0], formPart[2]).
|
||||
AddOptions("gorm", "db").SetSelected(config.GetDBTag())
|
||||
form.AddSelect("language", SLocalize("language"), formPart[0], formPart[2]).
|
||||
AddOptions("English", "中 文").SetSelected(config.GetLG())
|
||||
|
||||
// add button
|
||||
form.AddButton("save", SLocalize("save"), buttonSave).AddHandler(gocui.MouseLeft, buttonSave)
|
||||
form.AddButton("cancel", SLocalize("cancel"), buttonCancel).AddHandler(gocui.MouseLeft, buttonCancel)
|
||||
|
||||
form.Draw()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func buttonCancel(g *gocui.Gui, v *gocui.View) error {
|
||||
menuFocusButton(g)
|
||||
if form != nil {
|
||||
return form.Close(g, nil)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func buttonSave(g *gocui.Gui, v *gocui.View) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
///////////////////////////////////////////
|
||||
|
||||
// OnInitDialog init main loop
|
||||
func OnInitDialog() {
|
||||
g, err := gocui.NewGui(gocui.OutputNormal)
|
||||
|
||||
if err != nil {
|
||||
log.Panicln(err)
|
||||
}
|
||||
defer g.Close()
|
||||
|
||||
g.Cursor = false // 光标
|
||||
g.Mouse = true
|
||||
g.Highlight = true
|
||||
g.SelFgColor = gocui.ColorGreen // 设置边框颜色
|
||||
|
||||
mainLayout(g)
|
||||
//g.SetManagerFunc(mainLayout) // 主布局
|
||||
keybindings(g)
|
||||
|
||||
if err := g.MainLoop(); err != nil && err != gocui.ErrQuit { // 主循环
|
||||
log.Panicln(err)
|
||||
}
|
||||
}
|
||||
31
data/dlg/def.go
Normal file
31
data/dlg/def.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package dlg
|
||||
|
||||
import (
|
||||
"github.com/xxjwxc/public/mycui"
|
||||
)
|
||||
|
||||
const (
|
||||
_menuDefine = "menu"
|
||||
_listDefine = "list"
|
||||
_viewDefine = "view"
|
||||
_run = "run"
|
||||
_set = "set"
|
||||
)
|
||||
|
||||
var (
|
||||
uiPart = []float32{4, 3} // x,y 对应列表
|
||||
mainViewArr = []string{_menuDefine, _listDefine, _viewDefine} // 主菜单列表
|
||||
mainIndex = 0
|
||||
|
||||
btnLogArr = []string{"log_run", "log_set"} // 主菜单列表
|
||||
formPart = []int{14, 28, 10}
|
||||
)
|
||||
|
||||
// menu 内容
|
||||
type menuDetails struct {
|
||||
active int
|
||||
btnList []*mycui.Button
|
||||
}
|
||||
|
||||
var menuDlg *menuDetails
|
||||
var form *mycui.Form
|
||||
186
data/dlg/i18n.go
Normal file
186
data/dlg/i18n.go
Normal file
@@ -0,0 +1,186 @@
|
||||
package dlg
|
||||
|
||||
import (
|
||||
"github.com/nicksnyder/go-i18n/v2/i18n"
|
||||
"github.com/xxjwxc/public/myi18n"
|
||||
"golang.org/x/text/language"
|
||||
)
|
||||
|
||||
/*
|
||||
Internationalization 国际化
|
||||
*/
|
||||
|
||||
func init() {
|
||||
addChinese()
|
||||
addEnglish()
|
||||
myi18n.SetLocalLG("zh") // default
|
||||
}
|
||||
|
||||
// SLocalize 获取值
|
||||
func SLocalize(ID string) string {
|
||||
return myi18n.Get(ID)
|
||||
}
|
||||
|
||||
func addChinese() error {
|
||||
return myi18n.AddMessages(language.Chinese, &i18n.Message{
|
||||
ID: "menu",
|
||||
Other: "菜单",
|
||||
}, &i18n.Message{
|
||||
ID: "list",
|
||||
Other: "列表",
|
||||
}, &i18n.Message{
|
||||
ID: "view",
|
||||
Other: "视图",
|
||||
}, &i18n.Message{
|
||||
ID: "run",
|
||||
Other: "执 行 ⏯ ",
|
||||
}, &i18n.Message{
|
||||
ID: "set",
|
||||
Other: "设 置 🛠 ",
|
||||
}, &i18n.Message{
|
||||
ID: "out_dir",
|
||||
Other: " 输 出 目 录 :",
|
||||
}, &i18n.Message{
|
||||
ID: "db_host",
|
||||
Other: " 数 据 库 地 址 :",
|
||||
}, &i18n.Message{
|
||||
ID: "db_port",
|
||||
Other: " 数 据 库 端 口 :",
|
||||
}, &i18n.Message{
|
||||
ID: "db_usename",
|
||||
Other: " 数 据 库 用 户 名 :",
|
||||
}, &i18n.Message{
|
||||
ID: "db_pwd",
|
||||
Other: " 数 据 库 密 码:",
|
||||
}, &i18n.Message{
|
||||
ID: "db_name",
|
||||
Other: " 数 据 库 名 字 :",
|
||||
}, &i18n.Message{
|
||||
ID: "is_dev",
|
||||
Other: " 开 发 模 式:",
|
||||
}, &i18n.Message{
|
||||
ID: "is_singular",
|
||||
Other: " 单 表 模 式 :",
|
||||
}, &i18n.Message{
|
||||
ID: "is_simple",
|
||||
Other: " 简 单 输 出 :",
|
||||
}, &i18n.Message{
|
||||
ID: "is_out_sql",
|
||||
Other: " 输 出 sql 原 :",
|
||||
}, &i18n.Message{
|
||||
ID: "is_out_func",
|
||||
Other: " 输 出 快 捷 函 数 :",
|
||||
}, &i18n.Message{
|
||||
ID: "is_foreign_key",
|
||||
Other: " 导 出 外 键 :",
|
||||
}, &i18n.Message{
|
||||
ID: "url_tag",
|
||||
Other: " web 标 签:",
|
||||
}, &i18n.Message{
|
||||
ID: "db_tag",
|
||||
Other: " 数 据 库 标 签 :",
|
||||
}, &i18n.Message{
|
||||
ID: "language",
|
||||
Other: " 语 言 :",
|
||||
}, &i18n.Message{
|
||||
ID: "true",
|
||||
Other: " 是",
|
||||
}, &i18n.Message{
|
||||
ID: "false",
|
||||
Other: " 否",
|
||||
}, &i18n.Message{
|
||||
ID: "save",
|
||||
Other: " 保 存 ",
|
||||
}, &i18n.Message{
|
||||
ID: "cancel",
|
||||
Other: " 取 消 ",
|
||||
}, &i18n.Message{
|
||||
ID: "log_run",
|
||||
Other: " Enter : 执 行 \n ↑ ↓: 本 视 图 选 择 \n Tab : 多 视 图 切 换 \n 支 持 鼠 标 操 作 方 式 \n \n \033[33;7m 输 入 Enter 直 接 执 行 \033[0m\n ",
|
||||
}, &i18n.Message{
|
||||
ID: "log_set",
|
||||
Other: " Enter : 执 行 \n ↑ ↓: 本 视 图 选 择 \n Tab : 多 视 图 切 换 \n 支 持 鼠 标 操 作 方 式 \n \n \033[33;7m 输 入 Enter 打 开 设 置 窗 口 \033[0m\n ",
|
||||
})
|
||||
}
|
||||
|
||||
func addEnglish() error {
|
||||
return myi18n.AddMessages(language.English, &i18n.Message{
|
||||
ID: "menu",
|
||||
Other: "Menu",
|
||||
}, &i18n.Message{
|
||||
ID: "list",
|
||||
Other: "List",
|
||||
}, &i18n.Message{
|
||||
ID: "view",
|
||||
Other: "View",
|
||||
}, &i18n.Message{
|
||||
ID: "run",
|
||||
Other: "Run ⏯ ",
|
||||
}, &i18n.Message{
|
||||
ID: "set",
|
||||
Other: "Set 🛠 ",
|
||||
}, &i18n.Message{
|
||||
ID: "out_dir",
|
||||
Other: "out dir:",
|
||||
}, &i18n.Message{
|
||||
ID: "db_host",
|
||||
Other: "db host:",
|
||||
}, &i18n.Message{
|
||||
ID: "db_port",
|
||||
Other: "db port:",
|
||||
}, &i18n.Message{
|
||||
ID: "db_usename",
|
||||
Other: "db username:",
|
||||
}, &i18n.Message{
|
||||
ID: "db_pwd",
|
||||
Other: "db password:",
|
||||
}, &i18n.Message{
|
||||
ID: "db_name",
|
||||
Other: "db name:",
|
||||
}, &i18n.Message{
|
||||
ID: "is_dev",
|
||||
Other: "is dev:",
|
||||
}, &i18n.Message{
|
||||
ID: "is_simple",
|
||||
Other: "is simple :",
|
||||
}, &i18n.Message{
|
||||
ID: "is_singular",
|
||||
Other: "is singular :",
|
||||
}, &i18n.Message{
|
||||
ID: "is_out_sql",
|
||||
Other: "is out sql :",
|
||||
}, &i18n.Message{
|
||||
ID: "is_out_func",
|
||||
Other: "is out func :",
|
||||
}, &i18n.Message{
|
||||
ID: "is_foreign_key",
|
||||
Other: "is foreign key:",
|
||||
}, &i18n.Message{
|
||||
ID: "url_tag",
|
||||
Other: "url tag:",
|
||||
}, &i18n.Message{
|
||||
ID: "db_tag",
|
||||
Other: "db tag:",
|
||||
}, &i18n.Message{
|
||||
ID: "language",
|
||||
Other: "Language:",
|
||||
}, &i18n.Message{
|
||||
ID: "true",
|
||||
Other: "true",
|
||||
}, &i18n.Message{
|
||||
ID: "false",
|
||||
Other: "false",
|
||||
}, &i18n.Message{
|
||||
ID: "save",
|
||||
Other: "Save",
|
||||
}, &i18n.Message{
|
||||
ID: "cancel",
|
||||
Other: "Cancel",
|
||||
}, &i18n.Message{
|
||||
ID: "log_run",
|
||||
Other: " Enter : run \n ↑ ↓: Selection of this view \n Tab : Multi view switching \n Mouse operation supported \n \n \033[33;7m Enter to execute \033[0m",
|
||||
}, &i18n.Message{
|
||||
ID: "log_set",
|
||||
Other: " Enter : run \n ↑ ↓: Selection of this view \n Tab : Multi view switching \n Mouse operation supported \n \n \033[33;7m Enter enter to open the settings window \033[0m",
|
||||
})
|
||||
}
|
||||
6
data/dlg/mycui.go
Normal file
6
data/dlg/mycui.go
Normal file
@@ -0,0 +1,6 @@
|
||||
package dlg
|
||||
|
||||
// WinMain windows main loop
|
||||
func WinMain() {
|
||||
OnInitDialog()
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"fmt"
|
||||
"os/exec"
|
||||
|
||||
"github.com/xxjwxc/gormt/data/dlg"
|
||||
"github.com/xxjwxc/gormt/data/view/model"
|
||||
|
||||
"github.com/xxjwxc/gormt/data/config"
|
||||
@@ -13,7 +14,15 @@ import (
|
||||
|
||||
// Execute exe the cmd
|
||||
func Execute() {
|
||||
if config.GetIsGUI() {
|
||||
dlg.WinMain()
|
||||
} else {
|
||||
showCmd()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func showCmd() {
|
||||
// var tt oauth_db.UserInfoTbl
|
||||
// tt.Nickname = "ticket_001"
|
||||
// orm.Where("nickname = ?", "ticket_001").Find(&tt)
|
||||
|
||||
Reference in New Issue
Block a user