From 53b67068639ce2b7afda017f91c3b26262ee96cb Mon Sep 17 00:00:00 2001 From: shy Date: Wed, 17 Jan 2024 22:46:59 +0800 Subject: [PATCH] add some --- base/aaa/role.go | 6 ++++++ base/web/admin.go | 4 +++- base/web/dream.go | 5 +++++ base/web/space.go | 4 +++- core/chat/macos/desktop.go | 3 ++- core/chat/macos/desktop.js | 2 +- core/chat/macos/session.go | 3 ++- core/code/vimer.go | 1 + core/code/xterm.go | 5 ++++- core/wiki/portal.go | 1 + core/wiki/word.go | 1 + misc/git/status.go | 1 + 12 files changed, 30 insertions(+), 6 deletions(-) diff --git a/base/aaa/role.go b/base/aaa/role.go index 3fdcd575..8f8bb043 100644 --- a/base/aaa/role.go +++ b/base/aaa/role.go @@ -27,6 +27,9 @@ func _role_black(m *ice.Message, role, key string) { _role_set(m, role, BLACK, k func _role_check(value ice.Map, key []string, ok bool) bool { white, black := value[WHITE].(ice.Map), value[BLACK].(ice.Map) for i := 0; i < len(key); i++ { + ice.Pulse.Info("debug what %v", kit.Join(key[:i+1], ice.PT)) + ice.Pulse.Info("debug what %v", white[kit.Join(key[:i+1], ice.PT)]) + ice.Pulse.Info("debug what %v", black[kit.Join(key[:i+1], ice.PT)]) kit.If(white[kit.Join(key[:i+1], ice.PT)], func() { ok = true }) kit.If(black[kit.Join(key[:i+1], ice.PT)], func() { ok = false }) } @@ -164,3 +167,6 @@ func Right(m *ice.Message, key ...ice.Any) bool { return m.Option(ice.MSG_USERROLE) == ROOT || !m.Warn(m.Cmdx(ROLE, RIGHT, m.Option(ice.MSG_USERROLE), key, logs.FileLineMeta(-1)) != ice.OK, ice.ErrNotRight, kit.Keys(key...), USERROLE, m.Option(ice.MSG_USERROLE), logs.FileLineMeta(-1)) } +func IsTechOrRoot(m *ice.Message) bool { + return kit.IsIn(m.Option(ice.MSG_USERROLE), TECH, ROOT) +} diff --git a/base/web/admin.go b/base/web/admin.go index a279c3d0..b4890f03 100644 --- a/base/web/admin.go +++ b/base/web/admin.go @@ -5,6 +5,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" kit "shylinux.com/x/toolkits" @@ -14,7 +15,8 @@ const ADMIN = "admin" func init() { Index.MergeCommands(ice.Commands{ - ADMIN: {Name: "admin index list", Help: "管理", Actions: ice.Actions{ + ADMIN: {Name: "admin index list", Help: "管理", Role: aaa.VOID, Actions: ice.Actions{ + ice.CTX_INIT: {Hand: DreamWhiteHandle}, DREAM_TABLES: {Hand: func(m *ice.Message, arg ...string) { m.PushButton(kit.Dict(ADMIN, "后台")) }}, DREAM_ACTION: {Hand: func(m *ice.Message, arg ...string) { if kit.HasPrefixList(arg, ctx.ACTION, ADMIN) && len(arg) == 2 { diff --git a/base/web/dream.go b/base/web/dream.go index be40371e..d15fb4ae 100644 --- a/base/web/dream.go +++ b/base/web/dream.go @@ -437,3 +437,8 @@ func DreamEach(m *ice.Message, name string, status string, cb func(string)) *ice func DreamList(m *ice.Message) *ice.Message { return m.SplitIndex(AdminCmd(m, DREAM)) } +func DreamWhiteHandle(m *ice.Message, arg ...string) { + aaa.White(m, kit.Keys(DREAM, ctx.ACTION, m.CommandKey())) + aaa.White(m, kit.Keys(DREAM, ctx.ACTION, m.PrefixKey())) + aaa.White(m, kit.Keys(ctx.ShortCmd(m.PrefixKey()), ctx.ACTION, DREAM_ACTION)) +} diff --git a/base/web/space.go b/base/web/space.go index 16ce1bc0..75e98d8d 100644 --- a/base/web/space.go +++ b/base/web/space.go @@ -278,7 +278,9 @@ func init() { kit.If(kit.IsIn(value[mdb.TYPE], WORKER, SERVER), func() { m.Push(arg[0], value[mdb.NAME]) }) }) case ORIGIN: - m.Cmdy(SPIDE, kit.Dict(ice.MSG_FIELDS, CLIENT_ORIGIN)).CutTo(CLIENT_ORIGIN, arg[0]).Sort(arg[0]) + m.SetAppend() + m.Push(arg[0], SpideOrigin(m, ice.DEV)) + m.Copy(m.Cmd(SPIDE, kit.Dict(ice.MSG_FIELDS, CLIENT_ORIGIN)).CutTo(CLIENT_ORIGIN, arg[0]).Sort(arg[0])) case mdb.ICONS: m.Options(nfs.DIR_REG, kit.ExtReg(nfs.PNG, nfs.JPG, nfs.JPEG), nfs.DIR_DEEP, ice.TRUE) m.Cmdy(nfs.DIR, nfs.SRC, nfs.PATH) diff --git a/core/chat/macos/desktop.go b/core/chat/macos/desktop.go index 008b6036..87babf42 100644 --- a/core/chat/macos/desktop.go +++ b/core/chat/macos/desktop.go @@ -41,9 +41,10 @@ func init() { AppInstall(m, cmd.Icon, m.PrefixKey()) }) }) - Notify(m, "Infomation.png", cli.RUNTIME, "系统启动成功", ctx.INDEX, cli.RUNTIME) + Notify(m, "usr/icons/Infomation.png", cli.RUNTIME, "系统启动成功", ctx.INDEX, cli.RUNTIME) }}, DESKTOP: {Help: "应用桌面", Role: aaa.VOID, Actions: ice.MergeActions(ice.Actions{ + ice.CTX_INIT: {Hand: web.DreamWhiteHandle}, 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/desktop.js b/core/chat/macos/desktop.js index 11b80b59..4e26e626 100644 --- a/core/chat/macos/desktop.js +++ b/core/chat/macos/desktop.js @@ -9,7 +9,7 @@ Volcanos(chat.ONIMPORT, { var tabs = can.misc.sessionStorage(can, [can.ConfIndex(), html.TABS]) sub.onexport.output = function() { can.onimport._desktop(can, can._msg) var sess = can.misc.SearchHash(can)[0]||can.Conf("session") - sess? can.runActionCommand(event, "session", [sess], function(msg) { + sess? can.runActionCommand(event, "web.chat.macos.session", [sess], function(msg) { var item = msg.TableDetail(); can.onimport.session(can, can.base.Obj(item.args)) }): !window.parent && can.isCmdMode() && can.onimport.session(can, tabs) } diff --git a/core/chat/macos/session.go b/core/chat/macos/session.go index 16ec2097..4a84716a 100644 --- a/core/chat/macos/session.go +++ b/core/chat/macos/session.go @@ -2,6 +2,7 @@ package macos import ( ice "shylinux.com/x/icebergs" + "shylinux.com/x/icebergs/base/aaa" "shylinux.com/x/icebergs/base/mdb" ) @@ -9,7 +10,7 @@ const SESSION = "session" func init() { Index.MergeCommands(ice.Commands{ - SESSION: {Help: "会话", Actions: ice.MergeActions(CmdHashAction(mdb.NAME), mdb.ExportHashAction()), Hand: func(m *ice.Message, arg ...string) { + SESSION: {Help: "会话", Role: aaa.VOID, Actions: ice.MergeActions(CmdHashAction(mdb.NAME), mdb.ExportHashAction()), Hand: func(m *ice.Message, arg ...string) { if mdb.HashSelect(m, arg...); len(arg) > 0 { m.EchoIFrame(m.MergePodCmd("", DESKTOP) + "#" + m.Append(mdb.NAME)) } diff --git a/core/code/vimer.go b/core/code/vimer.go index 3006d331..0f05c1eb 100644 --- a/core/code/vimer.go +++ b/core/code/vimer.go @@ -202,6 +202,7 @@ func init() { kit.If(m.Option(mdb.TYPE) == nfs.FILE, func() { m.Push(arg[0], ice.SRC_MAIN_SHY, ice.SRC_MAIN_GO, ice.SRC_MAIN_JS) }) } }}, + ice.CTX_INIT: {Hand: web.DreamWhiteHandle}, chat.FAVOR_TABLES: {Hand: func(m *ice.Message, arg ...string) { kit.If(m.Option(mdb.TYPE) == nfs.FILE, func() { m.PushButton(kit.Dict(m.CommandKey(), "源码")) }) }}, diff --git a/core/code/xterm.go b/core/code/xterm.go index 80f3be80..561dbef2 100644 --- a/core/code/xterm.go +++ b/core/code/xterm.go @@ -6,6 +6,7 @@ import ( "strings" ice "shylinux.com/x/icebergs" + "shylinux.com/x/icebergs/base/aaa" "shylinux.com/x/icebergs/base/cli" "shylinux.com/x/icebergs/base/ctx" "shylinux.com/x/icebergs/base/lex" @@ -153,7 +154,9 @@ func init() { ctx.ProcessField(m, m.PrefixKey(), m.Cmdx("", mdb.CREATE, mdb.TYPE, m.Option(mdb.TEXT), mdb.NAME, m.Option(mdb.NAME), mdb.TEXT, "")) }) }}, - web.DREAM_TABLES: {Hand: func(m *ice.Message, arg ...string) { m.PushButton(kit.Dict(m.CommandKey(), "终端")) }}, + web.DREAM_TABLES: {Hand: func(m *ice.Message, arg ...string) { + kit.If(aaa.IsTechOrRoot(m), func() { m.PushButton(kit.Dict(m.CommandKey(), "终端")) }) + }}, web.DREAM_ACTION: {Hand: func(m *ice.Message, arg ...string) { web.DreamProcess(m, cli.Shell(m), arg...) }}, }, chat.FavorAction(), ctx.ProcessAction(), mdb.HashAction(mdb.FIELD, "time,hash,type,name,text,path")), Hand: func(m *ice.Message, arg ...string) { if mdb.HashSelect(m, arg...); len(arg) == 0 { diff --git a/core/wiki/portal.go b/core/wiki/portal.go index 1ce4e482..825de0f5 100644 --- a/core/wiki/portal.go +++ b/core/wiki/portal.go @@ -80,6 +80,7 @@ func init() { m.Copy(m.Spawn([]byte(m.Cmdx(nfs.CAT, p)))) } }}, + ice.CTX_INIT: {Hand: web.DreamWhiteHandle}, web.DREAM_TABLES: {Hand: func(m *ice.Message, arg ...string) { m.PushButton(kit.Dict(PORTAL, "官网")) }}, web.DREAM_ACTION: {Hand: func(m *ice.Message, arg ...string) { web.DreamProcess(m, nil, arg...) }}, }, aaa.WhiteAction("")), Hand: func(m *ice.Message, arg ...string) { diff --git a/core/wiki/word.go b/core/wiki/word.go index 3decd1d3..53375e87 100644 --- a/core/wiki/word.go +++ b/core/wiki/word.go @@ -36,6 +36,7 @@ func init() { WordAlias(m, LABEL, CHART, LABEL) WordAlias(m, CHAIN, CHART, CHAIN) WordAlias(m, SEQUENCE, CHART, SEQUENCE) + web.DreamWhiteHandle(m, arg...) }}, mdb.SEARCH: {Hand: func(m *ice.Message, arg ...string) { if mdb.IsSearchPreview(m, arg) { diff --git a/misc/git/status.go b/misc/git/status.go index e8f0894c..da17aadc 100644 --- a/misc/git/status.go +++ b/misc/git/status.go @@ -49,6 +49,7 @@ func init() { mdb.Config(m, aaa.USERNAME, m.Option(aaa.USERNAME)) mdb.Config(m, aaa.EMAIL, m.Option(aaa.EMAIL)) }}, + ice.CTX_INIT: {Hand: web.DreamWhiteHandle}, web.DREAM_TABLES: {Hand: func(m *ice.Message, arg ...string) { if !nfs.Exists(m, path.Join(ice.USR_LOCAL_WORK, m.Option(mdb.NAME), _GIT)) { m.Push(mdb.TEXT, "").PushButton(kit.Dict(m.CommandKey(), "源码"))