1
0
mirror of https://shylinux.com/x/icebergs synced 2025-06-26 02:17:30 +08:00
This commit is contained in:
shylinux 2021-10-22 15:52:26 +08:00
parent a243dea1e5
commit 7b20a96f51
16 changed files with 34 additions and 42 deletions

View File

@ -34,14 +34,14 @@ func _role_chain(arg ...string) string {
}
func _role_black(m *ice.Message, userrole, chain string, status bool) {
m.Richs(ROLE, nil, userrole, func(key string, value map[string]interface{}) {
m.Log_MODIFY(ROLE, userrole, BLACK, chain)
m.Log_CREATE(ROLE, userrole, BLACK, chain)
list := value[BLACK].(map[string]interface{})
list[chain] = status
})
}
func _role_white(m *ice.Message, userrole, chain string, status bool) {
m.Richs(ROLE, nil, userrole, func(key string, value map[string]interface{}) {
m.Log_MODIFY(ROLE, userrole, WHITE, chain)
m.Log_CREATE(ROLE, userrole, WHITE, chain)
list := value[WHITE].(map[string]interface{})
list[chain] = status
})

View File

@ -33,7 +33,7 @@ func (f *Frame) Start(m *ice.Message, arg ...string) bool {
// m.Cmd(TIMER, ACTION)
case s := <-f.s:
m.Cmd(SIGNAL, ACTION, SIGNAL, s)
m.Cmd(SIGNAL, ACTION, ACTION, SIGNAL, s)
}
}
return true
@ -46,13 +46,13 @@ const GDB = "gdb"
var Index = &ice.Context{Name: GDB, Help: "事件模块", Commands: map[string]*ice.Command{
ice.CTX_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
m.Load()
m.Load(TIMER)
}},
ice.CTX_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
if f, ok := m.Target().Server().(*Frame); ok {
f.e <- true
}
m.Save()
m.Save(TIMER)
}},
}}

View File

@ -101,6 +101,10 @@ func SetPage(m *ice.Message, arg ...string) {
const MDB = "mdb"
var Index = &ice.Context{Name: MDB, Help: "数据模块", Commands: map[string]*ice.Command{
ice.CTX_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
}},
ice.CTX_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
}},
INSERT: {Name: "insert key sub type arg...", Help: "添加", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
switch arg[2] {
case ZONE:

View File

@ -13,6 +13,7 @@ func init() {
}, Commands: map[string]*ice.Command{
RENDER: {Name: "render type name text auto", Help: "渲染", Action: map[string]*ice.Action{
CREATE: {Name: "create type cmd ctx", Help: "创建", Hand: func(m *ice.Message, arg ...string) {
m.Log_CREATE(RENDER, arg[0], kit.MDB_NAME, kit.Select(arg[0], arg, 1))
m.Rich(RENDER, nil, kit.Dict(kit.MDB_TYPE, arg[0], kit.MDB_NAME, kit.Select(arg[0], arg, 1), kit.MDB_TEXT, kit.Select("", arg, 2)))
}},
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {

View File

@ -15,6 +15,7 @@ func init() {
}, Commands: map[string]*ice.Command{
SEARCH: {Name: "search type word text auto", Help: "搜索", Action: map[string]*ice.Action{
CREATE: {Name: "create type cmd ctx", Help: "创建", Hand: func(m *ice.Message, arg ...string) {
m.Log_CREATE(SEARCH, arg[0], kit.MDB_NAME, kit.Select(arg[0], arg, 1))
m.Rich(SEARCH, nil, kit.Dict(kit.MDB_TYPE, arg[0], kit.MDB_NAME, kit.Select(arg[0], arg, 1), kit.MDB_TEXT, kit.Select("", arg, 2)))
}},
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {

View File

@ -259,6 +259,11 @@ func init() {
PS2, []interface{}{kit.MDB_COUNT, " ", TARGET, "> "},
)},
}, Commands: map[string]*ice.Command{
ice.CTX_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
if f, ok := m.Target().Server().(*Frame); ok {
f.close()
}
}},
SOURCE: {Name: "source file", Help: "脚本解析", Action: ice.MergeAction(map[string]*ice.Action{
mdb.REPEAT: {Name: "repeat", Help: "执行", Hand: func(m *ice.Message, arg ...string) {
m.Cmdy(SCREEN, m.Option(kit.MDB_TEXT))

View File

@ -85,9 +85,11 @@ func init() {
}},
HOST: {Name: "host name auto", Help: "主机", Action: map[string]*ice.Action{
aaa.BLACK: {Name: "black", Help: "黑名单", Hand: func(m *ice.Message, arg ...string) {
m.Log_CREATE(aaa.BLACK, arg[0])
m.Rich(HOST, kit.Keym(aaa.BLACK), kit.Dict(kit.MDB_TEXT, arg[0]))
}},
aaa.WHITE: {Name: "white", Help: "白名单", Hand: func(m *ice.Message, arg ...string) {
m.Log_CREATE(aaa.WHITE, arg[0])
m.Rich(HOST, kit.Keym(aaa.WHITE), kit.Dict(kit.MDB_TEXT, arg[0]))
}},
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {

View File

@ -263,11 +263,13 @@ func init() {
SERVE: {Name: "serve name auto start", Help: "服务器", Action: ice.MergeAction(map[string]*ice.Action{
aaa.BLACK: {Name: "black", Help: "黑名单", Hand: func(m *ice.Message, arg ...string) {
for _, k := range arg {
m.Log_CREATE(aaa.BLACK, k)
m.Config(kit.Keys(aaa.BLACK, k), ice.TRUE)
}
}},
aaa.WHITE: {Name: "white", Help: "白名单", Hand: func(m *ice.Message, arg ...string) {
for _, k := range arg {
m.Log_CREATE(aaa.WHITE, k)
m.Config(kit.Keys(aaa.WHITE, k), ice.TRUE)
}
}},

View File

@ -2,23 +2,12 @@ package chat
import (
ice "shylinux.com/x/icebergs"
"shylinux.com/x/icebergs/base/aaa"
"shylinux.com/x/icebergs/base/web"
)
const CHAT = "chat"
var Index = &ice.Context{Name: CHAT, Help: "聊天中心",
Commands: map[string]*ice.Command{
ice.CTX_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
m.Cmd(web.SERVE, aaa.WHITE, HEADER, RIVER, ACTION, FOOTER)
m.Load()
}},
ice.CTX_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
m.Save()
}},
},
}
var Index = &ice.Context{Name: CHAT, Help: "聊天中心"}
func init() {
web.Index.Register(Index, &web.Frame{},

View File

@ -81,6 +81,9 @@ func init() {
LOGIN, kit.List("登录", "扫码"),
)},
}, Commands: map[string]*ice.Command{
ice.CTX_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
m.Cmd(web.SERVE, aaa.WHITE, HEADER, RIVER, ACTION, FOOTER)
}},
"/header": {Name: "/header", Help: "标题栏", Action: map[string]*ice.Action{
AGENT: {Name: "agent", Help: "应用宿主", Hand: func(m *ice.Message, arg ...string) {
m.Cmdy("web.chat.wx.access", "config")

2
go.mod
View File

@ -5,5 +5,5 @@ go 1.11
require (
github.com/gorilla/websocket v1.4.2
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e
shylinux.com/x/toolkits v0.3.6
shylinux.com/x/toolkits v0.3.7
)

4
go.sum
View File

@ -1,4 +0,0 @@
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e/go.mod h1:XV66xRDqSt+GTGFMVlhk3ULuV0y9ZmzeVGR4mloJI3M=
shylinux.com/x/toolkits v0.3.6 h1:vScxphySLIULkRps0i22yMW7b+sd5MbCBaZRfUmzTu0=
shylinux.com/x/toolkits v0.3.6/go.mod h1:8LbYHe7oxBIqb6s4MSOD+4d28QvPdvkyCVtwB/JW7AA=

12
init.go
View File

@ -39,6 +39,11 @@ func (f *Frame) Start(m *Message, arg ...string) bool {
m.Cap(CTX_STREAM, strings.Split(m.Time(), " ")[1])
m.Cmdy(INIT, arg)
m.target.root.wg = &sync.WaitGroup{}
for _, k := range kit.Split(kit.Select("ssh,gdb,log")) {
m.Start(k)
}
m.Cmdy(arg)
return true
}
func (f *Frame) Close(m *Message, arg ...string) bool {
@ -69,16 +74,10 @@ var Index = &Context{Name: "ice", Help: "冰山模块", Caches: map[string]*Cach
c.cmd(m.Spawn(c), cmd, CTX_INIT, arg...)
}
})
m.target.root.wg = &sync.WaitGroup{}
for _, k := range kit.Split(kit.Select("gdb,log,ssh,mdb")) {
m.Start(k)
}
}},
INIT: {Name: "init", Help: "启动", Hand: func(m *Message, c *Context, cmd string, arg ...string) {
m.root.Cmd(CTX_INIT)
m.Cmd("ssh.source", ETC_INIT_SHY)
m.Cmdy(arg)
}},
HELP: {Name: "help", Help: "帮助", Hand: func(m *Message, c *Context, cmd string, arg ...string) {
m.Echo(m.Config("index"))
@ -97,7 +96,6 @@ var Index = &Context{Name: "ice", Help: "冰山模块", Caches: map[string]*Cach
})
}
})
c.server.(*Frame).wait <- kit.Int(m.root.Option(EXIT))
}},
}}

View File

@ -114,8 +114,8 @@ func init() {
}},
"/repos/": {Name: "/repos/", Help: "代码库", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
if m.Option("go-get") == "1" { // 下载地址
p := m.Conf(web.SHARE, kit.Keym(kit.MDB_DOMAIN)) + "/x/" + path.Join(arg...)
web.RenderMeta(m, "go-import", kit.Format(`%s git %s`, strings.TrimPrefix(p, "https://"), p))
p := kit.Split(kit.MergeURL2(m.Option(ice.MSG_USERWEB), "/x/"+path.Join(arg...)), "?")[0]
m.RenderResult(kit.Format(`<meta name="%s" content="%s">`, "go-import", kit.Format(`%s git %s`, strings.TrimPrefix(p, "https://"), p)))
return
}

View File

@ -26,7 +26,7 @@ func init() {
)},
}, Commands: map[string]*ice.Command{
ice.CTX_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
m.Cmd(web.SPIDE, mdb.CREATE, LARK, m.Config(LARK))
m.Cmd(web.SPIDE, mdb.CREATE, LARK, m.Conf(APP, kit.Keym(LARK)))
}},
APP: {Name: "app appid auto token login", Help: "应用", Action: ice.MergeAction(map[string]*ice.Action{
LOGIN: {Name: "login appid appmm duty", Help: "登录", Hand: func(m *ice.Message, arg ...string) {

View File

@ -8,15 +8,6 @@ import (
const LARK = "lark"
var Index = &ice.Context{Name: LARK, Help: "机器人",
Commands: map[string]*ice.Command{
ice.CTX_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
m.Load()
}},
ice.CTX_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
m.Save()
}},
},
}
var Index = &ice.Context{Name: LARK, Help: "机器人"}
func init() { chat.Index.Register(Index, &web.Frame{}) }