1
0
forked from x/icebergs
This commit is contained in:
IT 老营长 @云轩领航-创始人 2024-01-14 22:59:20 +08:00
parent b559e6c92b
commit 62d86ee286
12 changed files with 70 additions and 26 deletions

View File

@ -215,3 +215,10 @@ func TravelCmd(m *ice.Message, cb func(key, file, line string)) *ice.Message {
return m
}
func IsOrderCmd(key string) bool { return key[0] == '/' || key[0] == '_' }
func ShortCmd(key string) string {
_key := kit.Select("", kit.Split(key, "."), -1)
if _p, ok := ice.Info.Index[_key].(*ice.Context); ok && _p.Prefix(_key) == key {
return _key
}
return key
}

View File

@ -148,6 +148,7 @@ func (f *Frame) Start(m *ice.Message, arg ...string) {
f.pipe, f.stdin, f.stdout = w, r, os.Stdout
kit.If(f.target == nil, func() { f.target = m.Target() })
m.Optionv(ice.MSG_OPTS, ice.MSG_USERNAME, ice.MSG_USERROLE)
m.Option(ice.MSG_USERWEB, "http://localhost:9020")
f.scan(m, STDIO, "")
default:
if m.Option(ice.MSG_SCRIPT) != "" {

View File

@ -18,8 +18,14 @@ func init() {
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 {
ctx.ProcessField(m, CHAT_IFRAME, m.MergePodCmd(m.Option(mdb.NAME), ""), arg...)
m.ProcessField(ctx.ACTION, ctx.RUN, CHAT_IFRAME)
if m.Option(mdb.TYPE) == MASTER {
m.ProcessOpen(SpideOrigin(m, m.Option(mdb.NAME)) + C(m.PrefixKey()))
// ctx.ProcessField(m, CHAT_IFRAME, SpideOrigin(m, m.Option(mdb.NAME))+C(m.PrefixKey()), arg...)
// m.ProcessField(ctx.ACTION, ctx.RUN, CHAT_IFRAME)
} else {
ctx.ProcessField(m, CHAT_IFRAME, m.MergePodCmd(m.Option(mdb.NAME), ""), arg...)
m.ProcessField(ctx.ACTION, ctx.RUN, CHAT_IFRAME)
}
}
}},
}, Hand: func(m *ice.Message, arg ...string) {

View File

@ -46,7 +46,7 @@ func _dream_list(m *ice.Message) *ice.Message {
}
}
})
return m.Sort("status,type,name", []string{cli.START, cli.STOP, cli.BEGIN}, ice.STR, ice.STR_R).StatusTimeCount(stat)
return m.Sort("type,status,name", []string{MASTER, SERVER, WORKER}, []string{cli.START, cli.STOP, cli.BEGIN}, ice.STR_R).StatusTimeCount(stat)
}
func _dream_start(m *ice.Message, name string) {
if m.Warn(name == "", ice.ErrNotValid, mdb.NAME) {
@ -151,11 +151,11 @@ func init() {
m.Cmd(DREAM, cli.START, kit.Dict(mdb.NAME, value[mdb.NAME]))
}
})
for _, cmd := range kit.Reverse(kit.Split(mdb.Config(m, html.BUTTON))) {
m.Cmd(gdb.EVENT, gdb.LISTEN, gdb.EVENT, DREAM_TABLES, ice.CMD, cmd)
m.Cmd(gdb.EVENT, gdb.LISTEN, gdb.EVENT, DREAM_ACTION, ice.CMD, cmd)
}
})
for _, cmd := range kit.Reverse(kit.Split(mdb.Config(m, html.BUTTON))) {
m.Cmd(gdb.EVENT, gdb.LISTEN, gdb.EVENT, DREAM_TABLES, ice.CMD, cmd)
m.Cmd(gdb.EVENT, gdb.LISTEN, gdb.EVENT, DREAM_ACTION, ice.CMD, cmd)
}
}},
html.BUTTON: {Hand: func(m *ice.Message, arg ...string) {
mdb.Config(m, html.BUTTON, kit.Join(arg))
@ -293,11 +293,18 @@ func init() {
nfs.Trash(m, path.Join(ice.USR_LOCAL_WORK, m.Option(mdb.NAME)))
}},
OPEN: {Role: aaa.VOID, Hand: func(m *ice.Message, arg ...string) {
m.ProcessOpen(m.MergePod(m.Option(mdb.NAME)))
if m.Option(mdb.TYPE) == MASTER {
m.ProcessOpen(SpideOrigin(m, m.Option(mdb.NAME)) + C(ADMIN))
} else {
m.ProcessOpen(m.MergePod(m.Option(mdb.NAME)))
}
}},
MAIN: {Name: "main index", Help: "首页", Hand: func(m *ice.Message, arg ...string) {
m.Cmdy(SPACE, m.Option(mdb.NAME), SPACE, ice.MAIN, m.Option(ctx.INDEX))
}},
"grant": {Help: "授权", Hand: func(m *ice.Message, arg ...string) {
m.Cmd(CHAT_GRANT, aaa.CONFIRM, kit.Dict(SPACE, m.Option(mdb.NAME)))
}},
DREAM_OPEN: {Hand: func(m *ice.Message, arg ...string) {}},
DREAM_CLOSE: {Hand: func(m *ice.Message, arg ...string) {
if m.Option(cli.DAEMON) == ice.OPS && m.Cmdv(SPACE, m.Option(mdb.NAME), mdb.STATUS) != cli.STOP {
@ -343,17 +350,32 @@ func init() {
}, func() {
m.Action(mdb.CREATE, STARTALL, STOPALL)
})
return
m.Cmds(SPACE, func(value ice.Maps) {
if value[mdb.TYPE] == SERVER {
msg := m.Cmds(SPACE)
msg.Table(func(value ice.Maps) {
switch value[mdb.TYPE] {
case SERVER:
m.Push(mdb.TYPE, value[mdb.TYPE])
m.Push(mdb.NAME, value[mdb.NAME])
m.Push(mdb.ICON, nfs.USR_ICONS_ICEBERGS)
m.Push(mdb.TEXT, SERVER)
m.Push(mdb.TEXT, value[mdb.TEXT])
msg := gdb.Event(m.Spawn(value), DREAM_TABLES)
m.PushButton(strings.Join(msg.Appendv(ctx.ACTION), ""))
case MASTER:
m.Push(mdb.TYPE, value[mdb.TYPE])
m.Push(mdb.NAME, value[mdb.NAME])
m.Push(mdb.ICON, nfs.USR_ICONS_VOLCANOS)
m.Push(mdb.TEXT, value[mdb.TEXT])
msg := gdb.Event(m.Spawn(value), DREAM_TABLES)
m.PushButton(strings.Join(msg.Appendv(ctx.ACTION), ""))
case aaa.LOGIN:
m.Push(mdb.TYPE, value[mdb.TYPE])
m.Push(mdb.NAME, value[mdb.NAME])
m.Push(mdb.ICON, nfs.USR_ICONS_VOLCANOS)
m.Push(mdb.TEXT, kit.JoinWord(value["agent"], value["system"], value[aaa.IP]))
m.PushButton("grant")
}
})
m.Sort("type,status,name", []string{aaa.LOGIN, WORKER, SERVER, MASTER}, []string{cli.START, cli.STOP, cli.BEGIN}, ice.STR_R)
} else if arg[0] == ctx.ACTION {
gdb.Event(m, DREAM_ACTION, arg)
} else {
@ -365,14 +387,18 @@ func init() {
func DreamAction() ice.Actions {
return ice.MergeActions(ice.Actions{
DREAM_ACTION: {Hand: func(m *ice.Message, arg ...string) { DreamProcess(m, []string{}, arg...) }},
DREAM_ACTION: {Hand: func(m *ice.Message, arg ...string) {
DreamProcess(m, nil, arg...)
}},
}, gdb.EventsAction(DREAM_OPEN, DREAM_CLOSE, DREAM_INPUTS, DREAM_CREATE, DREAM_TRASH, DREAM_TABLES, DREAM_ACTION, SERVE_START))
}
func DreamProcess(m *ice.Message, args ice.Any, arg ...string) {
if kit.HasPrefixList(arg, ctx.RUN) {
ctx.ProcessField(m, m.PrefixKey(), args, kit.Slice(arg, 1)...)
} else if kit.HasPrefixList(arg, ctx.ACTION, m.PrefixKey()) || kit.HasPrefixList(arg, ctx.ACTION, m.CommandKey()) {
if arg = kit.Slice(arg, 2); kit.HasPrefixList(arg, DREAM) {
if m.Option(mdb.TYPE) == MASTER {
m.ProcessOpen(SpideOrigin(m, m.Option(mdb.NAME)) + C(m.PrefixKey()))
} else if arg = kit.Slice(arg, 2); kit.HasPrefixList(arg, DREAM) {
m.Cmdy(SPACE, m.Option(ice.MSG_USERPOD, arg[1]), m.PrefixKey(), ctx.ACTION, DREAM_ACTION, ctx.RUN, arg[2:])
} else if dream := m.Option(mdb.NAME); dream != "" {
m.Cmdy(SPACE, dream, m.PrefixKey(), ctx.ACTION, DREAM_ACTION, ctx.RUN, arg).Optionv(ice.FIELD_PREFIX, kit.Simple(ctx.ACTION, m.PrefixKey(), DREAM, dream, ctx.RUN))

View File

@ -403,7 +403,7 @@ func init() {
}
m.PushButton(kit.Select(OPEN, LOGIN, value[mdb.TYPE] == LOGIN), mdb.REMOVE)
})
m.Sort("", kit.Simple(WEIXIN, PORTAL, MASTER, WORKER, SERVER))
m.Sort("", kit.Simple(WEIXIN, PORTAL, WORKER, SERVER, MASTER))
} else {
_space_send(m, arg[0], kit.Simple(kit.Split(arg[1]), arg[2:])...)
}

View File

@ -59,7 +59,7 @@ func devTokenAction(name, origin string) ice.Actions {
return ice.Actions{
"dev.request.text": {Hand: func(m *ice.Message, arg ...string) { m.Echo(ice.Info.NodeName) }},
"dev.create.token": {Hand: func(m *ice.Message, arg ...string) {}},
mdb.DEV_REQUEST: {Name: "request", Help: "连接", Hand: func(m *ice.Message, arg ...string) {
mdb.DEV_REQUEST: {Name: "dev.request", Help: "连接", Hand: func(m *ice.Message, arg ...string) {
m.ProcessOpen(m.Options(ice.MSG_USERWEB, m.Option(origin)).MergePodCmd("", m.PrefixKey(), ctx.ACTION, mdb.DEV_CHOOSE, cli.BACK, m.Option(ice.MSG_USERHOST), cli.DAEMON, m.Option(ice.MSG_DAEMON),
m.OptionSimple(name), mdb.TEXT, m.Cmdx("", "dev.request.text"),
))

View File

@ -101,6 +101,6 @@ func Prefix(arg ...string) string {
func X(arg ...string) string { return "/x/" + path.Join(arg...) }
func S(arg ...string) string { return "/s/" + path.Join(arg...) }
func C(arg ...string) string { return "/c/" + path.Join(arg...) }
func C(arg ...string) string { return "/c/" + ctx.ShortCmd(path.Join(arg...)) }
func P(arg ...string) string { return path.Join(nfs.PS, path.Join(arg...)) }
func PP(arg ...string) string { return P(arg...) + nfs.PS }

View File

@ -44,8 +44,12 @@ func init() {
Notify(m, "Infomation.png", cli.RUNTIME, "系统启动成功", ctx.INDEX, cli.RUNTIME)
}},
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...) }},
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())},
})
}

View File

@ -111,7 +111,7 @@ func init() {
})
})
}},
web.DREAM_ACTION: {Hand: func(m *ice.Message, arg ...string) { web.DreamProcess(m, []string{}, arg...) }},
web.DREAM_ACTION: {Hand: func(m *ice.Message, arg ...string) { web.DreamProcess(m, nil, arg...) }},
}, ctx.ConfAction(cli.ENV, kit.Dict(GOPRIVATE, "shylinux.com,github.com", GOPROXY, "https://goproxy.cn,direct", CGO_ENABLED, "0"))), Hand: func(m *ice.Message, arg ...string) {
defer web.ToastProcess(m)()
main, file, goos, arch := _compile_target(m, arg...)

View File

@ -154,7 +154,9 @@ 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, cli.Shell(m), arg...) }},
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 {
if web.IsLocalHost(m) {

View File

@ -74,9 +74,8 @@ func init() {
m.Cmdy(arg)
}
}},
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(), "计划")) })
}},
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...) }},
}, 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))

View File

@ -53,8 +53,7 @@ func init() {
}},
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, "")
m.PushButton(kit.Dict(m.CommandKey(), "源码"))
m.Push(mdb.TEXT, "").PushButton(kit.Dict(m.CommandKey(), "源码"))
return
}
text := []string{}