1
0
mirror of https://shylinux.com/x/icebergs synced 2025-06-26 10:27:31 +08:00

add web.share

This commit is contained in:
shaoying 2019-12-22 01:42:47 +08:00
parent 68a2e9525e
commit bc53f6bb8d
7 changed files with 169 additions and 95 deletions

View File

@ -128,6 +128,7 @@ func Run(arg ...string) string {
frame := &Frame{}
Index.server = frame
Pulse.Option("begin_time", Pulse.Time())
if frame.Begin(Pulse.Spawns(), arg...).Start(Pulse.Spawns(), arg...) {
frame.Close(Pulse.Spawns(), arg...)

View File

@ -7,6 +7,7 @@ import (
"bytes"
"encoding/json"
"fmt"
"math/rand"
"net"
"net/http"
@ -113,8 +114,7 @@ func (web *Frame) HandleCGI(m *ice.Message, alias map[string]interface{}, which
cb := func(k string, p []string, v *ice.Command) {
cgi[k] = func(arg ...interface{}) (res interface{}) {
m.TryCatch(m.Spawn(), true, func(msg *ice.Message) {
m.Log("cmd", "%v %v %v", k, p, arg)
v.Hand(msg, m.Target(), k, kit.Simple(p, arg)...)
msg.Target().Run(msg, v, k, kit.Simple(p, arg)...)
buffer := bytes.NewBuffer([]byte{})
m.Assert(tmpl.ExecuteTemplate(buffer, msg.Option(ice.WEB_TMPL), msg))
@ -139,10 +139,10 @@ func (web *Frame) HandleCGI(m *ice.Message, alias map[string]interface{}, which
}
tmpl = tmpl.Funcs(cgi)
// tmpl = template.Must(tmpl.ParseGlob(path.Join(m.Conf(ice.WEB_SERVE, "template.path"), "/*.tmpl")))
// tmpl = template.Must(tmpl.ParseGlob(path.Join(m.Conf(ice.WEB_SERVE, "template.path"), m.Target().Name, "/*.tmpl")))
// tmpl = template.Must(tmpl.ParseGlob(path.Join(m.Conf(ice.WEB_SERVE, ice.Meta("template", "path")), "/*.tmpl")))
// tmpl = template.Must(tmpl.ParseGlob(path.Join(m.Conf(ice.WEB_SERVE, ice.Meta("template", "path")), m.Target().Name, "/*.tmpl")))
tmpl = template.Must(tmpl.ParseFiles(which))
m.Confm(ice.WEB_SERVE, "template.list", func(index int, value string) { tmpl = template.Must(tmpl.Parse(value)) })
m.Confm(ice.WEB_SERVE, ice.Meta("template", "list"), func(index int, value string) { tmpl = template.Must(tmpl.Parse(value)) })
for i, v := range tmpl.Templates() {
m.Log("info", "%v, %v", i, v.Name())
}
@ -209,7 +209,13 @@ func (web *Frame) HandleCmd(m *ice.Message, key string, cmd *ice.Command) {
if web.Login(msg, w, r) {
msg.Log("cmd", "%s %s", msg.Target().Name, key)
cmd.Hand(msg, msg.Target(), msg.Option("url"), kit.Simple(msg.Optionv("cmds"))...)
w.Write([]byte(msg.Formats("meta")))
switch msg.Append("content-type") {
case "text/html":
w.Header().Set("Content-Type", "text/html")
fmt.Fprintf(w, msg.Result())
default:
fmt.Fprintf(w, msg.Formats("meta"))
}
}
})
})
@ -261,7 +267,7 @@ func (web *Frame) Start(m *ice.Message, arg ...string) bool {
}
// 静态路由
m.Confm("web.serve", "static", func(key string, value string) {
m.Confm(ice.WEB_SERVE, ice.Meta("static"), func(key string, value string) {
msg.Log("route", "%s <- %s <- %s", s.Name, key, value)
w.Handle(key, http.StripPrefix(key, http.FileServer(http.Dir(value))))
})
@ -290,15 +296,15 @@ var Index = &ice.Context{Name: "web", Help: "网页模块",
Caches: map[string]*ice.Cache{},
Configs: map[string]*ice.Config{
ice.WEB_SPIDE: {Name: "spide", Help: "客户端", Value: ice.Data("self.port", ice.WEB_PORT)},
ice.WEB_SERVE: {Name: "serve", Help: "服务器", Value: map[string]interface{}{
"static": map[string]interface{}{"/": "usr/volcanos/",
ice.WEB_SERVE: {Name: "serve", Help: "服务器", Value: ice.Data(
"static", map[string]interface{}{"/": "usr/volcanos/",
"/static/volcanos/": "usr/volcanos/",
},
"template": map[string]interface{}{"path": "usr/template", "list": []interface{}{
"template", map[string]interface{}{"path": "usr/template", "list": []interface{}{
`{{define "raw"}}{{.Result}}{{end}}`,
}},
}},
ice.WEB_SPACE: {Name: "space", Help: "空间站", Value: ice.Meta("buffer", 4096, "redial", 3000)},
)},
ice.WEB_SPACE: {Name: "space", Help: "空间站", Value: ice.Data("buffer", 4096, "redial", 3000)},
ice.WEB_STORY: {Name: "story", Help: "故事会", Value: ice.Data("short", "data")},
ice.WEB_CACHE: {Name: "cache", Help: "缓存", Value: ice.Data(
"short", "text", "path", "var/file",
@ -306,6 +312,7 @@ var Index = &ice.Context{Name: "web", Help: "网页模块",
)},
ice.WEB_ROUTE: {Name: "route", Help: "路由", Value: ice.Data()},
ice.WEB_PROXY: {Name: "proxy", Help: "代理", Value: ice.Data()},
ice.WEB_SHARE: {Name: "share", Help: "共享", Value: ice.Data()},
},
Commands: map[string]*ice.Command{
ice.ICE_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {}},
@ -398,16 +405,16 @@ var Index = &ice.Context{Name: "web", Help: "网页模块",
switch arg[0] {
case "add":
// 查询索引
head := kit.Hashs(arg[1])
head := kit.Hashs(arg[1], arg[2])
prev := m.Conf("story", ice.Meta("head", head, "list"))
m.Log("info", "head: %v prev: %v", head, prev)
// 添加节点
meta := map[string]interface{}{
"time": m.Time(),
"story": arg[1],
"scene": arg[2],
"data": m.Cmdx(ice.WEB_CACHE, "add", "text", arg[2]),
"scene": arg[1],
"story": arg[2],
"data": m.Cmdx(ice.WEB_CACHE, "add", "text", arg[3]),
"prev": prev,
}
list := m.Rich("story", nil, meta)
@ -415,8 +422,7 @@ var Index = &ice.Context{Name: "web", Help: "网页模块",
// 添加索引
m.Conf("story", ice.Meta("head", head), map[string]interface{}{
"time": m.Time(), "type": "text",
"story": arg[1], "list": list,
"time": m.Time(), "scene": arg[1], "story": arg[2], "list": list,
})
m.Echo(list)
@ -433,9 +439,9 @@ var Index = &ice.Context{Name: "web", Help: "网页模块",
menu[arg[i]] = arg[i+1]
i++
} else if head := kit.Hashs(arg[i]); m.Confs("story", kit.Keys("meta", "head", head)) {
menu[arg[i]] = head
menu[arg[i]] = m.Conf(ice.WEB_STORY, ice.Meta("head", head, "list"))
} else {
m.Error("not found %v", arg[i])
m.Error(true, "not found %v", arg[i])
return
}
}
@ -443,6 +449,7 @@ var Index = &ice.Context{Name: "web", Help: "网页模块",
// 添加节点
meta := map[string]interface{}{
"time": m.Time(),
"scene": "commit",
"story": arg[1],
"list": menu,
"prev": prev,
@ -452,10 +459,40 @@ var Index = &ice.Context{Name: "web", Help: "网页模块",
// 添加索引
m.Conf("story", ice.Meta("head", head), map[string]interface{}{
"time": m.Time(), "type": "list",
"story": arg[1], "list": list,
"time": m.Time(), "scene": "commit", "story": arg[1], "list": list,
})
m.Echo(list)
case "history":
list := kit.Select(arg[1], kit.Select(m.Conf(ice.WEB_STORY, ice.Meta("head", arg[1], "list")),
m.Conf(ice.WEB_STORY, ice.Meta("head", kit.Hashs(arg[1]), "list"))))
for i := 0; i < 10 && list != ""; i++ {
m.Confm(ice.WEB_STORY, kit.Keys("hash", list), func(value map[string]interface{}) {
m.Push(list, value, []string{"key", "time", "story", "scene"})
m.Push("text", m.Conf(ice.WEB_CACHE, kit.Keys("hash", value["data"], "text")))
m.Push(list, value, []string{"data"})
kit.Fetch(value["list"], func(key string, val string) {
m.Push(list, value, []string{"key", "time"})
m.Push("story", kit.Keys(kit.Format(value["story"]), key))
m.Push("scene", value["scene"])
data := m.Conf(ice.WEB_STORY, kit.Keys("hash", val, "data"))
m.Push("text", m.Conf(ice.WEB_CACHE, kit.Keys("hash", data, "text")))
m.Push("data", data)
})
list = kit.Format(value["prev"])
})
}
case "share":
m.Cmdy(ice.WEB_SHARE, arg[1:])
case "index":
list := kit.Select(arg[1], kit.Select(m.Conf(ice.WEB_STORY, ice.Meta("head", arg[1], "list")),
m.Conf(ice.WEB_STORY, ice.Meta("head", kit.Hashs(arg[1]), "list"))))
data := kit.Select(list, m.Conf(ice.WEB_STORY, []string{"hash", list, "data"}))
text := m.Conf(ice.WEB_CACHE, []string{"hash", data, "text"})
m.Echo(text)
}
}},
ice.WEB_CACHE: {Name: "cache", Help: "缓存", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
@ -481,6 +518,38 @@ var Index = &ice.Context{Name: "web", Help: "网页模块",
}},
ice.WEB_PROXY: {Name: "proxy", Help: "代理", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
}},
ice.WEB_SHARE: {Name: "share type name value", Help: "共享", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
if len(arg) == 0 {
m.Confm(ice.WEB_SHARE, "hash", func(key string, value map[string]interface{}) {
m.Push(key, value)
})
return
}
m.Echo(m.Rich(ice.WEB_SHARE, nil, map[string]interface{}{
"create_time": m.Time(), "type": arg[0], "name": arg[1], "text": kit.Select("", arg, 2),
}))
}},
"/share/": &ice.Command{Name: "/share", Help: "共享", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
key := kit.Select("", strings.Split(cmd, "/"), 2)
m.Confm(ice.WEB_SHARE, kit.Keys("hash", key), func(value map[string]interface{}) {
m.Push("content-type", "text/html")
m.Echo(`<!DOCTYPE html>`)
m.Echo(`<head>`)
m.Echo(`<meta charset="utf-8">`)
m.Echo(`<link rel="stylesheet" text="text/css" href="/style.css">`)
m.Echo(`</head>`)
m.Echo(`<body>`)
m.Echo(`<fieldset>`)
key := kit.Keys("web.wiki", value["type"])
if key == "web.wiki.chain" {
m.Cmdy("web.wiki.chart", "chain", value["name"], value["text"])
} else {
m.Cmdy(key, value["name"], "", value["text"])
}
m.Echo(`</fieldset>`)
m.Echo(`</body>`)
})
}},
"/space": &ice.Command{Name: "/space", Help: "空间站", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
r := m.Optionv("request").(*http.Request)

View File

@ -38,6 +38,7 @@ const (
WEB_CACHE = "cache"
WEB_ROUTE = "route"
WEB_PROXY = "proxy"
WEB_SHARE = "share"
)
const (
GDB_SIGNAL = "signal"
@ -49,6 +50,7 @@ const (
LOG_INFO = "info"
LOG_WARN = "warn"
LOG_ERROR = "error"
LOG_TRACE = "trace"
LOG_BEGIN = "begin"
LOG_START = "start"
@ -70,6 +72,7 @@ var Alias = map[string]string{
WEB_CACHE: "web.cache",
WEB_ROUTE: "web.route",
WEB_PROXY: "web.proxy",
WEB_SHARE: "web.share",
"note": "web.wiki.note",
}

View File

@ -20,15 +20,14 @@ var Index = &ice.Context{Name: "chat", Help: "聊天模块",
}},
ice.ICE_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
m.Cmd(ice.CTX_CONFIG, "save", "chat.json", "web.chat.group")
m.Cmd(ice.CTX_CONFIG, "save", "web.json", "web.story", "web.cache")
m.Cmd(ice.CTX_CONFIG, "save", "web.json", "web.story", "web.cache", "web.share")
m.Cmd(ice.CTX_CONFIG, "save", "aaa.json", "aaa.role", "aaa.user", "aaa.sess")
}},
ice.WEB_LOGIN: {Name: "login", Help: "登录", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
if cmd != "/login" {
if !m.Options(ice.WEB_SESS) || !m.Options("username") {
if m.Warn(!m.Options(ice.WEB_SESS) || !m.Options("username"), "not login") {
// 检查失败
m.Log(ice.LOG_WARN, "not login").Error("not login")
m.Option("path", "")
return
}

View File

@ -13,34 +13,6 @@ import (
"strings"
)
var prefix = `<svg class="story" data-name="{{.Option "name"}}" data-text="{{.Option "text"}}" vertion="1.1" xmlns="http://www.w3.org/2000/svg"
width="{{.Option "width"}}" height="{{.Option "height"}}" style="{{.Option "style"}}"
data-name="{{.Option "name"}}"
>`
var shell = `<div class="story code" data-name="{{.Option "name"}}" data-text="{{.Option "text"}}" data-input="{{.Option "input"}}">$ {{.Option "input"}}
{{.Option "output"}}</div>`
var title = `<span class="story">{{.Option "prefix"}}{{.Option "content"}}</span>`
var order = `<ul class="story" data-name="{{.Option "name"}}" data-text="{{.Option "text"}}">{{range $index, $value := .Optionv "list"}}<li>{{$value}}</li>{{end}}</ul>`
var table = `<table class="story" data-name="{{.Option "name"}} data-text="{{.Option "text"}}>
<tr>{{range $i, $v := .Optionv "head"}}<th>{{$v}}</th>{{end}}</tr>
{{range $index, $value := .Optionv "list"}}
<tr>{{range $i, $v := $value}}<td>{{$v}}</td>{{end}}</tr>
{{end}}
</table>`
var premenu = `<ul class="story premenu"></ul>`
var endmenu = `<ul class="story endmenu">
{{$menu := .Optionv "menu"}}
{{range $index, $value := Value $menu "list"}}
<li>{{Value $value "prefix"}} {{Value $value "content"}}</li>
{{end}}
</ul>
`
var Index = &ice.Context{Name: "wiki", Help: "文档模块",
Caches: map[string]*ice.Cache{},
Configs: map[string]*ice.Config{
@ -65,11 +37,11 @@ var Index = &ice.Context{Name: "wiki", Help: "文档模块",
Commands: map[string]*ice.Command{
"chart": {Name: "chart block|chain|table name text [fg bg fs ls p m]", Help: "绘图", Meta: map[string]interface{}{
"display": "inner",
}, List: []interface{}{
map[string]interface{}{"type": "select", "value": "chain", "values": "block chain table"},
map[string]interface{}{"type": "text", "value": ""},
map[string]interface{}{"type": "button", "value": "生成"},
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
}, List: ice.List(
ice.MDB_TYPE, "select", "value", "chain", "values", "block chain table",
ice.MDB_TYPE, "text", "value", "",
ice.MDB_TYPE, "button", "value", "生成",
), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
// 创建类型
var chart Chart
switch arg[0] {
@ -84,6 +56,7 @@ var Index = &ice.Context{Name: "wiki", Help: "文档模块",
arg[2] = strings.TrimSpace(arg[2])
// 构造数据
m.Option("type", arg[0])
m.Option("name", arg[1])
m.Option("text", arg[2])
chart.Init(m, arg[2:]...)
@ -95,7 +68,10 @@ var Index = &ice.Context{Name: "wiki", Help: "文档模块",
chart.Draw(m, 0, 0)
m.Render(m.Conf("chart", ice.Meta("suffix")))
}},
"table": {Name: "table name text", Help: "表格", Hand: func(m *ice.Message, c *ice.Context, key string, arg ...string) {
"table": {Name: "table name text", Help: "表格", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
m.Option("type", "table")
m.Option("name", arg[0])
m.Option("text", arg[1])
head, list := []string{}, [][]string{}
for i, v := range kit.Split(arg[1], "\n") {
if i == 0 {
@ -109,27 +85,29 @@ var Index = &ice.Context{Name: "wiki", Help: "文档模块",
m.Render(m.Conf("table", ice.Meta("template")))
}},
"order": {Name: "order name text", Help: "列表", Hand: func(m *ice.Message, c *ice.Context, key string, arg ...string) {
m.Optionv("name", arg[0])
m.Optionv("text", arg[1])
m.Option("type", "order")
m.Option("name", arg[0])
m.Option("text", arg[1])
m.Optionv("list", kit.Split(arg[1], "\n"))
m.Render(m.Conf("order", ice.Meta("template")))
}},
"shell": {Name: "shell dir cmd", Help: "命令", Hand: func(m *ice.Message, c *ice.Context, key string, arg ...string) {
m.Option("cmd_dir", arg[0])
m.Option("input", strings.Join(arg[1:], " "))
m.Option("output", m.Cmdx("cli.system", "sh", "-c", strings.Join(arg[1:], " ")))
"shell": {Name: "shell name dir cmd", Help: "命令", Hand: func(m *ice.Message, c *ice.Context, key string, arg ...string) {
m.Option("type", "shell")
m.Option("name", arg[0])
m.Option("cmd_dir", arg[1])
m.Option("output", m.Cmdx("cli.system", "sh", "-c", m.Option("input", strings.Join(arg[2:], " "))))
m.Render(m.Conf("shell", ice.Meta("template")))
}},
"title": {Name: "title text", Help: "标题", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
// 生成序号
title, _ := m.Optionv("title").(map[string]int)
switch arg[0] {
case "premenu":
m.Echo(premenu)
return
case "endmenu":
m.Render(endmenu)
return
case "premenu":
m.Render(premenu)
return
case "section":
arg = arg[1:]
title["section"]++
@ -142,13 +120,13 @@ var Index = &ice.Context{Name: "wiki", Help: "文档模块",
default:
m.Option("prefix", "")
}
ns := strings.Split(m.Conf("runtime", "node.name"), "-")
m.Option("type", "title")
m.Option("text", arg[0])
// 生成菜单
ns := strings.Split(m.Conf("runtime", "node.name"), "-")
menu, _ := m.Optionv("menu").(map[string]interface{})
list, _ := menu["list"].([]interface{})
menu["list"] = append(list, map[string]interface{}{
menu["list"] = append(menu["list"].([]interface{}), map[string]interface{}{
"content": m.Option("content", kit.Select(ns[len(ns)-1], arg, 0)),
"prefix": m.Option("prefix"),
})
@ -160,7 +138,7 @@ var Index = &ice.Context{Name: "wiki", Help: "文档模块",
"_text": {Name: "_text file", Help: "文章", Hand: func(m *ice.Message, c *ice.Context, key string, arg ...string) {
m.Option(ice.WEB_TMPL, "raw")
m.Optionv("title", map[string]int{})
m.Optionv("menu", map[string]interface{}{})
m.Optionv("menu", map[string]interface{}{"list": []interface{}{}})
// 生成文章
buffer := bytes.NewBuffer([]byte{})
@ -185,7 +163,7 @@ var Index = &ice.Context{Name: "wiki", Help: "文档模块",
}},
"note": {Name: "note file", Help: "笔记", Meta: map[string]interface{}{
"remote": "true", "display": "inner",
"detail": []string{"add", "commit", "favor", "detail"},
"detail": []string{"add", "commit", "history", "share"},
}, List: ice.List(
ice.MDB_TYPE, "text", "value", "miss.md", "name", "path",
ice.MDB_TYPE, "button", "value", "执行", "action", "auto",
@ -200,6 +178,9 @@ var Index = &ice.Context{Name: "wiki", Help: "文档模块",
}
m.Cmdy(kit.Select("_tree", "_text", len(arg) > 0 && strings.HasSuffix(arg[0], ".md")), arg)
}},
"index": {Name: "index hash", Help: "索引", Hand: func(m *ice.Message, c *ice.Context, key string, arg ...string) {
m.Cmd(ice.WEB_STORY, "index", arg)
}},
},
}

View File

@ -1,17 +1,17 @@
# {{title "hello world"}}
{{shell "" "uptime"}}
{{shell "开机时长" "" "uptime"}}
{{title "premenu"}}
## {{chapter "项目总览"}}
{{table "总览" `
{{order "总览" `
volcano iceberg
context toolkit
preload appframe
`}}
{{order "总览" `
{{table "总览" `
volcano iceberg
context toolkit
preload appframe

45
type.go
View File

@ -370,9 +370,6 @@ func (m *Message) Echo(str string, arg ...interface{}) *Message {
m.meta[MSG_RESULT] = append(m.meta[MSG_RESULT], fmt.Sprintf(str, arg...))
return m
}
func (m *Message) Error(str string, arg ...interface{}) *Message {
return m.Echo("error").Echo(str, arg...)
}
func (m *Message) Sort(key string, arg ...string) *Message {
cmp := "str"
if len(arg) > 0 && arg[0] != "" {
@ -550,10 +547,10 @@ func (m *Message) Optionv(key string, arg ...interface{}) interface{} {
}
for msg := m; msg != nil; msg = msg.message {
if list, ok := msg.meta[key]; ok {
if list, ok := msg.data[key]; ok {
return list
}
if list, ok := msg.data[key]; ok {
if list, ok := msg.meta[key]; ok {
return list
}
}
@ -579,8 +576,9 @@ func (m *Message) Result(arg ...interface{}) string {
}
func (m *Message) Log(level string, str string, arg ...interface{}) *Message {
str = strings.TrimSpace(fmt.Sprintf(str, arg...))
if Log != nil {
Log(m, level, fmt.Sprintf(str, arg...))
Log(m, level, str)
}
prefix, suffix := "", ""
switch level {
@ -593,12 +591,37 @@ func (m *Message) Log(level string, str string, arg ...interface{}) *Message {
}
fmt.Fprintf(os.Stderr, "%s %d %s->%s %s%s %s%s\n",
time.Now().Format(ICE_TIME), m.code, m.source.Name, m.target.Name,
prefix, level, fmt.Sprintf(str, arg...), suffix)
prefix, level, str, suffix)
return m
}
func (m *Message) Info(str string, arg ...interface{}) *Message {
return m.Log(LOG_INFO, str, arg...)
}
func (m *Message) Warn(err bool, str string, arg ...interface{}) bool {
if err {
m.Echo("warn: ").Echo(str, arg...)
return m.Log(LOG_WARN, str, arg...) != nil
}
return false
}
func (m *Message) Error(err bool, str string, arg ...interface{}) bool {
if err {
m.Echo("error: ").Echo(str, arg...)
m.Log(LOG_ERROR, m.Format("stack"))
m.Log(LOG_ERROR, str, arg...)
m.Log(LOG_ERROR, m.Format("chain"))
return true
}
return false
}
func (m *Message) Trace(key string, str string, arg ...interface{}) *Message {
if m.Options(key) {
m.Echo("trace: ").Echo(str, arg...)
return m.Log(LOG_TRACE, str, arg...)
}
return m
}
func (m *Message) Assert(arg interface{}) bool {
switch arg := arg.(type) {
case nil:
@ -749,12 +772,14 @@ func (m *Message) Search(key interface{}, cb interface{}) *Message {
for c := p; c != nil; c = c.context {
if cmd, ok := c.Commands[key]; ok {
cb(c.context, c, key, cmd)
break
}
}
case func(p *Context, s *Context, key string, conf *Config):
for c := p; c != nil; c = c.context {
if cmd, ok := c.Configs[key]; ok {
cb(c.context, c, key, cmd)
break
}
}
case func(p *Context, s *Context, key string):
@ -1039,9 +1064,7 @@ func (m *Message) Cmd(arg ...interface{}) *Message {
return m
}
func (m *Message) Confv(arg ...interface{}) (val interface{}) {
m.Search(arg[0], func(p *Context, s *Context, key string) {
for c := s; c != nil; c = c.context {
if conf, ok := c.Configs[key]; ok {
m.Search(arg[0], func(p *Context, s *Context, key string, conf *Config) {
if len(arg) > 1 {
if len(arg) > 2 {
kit.Value(conf.Value, arg[1:]...)
@ -1050,8 +1073,6 @@ func (m *Message) Confv(arg ...interface{}) (val interface{}) {
} else {
val = conf.Value
}
}
}
})
return
}