From f313b20ce104ac331379996b1efa1a62d8788aa1 Mon Sep 17 00:00:00 2001 From: shaoying Date: Mon, 9 Jul 2018 09:30:32 +0800 Subject: [PATCH] mac add web.travel.value --- src/contexts/ctx.go | 6 +++-- src/contexts/web/web.go | 6 ++++- usr/library/context.js | 2 +- usr/template/travel.html | 53 +++++++++++++++++++++++++++++----------- 4 files changed, 49 insertions(+), 18 deletions(-) diff --git a/src/contexts/ctx.go b/src/contexts/ctx.go index 1b17e54c..e1ab9241 100644 --- a/src/contexts/ctx.go +++ b/src/contexts/ctx.go @@ -2296,6 +2296,8 @@ var Index = &Context{Name: "ctx", Help: "模块中心", "detail_index": &Config{Name: "detail_index", Value: "0", Help: "参数的索引"}, "result_index": &Config{Name: "result_index", Value: "-2", Help: "返回值的索引"}, + + "list_help": &Config{Name: "list_help", Value: "list command", Help: "返回值的索引"}, }, Commands: map[string]*Command{ "help": &Command{Name: "help topic", Help: "帮助", Hand: func(m *Message, c *Context, key string, arg ...string) { @@ -2788,7 +2790,7 @@ var Index = &Context{Name: "ctx", Help: "模块中心", "command": &Command{ Name: "command [all|add cmd arg...|list [begin [end]]|test [begin [end]]|delete cmd]", Help: "查看或修改命令", - Form: map[string]int{"condition": -1}, + Form: map[string]int{"condition": -1, "list_help": 1}, Hand: func(m *Message, c *Context, key string, arg ...string) { if len(arg) == 0 { // {{{ keys := []string{} @@ -2832,7 +2834,7 @@ var Index = &Context{Name: "ctx", Help: "模块中心", } m.target.Commands[m.Cap("list_count")] = &Command{ Name: strings.Join(arg[1:], " "), - Help: "list_command", + Help: m.Confx("list_help"), Hand: func(m *Message, c *Context, key string, args ...string) { list := []string{} j := 0 diff --git a/src/contexts/web/web.go b/src/contexts/web/web.go index 809fb079..bce8b431 100644 --- a/src/contexts/web/web.go +++ b/src/contexts/web/web.go @@ -557,7 +557,11 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心", msg = msg.Spawn(msg.Target()) msg.Detail(0, m.Option("name")) if m.Options("value") { - msg.Add("detail", m.Option("value")) + value := []string{} + json.Unmarshal([]byte(m.Option("value")), &value) + if len(value) > 0 { + msg.Add("detail", value[0], value[1:]...) + } } msg.Cmd() diff --git a/usr/library/context.js b/usr/library/context.js index f80948b6..c1b1d8ad 100644 --- a/usr/library/context.js +++ b/usr/library/context.js @@ -140,7 +140,7 @@ ctx = { args.name = cmd } if (value != undefined) { - args.value = value + args.value = JSON.stringify(value) } this.POST("", args, cb); diff --git a/usr/template/travel.html b/usr/template/travel.html index a895f009..108f2e1c 100644 --- a/usr/template/travel.html +++ b/usr/template/travel.html @@ -108,19 +108,19 @@ {{if gt $l 0}} {{$first := index .append 0}} {{range $i, $k := index . $first}} -
{{$command := index $meta "key" $i}} - {{range $key := index $meta "append"}} -
- {{if eq $key "input"}} - - {{else if eq $key "key"}} - {{$command}} - {{else}} - {{index $meta $key $i}} - {{end}} +
+
+ + {{$command}}: + {{index $meta "name" $i}} + {{index $meta "help" $i}} +
- {{end}} +
+ + +
@@ -128,7 +128,7 @@ {{end}}
-
+