From aeea2a4badd134a49317566c922730338044afb9 Mon Sep 17 00:00:00 2001 From: shy Date: Tue, 16 Jan 2024 22:09:32 +0800 Subject: [PATCH] opt some --- base/cli/runtime.go | 2 +- base/web/dream.go | 12 +++++------- base/web/spide.go | 3 ++- conf.go | 7 ++++--- core/chat/macos/applications.go | 3 ++- core/chat/macos/desktop.go | 8 ++------ core/chat/macos/macos.go | 5 ++++- core/wiki/draw.go | 3 +-- misc/git/search.go | 14 ++++++-------- 9 files changed, 27 insertions(+), 30 deletions(-) diff --git a/base/cli/runtime.go b/base/cli/runtime.go index c4267462..34f01c2f 100644 --- a/base/cli/runtime.go +++ b/base/cli/runtime.go @@ -253,7 +253,7 @@ func init() { m.Echo("%v", string(buf)) }}, "upgrade": {Help: "升级", Hand: func(m *ice.Message, arg ...string) { - if nfs.Exists(m, ".git") { + if nfs.Exists(m, ".git") && SystemFind(m, "go") != "" { m.Cmdy("web.code.compile") } else { m.Cmdy("web.code.upgrade") diff --git a/base/web/dream.go b/base/web/dream.go index 0a636887..f9e125f8 100644 --- a/base/web/dream.go +++ b/base/web/dream.go @@ -71,7 +71,7 @@ func _dream_start(m *ice.Message, name string) { cli.CTX_ROOT, kit.Path(""), cli.PATH, cli.BinPath(p, ""), cli.USER, ice.Info.Username, )...), cli.CMD_OUTPUT, path.Join(p, ice.VAR_LOG_BOOT_LOG), mdb.CACHE_CLEAR_ONEXIT, ice.TRUE) gdb.Event(m, DREAM_CREATE, m.OptionSimple(mdb.NAME, mdb.TYPE, cli.CMD_DIR)) - kit.If(m.Option(nfs.BINARY) == "", func(p string) { m.Option(nfs.BINARY, SpideOrigin(m, ice.DEV)+S(name)) }) + kit.If(m.Option(nfs.BINARY) == "" && cli.SystemFind(m, "go") == "", func(p string) { m.Option(nfs.BINARY, SpideOrigin(m, ice.DEV_IP)+S(name)) }) kit.If(m.Option(nfs.BINARY), func(p string) { _dream_binary(m, p) }) kit.If(m.Option(nfs.TEMPLATE), func(p string) { _dream_template(m, p) }) bin := kit.Select(kit.Path(os.Args[0]), cli.SystemFind(m, ice.ICE_BIN, nfs.PWD+path.Join(p, ice.BIN), nfs.PWD+ice.BIN)) @@ -156,10 +156,9 @@ func init() { m.Cmd(gdb.EVENT, gdb.LISTEN, gdb.EVENT, DREAM_TABLES, ice.CMD, cmd) m.Cmd(gdb.EVENT, gdb.LISTEN, gdb.EVENT, DREAM_ACTION, ice.CMD, cmd) } + aaa.White(m, kit.Keys(m.PrefixKey(), ctx.ACTION, DREAM_ACTION, ctx.RUN)) }}, - html.BUTTON: {Hand: func(m *ice.Message, arg ...string) { - mdb.Config(m, html.BUTTON, kit.Join(arg)) - }}, + html.BUTTON: {Hand: func(m *ice.Message, arg ...string) { mdb.Config(m, html.BUTTON, kit.Join(arg)) }}, mdb.SEARCH: {Hand: func(m *ice.Message, arg ...string) { if mdb.IsSearchPreview(m, arg) { mdb.HashSelects(m.Spawn()).Table(func(value ice.Maps) { m.PushSearch(mdb.TYPE, WORKER, mdb.TEXT, m.MergePod(value[mdb.NAME]), value) }) @@ -251,8 +250,7 @@ func init() { }}, FOR_FLOW: {Name: "forFlow name cmd*='sh etc/miss.sh'", Help: "流程", Icon: "bi bi-terminal", Hand: func(m *ice.Message, arg ...string) { m.Options(ctx.DISPLAY, PLUGIN_XTERM, cli.CMD_OUTPUT, nfs.NewWriteCloser(func(buf []byte) (int, error) { - m.Option(ice.MSG_COUNT, "0") - PushNoticeGrow(m, strings.ReplaceAll(string(buf), lex.NL, "\r\n")) + PushNoticeGrow(m.Options(ice.MSG_COUNT, "0"), strings.ReplaceAll(string(buf), lex.NL, "\r\n")) return len(buf), nil }, func() error { return nil })) msg := mdb.HashSelects(m.Spawn(), m.Option(mdb.NAME)) @@ -278,7 +276,7 @@ func init() { }).StatusTimeCount(m.OptionSimple(nfs.FILE)) }}, cli.START: {Hand: func(m *ice.Message, arg ...string) { - gdb.Event(m, DREAM_START, arg) + defer gdb.Event(m, DREAM_START, arg) _dream_start(m, m.Option(mdb.NAME)) }}, cli.STOP: {Hand: func(m *ice.Message, arg ...string) { diff --git a/base/web/spide.go b/base/web/spide.go index a02ec75d..c943b953 100644 --- a/base/web/spide.go +++ b/base/web/spide.go @@ -418,7 +418,8 @@ func SpideDelete(m *ice.Message, arg ...ice.Any) ice.Any { return kit.UnMarshal(m.Cmdx(http.MethodDelete, arg)) } func SpideSave(m *ice.Message, file, link string, cb func(count, total, value int)) *ice.Message { - return m.Cmd(Prefix(SPIDE), ice.DEV, SPIDE_SAVE, file, http.MethodGet, link, cb) + return m.Cmd(Prefix(SPIDE), ice.DEV_IP, SPIDE_SAVE, file, http.MethodGet, link, cb) + // return m.Cmd(Prefix(SPIDE), ice.DEV, SPIDE_SAVE, file, http.MethodGet, link, cb) } func SpideCache(m *ice.Message, link string) *ice.Message { return m.Cmd(Prefix(SPIDE), ice.DEV, SPIDE_CACHE, http.MethodGet, link) diff --git a/conf.go b/conf.go index d3a123f5..52826dda 100644 --- a/conf.go +++ b/conf.go @@ -36,9 +36,10 @@ const ( CORE = "core" MISC = "misc" - SHY = "shy" - DEV = "dev" - OPS = "ops" + SHY = "shy" + DEV = "dev" + DEV_IP = "dev_ip" + OPS = "ops" ICE = "ice" CAN = "can" diff --git a/core/chat/macos/applications.go b/core/chat/macos/applications.go index cec316b3..b8f8298c 100644 --- a/core/chat/macos/applications.go +++ b/core/chat/macos/applications.go @@ -4,6 +4,7 @@ import ( "path" ice "shylinux.com/x/icebergs" + "shylinux.com/x/icebergs/base/aaa" "shylinux.com/x/icebergs/base/ctx" "shylinux.com/x/icebergs/base/mdb" "shylinux.com/x/icebergs/base/nfs" @@ -16,7 +17,7 @@ const APPLICATIONS = "applications" func init() { Index.MergeCommands(ice.Commands{ - APPLICATIONS: {Help: "应用", Actions: ice.MergeActions(ice.Actions{ + APPLICATIONS: {Help: "应用", Role: aaa.VOID, Actions: ice.MergeActions(ice.Actions{ ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { FinderAppend(m, APPLICATIONS, m.PrefixKey()) }}, code.INSTALL: {Hand: func(m *ice.Message, arg ...string) { AppInstall(m, arg[0], arg[1]) }}, mdb.CREATE: {Name: "create space index args name icon"}, diff --git a/core/chat/macos/desktop.go b/core/chat/macos/desktop.go index 8415b810..008b6036 100644 --- a/core/chat/macos/desktop.go +++ b/core/chat/macos/desktop.go @@ -44,12 +44,8 @@ func init() { Notify(m, "Infomation.png", cli.RUNTIME, "系统启动成功", ctx.INDEX, cli.RUNTIME) }}, DESKTOP: {Help: "应用桌面", Role: aaa.VOID, Actions: ice.MergeActions(ice.Actions{ - web.DREAM_TABLES: {Hand: func(m *ice.Message, arg ...string) { - m.PushButton(kit.Dict(m.CommandKey(), "桌面")) - }}, - web.DREAM_ACTION: {Hand: func(m *ice.Message, arg ...string) { - web.DreamProcess(m, nil, arg...) - }}, + web.DREAM_TABLES: {Hand: func(m *ice.Message, arg ...string) { m.PushButton(kit.Dict(m.CommandKey(), "桌面")) }}, + web.DREAM_ACTION: {Hand: func(m *ice.Message, arg ...string) { web.DreamProcess(m, nil, arg...) }}, }, PodCmdAction(), CmdHashAction(), mdb.ExportHashAction())}, }) } diff --git a/core/chat/macos/macos.go b/core/chat/macos/macos.go index 98e381a7..80aa6542 100644 --- a/core/chat/macos/macos.go +++ b/core/chat/macos/macos.go @@ -24,7 +24,7 @@ func Prefix(arg ...string) string { return chat.Prefix(MACOS, kit.Keys(arg)) } func disableApp(m *ice.Message) *ice.Message { m.Table(func(value ice.Maps) { - switch ctx.ShortCmd(value[ctx.INDEX]) { + switch index := ctx.ShortCmd(value[ctx.INDEX]); index { case web.DREAM, web.CODE_GIT_SEARCH: if ice.Info.NodeType == web.WORKER { m.Push(mdb.STATUS, mdb.DISABLE) @@ -41,6 +41,9 @@ func disableApp(m *ice.Message) *ice.Message { m.Push(mdb.STATUS, mdb.DISABLE) return } + default: + m.Push(mdb.STATUS, kit.Select(mdb.DISABLE, mdb.ENABLE, aaa.Right(m.Spawn(), index))) + return } m.Push(mdb.STATUS, mdb.ENABLE) }) diff --git a/core/wiki/draw.go b/core/wiki/draw.go index 8ec81b72..d68d06af 100644 --- a/core/wiki/draw.go +++ b/core/wiki/draw.go @@ -4,7 +4,6 @@ import ( "path" ice "shylinux.com/x/icebergs" - "shylinux.com/x/icebergs/base/aaa" "shylinux.com/x/icebergs/base/lex" "shylinux.com/x/icebergs/base/mdb" "shylinux.com/x/icebergs/base/nfs" @@ -14,7 +13,7 @@ const DRAW = "draw" func init() { Index.MergeCommands(ice.Commands{ - DRAW: {Name: "draw path=src/main.svg pid list save actions", Help: "思维导图", Icon: "Grapher.png", Role: aaa.VOID, Actions: ice.MergeActions(ice.Actions{ + DRAW: {Name: "draw path=src/main.svg pid list save actions", Help: "思维导图", Icon: "Grapher.png", Actions: ice.MergeActions(ice.Actions{ ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { m.Cmd(mdb.RENDER, mdb.CREATE, mdb.Config(m, lex.REGEXP), m.PrefixKey()) }}, diff --git a/misc/git/search.go b/misc/git/search.go index 30b787b7..d7f7c227 100644 --- a/misc/git/search.go +++ b/misc/git/search.go @@ -29,14 +29,12 @@ func init() { ) const SEARCH = "search" Index.MergeCommands(ice.Commands{ - SEARCH: {Name: "search keyword auto", Help: "源码库", Actions: ice.MergeActions(ice.Actions{ - ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { - macos.AppInstall(m, "App Store.png", m.PrefixKey()) - }}, - cli.START: {Name: "start name*", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(web.DREAM, mdb.CREATE); m.Cmdy(web.DREAM, cli.START) }}, - CLONE: {Name: "clone name*", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(REPOS, CLONE, m.Option(REPOS)) }}, - HTML_URL: {Help: "源码", Hand: func(m *ice.Message, arg ...string) { m.ProcessOpen(m.Option(HTML_URL)) }}, - WEBSITE: {Help: "官网", Hand: func(m *ice.Message, arg ...string) { m.ProcessOpen(m.Option(WEBSITE)) }}, + SEARCH: {Name: "search keyword auto", Help: "源码库", Role: aaa.VOID, Actions: ice.MergeActions(ice.Actions{ + ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { macos.AppInstall(m, "App Store.png", m.PrefixKey()) }}, + cli.START: {Name: "start name*", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(web.DREAM, mdb.CREATE); m.Cmdy(web.DREAM, cli.START) }}, + CLONE: {Name: "clone name*", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(REPOS, CLONE, m.Option(REPOS)) }}, + HTML_URL: {Help: "源码", Hand: func(m *ice.Message, arg ...string) { m.ProcessOpen(m.Option(HTML_URL)) }}, + WEBSITE: {Help: "官网", Hand: func(m *ice.Message, arg ...string) { m.ProcessOpen(m.Option(WEBSITE)) }}, ORIGIN: {Help: "平台", Icon: "bi bi-box-arrow-up-right", Hand: func(m *ice.Message, arg ...string) { m.ProcessOpen(web.SpideOrigin(m, REPOS) + EXPLORE_REPOS) }},