1
0
forked from x/icebergs
This commit is contained in:
IT 老营长 @云轩领航-创始人 2023-09-18 22:07:42 +08:00
parent c356669ff5
commit b3520df582
7 changed files with 57 additions and 29 deletions

View File

@ -147,27 +147,13 @@ var Index = &ice.Context{Name: MDB, Help: "数据模块", Commands: ice.Commands
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {}},
ice.CTX_EXIT: {Hand: func(m *ice.Message, arg ...string) {}},
INPUTS: {Name: "inputs key sub type field value", Hand: func(m *ice.Message, arg ...string) {
switch arg[3] {
case "space":
m.Cmd("space", func(value ice.Maps) {
kit.If(kit.IsIn(value[TYPE], "worker", "server"), func() { m.Push(arg[3], value[NAME]) })
})
case "index":
if space := m.Option("space"); space != "" {
m.Options("space", []string{}).Cmdy("space", space, INPUTS, arg)
} else {
m.Cmdy("command")
}
case "args":
m.Cmdy("command", INPUTS, m.Option("index"))
case ICON:
m.Cmdy("nfs.dir", "usr/icons/", "path")
default:
kit.Switch(arg[2],
HASH, func() { _hash_inputs(m, arg[0], arg[1], kit.Select(NAME, arg, 3), kit.Select("", arg, 4)) },
ZONE, func() { _zone_inputs(m, arg[0], arg[1], arg[3], kit.Select(NAME, arg, 4), kit.Select("", arg, 5)) },
LIST, func() { _list_inputs(m, arg[0], arg[1], kit.Select(NAME, arg, 3), kit.Select("", arg, 4)) },
)
kit.Switch(arg[2],
HASH, func() { _hash_inputs(m, arg[0], arg[1], kit.Select(NAME, arg, 3), kit.Select("", arg, 4)) },
ZONE, func() { _zone_inputs(m, arg[0], arg[1], arg[3], kit.Select(NAME, arg, 4), kit.Select("", arg, 5)) },
LIST, func() { _list_inputs(m, arg[0], arg[1], kit.Select(NAME, arg, 3), kit.Select("", arg, 4)) },
)
for _, inputs := range ice.Info.Inputs {
inputs(m, arg[3])
}
}},
INSERT: {Name: "insert key sub type arg...", Hand: func(m *ice.Message, arg ...string) {

View File

@ -175,6 +175,28 @@ const (
const SPACE = "space"
func init() {
ice.Info.Inputs = append(ice.Info.Inputs, func(m *ice.Message, arg ...string) {
switch arg[0] {
case SPACE:
m.Cmd(SPACE, func(value ice.Maps) {
kit.If(kit.IsIn(value[mdb.TYPE], WORKER, SERVER), func() { m.Push(arg[0], value[mdb.NAME]) })
})
case mdb.ICON:
m.Cmdy(nfs.DIR, "usr/icons/", nfs.PATH)
case ctx.INDEX:
if space := m.Option(SPACE); space != "" {
m.Options(SPACE, []string{}).Cmdy(SPACE, space, mdb.INPUTS, arg)
} else {
m.Cmdy(ctx.COMMAND)
}
case ctx.ARGS:
if space := m.Option(SPACE); space != "" {
m.Options(SPACE, []string{}).Cmdy(SPACE, space, ctx.COMMAND, mdb.INPUTS, m.Option(ctx.INDEX))
} else {
m.Cmdy(ctx.COMMAND, mdb.INPUTS, m.Option(ctx.INDEX))
}
}
})
Index.MergeCommands(ice.Commands{
SPACE: {Name: "space name cmds auto", Help: "空间站", Actions: ice.MergeActions(ice.Actions{
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { aaa.White(m, SPACE, ice.MAIN) }},

26
core/chat/icons.go Normal file
View File

@ -0,0 +1,26 @@
package chat
import (
"strings"
ice "shylinux.com/x/icebergs"
"shylinux.com/x/icebergs/base/lex"
kit "shylinux.com/x/toolkits"
)
func init() {
const ICONS = "icons"
Index.MergeCommands(ice.Commands{
ICONS: {Hand: func(m *ice.Message, arg ...string) {
m.Option(lex.SPLIT_SPACE, " {:;}")
m.Cmd(lex.SPLIT, "usr/node_modules/bootstrap-icons/font/bootstrap-icons.css", func(text string, ls []string) {
if len(ls) > 2 && ls[2] == "content" {
name := "bi " + strings.TrimPrefix(ls[0], ".")
m.Push("name", name)
m.Push("icon", kit.Format(`<i class="%s"></i>`, name))
}
})
m.StatusTimeCount()
}},
})
}

View File

@ -20,7 +20,6 @@ func init() {
DeskAppend(m, "usr/icons/Photos.png", web.WIKI_FEEL)
DeskAppend(m, "usr/icons/Grapher.png", web.WIKI_DRAW)
DeskAppend(m, "usr/icons/Calendar.png", web.TEAM_PLAN)
DeskAppend(m, "usr/icons/flows.png", web.CHAT_FLOWS)
}
}},
ice.CTX_EXIT: {Hand: func(m *ice.Message, arg ...string) { mdb.HashExport(m) }},

View File

@ -3,7 +3,6 @@ package chat
import (
ice "shylinux.com/x/icebergs"
"shylinux.com/x/icebergs/base/aaa"
"shylinux.com/x/icebergs/base/ctx"
"shylinux.com/x/icebergs/base/gdb"
"shylinux.com/x/icebergs/base/mdb"
"shylinux.com/x/icebergs/base/nfs"
@ -48,12 +47,6 @@ func init() {
switch arg[0] {
case nfs.TEMPLATE:
m.Cmdy(TEMPLATE).CutTo(RIVER, arg[0])
case web.SPACE:
m.Cmdy(web.SPACE).CutTo(mdb.NAME, arg[0])
case ctx.INDEX:
m.Cmdy(web.Space(m, m.Option(web.SPACE)), ctx.COMMAND)
case ctx.ARGS:
m.Cmdy(web.Space(m, m.Option(web.SPACE)), ctx.COMMAND, mdb.INPUTS, m.Option(ctx.INDEX))
default:
mdb.HashInputs(m, arg)
}

View File

@ -74,6 +74,7 @@ var Info = struct {
OpenFile func(m *Message, p string) (io.ReadCloser, error)
PushStream func(m *Message)
PushNotice func(m *Message, arg ...Any)
Inputs []func(m *Message, arg ...string)
Load func(m *Message, key ...string) *Message
Save func(m *Message, key ...string) *Message
Log func(m *Message, p, l, s string)

View File

@ -174,6 +174,7 @@ func (c *Context) Merge(s *Context) *Context {
kit.If(action.List == nil, func() { action.List = SplitCmd(action.Name, nil) })
kit.If(len(action.List) > 0, func() { cmd.Meta[sub] = action.List })
}
kit.If(cmd.Name == "", func() { cmd.Name = "list path auto" })
kit.If(strings.HasPrefix(cmd.Name, "list"), func() { cmd.Name = strings.Replace(cmd.Name, "list", key, 1) })
kit.If(cmd.List == nil, func() { cmd.List = SplitCmd(cmd.Name, cmd.Actions) })
}