From 08a56cfeb1f2ad67d847c64c8c686026daf572fc Mon Sep 17 00:00:00 2001 From: shaoying Date: Tue, 9 Feb 2021 18:09:11 +0800 Subject: [PATCH] opt some --- core/code/code.go | 20 ++++++++++---------- core/code/vimer.go | 4 ++++ core/team/plan.go | 4 ++-- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/core/code/code.go b/core/code/code.go index 7282033c..4414b2f4 100644 --- a/core/code/code.go +++ b/core/code/code.go @@ -3,20 +3,20 @@ package code import ( ice "github.com/shylinux/icebergs" "github.com/shylinux/icebergs/base/web" + kit "github.com/shylinux/toolkits" ) const CODE = "code" -var Index = &ice.Context{Name: CODE, Help: "编程中心", - Configs: map[string]*ice.Config{}, - Commands: map[string]*ice.Command{ - ice.CTX_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { - m.Load() - m.Conf(PUBLISH, "meta.contexts", _contexts) - }}, - ice.CTX_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { m.Save() }}, - }, -} +var Index = &ice.Context{Name: CODE, Help: "编程中心", Commands: map[string]*ice.Command{ + ice.CTX_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + m.Load() + m.Conf(PUBLISH, kit.Keym("contexts"), _contexts) + }}, + ice.CTX_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + m.Save() + }}, +}} func init() { web.Index.Register(Index, &web.Frame{}, diff --git a/core/code/vimer.go b/core/code/vimer.go index 58522284..aab5daec 100644 --- a/core/code/vimer.go +++ b/core/code/vimer.go @@ -19,6 +19,10 @@ func init() { "display", "/plugin/local/code/vimer.js", "style", "editor", ), Action: map[string]*ice.Action{ mdb.ENGINE: {Name: "engine", Help: "运行", Hand: func(m *ice.Message, arg ...string) { + if m.Cmdy(mdb.ENGINE, arg); len(m.Resultv()) > 0 || len(m.Appendv(ice.MSG_APPEND)) > 0 { + return + } + if arg = kit.Split(strings.Join(arg, " ")); !m.Warn(!m.Right(arg)) { if m.Cmdy(arg); len(m.Appendv(ice.MSG_APPEND)) == 0 && len(m.Resultv()) == 0 { m.Cmdy(cli.SYSTEM, arg) diff --git a/core/team/plan.go b/core/team/plan.go index 3e288dfc..a3d7fe91 100644 --- a/core/team/plan.go +++ b/core/team/plan.go @@ -37,8 +37,8 @@ func init() { _task_inputs(m, kit.Select("", arg, 0), kit.Select("", arg, 1)) }}, - mdb.PLUGIN: {Name: "plugin extra.pod extra.ctx extra.cmd extra.arg", Help: "插件", Hand: func(m *ice.Message, arg ...string) { - _task_modify(m, m.Option(kit.MDB_ZONE), m.Option(kit.MDB_ID), kit.MDB_TIME, m.Time(), kit.Simple(kit.KeyValue(nil, "", kit.Dict(arg)))...) + mdb.PLUGIN: {Name: "plugin extra.ctx extra.cmd extra.arg", Help: "插件", Hand: func(m *ice.Message, arg ...string) { + _task_modify(m, m.Option(kit.MDB_ZONE), m.Option(kit.MDB_ID), kit.MDB_TIME, m.Time(), arg...) m.Set(ice.MSG_RESULT).Cmdy(PLAN, m.Option("scale")) }}, ctx.COMMAND: {Name: "command", Help: "命令", Hand: func(m *ice.Message, arg ...string) {