forked from x/icebergs
fix web._render
This commit is contained in:
parent
d84f795330
commit
b482caf902
@ -3,7 +3,6 @@ package web
|
||||
import (
|
||||
ice "github.com/shylinux/icebergs"
|
||||
"github.com/shylinux/icebergs/base/aaa"
|
||||
"github.com/shylinux/icebergs/base/mdb"
|
||||
kit "github.com/shylinux/toolkits"
|
||||
"github.com/skip2/go-qrcode"
|
||||
|
||||
@ -103,27 +102,21 @@ func RenderStatus(msg *ice.Message, code int, text string) { // name path expire
|
||||
}
|
||||
|
||||
var RENDER = struct {
|
||||
Button string
|
||||
Field string
|
||||
A string
|
||||
IMG string
|
||||
Field string
|
||||
Button string
|
||||
}{
|
||||
Button: "button",
|
||||
Field: "field",
|
||||
A: "a",
|
||||
IMG: "img",
|
||||
Field: "field",
|
||||
Button: "button",
|
||||
}
|
||||
|
||||
func init() {
|
||||
Index.Merge(&ice.Context{
|
||||
Commands: map[string]*ice.Command{
|
||||
mdb.RENDER: {Action: map[string]*ice.Action{
|
||||
RENDER.Button: {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Echo(`<input type="button" value="%s">`, arg[0])
|
||||
}},
|
||||
RENDER.Field: {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Echo(`<fieldset><legend>%s(%s)</legend><form></form></fieldset>`, arg[0], arg[1])
|
||||
}},
|
||||
"_render": {Action: map[string]*ice.Action{
|
||||
RENDER.A: {Hand: func(m *ice.Message, arg ...string) {
|
||||
u := kit.Select(m.Conf(SHARE, "meta.domain"), arg, 1)
|
||||
m.Echo(`<a href="%s" target="_blank">%s</a>`, u, arg[0])
|
||||
@ -131,8 +124,14 @@ func init() {
|
||||
RENDER.IMG: {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Echo(`<img src="%s">`, arg[0])
|
||||
}},
|
||||
RENDER.Field: {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Echo(`<fieldset><legend>%s(%s)</legend><form></form></fieldset>`, arg[0], arg[1])
|
||||
}},
|
||||
RENDER.Button: {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Echo(`<input type="button" value="%s">`, arg[0])
|
||||
}},
|
||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
m.Echo(`<input type="%s" value="%s">`, arg[0], arg[1])
|
||||
m.Echo(`<input type="%s" value="%s">`, arg[1], arg[2])
|
||||
}},
|
||||
},
|
||||
}, nil)
|
||||
|
@ -107,10 +107,6 @@ var Index = &ice.Context{Name: "web", Help: "网络模块",
|
||||
m.Cmd(mdb.SEARCH, mdb.CREATE, FAVOR)
|
||||
m.Cmd(mdb.SEARCH, mdb.CREATE, SPIDE)
|
||||
m.Cmd(mdb.RENDER, mdb.CREATE, SPIDE)
|
||||
|
||||
for k := range c.Commands[mdb.RENDER].Action {
|
||||
m.Cmdy(mdb.RENDER, mdb.CREATE, k, mdb.RENDER, c.Cap(ice.CTX_FOLLOW))
|
||||
}
|
||||
}},
|
||||
ice.CTX_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
m.Save(SPIDE, SERVE, GROUP, LABEL,
|
||||
|
@ -24,7 +24,7 @@ func _bench_list(m *ice.Message, zone string, id string, field ...interface{}) {
|
||||
if zone = kit.Format(kit.Value(val, kit.MDB_ZONE)); id == "" {
|
||||
m.Grows(BENCH, kit.Keys(kit.MDB_HASH, key), "", "", func(index int, value map[string]interface{}) {
|
||||
// 查看信息
|
||||
m.Push("操作", m.Cmdx(mdb.RENDER, web.RENDER.Button, "运行"))
|
||||
m.Push("操作", m.Cmdx("_render", web.RENDER.Button, "运行"))
|
||||
m.Push(zone, value, []string{
|
||||
kit.MDB_ZONE, kit.MDB_ID, kit.MDB_TYPE,
|
||||
kit.MDB_NAME, NCONN, NREQS, kit.MDB_TEXT,
|
||||
@ -36,7 +36,7 @@ func _bench_list(m *ice.Message, zone string, id string, field ...interface{}) {
|
||||
// 查看信息
|
||||
m.Push("detail", value)
|
||||
m.Push(kit.MDB_KEY, "操作")
|
||||
m.Push(kit.MDB_VALUE, m.Cmdx(mdb.RENDER, web.RENDER.Button, "运行"))
|
||||
m.Push(kit.MDB_VALUE, m.Cmdx("_render", web.RENDER.Button, "运行"))
|
||||
})
|
||||
})
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ func _pprof_list(m *ice.Message, zone string, id string, field ...interface{}) {
|
||||
if zone = kit.Format(kit.Value(val, kit.MDB_ZONE)); id == "" {
|
||||
m.Grows(PPROF, kit.Keys(kit.MDB_HASH, key), "", "", func(index int, value map[string]interface{}) {
|
||||
// 列表信息
|
||||
m.Push("操作", m.Cmdx(mdb.RENDER, web.RENDER.Button, "运行"))
|
||||
m.Push("操作", m.Cmdx("_render", web.RENDER.Button, "运行"))
|
||||
m.Push(zone, value, []string{
|
||||
kit.MDB_ZONE, kit.MDB_ID, kit.MDB_TYPE,
|
||||
kit.MDB_NAME, kit.MDB_TEXT, SECONDS, BINNARY, SERVICE,
|
||||
@ -31,7 +31,7 @@ func _pprof_list(m *ice.Message, zone string, id string, field ...interface{}) {
|
||||
// 详细信息
|
||||
m.Push("detail", value)
|
||||
m.Push(kit.MDB_KEY, "操作")
|
||||
m.Push(kit.MDB_VALUE, m.Cmdx(mdb.RENDER, web.RENDER.Button, "运行"))
|
||||
m.Push(kit.MDB_VALUE, m.Cmdx("_render", web.RENDER.Button, "运行"))
|
||||
})
|
||||
}
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user