From 3c9db97ffad8884b71d0f381e110eabc11a1712e Mon Sep 17 00:00:00 2001 From: shy Date: Wed, 10 Jan 2024 13:31:25 +0800 Subject: [PATCH] add some --- base/web/dream.go | 20 +++++++++++--------- base/web/space.go | 1 + core/chat/header.go | 2 +- core/chat/iframe.go | 2 +- core/chat/pod.go | 2 +- core/chat/portal.go | 13 ++++++++++++- misc/git/repos.go | 6 ++---- 7 files changed, 29 insertions(+), 17 deletions(-) diff --git a/base/web/dream.go b/base/web/dream.go index 648f6b35..2ab113ee 100644 --- a/base/web/dream.go +++ b/base/web/dream.go @@ -18,6 +18,7 @@ import ( "shylinux.com/x/icebergs/base/mdb" "shylinux.com/x/icebergs/base/nfs" "shylinux.com/x/icebergs/base/tcp" + "shylinux.com/x/icebergs/base/web/html" kit "shylinux.com/x/toolkits" ) @@ -149,13 +150,14 @@ func init() { m.Cmd(DREAM, cli.START, kit.Dict(mdb.NAME, value[mdb.NAME])) } }) + for _, cmd := range kit.Reverse(kit.Split(mdb.Config(m, html.BUTTON))) { + 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) + } }) }}, - ctx.CONFIG: {Hand: func(m *ice.Message, arg ...string) { - for _, cmd := range kit.Reverse(arg) { - 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) - } + 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) { @@ -315,10 +317,10 @@ func init() { PushStats(m, kit.Keys(m.CommandKey(), mdb.TOTAL), msg.Length(), "", "已启动空间") } }}, - }, StatsAction(), DreamAction(), mdb.ImportantHashAction(ctx.TOOLS, "web.code.git.search,route", mdb.SHORT, mdb.NAME, mdb.FIELD, "time,name,icon,repos,binary,template,restart")), Hand: func(m *ice.Message, arg ...string) { - if ice.Info.NodeType == WORKER { - return - } else if len(arg) == 0 { + }, StatsAction(), DreamAction(), mdb.ImportantHashAction( + html.BUTTON, "web.wiki.portal web.chat.portal web.chat.macos.desktop web.code.git.status web.code.vimer web.code.xterm web.code.compile", + ctx.TOOLS, "web.code.git.search,route", mdb.SHORT, mdb.NAME, mdb.FIELD, "time,name,icon,repos,binary,template,restart")), Hand: func(m *ice.Message, arg ...string) { + if len(arg) == 0 { _dream_list(m).RewriteAppend(func(value, key string, index int) string { if key == mdb.ICON { if kit.HasPrefix(value, HTTP, nfs.PS) { diff --git a/base/web/space.go b/base/web/space.go index cc675542..bcb54f25 100644 --- a/base/web/space.go +++ b/base/web/space.go @@ -192,6 +192,7 @@ func _space_exec(m *ice.Message, name string, source, target []string, c *websoc m.OptionDefault(ice.MSG_COUNT, "0") m.Option(ice.MSG_DAEMON, kit.Keys(kit.Slice(kit.Reverse(kit.Simple(source)), 0, -1), m.Option(ice.MSG_DAEMON))) kit.If(aaa.Right(m, m.Detailv()), func() { m.TryCatch(true, func(_ *ice.Message) { m = m.Cmd() }) }) + kit.If(m.Optionv(ice.MSG_ARGS) != nil, func() { m.Options(ice.MSG_ARGS, kit.Simple(m.Optionv(ice.MSG_ARGS))) }) } defer m.Cost(kit.Format("%v->%v %v %v", source, target, m.Detailv(), m.FormatSize())) _space_echo(m.Set(ice.MSG_OPTS).Options(log.DEBUG, m.Option(log.DEBUG)), []string{}, kit.Reverse(kit.Simple(source)), c) diff --git a/core/chat/header.go b/core/chat/header.go index 691a5116..f4196939 100644 --- a/core/chat/header.go +++ b/core/chat/header.go @@ -80,7 +80,7 @@ func init() { aaa.BACKGROUND: {Hand: _header_users}, aaa.THEME: {Hand: func(m *ice.Message, arg ...string) { if tcp.IsLocalHost(m, m.Option(ice.MSG_USERIP)) { - m.Cmd(cli.SYSTEM, "osascript", "-e", `tell app "System Events" to tell appearance preferences to set dark mode to `+ + cli.TellApp(m, "System Events", `tell appearance preferences to set dark mode to `+ kit.Select(ice.TRUE, ice.FALSE, kit.IsIn(kit.Select(html.LIGHT, arg, 0), html.LIGHT, html.WHITE))) } }}, diff --git a/core/chat/iframe.go b/core/chat/iframe.go index 9562f49d..7a80aef0 100644 --- a/core/chat/iframe.go +++ b/core/chat/iframe.go @@ -87,7 +87,7 @@ func init() { } m.Append(web.LINK, arg[0]) }) - m.Action(web.FULL, web.OPEN, ice.APP).StatusTime(m.AppendSimple(web.LINK)) + m.StatusTime(m.AppendSimple(web.LINK)) ctx.DisplayLocal(m, "") } }}, diff --git a/core/chat/pod.go b/core/chat/pod.go index e4f70e8d..41194e4c 100644 --- a/core/chat/pod.go +++ b/core/chat/pod.go @@ -46,7 +46,7 @@ func init() { m.Cmdy(web.SPACE, arg[0], web.SPACE, ice.MAIN) } else if kit.IsIn(arg[1], CMD, "c") { if arg[2] == web.CHAT_PORTAL { - m.Cmdy(web.SPACE, arg[0], web.SPACE, ice.MAIN) + m.Cmdy(web.SPACE, arg[0], arg[2]) } else { web.RenderPodCmd(m, arg[0], arg[2], arg[3:]) } diff --git a/core/chat/portal.go b/core/chat/portal.go index 4caf3c20..3012d190 100644 --- a/core/chat/portal.go +++ b/core/chat/portal.go @@ -2,13 +2,24 @@ package chat import ( ice "shylinux.com/x/icebergs" + "shylinux.com/x/icebergs/base/ctx" + "shylinux.com/x/icebergs/base/mdb" "shylinux.com/x/icebergs/base/web" + kit "shylinux.com/x/toolkits" ) const PORTAL = "portal" func init() { Index.MergeCommands(ice.Commands{ - PORTAL: {Help: "门户", Actions: web.ApiAction(), Hand: func(m *ice.Message, arg ...string) { web.RenderMain(m) }}, + PORTAL: {Help: "门户", Actions: ice.MergeActions(ice.Actions{ + web.DREAM_TABLES: {Hand: func(m *ice.Message, arg ...string) { m.PushButton(kit.Dict(web.ADMIN, "后台")) }}, + web.DREAM_ACTION: {Hand: func(m *ice.Message, arg ...string) { + if kit.HasPrefixList(arg, ctx.ACTION, web.ADMIN) && len(arg) == 2 { + ctx.ProcessField(m, web.CHAT_IFRAME, m.MergePodCmd(m.Option(mdb.NAME), m.PrefixKey()), arg...) + m.ProcessField(ctx.ACTION, ctx.RUN, web.CHAT_IFRAME) + } + }}, + }, web.ApiAction()), Hand: func(m *ice.Message, arg ...string) { web.RenderMain(m) }}, }) } diff --git a/misc/git/repos.go b/misc/git/repos.go index 2c484d3a..1e18a638 100644 --- a/misc/git/repos.go +++ b/misc/git/repos.go @@ -615,12 +615,10 @@ func init() { kit.If(m.Option(REPOS), func(p string) { p = strings.Split(p, mdb.QS)[0] kit.If(!strings.Contains(p, "://"), func() { p = kit.MergeURL2(web.UserHost(m), web.X(p)) }) - m.Cmd("", CLONE, ORIGIN, p, nfs.PATH, m.Option(cli.CMD_DIR), ice.Maps{cli.CMD_DIR: ""}) + m.Cmd("", CLONE, ORIGIN, p, nfs.PATH, path.Join(ice.USR_LOCAL_WORK, m.Option(mdb.NAME)), ice.Maps{cli.CMD_DIR: ""}) }) }}, - web.DREAM_TRASH: {Hand: func(m *ice.Message, arg ...string) { - m.Cmd("", mdb.REMOVE, kit.Dict(REPOS, m.Option(mdb.NAME))) - }}, + web.DREAM_TRASH: {Hand: func(m *ice.Message, arg ...string) { m.Cmd("", mdb.REMOVE, kit.Dict(REPOS, m.Option(mdb.NAME))) }}, web.SPACE_OPEN: {Hand: func(m *ice.Message, arg ...string) { if m.Option(mdb.TYPE) == web.SERVER { m.Cmd(web.DREAM).Table(func(value ice.Maps) {