diff --git a/src/contexts/ctx/type.go b/src/contexts/ctx/type.go index 6ea6bbf5..8d0b91ba 100644 --- a/src/contexts/ctx/type.go +++ b/src/contexts/ctx/type.go @@ -666,7 +666,10 @@ func (m *Message) Cmd(args ...interface{}) *Message { msg := m if strings.Contains(key, ":") { ps := strings.Split(key, ":") - msg, key, arg = msg.Sess("ssh"), "_route", append([]string{"sync", ps[0], ps[1]}, arg...) + if ps[0] == "_" { + ps[0], arg = arg[0], arg[1:] + } + msg, key, arg = m.Sess("ssh"), "_route", append([]string{"sync", ps[0], ps[1]}, arg...) defer func() { m.Copy(msg, "append").Copy(msg, "result") }() m.Hand = true diff --git a/src/contexts/ssh/ssh.go b/src/contexts/ssh/ssh.go index be809c2f..dd23c728 100644 --- a/src/contexts/ssh/ssh.go +++ b/src/contexts/ssh/ssh.go @@ -334,7 +334,14 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心", } } + prefix := []string{} msg := m.Find(kit.Format(tool["ctx"])) + if strings.Contains(kit.Format(tool["ctx"]), ":") { + ps := strings.Split(kit.Format(tool["ctx"]), ":") + prefix = append(prefix, "_route", ps[0], "context", "find", ps[1]) + msg = m.Sess("ssh") + } + if option, ok := tool["options"].(map[string]interface{}); ok { for k, v := range option { msg.Option(k, v) @@ -345,6 +352,9 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心", msg.Option("storm", arg[1]) arg = arg[4:] + if len(prefix) > 0 && prefix[1] == "_" { + prefix[1], arg = arg[0], arg[1:] + } args := []string{} for _, v := range kit.Trans(tool["args"]) { if strings.HasPrefix(v, "__") { @@ -361,7 +371,7 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心", args = append(args, msg.Parse(v)) } } - msg.Cmd(tool["cmd"], args, arg) + msg.Cmd(prefix, tool["cmd"], args, arg) msg.CopyTo(m) default: @@ -555,7 +565,8 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心", m.Cmdy("ssh.data", "save", arg[1]) case "update": - index := kit.Int(arg[2]) - 1 - m.Confi("flow", []string{m.Option("river"), "data", arg[1], "meta", "offset"}) + offset := m.Confi("flow", []string{m.Option("river"), "data", arg[1], "meta", "offset"}) + index := kit.Int(arg[2]) - 1 - offset table, prefix, arg := arg[1], "", arg[3:] if index >= 0 { if arg[0] == "extra" { @@ -565,7 +576,7 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心", m.Confv("flow", []string{m.Option("river"), "data", table, "list", kit.Format(index), prefix + arg[i]}, arg[i+1]) } } - m.Cmdy("ssh.data", "show", table, index+1) + m.Cmdy("ssh.data", "show", table, index+1+offset) case "import": if len(arg) < 3 { diff --git a/src/examples/code/code.go b/src/examples/code/code.go index 1eff6ce5..9dd81410 100644 --- a/src/examples/code/code.go +++ b/src/examples/code/code.go @@ -228,7 +228,7 @@ var Index = &ctx.Context{Name: "code", Help: "代码中心", m.Set("append") case "file": // 文件列表 - m.Cmd("ssh._route", arg[1], "ssh.data", "show", arg[2]).Table(func(index int, value map[string]string) { + m.Cmd("ssh.data", "show", arg[1:]).Table(func(index int, value map[string]string) { m.Push("id", value["id"]) m.Push("kind", value["kind"]) m.Push("name", value["name"]) @@ -250,14 +250,10 @@ var Index = &ctx.Context{Name: "code", Help: "代码中心", case "list": if len(arg) > 2 && arg[2] == "modify" { - m.Cmdy("ssh._route", m.Option("dream"), "ssh.data", "update", m.Option("favor"), arg[1], arg[3], arg[4]) + m.Cmdy("ssh.data", "update", m.Option("favor"), arg[1], arg[3], arg[4]) arg = []string{"list", m.Option("dream"), m.Option("favor")} } - if len(arg) > 1 { - m.Cmdy("ssh._route", arg[1], "ssh.data", "show", arg[2:]) - break - } - m.Cmdy("ssh.data", "show") + m.Cmdy("ssh.data", "show", arg[1:]) } return }}, diff --git a/src/examples/team/team.go b/src/examples/team/team.go index e20fb181..858ba70a 100644 --- a/src/examples/team/team.go +++ b/src/examples/team/team.go @@ -17,7 +17,6 @@ var Index = &ctx.Context{Name: "team", Help: "团队中心", if len(arg) > 2 && arg[1] != "" { switch arg[2] { case "prepare", "action", "cancel", "finish": - prefix := []string{"ssh._route", m.Option("dream"), "ssh.data", "update"} time := "close_time" switch arg[2] { case "prepare", "action": @@ -29,7 +28,7 @@ var Index = &ctx.Context{Name: "team", Help: "团队中心", } // 更新任务 - m.Cmd(prefix, m.Option("table"), arg[1], "status", arg[2], time, m.Time()) + m.Cmd("ssh.data", "update", m.Option("table"), arg[1], "status", arg[2], time, m.Time()) arg = []string{arg[0], m.Option("table")} } } @@ -52,6 +51,7 @@ var Index = &ctx.Context{Name: "team", Help: "团队中心", m.Cmdy("ssh.data", "insert", arg[1], "level", arg[2], "class", arg[3], "status", arg[4], "begin_time", arg[5], "close_time", arg[6], "target", arg[7], "detail", arg[8], arg[9:]) + break } arg = []string{arg[1]} diff --git a/src/plugin/feature/index.shy b/src/plugin/feature/index.shy index 6030c16b..bfc691ac 100644 --- a/src/plugin/feature/index.shy +++ b/src/plugin/feature/index.shy @@ -14,7 +14,7 @@ fun date "每一天" "index.js" "index.css" protected \ end end -kit progress "任务进度" public "ssh._route" _ "web.team.task" progress \ +kit progress "任务进度" public "_:web.team.task" progress \ text "" name dream imports plugin_you \ text "task" name table \ text "30" name limit \ @@ -22,7 +22,7 @@ kit progress "任务进度" public "ssh._route" _ "web.team.task" progress \ feature detail action finish cancel prepare \ button "查看" action auto -kit create "创建任务" public "ssh._route" _ "web.team.task" create \ +kit create "创建任务" public "_:web.team.task" create \ text "" name dream imports plugin_you \ text "task" name table \ select "3" name level values 1 values 2 values 3 values 4 values 5 \ @@ -34,7 +34,7 @@ kit create "创建任务" public "ssh._route" _ "web.team.task" create \ textarea "" name detail half "4" \ button "添加" before br -kit select "查看任务" public "ssh._route" _ "web.team.task" \ +kit select "查看任务" public "_:web.team.task" \ text "" name dream imports plugin_you \ text "task" name table imports pluing_table \ text "" name index imports plugin_task_id action auto \ diff --git a/src/plugin/vim/index.shy b/src/plugin/vim/index.shy index 7f068b55..64d80f2a 100644 --- a/src/plugin/vim/index.shy +++ b/src/plugin/vim/index.shy @@ -1,4 +1,4 @@ -kit tips "便签" private "web.code.favor" list \ +kit tips "便签" private "_:web.code.favor" list \ text "" name dream imports plugin_you action auto \ text "tip" name favor imports plugin_vim_favor action auto \ text "" name index imports plugin_tip_id view tiny action auto \ diff --git a/src/plugin/zsh/index.shy b/src/plugin/zsh/index.shy index 01452cad..b17c587f 100644 --- a/src/plugin/zsh/index.shy +++ b/src/plugin/zsh/index.shy @@ -1,10 +1,10 @@ -kit file "文件" private "web.code.favor" file \ +kit file "文件" private "_:web.code.favor" file \ text "" name dream imports plugin_you action auto \ text "file" name type \ button "查看" action auto -kit taps "便签" private "web.code.favor" list \ +kit taps "便签" private "_:web.code.favor" list \ text "" name dream imports plugin_you action auto \ text "tap" name favor imports plugin_zsh_favor action auto \ text "" name index imports plugin_tap_id view tiny action auto \ diff --git a/usr/librarys/example.js b/usr/librarys/example.js index 5965ab86..0e8e3be1 100644 --- a/usr/librarys/example.js +++ b/usr/librarys/example.js @@ -1493,31 +1493,40 @@ function Output(plugin, type, msg, cb, target, option) { kit.Selector(option, ".args", function(item) { msg.Option(item.name, item.value) }) - item == "修改"? (text = kit.AppendChilds(td, [{type: "input", value: text, style: {width: td.clientWidth+"px"}, data: {onkeydown: function(event) { - if (event.key == "Enter") { - var id = "" - for (var i = 0; i < exports.length-1; i += 3) { - id = (id || line[exports[i+1]] || "").trim() - } + var cmd = [] + option.dream && cmd.push(option.dream.value) + if (item == "修改") { + text = kit.AppendChilds(td, [{type: "input", value: text, style: {width: td.clientWidth+"px"}, data: {onkeydown: function(event) { + if (event.key == "Enter") { + var id = "" + for (var i = 0; i < exports.length-1; i += 3) { + id = (id || line[exports[i+1]] || "").trim() + } - var msg = plugin.Event(event) - kit.Selector(option, ".args", function(item) { - msg.Option(item.name, item.value) - }) - if (name == "value") { - name = line.key - id = option.index.value + var msg = plugin.Event(event) + kit.Selector(option, ".args", function(item) { + msg.Option(item.name, item.value) + }) + if (name == "value") { + name = line.key + id = option.index.value + } + cmd.push(id, meta[item], name, event.target.value) + plugin.Run(event, cmd, function(msg) { + td.innerHTML = event.target.value + plugin.ontoast("修改成功") + }, true) + return } - plugin.Run(event, [id, meta[item], name, event.target.value], function(msg) { - td.innerHTML = event.target.value - plugin.ontoast("修改成功") - }, true) - return - } - }}}]).input, text.focus(), text.setSelectionRange(0, -1)): output[meta[item]]? output[meta[item]](event): plugin.Run(event, [td.dataset.id||(line[exports[1]]||"").trim(), meta[item]||item], function(msg) { - console.log(msg) - }) - + }}}]).input, text.focus(), text.setSelectionRange(0, -1) + } else if (output[meta[item]]) { + output[meta[item]](event) + } else { + cmd.push(td.dataset.id||(line[exports[1]]||"").trim(), meta[item]||item) + plugin.Run(event, cmd, function(msg) { + console.log(msg) + }) + } return true }), )