From 75b80458520639b1d9676381aee96e635019c376 Mon Sep 17 00:00:00 2001 From: shaoying Date: Sun, 23 May 2021 21:48:58 +0800 Subject: [PATCH] opt panel --- core/chat/action.go | 24 +++++++++++++++++++++--- core/chat/footer.go | 13 ++++++++++++- core/chat/header.go | 7 ++++--- core/chat/river.go | 25 ++++++------------------- core/chat/search.go | 4 +++- 5 files changed, 46 insertions(+), 27 deletions(-) diff --git a/core/chat/action.go b/core/chat/action.go index 24b922f7..557b743a 100644 --- a/core/chat/action.go +++ b/core/chat/action.go @@ -56,6 +56,22 @@ func _action_right(m *ice.Message, river string, storm string) (ok bool) { } func _action_share(m *ice.Message, arg ...string) { switch msg := m.Cmd(web.SHARE, arg[1]); msg.Append(kit.MDB_TYPE) { + case web.STORM: + if len(arg) == 2 { + _action_list(m, msg.Append(web.RIVER), msg.Append(web.STORM)) + return + } + + if m.Warn(kit.Time() > kit.Time(msg.Append(kit.MDB_TIME)), ice.ErrExpire) { + break // 分享超时 + } + m.Log_AUTH( + aaa.USERROLE, m.Option(ice.MSG_USERROLE, msg.Append(aaa.USERROLE)), + aaa.USERNAME, m.Option(ice.MSG_USERNAME, msg.Append(aaa.USERNAME)), + ) + + _action_show(m, msg.Append(web.RIVER), msg.Append(web.STORM), arg[2], arg[3:]...) + case web.FIELD: if cmd := kit.Keys(msg.Append(web.RIVER), msg.Append(web.STORM)); len(arg) == 2 { m.Push("index", cmd) @@ -71,6 +87,7 @@ func _action_share(m *ice.Message, arg ...string) { aaa.USERROLE, m.Option(ice.MSG_USERROLE, msg.Append(aaa.USERROLE)), aaa.USERNAME, m.Option(ice.MSG_USERNAME, msg.Append(aaa.USERNAME)), ) + if m.Warn(!m.Right(arg[2:]), ice.ErrNotRight) { break // 没有授权 } @@ -90,6 +107,9 @@ func _action_list(m *ice.Message, river, storm string) { m.SortInt(kit.MDB_ID) } func _action_show(m *ice.Message, river, storm, index string, arg ...string) { + m.Option(ice.MSG_RIVER, river) + m.Option(ice.MSG_STORM, storm) + cmds := []string{index} prefix := kit.Keys(kit.MDB_HASH, river, TOOL, kit.MDB_HASH, storm) if m.Grows(RIVER, prefix, kit.MDB_ID, index, func(index int, value map[string]interface{}) { @@ -159,13 +179,11 @@ func init() { return // 没有授权 } - m.Option(ice.MSG_RIVER, arg[0]) - m.Option(ice.MSG_STORM, arg[1]) - if len(arg) == 2 { _action_list(m, arg[0], arg[1]) return //命令列表 } + _action_show(m, arg[0], arg[1], arg[2], arg[3:]...) }}, }}) diff --git a/core/chat/footer.go b/core/chat/footer.go index bb1d8137..0a7b2e6e 100644 --- a/core/chat/footer.go +++ b/core/chat/footer.go @@ -2,6 +2,7 @@ package chat import ( ice "github.com/shylinux/icebergs" + "github.com/shylinux/icebergs/base/ctx" kit "github.com/shylinux/toolkits" ) @@ -19,7 +20,17 @@ func init() { )}, }, Commands: map[string]*ice.Command{ - P_FOOTER: {Name: "/footer", Help: "状态栏", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + P_FOOTER: {Name: "/footer", Help: "状态栏", Action: map[string]*ice.Action{ + ctx.COMMAND: {Name: "command", Help: "命令", Hand: func(m *ice.Message, arg ...string) { + if len(arg) > 0 && arg[0] == "run" { + if m.Right(arg[1:]) { + m.Cmdy(arg[1:]) + } + return + } + m.Cmdy(ctx.COMMAND, arg) + }}, + }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { kit.Fetch(m.Confv(FOOTER, LEGAL), func(index int, value string) { m.Echo(value) }) }}, }, diff --git a/core/chat/header.go b/core/chat/header.go index 438cf582..672f9251 100644 --- a/core/chat/header.go +++ b/core/chat/header.go @@ -19,6 +19,8 @@ func _header_check(m *ice.Message) { if m.Option(ice.MSG_USERNAME) != msg.Append(aaa.USERNAME) { web.RenderCookie(m, aaa.SessCreate(m, m.Option(ice.MSG_USERNAME, msg.Append(aaa.USERNAME)))) } + case web.STORM: + m.Option(ice.MSG_USERNAME, msg.Append(aaa.USERNAME)) case web.FIELD: m.Option(ice.MSG_USERNAME, msg.Append(aaa.USERNAME)) } @@ -36,10 +38,9 @@ func _header_share(m *ice.Message, arg ...string) { link = strings.Replace(link, tcp.LOCALHOST, m.Cmd(tcp.HOST, ice.OptionFields(tcp.IP)).Append(tcp.IP), 1) } - m.Set(kit.MDB_NAME) - m.Set(kit.MDB_TEXT) - m.Push(kit.MDB_NAME, link) + m.Set(kit.MDB_NAME, kit.MDB_TEXT) m.PushQRCode(kit.MDB_TEXT, link) + m.Push(kit.MDB_NAME, link) } func _header_grant(m *ice.Message, arg ...string) { if pod := m.Option(kit.SSH_POD); pod != "" { diff --git a/core/chat/river.go b/core/chat/river.go index 8d4d1577..6425b179 100644 --- a/core/chat/river.go +++ b/core/chat/river.go @@ -17,7 +17,7 @@ func _river_list(m *ice.Message) { if m.Option(web.SHARE) != "" { switch msg := m.Cmd(web.SHARE, m.Option(web.SHARE)); msg.Append(kit.MDB_TYPE) { - case web.RIVER, web.STORM: // 应用入口 + case web.RIVER: // 应用入口 m.Option(ice.MSG_TITLE, msg.Append(kit.MDB_NAME)) m.Option(ice.MSG_RIVER, msg.Append(RIVER)) m.Option(ice.MSG_STORM, msg.Append(STORM)) @@ -29,6 +29,11 @@ func _river_list(m *ice.Message) { msg.Cmd(m.Prefix(USER), mdb.INSERT, aaa.USERNAME, m.Option(ice.MSG_USERNAME)) // 加入群组 } + case web.STORM: // 应用入口 + m.Option(ice.MSG_TITLE, msg.Append(kit.MDB_NAME)) + m.Option(ice.MSG_STORM, msg.Append(STORM)) + m.Option(ice.MSG_RIVER, "_share") + case web.FIELD: // 应用入口 m.Option(ice.MSG_TITLE, msg.Append(kit.MDB_NAME)) m.Option(ice.MSG_RIVER, "_share") @@ -42,23 +47,6 @@ func _river_list(m *ice.Message) { }) }) } -func _river_share(m *ice.Message) { - return - msg := m.Spawn() - if res := msg.Cmd(web.SHARE, m.Option(web.SHARE)); res.Append(kit.MDB_TYPE) == RIVER { - msg.Option(ice.MSG_RIVER, res.Append(RIVER)) - } else { - if res := msg.Cmd(m.Prefix(AUTH), m.Option(web.SHARE)); res.Append(kit.MDB_TYPE) == USER { - } else { - return - } - } - - if msg.Cmd(m.Prefix(USER), m.Option(ice.MSG_USERNAME)).Append(aaa.USERNAME) == "" { - msg.Cmd(m.Prefix(USER), mdb.INSERT, aaa.USERNAME, m.Option(ice.MSG_USERNAME)) - // 加入群组 - } -} func _river_proxy(m *ice.Message, pod string) (proxy []string) { if p := kit.Select(m.Option(POD), pod); p != "" { proxy = append(proxy, web.SPACE, p) @@ -365,7 +353,6 @@ func init() { return // 没有登录 } if len(arg) == 0 { - _river_share(m) _river_list(m) return // 群组列表 } diff --git a/core/chat/search.go b/core/chat/search.go index 66829b73..26e3eed3 100644 --- a/core/chat/search.go +++ b/core/chat/search.go @@ -32,7 +32,9 @@ func init() { }}, ctx.COMMAND: {Name: "command", Help: "命令", Hand: func(m *ice.Message, arg ...string) { if len(arg) > 0 && arg[0] == "run" { - m.Cmdy(arg[1:]) + if m.Right(arg[1:]) { + m.Cmdy(arg[1:]) + } return } m.Cmdy(ctx.COMMAND, arg)