diff --git a/etc/common.shy b/etc/common.shy index 5eead9ad..75dd726a 100644 --- a/etc/common.shy +++ b/etc/common.shy @@ -1,4 +1,5 @@ ~aaa + user root shy shy user root shaoying shaoying user root oLqNu5iJYXXLbHM9WuvM0W1obfHM what user root o978M0XIrcmco28CU1UbPgNxIL78 what diff --git a/etc/exit.shy b/etc/exit.shy index e69de29b..d617c6d7 100644 --- a/etc/exit.shy +++ b/etc/exit.shy @@ -0,0 +1,5 @@ +~mdb + config save note.json note +~aaa + config save auth.json auth + diff --git a/etc/init.shy b/etc/init.shy index 32aac901..1a0822e7 100644 --- a/etc/init.shy +++ b/etc/init.shy @@ -1,3 +1,8 @@ +# ~aaa +# config load auth.json auth +# ~mdb +# config load note.json note +# source common.shy ~ssh remote auto diff --git a/src/contexts/cli/cli.go b/src/contexts/cli/cli.go index 37c5e3fe..caf5e2de 100644 --- a/src/contexts/cli/cli.go +++ b/src/contexts/cli/cli.go @@ -113,10 +113,11 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心", ":": []string{"command"}, "::": []string{"command", "list"}, - // "pwd": []string{"nfs.pwd"}, - // "path": []string{"nfs.path"}, - // "dir": []string{"nfs.dir"}, - // "git": []string{"nfs.git"}, + "note": []string{"mdb.note"}, + "pwd": []string{"nfs.pwd"}, + "path": []string{"nfs.path"}, + "dir": []string{"nfs.dir"}, + "git": []string{"nfs.git"}, "brow": []string{"web.brow"}, "ifconfig": []string{"tcp.ifconfig"}, }, Help: "启动脚本"}, diff --git a/src/contexts/ctx/ctx_init.go b/src/contexts/ctx/ctx_init.go index 0a12ad1a..aa921641 100644 --- a/src/contexts/ctx/ctx_init.go +++ b/src/contexts/ctx/ctx_init.go @@ -359,6 +359,13 @@ var Index = &Context{Name: "ctx", Help: "模块中心", Server: &CTX{}, return } + if v, ok := msg.Data[k]; ok { + b, e := json.MarshalIndent(v, "", " ") + m.Log("fuck", " %v", b) + m.Log("fuck", " %v", e) + m.Echo(kit.Formats(v)) + return e + } for i, v := range msg.Meta[k] { m.Add("append", "index", i) m.Add("append", "value", v) diff --git a/src/contexts/mdb/mdb.go b/src/contexts/mdb/mdb.go index dcaf74cb..8a3623ad 100644 --- a/src/contexts/mdb/mdb.go +++ b/src/contexts/mdb/mdb.go @@ -499,9 +499,11 @@ var Index = &ctx.Context{Name: "mdb", Help: "数据中心", hm, _ := kit.Hash("type", arg[0], "name", "shy") if len(arg) == 2 && arg[0] == "value" { hm, _ = kit.Hash("type", "index", "name", arg[1]) + hm = m.Conf("note", []string{hm, "ship", "value", "data"}) arg = arg[1:] } else if len(arg) == 2 && arg[0] == "note" { hm, _ = kit.Hash("type", "model", "name", arg[1]) + hm = m.Conf("note", []string{hm, "ship", "note", "data"}) arg = arg[1:] } @@ -513,6 +515,7 @@ var Index = &ctx.Context{Name: "mdb", Help: "数据中心", m.Add("append", "access_time", model["access_time"]) m.Add("append", "type", model["type"]) m.Add("append", "name", model["name"]) + m.Add("append", "view", kit.Format(model["view"])) m.Add("append", "data", kit.Format(model["data"])) m.Add("append", "ship", kit.Format(model["ship"])) } @@ -521,12 +524,48 @@ var Index = &ctx.Context{Name: "mdb", Help: "数据中心", } switch arg[0] { + case "search": + hv, _ := kit.Hash("type", "value", "name", arg[1], "data", kit.Select(m.Option(arg[1]), arg, 2)) + hn := m.Conf("note", []string{hv, "ship", "note", "data"}) + + for i := 0; hn != "" && i < kit.Int(kit.Select(m.Conf("page_limit"), m.Option("limit"))); hn, i = m.Conf("note", []string{hn, "ship", hv, "data"}), i+1 { + note := m.Confm("note", hn) + hvs := kit.Trans(note["data"]) + hm := kit.Format(kit.Chain(note, "ship.model.data")) + + value := []interface{}{} + m.Confm("note", []string{hm, "data"}, func(i int, model map[string]interface{}) { + value = append(value, map[string]interface{}{ + "type": model["type"], "name": model["name"], + "value": m.Conf("note", []string{hvs[i], "data"}), + }) + }) + + m.Add("append", "key", hn) + m.Add("append", "create_time", note["create_time"]) + m.Add("append", "access_time", note["access_time"]) + m.Add("append", "type", note["type"]) + m.Add("append", "name", note["name"]) + m.Add("append", "model", m.Conf("note", []string{hm, "name"})) + m.Add("append", "view", kit.Format(m.Conf("note", []string{hm, "view"}))) + m.Add("append", "value", kit.Format(value)) + m.Add("append", "data", kit.Format(note["data"])) + m.Add("append", "ship", kit.Format(note["ship"])) + } + m.Table() + case "model": // 模板详情 hm, _ := kit.Hash("type", arg[0], "name", arg[1]) if len(arg) == 2 { m.CopyFuck(m.Cmd("mdb.config", "note", hm), "append").Set("result").Table() - return + break + } + if arg[2] == "view" { + for i := 4; i < len(arg)-1; i += 2 { + m.Conf("note", []string{hm, "view", arg[3], arg[i]}, arg[i+1]) + } + break } // 操作模板 @@ -610,7 +649,7 @@ var Index = &ctx.Context{Name: "mdb", Help: "数据中心", data := []interface{}{} m.Confm("note", []string{hm, "data"}, func(i int, index map[string]interface{}) { - hv := m.Cmdx("mdb.note", "value", index["type"], kit.Select("", arg, i+2)) + hv := m.Cmdx("mdb.note", "value", index["type"], kit.Select(m.Option(kit.Format(index["name"])), arg, i+2)) data = append(data, hv) ship[hv] = map[string]interface{}{"type": "note", "data": m.Conf("note", []string{hv, "ship", "note", "data"})} diff --git a/src/contexts/web/web.go b/src/contexts/web/web.go index 095b0444..fe03af81 100644 --- a/src/contexts/web/web.go +++ b/src/contexts/web/web.go @@ -145,7 +145,7 @@ func (web *WEB) HandleCmd(m *ctx.Message, key string, cmd *ctx.Command) { msg.Optionv("debug", false) msg.Option("GOOS", m.Conf("runtime", "host.GOOS")) - msg.Option("GOOS", m.Conf("runtime", "host.GOARCH")) + msg.Option("GOARCH", m.Conf("runtime", "host.GOARCH")) agent := r.Header.Get("User-Agent") switch { case strings.Contains(agent, "Macintosh"): @@ -172,6 +172,22 @@ func (web *WEB) HandleCmd(m *ctx.Message, key string, cmd *ctx.Command) { msg.Option(k, v) } + switch r.Header.Get("Content-Type") { + case "application/json": + var data interface{} + json.NewDecoder(r.Body).Decode(&data) + msg.Optionv("content_data", data) + + switch d := data.(type) { + case map[string]interface{}: + for k, v := range d { + for _, v := range kit.Trans(v) { + msg.Add("option", k, v) + } + } + } + } + if msg.Put("option", "request", r).Put("option", "response", w).Sess("web", msg); web.Login(msg, w, r) { msg.Log("cmd", "%s [] %v", key, msg.Meta["option"]) cmd.Hand(msg, msg.Target(), msg.Option("path")) diff --git a/src/examples/chat/chat.go b/src/examples/chat/chat.go index a84b2982..e3a1aa42 100644 --- a/src/examples/chat/chat.go +++ b/src/examples/chat/chat.go @@ -198,6 +198,10 @@ var Index = &ctx.Context{Name: "chat", Help: "会议中心", return } + if m.Option("username") == "o978M0XIrcmco28CU1UbPgNxIL78" { + m.Option("username", "shy") + } + // 创建空间 if !m.Options("bench") && m.Option("bench", m.Cmd("aaa.sess", m.Option("sessid"), "bench").Append("key")) == "" { m.Option("bench", m.Cmdx("aaa.work", m.Option("sessid"), "mp")) @@ -205,10 +209,10 @@ var Index = &ctx.Context{Name: "chat", Help: "会议中心", m.Option("current_ctx", kit.Select("chat", m.Magic("bench", "current_ctx"))) // 执行命令 - cmd := strings.Split(m.Option("cmd"), " ") + cmd := kit.Trans(m.Optionv("cmd")) if !m.Cmds("aaa.work", m.Option("bench"), "right", m.Option("username"), "mp", cmd[0]) { m.Echo("no right %s %s", "chat", cmd[0]) - } else if m.Cmdy(m.Option("cmd")); m.Appends("redirect") { + } else if m.Cmdy(cmd); m.Appends("redirect") { } return }}, diff --git a/src/toolkit/kit.go b/src/toolkit/kit.go index 6026bd36..1a1b2f92 100644 --- a/src/toolkit/kit.go +++ b/src/toolkit/kit.go @@ -177,6 +177,8 @@ func Formats(arg ...interface{}) string { default: if b, e := json.MarshalIndent(val, "", " "); e == nil { result = append(result, string(b)) + } else { + result = append(result, fmt.Sprintf("%#v", val)) } } }