From 04be739f227947938c8ab089107bbf076ff88ae3 Mon Sep 17 00:00:00 2001 From: shaoying Date: Thu, 22 Aug 2019 21:06:56 +0800 Subject: [PATCH] opt some --- src/contexts/cli/cli.go | 23 +++++++++++++++++++---- src/contexts/cli/version.go | 2 +- src/contexts/ssh/ssh.go | 3 +++ src/plugin/context/index.shy | 19 +++++++++++++++---- src/plugin/favor/index.shy | 11 ++++++++++- usr/librarys/example.js | 12 ++++++------ 6 files changed, 54 insertions(+), 16 deletions(-) diff --git a/src/contexts/cli/cli.go b/src/contexts/cli/cli.go index 40778c2f..31a1db1c 100644 --- a/src/contexts/cli/cli.go +++ b/src/contexts/cli/cli.go @@ -343,9 +343,9 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心", // 执行命令 m.Gos(m, func(m *ctx.Message) { if e := cmd.Start(); e != nil { - m.Echo("error: ").Echo("%s\n", e) + m.Log("warn", "%v", e).Echo("error: ").Echo("%s\n", e) } else if e := cmd.Wait(); e != nil { - m.Echo("error: ").Echo("%s\n", e) + m.Log("warn", "%v", e).Echo("error: ").Echo("%s\n", e) } m.Conf("daemon", []string{h, "finish_time"}, time.Now().Format(m.Conf("time", "format"))) }) @@ -434,6 +434,13 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心", m.Table() default: + var data interface{} + if json.Unmarshal(out.Bytes(), &data) == nil { + if b, e := json.MarshalIndent(data, "", " "); e == nil { + m.Echo(string(b)) + break + } + } m.Echo(out.String()) } }) @@ -831,6 +838,9 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心", m.Table() } + case "restart": + m.Cmdy("cli.quit", "1") + case "plugin": arg = arg[1:] if len(arg) == 0 { @@ -1027,6 +1037,11 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心", return }}, "missyou": &ctx.Command{Name: "missyou [name [stop]]", Help: "任务管理", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) { + topic := "hello" + if len(arg) > 0 && (arg[0] == "" || m.Cmds("nfs.path", path.Join(m.Conf("cli.project", "plugin.path"), arg[0]))) { + topic, arg = arg[0], arg[1:] + } + if len(arg) == 0 { m.Option("dir_root", "") m.Cmd("nfs.dir", m.Conf("missyou", "path"), "time", "name").Table(func(value map[string]string) { @@ -1067,13 +1082,13 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心", args := []string{ "daemon", "cmd_dir", p, "cmd_env", "PATH", os.Getenv("PATH"), - "cmd_env", "ctx_type", kit.Select("hello", arg, 1), + "cmd_env", "ctx_type", kit.Select(topic, arg, 1), "cmd_env", "ctx_home", m.Conf("runtime", "boot.ctx_home"), "cmd_env", "ctx_ups", fmt.Sprintf("127.0.0.1%s", m.Conf("runtime", "boot.ssh_port")), "cmd_env", "ctx_box", fmt.Sprintf("http://127.0.0.1%s", m.Conf("runtime", "boot.web_port")), "cmd_daemon", "true", } - if m.Conf("runtime", "host.GOOS") == "windows" { + if m.Assert(os.MkdirAll(p, 0666)); m.Conf("runtime", "host.GOOS") == "windows" { m.Cmdy("cli.system", path.Join(m.Conf("runtime", "boot.ctx_home"), "bin/node.sh"), "start", args) } else { m.Cmdy("cli.system", m.Conf("runtime", "boot.ctx_bin"), args) diff --git a/src/contexts/cli/version.go b/src/contexts/cli/version.go index c0a71a5a..3ce864f5 100644 --- a/src/contexts/cli/version.go +++ b/src/contexts/cli/version.go @@ -4,5 +4,5 @@ var version = struct { host string self int }{ - "2019-08-22 09:22:24", "mac", 412, + "2019-08-22 17:02:38", "ZYB-20190522USI", 415, } diff --git a/src/contexts/ssh/ssh.go b/src/contexts/ssh/ssh.go index 9c35097e..206b0374 100644 --- a/src/contexts/ssh/ssh.go +++ b/src/contexts/ssh/ssh.go @@ -959,6 +959,9 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心", m.Log("time", "exec: %v", m.Format("cost")) return }}, + "relay": &ctx.Command{Name: "relay address", Help: "网络连接", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) { + return + }}, }, } diff --git a/src/plugin/context/index.shy b/src/plugin/context/index.shy index 59f50796..8c97c110 100644 --- a/src/plugin/context/index.shy +++ b/src/plugin/context/index.shy @@ -1,7 +1,7 @@ fun project "项目" "" "" \ private \ - select "" values plugin values submit values review values trend values stat values init \ + select "" values plugin values submit values review values trend values stat values init action auto \ text "" imports plugin_see action auto \ button "执行" \ exports see name see @@ -11,7 +11,7 @@ end fun compile "编译" "" "" \ private \ - select "" values plugin values windows values darwin values linux values self values all \ + select "" values plugin values restart values windows values darwin values linux values self values all \ text "" name see imports plugin_see \ button "编译" @@ -38,6 +38,7 @@ end fun missyou "任务" "" "" \ private \ + text "" imports plugin_see \ text "" view long \ button "行动" action auto \ exports you "" you @@ -66,7 +67,7 @@ end fun cmd "命令" "" "" \ private \ - text "" name pod imports plugin_pod view long \ + text "" name pod imports plugin_pod \ text "nfs" name ctx imports plugin_ctx \ text "pwd" \ button "执行" @@ -76,7 +77,7 @@ end fun dir "目录" "" "" \ private \ - text "" name pod imports plugin_pod action auto view long \ + text "" name pod imports plugin_pod action auto \ text "usr/script" name dir imports plugin_dir action auto view long \ button "查看" action auto \ button "回退" click Back \ @@ -85,3 +86,13 @@ fun dir "目录" "" "" \ copy ssh._route _ nfs.dir _ time size line path end +fun git "版本" "" "" \ + private \ + text "" name pod imports plugin_pod action auto \ + select "" values diff values status commit values values log values init action auto \ + text "" name txt action auto \ + button "查看" action auto + + copy ssh._route _ nfs.git __ +end + diff --git a/src/plugin/favor/index.shy b/src/plugin/favor/index.shy index c3b116e4..d80daf7a 100644 --- a/src/plugin/favor/index.shy +++ b/src/plugin/favor/index.shy @@ -62,9 +62,18 @@ fun macro "脚本宏" "" "macro.js" \ end +fun sys "命令行" "" "" \ + public \ + textarea "" view long \ + button "运行" \ + exports mac name + + copy nfs.source system __ +end + fun hello world "" "" \ public \ - text "" \ + textarea "" \ button "执行" copy pwd diff --git a/usr/librarys/example.js b/usr/librarys/example.js index 1675e516..7f322923 100644 --- a/usr/librarys/example.js +++ b/usr/librarys/example.js @@ -191,14 +191,14 @@ function Page(page) { page.oncontrol && page.oncontrol(event, document.body, "control") if (kit.isWindows && event.ctrlKey) { - event.stopPropagation() - event.preventDefault() + // event.stopPropagation() + // event.preventDefault() } }, document.body.onkeyup = function(event) { if (kit.isWindows && event.ctrlKey) { - event.stopPropagation() - event.preventDefault() + // event.stopPropagation() + // event.preventDefault() } }, document.body.oncontextmenu = function(event) { @@ -473,7 +473,7 @@ function Page(page) { }, Show: function() { output.innerHTML = "", kit.AppendChild(output, [ - {"view": ["title", "div", "shycontext"], click: function(event) { + {"view": ["title", "div", "github.com/shylinux/context"], click: function(event) { cb(event, "title", "shycontext") }}, {"view": ["state"], list: list.map(function(item) {return {text: [state[item], "div"], click: function(event) { @@ -717,7 +717,7 @@ function Plugin(page, pane, field, run) { }) break case "textarea": - input.type = "textarea", item.style = "height:300px;"+"width:"+(option.clientWidth-20)+"px" + input.type = "textarea", item.style = "height:100px;"+"width:"+(pane.target.clientWidth-30)+"px" item.className = "args" case "text": item.className = "args"