From d2e3cada57fae10ba72fd3c29d2145ac63c8ed2b Mon Sep 17 00:00:00 2001 From: shy Date: Wed, 3 Jan 2024 11:54:12 +0800 Subject: [PATCH] opt role --- base/aaa/aaa.go | 7 +--- base/aaa/email.go | 6 ++-- base/aaa/offer.go | 6 ++-- base/aaa/role.go | 65 +++++++++++++++++++++++++++----------- base/cli/qrcode.go | 4 +-- base/ctx/command.go | 4 +-- base/web/dream.go | 4 +-- base/web/share.go | 4 +-- base/web/stats.go | 1 + base/web/web.go | 2 +- core/chat/action.go | 2 +- core/chat/grant.go | 6 ++-- core/chat/macos/desktop.go | 4 +-- core/chat/macos/dock.go | 2 +- core/chat/macos/menu.go | 2 +- core/code/inner.go | 4 +-- core/code/publish.go | 6 ++-- core/code/vimer.go | 4 +-- core/mall/cart.go | 4 +-- core/mall/goods.go | 4 +-- core/mall/order.go | 4 +-- core/team/plan.go | 4 +-- core/wiki/draw.go | 4 +-- core/wiki/portal.go | 4 +-- core/wiki/word.go | 4 +-- misc/git/repos.go | 13 ++++++-- misc/git/service.go | 2 +- misc/git/status.go | 4 +-- misc/wx/access.go | 6 ++-- misc/wx/agent.go | 4 +-- misc/wx/login.go | 4 +-- misc/wx/pages.go | 2 +- type.go | 2 ++ 33 files changed, 116 insertions(+), 82 deletions(-) diff --git a/base/aaa/aaa.go b/base/aaa/aaa.go index 769927a9..a652499e 100644 --- a/base/aaa/aaa.go +++ b/base/aaa/aaa.go @@ -2,7 +2,6 @@ package aaa import ( ice "shylinux.com/x/icebergs" - "shylinux.com/x/icebergs/base/mdb" ) const ( @@ -13,10 +12,6 @@ const ( ) const AAA = "aaa" -var Index = &ice.Context{Name: AAA, Help: "认证模块", Commands: ice.Commands{ - ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { - ice.Info.Load(m).Cmd(ROLE, ice.CTX_INIT).Cmd(ROLE, mdb.CREATE, TECH, VOID) - }}, -}} +var Index = &ice.Context{Name: AAA, Help: "认证模块"} func init() { ice.Index.Register(Index, nil, APPLY, OFFER, EMAIL, USER, TOTP, SESS, ROLE, RSA) } diff --git a/base/aaa/email.go b/base/aaa/email.go index cf791f4c..4a9bb7b5 100644 --- a/base/aaa/email.go +++ b/base/aaa/email.go @@ -29,7 +29,7 @@ func init() { DF = ": " ) Index.MergeCommands(ice.Commands{ - EMAIL: {Help: "邮件", Actions: ice.MergeActions(ice.Actions{ + EMAIL: {Help: "邮件", Role: VOID, Actions: ice.MergeActions(ice.Actions{ mdb.CREATE: {Name: "create name*=admin service*='mail.shylinux.com:25' username*='shy@shylinux.com' password*"}, MAILBOX: {Help: "邮箱", Hand: func(m *ice.Message, arg ...string) { if p := mdb.Config(m, MAILBOX); !m.Warn(p == "", ice.ErrNotValid, MAILBOX) { @@ -47,9 +47,9 @@ func init() { auth := smtp.PlainAuth("", msg.Append(USERNAME), msg.Append(PASSWORD), kit.Split(msg.Append(SERVICE), ice.DF)[0]) m.Logs(EMAIL, SEND, string(content)).Warn(smtp.SendMail(msg.Append(SERVICE), auth, msg.Append(USERNAME), kit.Split(m.Option(TO)), content)) }}, - LOGIN: {Hand: func(m *ice.Message, arg ...string) { + LOGIN: {Role: VOID, Hand: func(m *ice.Message, arg ...string) { m.Echo("input email: ") }}, - }, RoleAction(LOGIN), mdb.HashAction(mdb.SHORT, mdb.NAME, mdb.FIELD, "time,name,service,username", ice.ACTION, SEND))}, + }, mdb.HashAction(mdb.SHORT, mdb.NAME, mdb.FIELD, "time,name,service,username", ice.ACTION, SEND))}, }) } diff --git a/base/aaa/offer.go b/base/aaa/offer.go index ef9d93c2..e0c21be2 100644 --- a/base/aaa/offer.go +++ b/base/aaa/offer.go @@ -15,14 +15,14 @@ const OFFER = "offer" func init() { Index.MergeCommands(ice.Commands{ - OFFER: {Help: "邀请", Actions: ice.MergeActions(ice.Actions{ + OFFER: {Help: "邀请", Role: VOID, Actions: ice.MergeActions(ice.Actions{ mdb.CREATE: {Name: "create email*='shy@shylinux.com' subject content", Help: "邀请", Hand: func(m *ice.Message, arg ...string) { h := mdb.HashCreate(m.Spawn(), m.OptionSimple(EMAIL, SUBJECT, CONTENT), INVITE, m.Option(ice.MSG_USERNAME), mdb.STATUS, INVITE) m.Cmd(EMAIL, SEND, m.Option(EMAIL), "", m.OptionDefault(SUBJECT, "welcome to contexts, please continue"), m.OptionDefault(CONTENT, ice.Render(m, ice.RENDER_ANCHOR, m.Cmdx("host", "publish", m.MergePodCmd("", "", mdb.HASH, h)))), ) }}, - ACCEPT: {Help: "接受", Hand: func(m *ice.Message, arg ...string) { + ACCEPT: {Help: "接受", Role: VOID, Hand: func(m *ice.Message, arg ...string) { if m.Warn(m.Option(mdb.HASH) == "", ice.ErrNotValid, mdb.HASH) { return } @@ -33,7 +33,7 @@ func init() { mdb.HashModify(m, m.OptionSimple(mdb.HASH), mdb.STATUS, ACCEPT) } }}, - }, RoleAction(ACCEPT), mdb.ImportantHashAction(mdb.SHORT, mdb.UNIQ, mdb.FIELD, "time,hash,status,invite,email,title,content")), Hand: func(m *ice.Message, arg ...string) { + }, mdb.ImportantHashAction(mdb.SHORT, mdb.UNIQ, mdb.FIELD, "time,hash,status,invite,email,title,content")), Hand: func(m *ice.Message, arg ...string) { if !m.Warn(len(arg) == 0 && m.Option(ice.MSG_USERROLE) == VOID, ice.ErrNotRight) { kit.If(mdb.HashSelect(m, arg...).FieldsIsDetail(), func() { m.PushAction(ACCEPT) }) } diff --git a/base/aaa/role.go b/base/aaa/role.go index 06d7f8ae..3fdcd575 100644 --- a/base/aaa/role.go +++ b/base/aaa/role.go @@ -71,7 +71,22 @@ const ROLE = "role" func init() { Index.MergeCommands(ice.Commands{ - ROLE: {Name: "role role key auto insert filter:text", Help: "角色", Actions: ice.MergeActions(ice.Actions{ + ROLE: {Name: "role role key auto insert filter:text simple", Help: "角色", Actions: ice.MergeActions(ice.Actions{ + ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { + m.Cmd(ROLE, mdb.CREATE, VOID, TECH) + has := map[string]bool{VOID: true, TECH: true} + m.Travel(func(p *ice.Context, c *ice.Context, key string, cmd *ice.Command) { + role := map[string][]string{} + kit.For(kit.Split(cmd.Role), func(k string) { role[k] = []string{} }) + for sub, action := range cmd.Actions { + kit.For(kit.Split(action.Role), func(k string) { role[k] = append(role[k], sub) }) + } + kit.For(role, func(role string, list []string) { + kit.If(!has[role], func() { m.Cmd(ROLE, mdb.CREATE, role); has[role] = true }) + roleHandle(m, role, list...) + }) + }) + }}, mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) { switch arg[0] { case mdb.KEY: @@ -83,7 +98,7 @@ func init() { mdb.Rich(m, ROLE, nil, kit.Dict(mdb.NAME, role, BLACK, kit.Dict(), WHITE, kit.Dict())) }) }}, - mdb.INSERT: {Name: "insert role*=void,tech zone*=white,black key*", Hand: func(m *ice.Message, arg ...string) { + mdb.INSERT: {Name: "insert role*=void zone*=white,black key*", Hand: func(m *ice.Message, arg ...string) { _role_set(m, m.Option(ROLE), m.Option(mdb.ZONE), m.Option(mdb.KEY), true) }}, mdb.DELETE: {Hand: func(m *ice.Message, arg ...string) { @@ -94,30 +109,44 @@ func init() { RIGHT: {Hand: func(m *ice.Message, arg ...string) { kit.If(_role_right(m, arg[0], kit.Split(_role_keys(arg[1:]...), ice.PT)...), func() { m.Echo(ice.OK) }) }}, - "whiteblack": {Hand: func(m *ice.Message, arg ...string) { - kit.For(arg, func(cmd string) { m.Cmd(ROLE, WHITE, VOID, cmd); m.Cmd(ROLE, BLACK, VOID, cmd, ice.ACTION) }) + "simple": {Hand: func(m *ice.Message, arg ...string) { + list := map[string][]string{} + m.Cmd("", func(value ice.Maps) { + if value[mdb.ZONE] == WHITE { + if strings.Contains(value[mdb.KEY], ".action.") { + ls := strings.Split(value[mdb.KEY], ".action.") + list[ls[0]] = append(list[ls[0]], ls[1]) + } else { + list[value[mdb.KEY]] = []string{} + } + } + }) + kit.For(list, func(cmd string, action []string) { + m.Push(ice.CMD, cmd).Push("actions", kit.Join(action)) + }) }}, }, mdb.HashAction(mdb.SHORT, mdb.NAME)), Hand: func(m *ice.Message, arg ...string) { _role_list(m, kit.Select("", arg, 0), kit.Slice(arg, 1)...).PushAction(mdb.DELETE) }}, }) } -func RoleAction(key ...string) ice.Actions { - return ice.Actions{ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { - cmd := m.PrefixKey() - if c, ok := ice.Info.Index[m.CommandKey()].(*ice.Context); ok && c == m.Target() { - cmd = m.CommandKey() - } - m.Cmd(ROLE, WHITE, VOID, cmd) - m.Cmd(ROLE, BLACK, VOID, cmd, ice.ACTION) - kit.For(key, func(key string) { m.Cmd(ROLE, WHITE, VOID, cmd, ice.ACTION, key) }) - }}} +func roleHandle(m *ice.Message, role string, key ...string) { + role = kit.Select(VOID, role) + cmd := m.PrefixKey() + if c, ok := ice.Info.Index[m.CommandKey()].(*ice.Context); ok && c == m.Target() { + cmd = m.CommandKey() + } + m.Cmd(ROLE, WHITE, role, cmd) + m.Cmd(ROLE, BLACK, role, cmd, ice.ACTION) + kit.For(key, func(key string) { m.Cmd(ROLE, WHITE, role, cmd, ice.ACTION, key) }) } -func WhiteAction(key ...string) ice.Actions { +func WhiteAction(role string, key ...string) ice.Actions { + role = kit.Select(VOID, role) return ice.Actions{ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { - m.Cmd(ROLE, WHITE, VOID, m.CommandKey()) - m.Cmd(ROLE, BLACK, VOID, m.CommandKey(), ice.ACTION) - kit.For(key, func(key string) { m.Cmd(ROLE, WHITE, VOID, m.CommandKey(), ice.ACTION, key) }) + cmd := m.CommandKey() + m.Cmd(ROLE, WHITE, role, cmd) + m.Cmd(ROLE, BLACK, role, cmd, ice.ACTION) + kit.For(key, func(key string) { m.Cmd(ROLE, WHITE, role, cmd, ice.ACTION, key) }) }}} } func White(m *ice.Message, key ...string) { diff --git a/base/cli/qrcode.go b/base/cli/qrcode.go index 8e0313da..e38b3f4e 100644 --- a/base/cli/qrcode.go +++ b/base/cli/qrcode.go @@ -49,7 +49,7 @@ const QRCODE = "qrcode" func init() { Index.MergeCommands(ice.Commands{ - QRCODE: {Name: "qrcode text fg@key bg@key size auto", Help: "二维码", Meta: kit.Dict( + QRCODE: {Name: "qrcode text fg@key bg@key size auto", Help: "二维码", Role: aaa.VOID, Meta: kit.Dict( ice.CTX_TRANS, kit.Dict(html.INPUT, kit.Dict( mdb.TEXT, "文本", BG, "背景色", FG, "字体色", )), @@ -65,7 +65,7 @@ func init() { m.Push(arg[0], BLACK, WHITE) } }}, - }, aaa.RoleAction()), Hand: func(m *ice.Message, arg ...string) { + }), Hand: func(m *ice.Message, arg ...string) { if m.IsCliUA() { m.OptionDefault(FG, BLACK, BG, WHITE) _qrcode_cli(m, kit.Select(kit.Select(ice.Info.Make.Domain, ice.Info.Domain), arg, 0)) diff --git a/base/ctx/command.go b/base/ctx/command.go index 4204bd20..9e14f1f2 100644 --- a/base/ctx/command.go +++ b/base/ctx/command.go @@ -75,7 +75,7 @@ const COMMAND = "command" func init() { Index.MergeCommands(ice.Commands{ - COMMAND: {Name: "command key auto", Help: "命令", Actions: ice.MergeActions(ice.Actions{ + COMMAND: {Name: "command key auto", Help: "命令", Role: aaa.VOID, Actions: ice.MergeActions(ice.Actions{ ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { TravelCmd(m, func(key, file, line string) { AddFileCmd(file, key) }) m.Travel(func(p *ice.Context, c *ice.Context, key string, cmd *ice.Command) { @@ -111,7 +111,7 @@ func init() { m.Echo(`%s %s %s;" f`+lex.NL, value[mdb.NAME], value[nfs.FILE], value[nfs.LINE]) }).Cmd(nfs.SAVE, nfs.TAGS, m.Result()) }}, - }, aaa.RoleAction()), Hand: func(m *ice.Message, arg ...string) { + }), Hand: func(m *ice.Message, arg ...string) { if len(arg) == 0 { m.Cmdy("", mdb.SEARCH, COMMAND, ice.OptionFields(INDEX)).Action(mdb.EXPORT) DisplayStory(m.Options(nfs.DIR_ROOT, "ice."), "spide.js?split=.") diff --git a/base/web/dream.go b/base/web/dream.go index 17017b5d..adfd087a 100644 --- a/base/web/dream.go +++ b/base/web/dream.go @@ -143,7 +143,7 @@ const DREAM = "dream" func init() { Index.MergeCommands(ice.Commands{ - DREAM: {Name: "dream name@key auto create repos startall stopall build publish", Help: "梦想家", Icon: "Launchpad.png", Actions: ice.MergeActions(ice.Actions{ + DREAM: {Name: "dream name@key auto create repos startall stopall build publish", Help: "梦想家", Icon: "Launchpad.png", Role: aaa.VOID, Actions: ice.MergeActions(ice.Actions{ ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { m = m.Spawn() m.GoSleep("10s", func() { @@ -310,7 +310,7 @@ func init() { PushStats(m, kit.Keys(m.CommandKey(), mdb.TOTAL), msg.Length(), "", "已启动空间") } }}, - }, aaa.RoleAction(), StatsAction(), DreamAction(), mdb.ImportantHashAction(ctx.TOOLS, ROUTE, mdb.SHORT, mdb.NAME, mdb.FIELD, "time,name,icon,repos,binary,template,restart")), Hand: func(m *ice.Message, arg ...string) { + }, StatsAction(), DreamAction(), mdb.ImportantHashAction(ctx.TOOLS, 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 { diff --git a/base/web/share.go b/base/web/share.go index 67bc1abd..9dcc939e 100644 --- a/base/web/share.go +++ b/base/web/share.go @@ -71,7 +71,7 @@ const SHARE = "share" func init() { Index.MergeCommands(ice.Commands{ - SHARE: {Name: "share hash auto login", Help: "共享链", Actions: ice.MergeActions(ice.Actions{ + SHARE: {Name: "share hash auto login", Help: "共享链", Role: aaa.VOID, Actions: ice.MergeActions(ice.Actions{ mdb.CREATE: {Name: "create type name text", Hand: func(m *ice.Message, arg ...string) { // kit.If(m.Option(mdb.TYPE) == LOGIN, func() { arg = append(arg, mdb.TEXT, tcp.PublishLocalhost(m, m.Option(mdb.TEXT))) }) kit.If(m.Option(mdb.TYPE) == LOGIN && m.Option(mdb.TEXT) == "", func() { arg = append(arg, mdb.TEXT, tcp.PublishLocalhost(m, m.Option(ice.MSG_USERWEB))) }) @@ -113,7 +113,7 @@ func init() { RenderMain(m) } }}, - }, aaa.WhiteAction(), mdb.HashAction(mdb.FIELD, "time,hash,type,name,text,usernick,username,userrole", mdb.EXPIRE, mdb.DAYS)), Hand: func(m *ice.Message, arg ...string) { + }, mdb.HashAction(mdb.FIELD, "time,hash,type,name,text,usernick,username,userrole", mdb.EXPIRE, mdb.DAYS)), Hand: func(m *ice.Message, arg ...string) { if kit.IsIn(m.Option(ice.MSG_USERROLE), aaa.ROOT, aaa.TECH) || len(arg) > 0 && arg[0] != "" { mdb.HashSelect(m, arg...) } diff --git a/base/web/stats.go b/base/web/stats.go index 8dfbfae3..3b6e4d6c 100644 --- a/base/web/stats.go +++ b/base/web/stats.go @@ -28,6 +28,7 @@ func init() { PushStats(m, "", m.Cmd(aaa.USER).Length()-2, "", "用户总数", aaa.USER) } PushStats(m, "", "", "", "会话总数", aaa.SESS) + PushStats(m, "", m.Cmd(mdb.SELECT, aaa.ROLE, "", mdb.HASH).Length(), "", "角色总数", aaa.ROLE) PushStats(m, "", "", "", "令牌总数", TOKEN) PushStats(m, "", "", "", "共享总数", SHARE) PushStats(m, "", "", "", "命令总数", ctx.COMMAND) diff --git a/base/web/web.go b/base/web/web.go index 68b8d8e8..784826fd 100644 --- a/base/web/web.go +++ b/base/web/web.go @@ -87,7 +87,7 @@ func init() { func ApiAction(arg ...string) ice.Actions { return ice.Actions{kit.Select(nfs.PS, arg, 0): {}} } func ApiWhiteAction() ice.Actions { - return ice.MergeActions(ApiAction(), aaa.WhiteAction()) + return ice.MergeActions(ApiAction(), aaa.WhiteAction("")) } func Prefix(arg ...string) string { for i, k := range arg { diff --git a/core/chat/action.go b/core/chat/action.go index 8dafb548..fdd2a95d 100644 --- a/core/chat/action.go +++ b/core/chat/action.go @@ -68,7 +68,7 @@ func init() { m.Cmdy(mdb.MODIFY, RIVER, _storm_key(m), mdb.LIST, m.OptionSimple(mdb.ID), arg) }}, web.SHARE: {Hand: func(m *ice.Message, arg ...string) { _action_share(m, arg...) }}, - }, web.ApiAction(), aaa.WhiteAction(web.SHARE)), Hand: func(m *ice.Message, arg ...string) { + }, web.ApiAction(""), aaa.WhiteAction(web.SHARE)), Hand: func(m *ice.Message, arg ...string) { if m.Warn(m.Option(ice.MSG_USERNAME) == "", ice.ErrNotLogin, arg) { return } else if m.Warn(!_river_right(m, arg[0]), ice.ErrNotRight, arg) { diff --git a/core/chat/grant.go b/core/chat/grant.go index 6f7e0824..49af070f 100644 --- a/core/chat/grant.go +++ b/core/chat/grant.go @@ -19,7 +19,7 @@ const GRANT = "grant" func init() { Index.MergeCommands(ice.Commands{ - GRANT: {Name: "grant space auto", Help: "授权", Actions: ice.MergeActions(ice.Actions{ + GRANT: {Name: "grant space auto", Help: "授权", Role: aaa.VOID, Actions: ice.MergeActions(ice.Actions{ web.SPACE_LOGIN: {Hand: func(m *ice.Message, arg ...string) { m.GoSleep30ms(func() { p := m.Cmdx(web.SPACE, web.DOMAIN) @@ -28,7 +28,7 @@ func init() { }) }}, web.HOME: {Help: "首页", Hand: func(m *ice.Message, arg ...string) { m.ProcessOpen(web.MergeLink(m, web.CHAT_PORTAL)) }}, - aaa.CONFIRM: {Help: "授权", Hand: func(m *ice.Message, arg ...string) { + aaa.CONFIRM: {Help: "授权", Role: aaa.VOID, Hand: func(m *ice.Message, arg ...string) { if m.Warn(m.R.Method == http.MethodGet, ice.ErrNotAllow) { return } else if m.Warn(m.Option(ice.MSG_USERNAME) == "", ice.ErrNotLogin) || m.Warn(m.Option(web.SPACE) == "", ice.ErrNotValid, web.SPACE) { @@ -49,7 +49,7 @@ func init() { gdb.Event(m, web.SPACE_GRANT, m.OptionSimple(web.SPACE)) } }}, - }, aaa.RoleAction(aaa.CONFIRM), gdb.EventsAction(web.SPACE_LOGIN)), Hand: func(m *ice.Message, arg ...string) { + }, gdb.EventsAction(web.SPACE_LOGIN)), Hand: func(m *ice.Message, arg ...string) { msg := m.Cmd(web.SPACE, m.Option(web.SPACE, arg[0])) m.Options(tcp.HOSTNAME, ice.Info.Hostname, nfs.PATH, msg.Append(mdb.TEXT)) if !m.Warn(m.Option(nfs.PATH) == "", ice.ErrNotFound, arg[0]) { diff --git a/core/chat/macos/desktop.go b/core/chat/macos/desktop.go index 882793a2..008b6036 100644 --- a/core/chat/macos/desktop.go +++ b/core/chat/macos/desktop.go @@ -43,10 +43,10 @@ func init() { }) Notify(m, "Infomation.png", cli.RUNTIME, "系统启动成功", ctx.INDEX, cli.RUNTIME) }}, - DESKTOP: {Help: "应用桌面", Actions: ice.MergeActions(ice.Actions{ + 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...) }}, - }, aaa.RoleAction(), PodCmdAction(), CmdHashAction(), mdb.ExportHashAction())}, + }, PodCmdAction(), CmdHashAction(), mdb.ExportHashAction())}, }) } diff --git a/core/chat/macos/dock.go b/core/chat/macos/dock.go index 57a022b2..4a5fc2b5 100644 --- a/core/chat/macos/dock.go +++ b/core/chat/macos/dock.go @@ -10,7 +10,7 @@ const DOCK = "dock" func init() { Index.MergeCommands(ice.Commands{ - DOCK: {Help: "工具栏", Actions: ice.MergeActions(ice.Actions{}, aaa.RoleAction(), CmdHashAction(), mdb.ExportHashAction())}, + DOCK: {Help: "工具栏", Role: aaa.VOID, Actions: ice.MergeActions(ice.Actions{}, CmdHashAction(), mdb.ExportHashAction())}, }) } diff --git a/core/chat/macos/menu.go b/core/chat/macos/menu.go index 7d186854..c275b627 100644 --- a/core/chat/macos/menu.go +++ b/core/chat/macos/menu.go @@ -10,7 +10,7 @@ const MENU = "menu" func init() { Index.MergeCommands(ice.Commands{ - MENU: {Help: "菜单栏", Actions: ice.MergeActions(aaa.RoleAction(), CmdHashAction(), mdb.ClearOnExitHashAction())}, + MENU: {Help: "菜单栏", Role: aaa.VOID, Actions: ice.MergeActions(CmdHashAction(), mdb.ClearOnExitHashAction())}, }) } diff --git a/core/code/inner.go b/core/code/inner.go index e42863ad..51df9a74 100644 --- a/core/code/inner.go +++ b/core/code/inner.go @@ -87,7 +87,7 @@ const INNER = "inner" func init() { Index.MergeCommands(ice.Commands{ - INNER: {Name: "inner path=src/ file=main.go line=1 auto", Help: "源代码", Actions: ice.MergeActions(ice.Actions{ + INNER: {Name: "inner path=src/ file=main.go line=1 auto", Help: "源代码", Role: aaa.VOID, Actions: ice.MergeActions(ice.Actions{ mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) { m.Cmdy(FAVOR, mdb.INPUTS, arg) }}, mdb.PLUGIN: {Hand: func(m *ice.Message, arg ...string) { if m.Cmdy(mdb.PLUGIN, arg); m.Result() == "" { @@ -101,7 +101,7 @@ func init() { NAVIGATE: {Hand: func(m *ice.Message, arg ...string) { m.Cmdy(NAVIGATE, kit.Ext(m.Option(mdb.FILE)), m.Option(nfs.FILE), m.Option(nfs.PATH)) }}, - }, aaa.RoleAction()), Hand: func(m *ice.Message, arg ...string) { + }), Hand: func(m *ice.Message, arg ...string) { if kit.HasPrefix(arg[0], "/volcanos/", "/require/", ice.HTTP) { if kit.HasPrefix(arg[0], nfs.REQUIRE_SRC) { m.Option(nfs.FILE, strings.Split(strings.TrimPrefix(arg[0], nfs.REQUIRE_SRC), "?")[0]) diff --git a/core/code/publish.go b/core/code/publish.go index f5348c2a..cb34b0d8 100644 --- a/core/code/publish.go +++ b/core/code/publish.go @@ -75,12 +75,12 @@ const PUBLISH = "publish" func init() { web.Index.MergeCommands(ice.Commands{ - web.PP(ice.PUBLISH): {Actions: aaa.WhiteAction(), Hand: func(m *ice.Message, arg ...string) { + web.PP(ice.PUBLISH): {Role: aaa.VOID, Hand: func(m *ice.Message, arg ...string) { web.ShareLocalFile(m, ice.USR_PUBLISH, path.Join(arg...)) }}, }) Index.MergeCommands(ice.Commands{ - PUBLISH: {Name: "publish path auto create volcanos icebergs intshell", Help: "发布", Actions: ice.MergeActions(ice.Actions{ + PUBLISH: {Name: "publish path auto create volcanos icebergs intshell", Help: "发布", Role: aaa.VOID, Actions: ice.MergeActions(ice.Actions{ ice.VOLCANOS: {Help: "火山架", Hand: func(m *ice.Message, arg ...string) { _publish_list(m, kit.ExtReg(HTML, CSS, JS)) }}, ice.ICEBERGS: {Help: "冰山架", Hand: func(m *ice.Message, arg ...string) { _publish_bin_list(m).Cmdy("", ice.CONTEXTS) }}, ice.INTSHELL: {Help: "神农架", Hand: func(m *ice.Message, arg ...string) { _publish_list(m, kit.ExtReg(SH, VIM, CONF)) }}, @@ -113,7 +113,7 @@ func init() { mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) { m.Cmdy(nfs.DIR, arg[1:], nfs.DIR_CLI_FIELDS) }}, mdb.CREATE: {Hand: func(m *ice.Message, arg ...string) { _publish_file(m, m.Option(nfs.PATH)) }}, nfs.TRASH: {Hand: func(m *ice.Message, arg ...string) { nfs.Trash(m, path.Join(ice.USR_PUBLISH, m.Option(nfs.PATH))) }}, - }, aaa.RoleAction(), ctx.ConfAction(mdb.FIELD, nfs.PATH)), Hand: func(m *ice.Message, arg ...string) { + }, ctx.ConfAction(mdb.FIELD, nfs.PATH)), Hand: func(m *ice.Message, arg ...string) { if m.Option(nfs.DIR_ROOT, ice.USR_PUBLISH); len(arg) == 0 { _publish_list(m).Cmdy("", ice.CONTEXTS, ice.APP) } else { diff --git a/core/code/vimer.go b/core/code/vimer.go index 9496dc05..6098e335 100644 --- a/core/code/vimer.go +++ b/core/code/vimer.go @@ -74,7 +74,7 @@ func init() { }}, }) Index.MergeCommands(ice.Commands{ - VIMER: {Name: "vimer path=src/ file=main.go line=1 list", Help: "编辑器", Icon: "vimer.png", Meta: kit.Dict( + VIMER: {Name: "vimer path=src/ file=main.go line=1 list", Help: "编辑器", Icon: "vimer.png", Role: aaa.VOID, Meta: kit.Dict( ctx.STYLE, INNER, ice.CTX_TRANS, kit.Dict(html.INPUT, kit.Dict(cli.MAIN, "程序")), ), Actions: ice.MergeActions(ice.Actions{ mdb.SEARCH: {Hand: func(m *ice.Message, arg ...string) { @@ -211,7 +211,7 @@ func init() { }}, 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...) }}, - }, aaa.RoleAction(), chat.FavorAction(), ctx.ConfAction(ctx.TOOLS, "xterm,compile,runtime")), Hand: func(m *ice.Message, arg ...string) { + }, chat.FavorAction(), ctx.ConfAction(ctx.TOOLS, "xterm,compile,runtime")), Hand: func(m *ice.Message, arg ...string) { if m.Cmdy(INNER, arg); arg[0] != ctx.ACTION { if web.IsLocalHost(m) { m.Action(nfs.SAVE, COMPILE, mdb.SHOW, cli.EXEC, ice.APP) diff --git a/core/mall/cart.go b/core/mall/cart.go index 576fa00a..3ef16bb1 100644 --- a/core/mall/cart.go +++ b/core/mall/cart.go @@ -13,7 +13,7 @@ const CART = "cart" func init() { Index.MergeCommands(ice.Commands{ - CART: {Name: "cart list", Help: "购物车", Actions: ice.MergeActions(ice.Actions{ + CART: {Name: "cart list", Help: "购物车", Role: aaa.VOID, Actions: ice.MergeActions(ice.Actions{ mdb.INSERT: {Hand: func(m *ice.Message, arg ...string) { m.Options(mdb.SUBKEY, kit.Keys(mdb.HASH, mdb.HashCreate(m.Spawn(), aaa.USERNAME, m.Option(ice.MSG_USERNAME), mdb.SHORT, GOODS))) mdb.HashCreate(m.Spawn(), GOODS, m.Option(mdb.HASH), m.OptionSimple(mdb.COUNT)) @@ -31,7 +31,7 @@ func init() { m.Options(mdb.HASH, m.Cmdx(ORDER, mdb.CREATE, aaa.USERNAME, m.Option(ice.MSG_USERNAME), mdb.STATUS, ORDER_CONFIRM, AMOUNT, amount)) msg.Table(func(value ice.Maps) { m.Cmd(ORDER, mdb.INSERT, kit.Simple(value)) }) }}, - }, aaa.RoleAction(), mdb.ExportHashAction(mdb.SHORT, aaa.USERNAME, mdb.FIELD, "time,username", mdb.FIELDS, "time,goods,count")), Hand: func(m *ice.Message, arg ...string) { + }, mdb.ExportHashAction(mdb.SHORT, aaa.USERNAME, mdb.FIELD, "time,username", mdb.FIELDS, "time,goods,count")), Hand: func(m *ice.Message, arg ...string) { m.Options(mdb.SUBKEY, kit.KeyHash(m.Option(ice.MSG_USERNAME))).OptionFields(mdb.Config(m, mdb.FIELDS)) mdb.HashSelect(m, arg...).Options(mdb.SUBKEY, "").Table(func(value ice.Maps) { m.Cmd(GOODS, value[GOODS], func(value ice.Maps) { diff --git a/core/mall/goods.go b/core/mall/goods.go index afc7d84a..6dac6060 100644 --- a/core/mall/goods.go +++ b/core/mall/goods.go @@ -19,7 +19,7 @@ const GOODS = "goods" func init() { Index.MergeCommands(ice.Commands{ - GOODS: {Help: "商品", Icon: "mall.png", Actions: ice.MergeActions(ice.Actions{ + GOODS: {Help: "商品", Icon: "mall.png", Role: aaa.VOID, Actions: ice.MergeActions(ice.Actions{ mdb.CREATE: {Name: "create zone* name* text price* count*=1 units*=件 image*=4@img"}, // mdb.MODIFY: {Name: "modify zone* name* text price* count*=1 units*=件 image*=4@img"}, ORDER: {Name: "order count*=1", Help: "选购", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(CART, mdb.INSERT, arg) }}, @@ -36,7 +36,7 @@ func init() { web.PushStats(m, kit.Keys(m.CommandKey(), mdb.COUNT), msg.Length(), "", "商品数量") } }}, - }, aaa.RoleAction(), web.StatsAction(), web.ExportCacheAction(nfs.IMAGE), mdb.ExportHashAction(ctx.TOOLS, kit.Fields(Prefix(CART), Prefix(ORDER)), mdb.FIELD, "time,hash,zone,name,text,price,count,units,image")), Hand: func(m *ice.Message, arg ...string) { + }, web.StatsAction(), web.ExportCacheAction(nfs.IMAGE), mdb.ExportHashAction(ctx.TOOLS, kit.Fields(Prefix(CART), Prefix(ORDER)), mdb.FIELD, "time,hash,zone,name,text,price,count,units,image")), Hand: func(m *ice.Message, arg ...string) { kit.If(len(arg) == 0 && m.IsMobileUA(), func() { m.OptionDefault(ice.MSG_FIELDS, "zone,name,price,count,units,text,hash,time,image") }) mdb.HashSelect(m, arg...).PushAction(ORDER).Action("filter:text") web.PushPodCmd(m, "", arg...).Sort("zone,name") diff --git a/core/mall/order.go b/core/mall/order.go index 9fe83f91..41ccfca5 100644 --- a/core/mall/order.go +++ b/core/mall/order.go @@ -27,7 +27,7 @@ const ORDER = "order" func init() { Index.MergeCommands(ice.Commands{ - ORDER: {Help: "订单", Actions: ice.MergeActions(ice.Actions{ + ORDER: {Help: "订单", Role: aaa.VOID, Actions: ice.MergeActions(ice.Actions{ mdb.INSERT: {Hand: func(m *ice.Message, arg ...string) { m.Options(mdb.SUBKEY, kit.Keys(mdb.HASH, m.Option(mdb.HASH))) mdb.HashCreate(m, arg) @@ -38,7 +38,7 @@ func init() { RECEIVE: {Help: "收货", Hand: func(m *ice.Message, arg ...string) { mdb.HashModify(m, mdb.STATUS, ORDER_RECEIVED) }}, RETURN: {Help: "退货", Hand: func(m *ice.Message, arg ...string) { mdb.HashModify(m, mdb.STATUS, ORDER_RETURNED) }}, REFUND: {Help: "退钱", Hand: func(m *ice.Message, arg ...string) { mdb.HashModify(m, mdb.STATUS, ORDER_REFUNDED) }}, - }, aaa.RoleAction(), mdb.ExportHashAction(mdb.FIELD, "time,hash,username,status,amount", mdb.FIELDS, "time,goods,price,count,units,name,text,image")), Hand: func(m *ice.Message, arg ...string) { + }, mdb.ExportHashAction(mdb.FIELD, "time,hash,username,status,amount", mdb.FIELDS, "time,goods,price,count,units,name,text,image")), Hand: func(m *ice.Message, arg ...string) { if len(arg) == 0 { stats := map[string]int{} mdb.HashSelect(m, arg...).Table(func(value ice.Maps) { diff --git a/core/team/plan.go b/core/team/plan.go index d2102ea5..111832ce 100644 --- a/core/team/plan.go +++ b/core/team/plan.go @@ -57,7 +57,7 @@ const PLAN = "plan" func init() { Index.MergeCommands(ice.Commands{ - PLAN: {Name: "plan scale=month,day,week,month,year,long begin_time@date list insert prev next", Icon: "Calendar.png", Help: "计划表", Meta: kit.Dict( + PLAN: {Name: "plan scale=month,day,week,month,year,long begin_time@date list insert prev next", Help: "计划表", Icon: "Calendar.png", Role: aaa.VOID, Meta: kit.Dict( ctx.TRANS, kit.Dict(html.INPUT, kit.Dict( SCALE, "跨度", "view", "视图", DAY, "日", WEEK, "周", MONTH, "月", YEAR, "年", LONG, "代", @@ -77,7 +77,7 @@ func init() { web.DREAM_TABLES: {Hand: func(m *ice.Message, arg ...string) { kit.Switch(m.Option(mdb.TYPE), kit.Simple(web.WORKER, web.SERVER), func() { m.PushButton(kit.Dict(m.CommandKey(), "计划")) }) }}, - }, aaa.RoleAction(), ctx.ConfAction(mdb.TOOLS, "todo,epic"), TASK), Hand: func(m *ice.Message, arg ...string) { + }, ctx.ConfAction(mdb.TOOLS, "todo,epic"), TASK), Hand: func(m *ice.Message, arg ...string) { begin_time, end_time := _plan_scope(m, kit.Slice(arg, 0, 2)...) _plan_list(m, begin_time.Format(ice.MOD_TIME), end_time.Format(ice.MOD_TIME)) web.PushPodCmd(m, "", arg...) diff --git a/core/wiki/draw.go b/core/wiki/draw.go index a6718e28..8ec81b72 100644 --- a/core/wiki/draw.go +++ b/core/wiki/draw.go @@ -14,7 +14,7 @@ const DRAW = "draw" func init() { Index.MergeCommands(ice.Commands{ - DRAW: {Name: "draw path=src/main.svg pid list save actions", Icon: "Grapher.png", Help: "思维导图", Actions: ice.MergeActions(ice.Actions{ + DRAW: {Name: "draw path=src/main.svg pid list save actions", Help: "思维导图", Icon: "Grapher.png", Role: aaa.VOID, 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()) }}, @@ -22,6 +22,6 @@ func init() { defer m.Echo("").Echo("") m.Cmdy(nfs.CAT, path.Join(arg[2], arg[1])) }}, - }, aaa.RoleAction(), WikiAction("", nfs.SVG))}, + }, WikiAction("", nfs.SVG))}, }) } diff --git a/core/wiki/portal.go b/core/wiki/portal.go index e12cfaaa..c2cb1597 100644 --- a/core/wiki/portal.go +++ b/core/wiki/portal.go @@ -70,7 +70,7 @@ const PORTAL = "portal" func init() { Index.MergeCommands(ice.Commands{ - PORTAL: {Name: "portal path auto", Help: "网站门户", Actions: ice.MergeActions(ice.Actions{ + PORTAL: {Name: "portal path auto", Help: "网站门户", Role: aaa.VOID, Actions: ice.MergeActions(ice.Actions{ nfs.PS: {Hand: func(m *ice.Message, arg ...string) { web.RenderCmd(m, "", arg) }}, ctx.RUN: {Hand: func(m *ice.Message, arg ...string) { if p := path.Join(ice.USR_PORTAL, path.Join(arg...)); (m.Option(ice.DEBUG) == ice.TRUE || !nfs.ExistsFile(m, p)) && aaa.Right(m.Spawn(), arg) { @@ -82,7 +82,7 @@ func init() { }}, 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(), aaa.RoleAction()), Hand: func(m *ice.Message, arg ...string) { + }, aaa.WhiteAction("")), Hand: func(m *ice.Message, arg ...string) { if m.Push(HEADER, m.Cmdx(WORD, path.Join(nfs.SRC_DOCUMENT, INDEX_SHY))); len(arg) > 0 { kit.If(path.Join(arg...) == "commands", func() { _portal_commands(m, arg...) }) m.Push(NAV, m.Cmdx(WORD, path.Join(nfs.SRC_DOCUMENT, path.Join(arg...), INDEX_SHY))) diff --git a/core/wiki/word.go b/core/wiki/word.go index bebcda2f..2421c7d3 100644 --- a/core/wiki/word.go +++ b/core/wiki/word.go @@ -25,7 +25,7 @@ const WORD = "word" func init() { Index.MergeCommands(ice.Commands{ - WORD: {Name: "word path=src/main.shy@key auto play favor", Help: "上下文", Icon: "Books.png", Actions: ice.MergeActions(ice.Actions{ + WORD: {Name: "word path=src/main.shy@key auto play favor", Help: "上下文", Icon: "Books.png", Role: aaa.VOID, Actions: ice.MergeActions(ice.Actions{ ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { WordAlias(m, NAVMENU, TITLE, NAVMENU) WordAlias(m, PREMENU, TITLE, PREMENU) @@ -73,7 +73,7 @@ func init() { m.Cmd(web.CHAT_FAVOR, mdb.CREATE, mdb.TYPE, nfs.SHY, mdb.NAME, path.Base(arg[0]), mdb.TEXT, arg[0]) m.ProcessHold("favor success") }}, - }, aaa.RoleAction(), WikiAction("", nfs.SHY), mdb.HashAction(mdb.SHORT, nfs.PATH, mdb.FIELD, "time,path")), Hand: func(m *ice.Message, arg ...string) { + }, WikiAction("", nfs.SHY), mdb.HashAction(mdb.SHORT, nfs.PATH, mdb.FIELD, "time,path")), Hand: func(m *ice.Message, arg ...string) { if len(arg) > 0 { mdb.HashCreate(m.Spawn(), nfs.PATH, arg[0]) } diff --git a/misc/git/repos.go b/misc/git/repos.go index ab44defa..e942d80c 100644 --- a/misc/git/repos.go +++ b/misc/git/repos.go @@ -425,7 +425,7 @@ func init() { }}, }) Index.MergeCommands(ice.Commands{ - REPOS: {Name: "repos repos branch:text commit:text file:text auto", Help: "代码库", Actions: ice.MergeActions(ice.Actions{ + REPOS: {Name: "repos repos branch:text commit:text file:text auto", Help: "代码库", Role: aaa.VOID, Actions: ice.MergeActions(ice.Actions{ ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { _repos_insert(m, kit.Path("")) m.Cmd(nfs.DIR, nfs.USR, func(value ice.Maps) { _repos_insert(m, value[nfs.PATH]) }) @@ -454,7 +454,7 @@ func init() { _git_cmd(m, CONFIG, GLOBAL, "url."+m.Option(REMOTE)+_INSTEADOF, strings.TrimSuffix(ice.Info.Make.Remote, path.Base(ice.Info.Make.Remote))) } }}, - REMOTE: {Hand: func(m *ice.Message, arg ...string) { + REMOTE: {Role: aaa.VOID, Hand: func(m *ice.Message, arg ...string) { repos := _repos_open(m, kit.Select(path.Base(kit.Path("")), kit.Select(m.Option(REPOS), arg, 0))) if _remote, err := repos.Remote(ORIGIN); err == nil { m.Push(REMOTE, kit.Select("", _remote.Config().URLs, 0)) @@ -635,7 +635,14 @@ func init() { m.Cmd("", CLONE, ORIGIN, "node_modules", mdb.NAME, "", nfs.PATH, "") m.Cmd("", CLONE, ORIGIN, "icons", mdb.NAME, "", nfs.PATH, "") }}, - }, aaa.RoleAction(REMOTE), web.StatsAction("", "代码库总数"), web.DreamAction(), mdb.HashAction(mdb.SHORT, REPOS, mdb.FIELD, "time,repos,branch,version,message,origin"), mdb.ClearOnExitHashAction()), Hand: func(m *ice.Message, arg ...string) { + web.STATS_TABLES: {Hand: func(m *ice.Message, _ ...string) { + if ice.Info.NodeType == web.SERVER { + if msg := mdb.HashSelects(m.Spawn()); msg.Length() > 0 { + web.PushStats(m, kit.Keys(m.CommandKey(), mdb.TOTAL), msg.Length(), "", "代码库总数") + } + } + }}, + }, web.StatsAction("", "代码库总数"), web.DreamAction(), mdb.HashAction(mdb.SHORT, REPOS, mdb.FIELD, "time,repos,branch,version,message,origin"), mdb.ClearOnExitHashAction()), Hand: func(m *ice.Message, arg ...string) { if len(arg) == 0 { mdb.HashSelect(m, arg...).Sort(REPOS).PushAction(STATUS, mdb.REMOVE).Action(CLONE, PULL, PUSH, STATUS) } else if repos := _repos_open(m, arg[0]); len(arg) == 1 { diff --git a/misc/git/service.go b/misc/git/service.go index c6ecbd1f..05922e70 100644 --- a/misc/git/service.go +++ b/misc/git/service.go @@ -107,7 +107,7 @@ const ( const SERVICE = "service" func init() { - web.Index.MergeCommands(ice.Commands{"/x/": {Actions: aaa.WhiteAction(), Hand: func(m *ice.Message, arg ...string) { + web.Index.MergeCommands(ice.Commands{"/x/": {Role: aaa.VOID, Hand: func(m *ice.Message, arg ...string) { if !m.IsCliUA() { web.RenderCmd(m, web.CODE_GIT_SERVICE, arg) return diff --git a/misc/git/status.go b/misc/git/status.go index f056b9a6..8eedff1f 100644 --- a/misc/git/status.go +++ b/misc/git/status.go @@ -29,7 +29,7 @@ const STATUS = "status" func init() { Index.MergeCommands(ice.Commands{ - STATUS: {Name: "status repos:text auto", Help: "代码库", Icon: "git.png", Meta: kit.Dict( + STATUS: {Name: "status repos:text auto", Help: "代码库", Icon: "git.png", Role: aaa.VOID, Meta: kit.Dict( ice.CTX_TRANS, kit.Dict(html.INPUT, kit.Dict("actions", "操作", "message", "信息")), ), Actions: ice.MergeActions(ice.Actions{ mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) { @@ -70,7 +70,7 @@ func init() { m.PushButton(kit.Dict(m.CommandKey(), "源码")) }}, web.DREAM_ACTION: {Hand: func(m *ice.Message, arg ...string) { web.DreamProcess(m, nil, arg...) }}, - }, aaa.RoleAction(), Prefix(REPOS)), Hand: func(m *ice.Message, arg ...string) { + }, Prefix(REPOS)), Hand: func(m *ice.Message, arg ...string) { if len(arg) > 0 && arg[0] == ctx.ACTION { m.Cmdy(REPOS, arg) } else if config, err := config.LoadConfig(config.GlobalScope); err == nil && config.User.Email == "" && mdb.Config(m, aaa.EMAIL) == "" { diff --git a/misc/wx/access.go b/misc/wx/access.go index d0e134fa..f09bdf2b 100644 --- a/misc/wx/access.go +++ b/misc/wx/access.go @@ -50,7 +50,7 @@ const ACCESS = "access" func init() { Index.MergeCommands(ice.Commands{ - ACCESS: {Help: "认证", Meta: Meta(), Actions: ice.MergeActions(ice.Actions{ + ACCESS: {Help: "认证", Role: aaa.VOID, Meta: Meta(), Actions: ice.MergeActions(ice.Actions{ ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { m.Cmd(web.SPIDE, mdb.CREATE, WX, mdb.Config(m, tcp.SERVER)) }}, @@ -89,7 +89,7 @@ func init() { m.Cmd(web.CHAT_HEADER, mdb.CREATE, mdb.TYPE, mdb.PLUGIN, m.OptionSimple(mdb.NAME, mdb.ORDER), ctx.INDEX, m.PrefixKey(), ctx.ARGS, kit.Join(kit.Simple(aaa.LOGIN, m.Option(ACCESS), m.Option(tcp.WIFI), m.Option(ENV)))) }}, - aaa.LOGIN: {Hand: func(m *ice.Message, arg ...string) { + aaa.LOGIN: {Role: aaa.VOID, Hand: func(m *ice.Message, arg ...string) { if m.Cmd("", m.Option(ACCESS, arg[0])).Append(mdb.TYPE) == ice.WEB { m.Cmdy(SCAN, mdb.CREATE, mdb.TYPE, QR_STR_SCENE, mdb.NAME, "请授权登录", mdb.TEXT, m.Option(web.SPACE), ctx.INDEX, web.CHAT_GRANT, ctx.ARGS, m.Option(web.SPACE)) } else { @@ -109,7 +109,7 @@ func init() { m.Cmd(mdb.PRUNES, m.Prefix(SCAN), "", mdb.HASH, m.OptionSimple(mdb.NAME)) m.Cmd(mdb.PRUNES, m.Prefix(IDE), "", mdb.HASH, m.OptionSimple(mdb.NAME)) }}, - }, aaa.RoleAction(aaa.LOGIN), gdb.EventsAction(web.SPACE_GRANT, web.SPACE_LOGIN_CLOSE), mdb.ImportantHashAction(mdb.SHORT, ACCESS, mdb.FIELD, "time,type,access,icons,usernick,appid", tcp.SERVER, CGI_BIN)), Hand: func(m *ice.Message, arg ...string) { + }, gdb.EventsAction(web.SPACE_GRANT, web.SPACE_LOGIN_CLOSE), mdb.ImportantHashAction(mdb.SHORT, ACCESS, mdb.FIELD, "time,type,access,icons,usernick,appid", tcp.SERVER, CGI_BIN)), Hand: func(m *ice.Message, arg ...string) { mdb.HashSelect(m, arg...).PushAction(web.SSO, mdb.REMOVE).StatusTimeCount(mdb.ConfigSimple(m, ACCESS, APPID), web.SERVE, web.MergeLink(m, "/chat/wx/login/")) m.RewriteAppend(func(value, key string, index int) string { kit.If(key == cli.QRCODE, func() { value = ice.Render(m, ice.RENDER_QRCODE, value) }) diff --git a/misc/wx/agent.go b/misc/wx/agent.go index 2b2cdcc3..bc4cac5c 100644 --- a/misc/wx/agent.go +++ b/misc/wx/agent.go @@ -36,13 +36,13 @@ const AGENT = "agent" func init() { Index.MergeCommands(ice.Commands{ - AGENT: {Name: "agent auto", Help: "代理", Actions: ice.MergeActions(ice.Actions{ + AGENT: {Name: "agent auto", Help: "代理", Role: aaa.VOID, Actions: ice.MergeActions(ice.Actions{ chat.HEADER_AGENT: {Hand: func(m *ice.Message, arg ...string) { kit.If(strings.Index(m.Option(ice.MSG_USERUA), "MicroMessenger") > -1, func() { m.Option(mdb.PLUGIN, m.PrefixKey()) }) }}, "getLocation": {Hand: func(m *ice.Message, arg ...string) { m.Cmdy(location.LOCATION, mdb.CREATE, arg) }}, "scanQRCode1": {Hand: func(m *ice.Message, arg ...string) { m.Cmdy(chat.FAVOR, mdb.CREATE, arg) }}, - }, aaa.RoleAction(), gdb.EventsAction(chat.HEADER_AGENT), ctx.ConfAction(nfs.SCRIPT, "https://res.wx.qq.com/open/js/jweixin-1.6.0.js")), Hand: func(m *ice.Message, arg ...string) { + }, gdb.EventsAction(chat.HEADER_AGENT), ctx.ConfAction(nfs.SCRIPT, "https://res.wx.qq.com/open/js/jweixin-1.6.0.js")), Hand: func(m *ice.Message, arg ...string) { m.Cmdy(ACCESS, AGENT).Options(SIGNATURE, _wx_sign(m, m.Option(NONCESTR, ice.Info.Pathname), m.Option(TIMESTAMP, kit.Format(time.Now().Unix())))).Display("") ctx.OptionFromConfig(m, nfs.SCRIPT) }}, diff --git a/misc/wx/login.go b/misc/wx/login.go index a2cf15ac..8cd13dca 100644 --- a/misc/wx/login.go +++ b/misc/wx/login.go @@ -76,7 +76,7 @@ func init() { ) if false { web.Index.MergeCommands(ice.Commands{ - "/MP_verify_0xp0zkW3fIzIq2Bo.txt": {Actions: aaa.WhiteAction(), Hand: func(m *ice.Message, arg ...string) { m.RenderResult("0xp0zkW3fIzIq2Bo") }}, + "/MP_verify_0xp0zkW3fIzIq2Bo.txt": {Role: aaa.VOID, Hand: func(m *ice.Message, arg ...string) { m.RenderResult("0xp0zkW3fIzIq2Bo") }}, }) } Index.MergeCommands(ice.Commands{ @@ -98,7 +98,7 @@ func init() { }}, SCENE: {Hand: func(m *ice.Message, arg ...string) { m.Cmdy(IDE, m.Option(SCENE)) }}, SCAN: {Hand: func(m *ice.Message, arg ...string) { m.Cmdy(web.CHAT_FAVOR, mdb.CREATE, mdb.TYPE, "", arg) }}, - }, aaa.WhiteAction(aaa.SESS, aaa.USER, SCENE)), Hand: func(m *ice.Message, arg ...string) { + }, aaa.WhiteAction("", aaa.SESS, aaa.USER, SCENE)), Hand: func(m *ice.Message, arg ...string) { if m.Cmdx(ACCESS, aaa.CHECK) == "" { return } else if m.Option("echostr") != "" { diff --git a/misc/wx/pages.go b/misc/wx/pages.go index bff58dd4..4bd5302c 100644 --- a/misc/wx/pages.go +++ b/misc/wx/pages.go @@ -11,7 +11,7 @@ import ( func init() { web.Index.MergeCommands(ice.Commands{ - web.PP(PAGES): {Actions: aaa.WhiteAction(ctx.ACTION), Hand: func(m *ice.Message, arg ...string) { + web.PP(PAGES): {Actions: aaa.WhiteAction("", ctx.ACTION), Hand: func(m *ice.Message, arg ...string) { if len(arg[0]) == 0 || arg[0] == "" || arg[0] == chat.RIVER { web.RenderMain(m) } else { diff --git a/type.go b/type.go index ca88616e..7a18218b 100644 --- a/type.go +++ b/type.go @@ -39,6 +39,7 @@ type Action struct { Name string Help string Icon string + Role string Hand Handler List List } @@ -46,6 +47,7 @@ type Command struct { Name string Help string Icon string + Role string Actions Actions Hand Handler RawHand Any