From b482caf902a42772b88afcd237681fb3719bd77c Mon Sep 17 00:00:00 2001 From: shylinux Date: Tue, 30 Jun 2020 18:27:59 +0800 Subject: [PATCH] fix web._render --- base/web/render.go | 25 ++++++++++++------------- base/web/web.go | 4 ---- core/code/bench.go | 4 ++-- core/code/pprof.go | 4 ++-- 4 files changed, 16 insertions(+), 21 deletions(-) diff --git a/base/web/render.go b/base/web/render.go index 9fcd883a..c4a6de6d 100644 --- a/base/web/render.go +++ b/base/web/render.go @@ -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(``, arg[0]) - }}, - RENDER.Field: {Hand: func(m *ice.Message, arg ...string) { - m.Echo(`
%s(%s)
`, 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(`%s`, u, arg[0]) @@ -131,8 +124,14 @@ func init() { RENDER.IMG: {Hand: func(m *ice.Message, arg ...string) { m.Echo(``, arg[0]) }}, + RENDER.Field: {Hand: func(m *ice.Message, arg ...string) { + m.Echo(`
%s(%s)
`, arg[0], arg[1]) + }}, + RENDER.Button: {Hand: func(m *ice.Message, arg ...string) { + m.Echo(``, arg[0]) + }}, }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { - m.Echo(``, arg[0], arg[1]) + m.Echo(``, arg[1], arg[2]) }}, }, }, nil) diff --git a/base/web/web.go b/base/web/web.go index c75fdbf1..d3c05668 100644 --- a/base/web/web.go +++ b/base/web/web.go @@ -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, diff --git a/core/code/bench.go b/core/code/bench.go index 7cad836a..3e13c351 100644 --- a/core/code/bench.go +++ b/core/code/bench.go @@ -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, "运行")) }) }) } diff --git a/core/code/pprof.go b/core/code/pprof.go index 728c7ad5..ae99ff57 100644 --- a/core/code/pprof.go +++ b/core/code/pprof.go @@ -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, "运行")) }) } })