mirror of
https://shylinux.com/x/icebergs
synced 2025-04-25 17:18:05 +08:00
opt process
This commit is contained in:
parent
83dc4bc12b
commit
d33f38d7e7
@ -130,11 +130,8 @@ func init() {
|
||||
})
|
||||
}
|
||||
func roleHandle(m *ice.Message, role string, key ...string) {
|
||||
cmd := m.ShortKey()
|
||||
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) })
|
||||
|
@ -187,6 +187,7 @@ func init() {
|
||||
}
|
||||
}
|
||||
|
||||
func SystemFindGo(m *ice.Message) bool { return SystemFind(m, "go") != "" }
|
||||
func SystemFind(m *ice.Message, bin string, dir ...string) string {
|
||||
dir = append(dir, EtcPath(m)...)
|
||||
return _system_find(m, bin, append(dir, _path_split(kit.Env(PATH))...)...)
|
||||
|
@ -29,15 +29,15 @@ func _process_args(m *ice.Message, args ice.Any) []string {
|
||||
}
|
||||
func ProcessField(m *ice.Message, cmd string, args ice.Any, arg ...string) *ice.Message {
|
||||
if cmd = kit.Select(m.ActionKey(), cmd); !kit.HasPrefixList(arg, RUN) {
|
||||
defer kit.If(m.IsMetaKey(), func() { m.Push(STYLE, html.FLOAT) })
|
||||
defer m.Push(ARGS, kit.Format(_process_args(m, args)))
|
||||
defer m.ProcessField(ACTION, m.ActionKey(), RUN)
|
||||
defer m.Options(ice.MSG_INDEX, m.PrefixKey())
|
||||
if PodCmd(m, COMMAND, cmd) {
|
||||
m.Push(ice.SPACE, m.Option(ice.MSG_USERPOD))
|
||||
} else {
|
||||
m.Cmdy(COMMAND, cmd)
|
||||
}
|
||||
m.Push(ARGS, kit.Format(_process_args(m, args)))
|
||||
kit.If(m.IsMetaKey(), func() { m.Push(STYLE, html.FLOAT) })
|
||||
m.ProcessField(ACTION, m.ActionKey(), RUN)
|
||||
m.Options(ice.MSG_INDEX, m.PrefixKey())
|
||||
} else if !PodCmd(m, cmd, arg[1:]) && aaa.Right(m, cmd, arg[1:]) {
|
||||
m.Cmdy(cmd, arg[1:])
|
||||
}
|
||||
|
@ -8,7 +8,6 @@ import (
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/aaa"
|
||||
"shylinux.com/x/icebergs/base/cli"
|
||||
"shylinux.com/x/icebergs/base/ctx"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/nfs"
|
||||
"shylinux.com/x/icebergs/base/tcp"
|
||||
@ -19,24 +18,9 @@ const ADMIN = "admin"
|
||||
|
||||
func init() {
|
||||
Index.MergeCommands(ice.Commands{
|
||||
ADMIN: {Name: "admin index list", Help: "管理", Role: aaa.VOID, Actions: ice.Actions{
|
||||
ice.CTX_INIT: {Hand: DreamWhiteHandle},
|
||||
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 {
|
||||
link := m.MergePodCmd(m.Option(mdb.NAME), "")
|
||||
if m.Option(mdb.TYPE) == MASTER {
|
||||
link = SpideOrigin(m, m.Option(mdb.NAME)) + C(m.PrefixKey())
|
||||
}
|
||||
if m.IsMetaKey() {
|
||||
m.ProcessOpen(link)
|
||||
} else {
|
||||
ctx.ProcessFloat(m, CHAT_IFRAME, link, arg...)
|
||||
m.ProcessField(ctx.ACTION, ctx.RUN, CHAT_IFRAME)
|
||||
}
|
||||
}
|
||||
}},
|
||||
}, Hand: func(m *ice.Message, arg ...string) {
|
||||
ADMIN: {Name: "admin index list", Help: "后台", Role: aaa.VOID, Actions: ice.MergeActions(ice.Actions{
|
||||
DREAM_ACTION: {Hand: func(m *ice.Message, arg ...string) { DreamProcessIframe(m, arg...) }},
|
||||
}, DreamTablesAction()), Hand: func(m *ice.Message, arg ...string) {
|
||||
if m.Option(ice.MSG_SOURCE) != "" {
|
||||
RenderMain(m)
|
||||
} else {
|
||||
|
@ -23,9 +23,6 @@ import (
|
||||
)
|
||||
|
||||
func _dream_list(m *ice.Message, simple bool) *ice.Message {
|
||||
if ice.Info.NodeType == WORKER {
|
||||
return m
|
||||
}
|
||||
list := m.CmdMap(SPACE, mdb.NAME)
|
||||
mdb.HashSelect(m).Table(func(value ice.Maps) {
|
||||
if space, ok := list[value[mdb.NAME]]; ok {
|
||||
@ -78,10 +75,7 @@ func _dream_list_icon(m *ice.Message) {
|
||||
})
|
||||
}
|
||||
func _dream_list_more(m *ice.Message, simple bool) *ice.Message {
|
||||
if m.IsCliUA() {
|
||||
return m
|
||||
}
|
||||
list := m.Spawn(ice.Maps{ice.MSG_FIELDS: ""}).CmdMap(SPIDE, CLIENT_NAME)
|
||||
list := m.CmdMap(SPIDE, CLIENT_NAME)
|
||||
m.Cmds(SPACE).Table(func(value ice.Maps) {
|
||||
value[mdb.ICONS] = nfs.USR_ICONS_VOLCANOS
|
||||
value[nfs.REPOS] = "https://" + value[nfs.MODULE]
|
||||
@ -90,7 +84,6 @@ func _dream_list_more(m *ice.Message, simple bool) *ice.Message {
|
||||
case SERVER:
|
||||
value[mdb.ICONS] = nfs.USR_ICONS_ICEBERGS
|
||||
value[mdb.TEXT] = kit.JoinLine(value[nfs.MODULE], value[mdb.TEXT])
|
||||
|
||||
if simple {
|
||||
defer m.PushButton("")
|
||||
} else {
|
||||
@ -129,12 +122,12 @@ func _dream_start(m *ice.Message, name string) {
|
||||
}
|
||||
defer mdb.Lock(m, m.PrefixKey(), cli.START, name)()
|
||||
p := _dream_check(m, name)
|
||||
gdb.Event(m, DREAM_CREATE, m.OptionSimple(mdb.NAME))
|
||||
defer m.Options(cli.CMD_DIR, "", cli.CMD_ENV, "", cli.CMD_OUTPUT, "")
|
||||
m.Options(cli.CMD_DIR, kit.Path(p), cli.CMD_ENV, kit.EnvList(kit.Simple(m.OptionSimple(ice.TCP_DOMAIN),
|
||||
cli.CTX_OPS, HostPort(m, tcp.LOCALHOST, m.Cmdv(SERVE, tcp.PORT)), cli.CTX_LOG, ice.VAR_LOG_BOOT_LOG, cli.CTX_PID, ice.VAR_LOG_ICE_PID,
|
||||
cli.CTX_ROOT, kit.Path(""), cli.PATH, cli.BinPath(p, ""), cli.USER, ice.Info.Username,
|
||||
)...), cli.CMD_OUTPUT, path.Join(p, ice.VAR_LOG_BOOT_LOG), mdb.CACHE_CLEAR_ONEXIT, ice.TRUE)
|
||||
gdb.Event(m, DREAM_CREATE, m.OptionSimple(mdb.NAME, mdb.TYPE, cli.CMD_DIR))
|
||||
kit.If(m.Option(nfs.BINARY) == "" && cli.SystemFind(m, "go") == "", func(p string) { m.Option(nfs.BINARY, SpideOrigin(m, ice.DEV_IP)+S(name)) })
|
||||
kit.If(m.Option(nfs.BINARY), func(p string) { _dream_binary(m, p) })
|
||||
kit.If(m.Option(nfs.TEMPLATE), func(p string) { _dream_template(m, p) })
|
||||
@ -178,7 +171,7 @@ func _dream_binary(m *ice.Message, p string) {
|
||||
}
|
||||
func _dream_template(m *ice.Message, p string) {
|
||||
kit.For([]string{
|
||||
ice.README_MD, ice.MAKEFILE, ice.LICENSE, ice.GO_MOD, ice.GO_SUM,
|
||||
ice.LICENSE, ice.README_MD, ice.MAKEFILE, ice.GO_MOD, ice.GO_SUM,
|
||||
ice.SRC_MAIN_SH, ice.SRC_MAIN_SHY, ice.SRC_MAIN_GO, ice.SRC_MAIN_JS,
|
||||
ice.ETC_MISS_SH, ice.ETC_INIT_SHY, ice.ETC_EXIT_SHY,
|
||||
}, func(file string) {
|
||||
@ -198,10 +191,10 @@ const (
|
||||
ALWAYS = "always"
|
||||
STARTALL = "startall"
|
||||
STOPALL = "stopall"
|
||||
PUBLISH = "publish"
|
||||
FOR_EACH = "forEach"
|
||||
FOR_FLOW = "forFlow"
|
||||
|
||||
DREAM_INPUTS = "dream.inputs"
|
||||
DREAM_CREATE = "dream.create"
|
||||
DREAM_REMOVE = "dream.remove"
|
||||
DREAM_TRASH = "dream.trash"
|
||||
@ -210,7 +203,6 @@ const (
|
||||
DREAM_OPEN = "dream.open"
|
||||
DREAM_CLOSE = "dream.close"
|
||||
|
||||
DREAM_INPUTS = "dream.inputs"
|
||||
DREAM_TABLES = "dream.tables"
|
||||
DREAM_ACTION = "dream.action"
|
||||
)
|
||||
@ -223,6 +215,13 @@ func init() {
|
||||
), Actions: ice.MergeActions(ice.Actions{
|
||||
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
|
||||
m = m.Spawn()
|
||||
m.GoSleep("1s", func() {
|
||||
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)
|
||||
aaa.White(m, kit.Keys(m.PrefixKey(), ctx.ACTION, cmd))
|
||||
}
|
||||
})
|
||||
m.GoSleep("10s", func() {
|
||||
mdb.HashSelects(m).Table(func(value ice.Maps) {
|
||||
if value[cli.RESTART] == ALWAYS && nfs.Exists(m, path.Join(ice.USR_LOCAL_WORK+value[mdb.NAME])) {
|
||||
@ -230,13 +229,6 @@ func init() {
|
||||
}
|
||||
})
|
||||
})
|
||||
m.GoSleep("1s", func() {
|
||||
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)
|
||||
}
|
||||
aaa.White(m, kit.Keys(m.PrefixKey(), ctx.ACTION, DREAM_ACTION, ctx.RUN))
|
||||
})
|
||||
}},
|
||||
html.BUTTON: {Hand: func(m *ice.Message, arg ...string) { mdb.Config(m, html.BUTTON, kit.Join(arg)) }},
|
||||
mdb.SEARCH: {Hand: func(m *ice.Message, arg ...string) {
|
||||
@ -251,6 +243,9 @@ func init() {
|
||||
case mdb.NAME, nfs.TEMPLATE:
|
||||
_dream_list(m, true).Cut("name,status,time")
|
||||
return
|
||||
case mdb.ICONS:
|
||||
mdb.HashInputs(m, arg)
|
||||
return
|
||||
case nfs.BINARY:
|
||||
m.Cmdy(nfs.DIR, ice.BIN, "path,size,time", kit.Dict(nfs.DIR_TYPE, nfs.TYPE_BIN))
|
||||
m.Cmd(nfs.DIR, ice.USR_LOCAL_WORK, kit.Dict(nfs.DIR_TYPE, nfs.TYPE_BOTH), func(value ice.Maps) {
|
||||
@ -263,17 +258,11 @@ func init() {
|
||||
m.Push(arg[0], origin+S(value[mdb.NAME])).Push(nfs.SIZE, value[nfs.SIZE]).Push(mdb.TIME, value[mdb.TIME])
|
||||
})
|
||||
})
|
||||
case mdb.ICONS:
|
||||
mdb.HashInputs(m, arg)
|
||||
return
|
||||
}
|
||||
case STARTALL:
|
||||
DreamEach(m, "", cli.STOP, func(name string) { m.Push(arg[0], name) })
|
||||
return
|
||||
case MAIN:
|
||||
m.Cmdy(SPACE, m.Option(mdb.NAME), SPACE, mdb.INPUTS, arg)
|
||||
return
|
||||
case "send":
|
||||
case tcp.SEND:
|
||||
m.Cmd(SPACE, func(value ice.Maps) {
|
||||
kit.If(kit.IsIn(value[mdb.TYPE], SERVER), func() { m.Push(arg[0], value[mdb.NAME]) })
|
||||
})
|
||||
@ -282,11 +271,11 @@ func init() {
|
||||
switch arg[0] {
|
||||
case mdb.NAME:
|
||||
DreamEach(m, "", cli.START, func(name string) { m.Push(arg[0], name) })
|
||||
case ctx.CMDS:
|
||||
m.Cmdy(ctx.COMMAND)
|
||||
case nfs.FILE:
|
||||
m.Options(nfs.DIR_TYPE, nfs.TYPE_CAT, ice.MSG_FIELDS, nfs.PATH)
|
||||
m.Cmdy(nfs.DIR, nfs.SRC).Cmdy(nfs.DIR, nfs.ETC).Cmdy(nfs.DIR, "")
|
||||
case ctx.CMDS:
|
||||
m.Cmdy(ctx.COMMAND)
|
||||
default:
|
||||
gdb.Event(m, DREAM_INPUTS, arg)
|
||||
}
|
||||
@ -295,9 +284,9 @@ func init() {
|
||||
kit.If(!strings.Contains(m.Option(mdb.NAME), "-") || !strings.HasPrefix(m.Option(mdb.NAME), "20"), func() { m.Option(mdb.NAME, m.Time("20060102-")+m.Option(mdb.NAME)) })
|
||||
kit.If(mdb.Config(m, nfs.BINARY), func(p string) { m.OptionDefault(nfs.BINARY, p+m.Option(mdb.NAME)) })
|
||||
kit.If(mdb.Config(m, nfs.REPOS), func(p string) { m.OptionDefault(nfs.REPOS, p+m.Option(mdb.NAME)) })
|
||||
m.Option(nfs.REPOS, kit.Select("", kit.Slice(kit.Split(m.Option(nfs.REPOS)), -1), 0))
|
||||
m.Option(nfs.REPOS, kit.Select("", kit.Split(m.Option(nfs.REPOS)), -1))
|
||||
m.OptionDefault(mdb.ICONS, nfs.USR_ICONS_CONTEXTS)
|
||||
if mdb.HashCreate(m); !m.IsCliUA() {
|
||||
if mdb.HashCreate(m); ice.Info.Important == true {
|
||||
_dream_start(m, m.Option(mdb.NAME))
|
||||
}
|
||||
}},
|
||||
@ -312,7 +301,7 @@ func init() {
|
||||
})
|
||||
}},
|
||||
cli.BUILD: {Name: "build name", Hand: func(m *ice.Message, arg ...string) {
|
||||
compile := cli.SystemFind(m, "go") != ""
|
||||
compile := cli.SystemFindGo(m)
|
||||
m.Option(ice.MSG_TITLE, kit.Keys(m.Option(ice.MSG_USERPOD0), m.Option(ice.MSG_USERPOD), m.CommandKey(), m.ActionKey()))
|
||||
m.Cmd("", FOR_FLOW, m.Option(mdb.NAME), kit.JoinWord(cli.SH, ice.ETC_MISS_SH), func(p string) bool {
|
||||
if compile && nfs.Exists(m, path.Join(p, ice.SRC_MAIN_GO)) {
|
||||
@ -324,7 +313,7 @@ func init() {
|
||||
})
|
||||
kit.If(m.Option(mdb.NAME) == "", func() { m.Sleep3s().Cmdy(ROUTE, cli.BUILD).ProcessInner() })
|
||||
}},
|
||||
PUBLISH: {Name: "publish name", Help: "发布", Icon: "bi bi-send-check", Hand: func(m *ice.Message, arg ...string) {
|
||||
PUBLISH: {Name: "publish name", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Option(ice.MSG_TITLE, kit.Keys(m.Option(ice.MSG_USERPOD0), m.Option(ice.MSG_USERPOD), m.CommandKey(), m.ActionKey()))
|
||||
list := []string{cli.LINUX, cli.DARWIN, cli.WINDOWS}
|
||||
msg := m.Spawn(ice.Maps{ice.MSG_DAEMON: ""})
|
||||
@ -340,67 +329,60 @@ func init() {
|
||||
kit.For(list, func(goos string) {
|
||||
PushNoticeRich(m, mdb.NAME, name, msg.Cmd(SPACE, name, COMPILE, goos, cli.AMD64, kit.Dict(ice.MSG_USERPOD, name)).AppendSimple())
|
||||
})
|
||||
})
|
||||
m.ProcessHold()
|
||||
}).ProcessHold()
|
||||
}},
|
||||
FOR_FLOW: {Name: "forFlow name cmd*='sh etc/miss.sh'", Help: "流程", Icon: "bi bi-terminal", Hand: func(m *ice.Message, arg ...string) {
|
||||
msg := m.Spawn()
|
||||
DreamEach(m.Spawn(ice.Maps{ice.MSG_DAEMON: ""}), m.Option(mdb.NAME), "", func(name string) { msg.Push(SPACE, name) })
|
||||
m.Options(ctx.DISPLAY, PLUGIN_XTERM, cli.CMD_OUTPUT, nfs.NewWriteCloser(func(buf []byte) (int, error) {
|
||||
PushNoticeGrow(m.Options(ice.MSG_COUNT, "0"), strings.ReplaceAll(string(buf), lex.NL, "\r\n"))
|
||||
return len(buf), nil
|
||||
}, func() error { return nil }))
|
||||
GoToastTable(msg, SPACE, func(value ice.Maps) {
|
||||
p := path.Join(ice.USR_LOCAL_WORK, value[SPACE])
|
||||
switch cb := m.OptionCB("").(type) {
|
||||
case func(string) bool:
|
||||
if cb(p) {
|
||||
return
|
||||
}
|
||||
}, nil))
|
||||
DreamEach(m, m.Option(mdb.NAME), "", func(name string) {
|
||||
p := path.Join(ice.USR_LOCAL_WORK, name)
|
||||
if cb, ok := m.OptionCB("").(func(string) bool); ok && cb(p) {
|
||||
return
|
||||
}
|
||||
PushNoticeGrow(m, strings.ReplaceAll(kit.Format("[%s]%s$ %s\r\n", time.Now().Format(ice.MOD_TIME_ONLY), value[SPACE], m.Option(ice.CMD)), lex.NL, "\r\n"))
|
||||
PushNoticeGrow(m, kit.Format("[%s]%s$ %s\r\n", time.Now().Format(ice.MOD_TIME_ONLY), name, m.Option(ice.CMD)))
|
||||
m.Cmd(cli.SYSTEM, kit.Split(m.Option(ice.CMD)), kit.Dict(cli.CMD_DIR, p)).Sleep300ms()
|
||||
PushNoticeGrow(m, "\r\n\r\n\r\n")
|
||||
})
|
||||
}},
|
||||
ctx.CMDS: {Name: "cmds name cmds*", Help: "命令", Icon: "bi bi-terminal", Hand: func(m *ice.Message, arg ...string) {
|
||||
DreamEach(m, m.Option(mdb.NAME), "", func(name string) {
|
||||
m.Push(mdb.NAME, name).Push(mdb.TEXT, m.Cmdx(SPACE, name, kit.Split(m.Option(ice.CMD))))
|
||||
m.Push(mdb.NAME, name).Push(mdb.TEXT, m.Cmdx(SPACE, name, kit.Split(m.Option(ctx.CMDS))))
|
||||
}).StatusTimeCount(m.OptionSimple(ctx.CMDS))
|
||||
}},
|
||||
nfs.CAT: {Name: "cat name file*", Help: "文件", Icon: "bi bi-file-earmark-code", Hand: func(m *ice.Message, arg ...string) {
|
||||
nfs.FILE: {Name: "file name file*", Help: "文件", Icon: "bi bi-file-earmark-code", Hand: func(m *ice.Message, arg ...string) {
|
||||
DreamEach(m, m.Option(mdb.NAME), "", func(name string) {
|
||||
m.Push(mdb.NAME, name).Push(mdb.TEXT, m.Cmdx(SPACE, name, nfs.CAT, m.Option(nfs.FILE)))
|
||||
}).StatusTimeCount(m.OptionSimple(nfs.FILE))
|
||||
}},
|
||||
cli.START: {Hand: func(m *ice.Message, arg ...string) {
|
||||
defer gdb.Event(m, DREAM_START, arg)
|
||||
_dream_start(m, m.Option(mdb.NAME))
|
||||
gdb.Event(m, DREAM_START, arg)
|
||||
}},
|
||||
cli.STOP: {Hand: func(m *ice.Message, arg ...string) {
|
||||
defer ToastProcess(m)()
|
||||
gdb.Event(m, DREAM_STOP, arg)
|
||||
m.Cmd(SPACE, mdb.MODIFY, m.OptionSimple(mdb.NAME), mdb.STATUS, cli.STOP)
|
||||
m.Cmd(SPACE, m.Option(mdb.NAME), ice.EXIT)
|
||||
m.Sleep3s()
|
||||
m.Cmd(SPACE, m.Option(mdb.NAME), ice.EXIT).Sleep3s()
|
||||
}},
|
||||
nfs.TRASH: {Hand: func(m *ice.Message, arg ...string) {
|
||||
gdb.Event(m, DREAM_TRASH, arg)
|
||||
nfs.Trash(m, path.Join(ice.USR_LOCAL_WORK, m.Option(mdb.NAME)))
|
||||
cli.RUNTIME: {Hand: func(m *ice.Message, arg ...string) {
|
||||
ProcessPodCmd(m, m.Option(mdb.NAME), "", nil, arg...)
|
||||
}},
|
||||
tcp.SEND: {Name: "send space*", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmd(SPACE, m.Option(SPACE), DREAM, mdb.CREATE, m.OptionSimple(mdb.NAME, mdb.ICONS, nfs.REPOS, nfs.BINARY))
|
||||
m.Cmd(SPACE, m.Option(SPACE), DREAM, cli.START, m.OptionSimple(mdb.NAME))
|
||||
ProcessIframe(m, "", m.MergePod(kit.Keys(m.Option(SPACE), m.Option(mdb.NAME))))
|
||||
}},
|
||||
GRANT: {Help: "授权", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmd(CHAT_GRANT, aaa.CONFIRM, kit.Dict(SPACE, m.Option(mdb.NAME)))
|
||||
nfs.TRASH: {Hand: func(m *ice.Message, arg ...string) {
|
||||
gdb.Event(m, DREAM_TRASH, arg)
|
||||
nfs.Trash(m, path.Join(ice.USR_LOCAL_WORK, m.Option(mdb.NAME)))
|
||||
}},
|
||||
OPEN: {Role: aaa.VOID, Hand: func(m *ice.Message, arg ...string) {
|
||||
ProcessIframe(m, m.Option(mdb.NAME), kit.Select(m.MergePod(m.Option(mdb.NAME), SpideOrigin(m, m.Option(mdb.NAME))+C(ADMIN)), m.Option(mdb.TYPE) == MASTER), arg...)
|
||||
ProcessIframe(m, m.Option(mdb.NAME), kit.Select(m.MergePod(m.Option(mdb.NAME)), SpideOrigin(m, m.Option(mdb.NAME)), m.Option(mdb.TYPE) == MASTER), arg...)
|
||||
}},
|
||||
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: {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) {
|
||||
@ -411,44 +393,44 @@ func init() {
|
||||
DREAM_TABLES: {Hand: func(m *ice.Message, arg ...string) {
|
||||
switch m.Option(mdb.TYPE) {
|
||||
case WORKER:
|
||||
m.PushButton(tcp.SEND, OPEN)
|
||||
m.PushButton(cli.RUNTIME, tcp.SEND, OPEN)
|
||||
default:
|
||||
m.PushButton(OPEN)
|
||||
m.PushButton(cli.RUNTIME, OPEN)
|
||||
}
|
||||
}},
|
||||
STATS_TABLES: {Hand: func(m *ice.Message, arg ...string) {
|
||||
if msg := mdb.HashSelects(m.Spawn()); msg.Length() > 0 {
|
||||
if msg := _dream_list(m, true); msg.Length() > 0 {
|
||||
stat := map[string]int{}
|
||||
list := m.CmdMap(SPACE, mdb.NAME)
|
||||
msg.Table(func(value ice.Maps) {
|
||||
if _, ok := list[value[mdb.NAME]]; ok {
|
||||
stat[cli.START]++
|
||||
}
|
||||
})
|
||||
PushStats(m, kit.Keys(m.CommandKey(), cli.START), stat[cli.START], "", "空间总数")
|
||||
PushStats(m, kit.Keys(m.CommandKey(), mdb.TOTAL), msg.Length(), "", "已启动空间")
|
||||
msg.Table(func(value ice.Maps) { stat[value[mdb.TYPE]]++; stat[value[mdb.STATUS]]++ })
|
||||
PushStats(m, kit.Keys(m.CommandKey(), MASTER), stat[MASTER], "", "已连接服务")
|
||||
PushStats(m, kit.Keys(m.CommandKey(), SERVER), stat[SERVER], "", "已连接机器")
|
||||
PushStats(m, kit.Keys(m.CommandKey(), cli.START), stat[cli.START], "", "已启动空间")
|
||||
}
|
||||
}},
|
||||
}, StatsAction(), DreamAction(), mdb.ImportantHashAction(
|
||||
mdb.SHORT, mdb.NAME, mdb.FIELD, "time,name,icons,repos,binary,template,restart", ctx.TOOLS, kit.Simple(STORE, SPIDE),
|
||||
html.BUTTON, kit.JoinWord(PORTAL, ADMIN, DESKTOP, WIKI_WORD, STATUS, VIMER, XTERM, COMPILE),
|
||||
}, StatsAction(), DreamAction(), DreamTablesAction(), mdb.ImportantHashAction(
|
||||
mdb.SHORT, mdb.NAME, mdb.FIELD, "time,name,icons,repos,binary,template,restart",
|
||||
html.BUTTON, kit.JoinWord(PORTAL, ADMIN, DESKTOP, WORD, STATUS, VIMER, COMPILE, XTERM, DREAM),
|
||||
ctx.TOOLS, kit.Simple(SPIDE, STORE, MATRIX, ROUTE),
|
||||
)), Hand: func(m *ice.Message, arg ...string) {
|
||||
if len(arg) == 0 {
|
||||
simple := m.Option("dream.simple") == ice.TRUE
|
||||
_dream_list(m, simple)
|
||||
_dream_list_icon(m)
|
||||
_dream_list_more(m, simple)
|
||||
stat := map[string]int{}
|
||||
m.Table(func(value ice.Maps) { stat[value[mdb.TYPE]]++; stat[value[mdb.STATUS]]++ })
|
||||
kit.If(stat[cli.START] == stat[WORKER], func() { delete(stat, cli.START) })
|
||||
m.Sort("type,status,name", []string{aaa.LOGIN, WORKER, SERVER, MASTER}, []string{cli.START, cli.STOP, cli.BEGIN}, ice.STR_R).StatusTimeCount(stat)
|
||||
if ctx.DisplayTableCard(m); ice.Info.NodeType == WORKER || !aaa.IsTechOrRoot(m) || m.IsCliUA() {
|
||||
m.Action()
|
||||
} else if cli.SystemFind(m, "go") == "" {
|
||||
m.Action(html.FILTER, mdb.CREATE, STARTALL, STOPALL)
|
||||
} else {
|
||||
m.Action(html.FILTER, mdb.CREATE, STARTALL, STOPALL, cli.BUILD, PUBLISH)
|
||||
if ice.Info.NodeType != WORKER {
|
||||
_dream_list(m, simple)
|
||||
_dream_list_icon(m)
|
||||
}
|
||||
if !m.IsCliUA() {
|
||||
_dream_list_more(m, simple)
|
||||
}
|
||||
if ice.Info.NodeType == WORKER || !aaa.IsTechOrRoot(m) || m.IsCliUA() {
|
||||
m.Action()
|
||||
} else if cli.SystemFindGo(m) {
|
||||
m.Action(html.FILTER, mdb.CREATE, STARTALL, STOPALL, cli.BUILD, PUBLISH)
|
||||
} else {
|
||||
m.Action(html.FILTER, mdb.CREATE, STARTALL, STOPALL)
|
||||
}
|
||||
m.Sort("type,status,name", []string{aaa.LOGIN, WORKER, SERVER, MASTER}, []string{cli.START, cli.STOP, cli.BEGIN}, ice.STR_R)
|
||||
m.StatusTimeCountStats(mdb.TYPE, mdb.STATUS)
|
||||
ctx.DisplayTableCard(m)
|
||||
} else if arg[0] == ctx.ACTION {
|
||||
gdb.Event(m, DREAM_ACTION, arg)
|
||||
} else {
|
||||
@ -458,68 +440,63 @@ func init() {
|
||||
})
|
||||
}
|
||||
|
||||
func DreamAction() ice.Actions {
|
||||
return ice.MergeActions(ice.Actions{
|
||||
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.ProcessFloat(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 m.Option(mdb.TYPE) == MASTER && (kit.IsIn(ctx.ShortCmd(m.PrefixKey()), PORTAL, DESKTOP)) {
|
||||
if ProcessIframe(m, "", SpideOrigin(m, m.Option(mdb.NAME))+C(m.PrefixKey()), arg...); !m.IsMetaKey() {
|
||||
m.ProcessField(ctx.ACTION, ctx.RUN, CHAT_IFRAME)
|
||||
}
|
||||
} 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))
|
||||
m.Push("_space", dream)
|
||||
}
|
||||
func DreamTablesAction() ice.Actions {
|
||||
return ice.Actions{ice.CTX_INIT: {Hand: DreamWhiteHandle},
|
||||
DREAM_TABLES: {Hand: func(m *ice.Message, arg ...string) { m.PushButton(kit.Dict(m.CommandKey(), m.Commands("").Help)) }},
|
||||
DREAM_ACTION: {Hand: func(m *ice.Message, arg ...string) { DreamProcess(m, "", nil, arg...) }},
|
||||
}
|
||||
}
|
||||
func DreamAction() ice.Actions {
|
||||
return gdb.EventsAction(DREAM_INPUTS, DREAM_CREATE, DREAM_TRASH, DREAM_OPEN, DREAM_CLOSE, SERVE_START)
|
||||
}
|
||||
func DreamWhiteHandle(m *ice.Message, arg ...string) {
|
||||
aaa.White(m, kit.Keys(DREAM, ctx.ACTION, m.ShortKey()))
|
||||
aaa.White(m, kit.Keys(m.ShortKey(), ctx.ACTION, DREAM_ACTION))
|
||||
}
|
||||
func DreamProcessIframe(m *ice.Message, arg ...string) {
|
||||
if kit.HasPrefixList(arg, ctx.ACTION, m.CommandKey()) && len(arg) == 2 {
|
||||
defer m.Push(TITLE, kit.Keys(m.Option(mdb.NAME), m.ShortKey()))
|
||||
}
|
||||
DreamProcess(m, CHAT_IFRAME, func() string {
|
||||
if m.Option(mdb.TYPE) == MASTER {
|
||||
return SpideOrigin(m, m.Option(mdb.NAME)) + C(m.ShortKey())
|
||||
}
|
||||
return m.MergePodCmd(m.Option(mdb.NAME), m.ShortKey())
|
||||
}, arg...)
|
||||
}
|
||||
func DreamProcess(m *ice.Message, cmd string, args ice.Any, arg ...string) {
|
||||
if !kit.HasPrefixList(arg, ctx.ACTION, m.ShortKey()) && !kit.HasPrefixList(arg, ctx.ACTION, m.CommandKey()) {
|
||||
return
|
||||
} else if arg = arg[2:]; len(arg) == 0 {
|
||||
arg = append(arg, m.Option(mdb.NAME))
|
||||
defer m.ProcessField(ctx.ACTION, m.ShortKey(), arg[0], ctx.RUN)
|
||||
defer processSpace(m, arg[0], arg[0], m.ShortKey())
|
||||
}
|
||||
ctx.ProcessFloat(m.Options(ice.POD, arg[0]), kit.Select(m.ShortKey(), cmd), args, arg[1:]...)
|
||||
}
|
||||
func DreamEach(m *ice.Message, name string, status string, cb func(string)) *ice.Message {
|
||||
reg, err := regexp.Compile(name)
|
||||
if m.WarnNotValid(err) {
|
||||
return m
|
||||
}
|
||||
list := []string{}
|
||||
m.Spawn().Cmds(DREAM).Table(func(value ice.Maps) {
|
||||
if value[mdb.STATUS] == kit.Select(cli.START, status) && reg.MatchString(value[mdb.NAME]) && value[mdb.TYPE] == WORKER {
|
||||
list = append(list, value[mdb.NAME])
|
||||
msg := m.Spawn()
|
||||
m.Cmds(DREAM).Table(func(value ice.Maps) {
|
||||
if value[mdb.STATUS] == kit.Select(cli.START, status) && (value[mdb.NAME] == name || reg.MatchString(kit.Format("%s:%s=%s@%d", value[mdb.NAME], value[mdb.TYPE], value[nfs.MODULE], value[nfs.VERSION]))) {
|
||||
msg.Push(mdb.NAME, value[mdb.NAME])
|
||||
}
|
||||
})
|
||||
if len(list) == 0 {
|
||||
return m
|
||||
}
|
||||
GoToast(m, func(toast func(string, int, int)) []string {
|
||||
kit.For(list, func(name string, index, total int) { toast(name, index, total); cb(name) })
|
||||
return nil
|
||||
})
|
||||
return m
|
||||
}
|
||||
func DreamList(m *ice.Message) *ice.Message {
|
||||
return m.SplitIndex(AdminCmd(m, DREAM).Result())
|
||||
}
|
||||
func DreamWhiteHandle(m *ice.Message, arg ...string) {
|
||||
aaa.White(m, kit.Keys(DREAM, ctx.ACTION, m.CommandKey()))
|
||||
aaa.White(m, kit.Keys(DREAM, ctx.ACTION, m.PrefixKey()))
|
||||
aaa.White(m, kit.Keys(ctx.ShortCmd(m.PrefixKey()), ctx.ACTION, DREAM_ACTION))
|
||||
return GoToastTable(msg, mdb.NAME, func(value ice.Maps) { cb(value[mdb.NAME]) })
|
||||
}
|
||||
func DreamListSpide(m *ice.Message, list []string, types string, cb func(dev, origin string)) {
|
||||
m.Cmds(DREAM).Table(func(value ice.Maps) {
|
||||
kit.If(value[mdb.TYPE] == types, func() { list = append(list, value[mdb.NAME]) })
|
||||
})
|
||||
msg := m.Spawn()
|
||||
kit.For(list, func(name string) { msg.Push(mdb.NAME, name) })
|
||||
m.Cmds(SPACE).Table(func(value ice.Maps) { kit.If(value[mdb.TYPE] == types, func() { msg.Push(mdb.NAME, value[mdb.NAME]) }) })
|
||||
has := map[string]bool{}
|
||||
GoToast(m, func(toast func(name string, count, total int)) []string {
|
||||
kit.For(list, func(dev string, index, total int) {
|
||||
toast(dev, index, total)
|
||||
if origin := SpideOrigin(m, dev); !has[origin] {
|
||||
has[origin] = true
|
||||
cb(dev, origin)
|
||||
}
|
||||
})
|
||||
return nil
|
||||
GoToastTable(msg, mdb.NAME, func(value ice.Maps) {
|
||||
origin := SpideOrigin(m, value[mdb.NAME])
|
||||
kit.If(!has[origin], func() { has[origin] = true; cb(value[mdb.NAME], origin) })
|
||||
})
|
||||
}
|
||||
func DreamList(m *ice.Message) *ice.Message {
|
||||
return AdminCmd(m.Options("dream.simple", ice.TRUE), DREAM)
|
||||
}
|
||||
|
@ -96,33 +96,3 @@ func PushStream(m *ice.Message) *ice.Message {
|
||||
}
|
||||
func init() { ice.Info.PushNotice = PushNotice }
|
||||
func init() { ice.Info.PushStream = PushStream }
|
||||
|
||||
func ProcessIframe(m *ice.Message, title, link string, arg ...string) *ice.Message {
|
||||
if m.IsMetaKey() {
|
||||
m.ProcessOpen(link)
|
||||
return m
|
||||
}
|
||||
if !kit.HasPrefixList(arg, ctx.RUN) {
|
||||
defer m.Push(TITLE, title)
|
||||
}
|
||||
return ctx.ProcessFloat(m, CHAT_IFRAME, link, arg...)
|
||||
}
|
||||
func ProcessPodCmd(m *ice.Message, pod, cmd string, args ice.Any, arg ...string) *ice.Message {
|
||||
if kit.HasPrefixList(arg, ctx.RUN) {
|
||||
ctx.ProcessField(m.Options(ice.POD, arg[1]), arg[2], args, kit.Simple(arg[0], arg[3:])...)
|
||||
} else {
|
||||
ctx.ProcessField(m.Options(ice.POD, pod), cmd, args, arg...).ProcessField(ctx.ACTION, m.ActionKey(), ctx.RUN, pod, cmd)
|
||||
}
|
||||
return m
|
||||
}
|
||||
func ProcessHashPodCmd(m *ice.Message, arg ...string) *ice.Message {
|
||||
msg := m
|
||||
if kit.HasPrefixList(arg, ctx.RUN) {
|
||||
msg = mdb.HashSelects(m.Spawn(), arg[1])
|
||||
arg = kit.Simple(arg[0], arg[2:])
|
||||
} else {
|
||||
msg = mdb.HashSelects(m.Spawn(), m.Option(mdb.HASH))
|
||||
defer m.ProcessField(ctx.ACTION, m.ActionKey(), ctx.RUN, m.Option(mdb.HASH))
|
||||
}
|
||||
return ctx.ProcessField(m.Options(ice.POD, msg.Append(SPACE)), msg.Append(ctx.INDEX), kit.Split(msg.Append(ctx.ARGS)), arg...)
|
||||
}
|
||||
|
43
base/web/process.go
Normal file
43
base/web/process.go
Normal file
@ -0,0 +1,43 @@
|
||||
package web
|
||||
|
||||
import (
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/ctx"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
)
|
||||
|
||||
func ProcessIframe(m *ice.Message, title, link string, arg ...string) *ice.Message {
|
||||
if m.IsMetaKey() {
|
||||
m.ProcessOpen(link)
|
||||
return m
|
||||
}
|
||||
if !kit.HasPrefixList(arg, ctx.RUN) {
|
||||
defer m.Push(TITLE, title)
|
||||
}
|
||||
return ctx.ProcessFloat(m, CHAT_IFRAME, link, arg...)
|
||||
}
|
||||
func ProcessPodCmd(m *ice.Message, pod, cmd string, args ice.Any, arg ...string) *ice.Message {
|
||||
if kit.HasPrefixList(arg, ctx.RUN) {
|
||||
pod, cmd, arg = arg[1], arg[2], kit.Simple(arg[0], arg[3:])
|
||||
} else {
|
||||
cmd = kit.Select(m.ActionKey(), cmd)
|
||||
defer processSpace(m, pod, pod, cmd)
|
||||
}
|
||||
return ctx.ProcessFloat(m.Options(ice.POD, pod), cmd, args, arg...)
|
||||
}
|
||||
func ProcessHashPodCmd(m *ice.Message, arg ...string) (msg *ice.Message) {
|
||||
if kit.HasPrefixList(arg, ctx.RUN) {
|
||||
msg = mdb.HashSelects(m.Spawn(), arg[1])
|
||||
arg = kit.Simple(arg[0], arg[2:])
|
||||
} else {
|
||||
msg = mdb.HashSelects(m.Spawn(), m.Option(mdb.HASH))
|
||||
defer processSpace(m, msg.Append(SPACE), m.Option(mdb.HASH))
|
||||
}
|
||||
return ctx.ProcessFloat(m.Options(ice.POD, msg.Append(SPACE)), msg.Append(ctx.INDEX), kit.Split(msg.Append(ctx.ARGS)), arg...)
|
||||
}
|
||||
func processSpace(m *ice.Message, pod string, arg ...string) {
|
||||
m.ProcessField(ctx.ACTION, m.ActionKey(), ctx.RUN, arg)
|
||||
m.RewriteAppend(func(value, key string, index int) string { return kit.Select("", value, key != SPACE) })
|
||||
m.Push(ice.MSG_SPACE, pod)
|
||||
}
|
@ -151,14 +151,16 @@ func RenderVersion(m *ice.Message) string {
|
||||
const (
|
||||
CHAT = "chat"
|
||||
WORD = "word"
|
||||
GRANT = "grant"
|
||||
VIMER = "vimer"
|
||||
XTERM = "xterm"
|
||||
GRANT = "grant"
|
||||
DESKTOP = "desktop"
|
||||
UPGRADE = "upgrade"
|
||||
COMPILE = "compile"
|
||||
BINPACK = "binpack"
|
||||
|
||||
AUTOGEN = "autogen"
|
||||
BINPACK = "binpack"
|
||||
COMPILE = "compile"
|
||||
PUBLISH = "publish"
|
||||
UPGRADE = "upgrade"
|
||||
INSTALL = "install"
|
||||
|
||||
CODE_GIT_SERVICE = "web.code.git.service"
|
||||
@ -167,8 +169,8 @@ const (
|
||||
CODE_GIT_REPOS = "web.code.git.repos"
|
||||
CODE_AUTOGEN = "web.code.autogen"
|
||||
CODE_COMPILE = "web.code.compile"
|
||||
CODE_UPGRADE = "web.code.upgrade"
|
||||
CODE_PUBLISH = "web.code.publish"
|
||||
CODE_UPGRADE = "web.code.upgrade"
|
||||
CODE_VIMER = "web.code.vimer"
|
||||
CODE_INNER = "web.code.inner"
|
||||
CODE_XTERM = "web.code.xterm"
|
||||
|
@ -259,6 +259,11 @@ func init() {
|
||||
})
|
||||
}
|
||||
|
||||
func ServeCmdAction() ice.Actions {
|
||||
return ice.MergeActions(ice.Actions{
|
||||
nfs.PS: {Hand: func(m *ice.Message, arg ...string) { RenderCmd(m, "", arg) }},
|
||||
})
|
||||
}
|
||||
func IsLocalHost(m *ice.Message) bool {
|
||||
return (m.R == nil || m.R.Header.Get(html.XForwardedFor) == "") && tcp.IsLocalHost(m, m.Option(ice.MSG_USERIP))
|
||||
}
|
||||
|
@ -44,11 +44,9 @@ func init() {
|
||||
})
|
||||
Notify(m, "usr/icons/Infomation.png", cli.RUNTIME, "系统启动成功", ctx.INDEX, cli.RUNTIME)
|
||||
}},
|
||||
DESKTOP: {Help: "应用桌面", Role: aaa.VOID, Actions: ice.MergeActions(ice.Actions{
|
||||
ice.CTX_INIT: {Hand: web.DreamWhiteHandle},
|
||||
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())},
|
||||
DESKTOP: {Help: "桌面", Role: aaa.VOID, Actions: ice.MergeActions(ice.Actions{
|
||||
web.DREAM_ACTION: {Hand: func(m *ice.Message, arg ...string) { web.DreamProcessIframe(m, arg...) }},
|
||||
}, web.DreamTablesAction(), PodCmdAction(), CmdHashAction(), mdb.ExportHashAction())},
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -86,7 +86,7 @@ const COMPILE = "compile"
|
||||
|
||||
func init() {
|
||||
Index.MergeCommands(ice.Commands{
|
||||
COMPILE: {Name: "compile arch=amd64,386,arm,arm64,mipsle os=linux,darwin,windows src=src/main.go@key run binpack webpack devpack install", Icon: "go.png", Help: "编译", Actions: ice.MergeActions(ice.Actions{
|
||||
COMPILE: {Name: "compile arch=amd64,386,arm,arm64,mipsle os=linux,darwin,windows src=src/main.go@key run binpack webpack devpack install", Help: "构建", Icon: "go.png", Actions: ice.MergeActions(ice.Actions{
|
||||
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { cli.IsAlpine(m, GO, "go git") }},
|
||||
mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) {
|
||||
switch arg[0] {
|
||||
@ -106,11 +106,10 @@ func init() {
|
||||
}},
|
||||
web.DREAM_TABLES: {Hand: func(m *ice.Message, arg ...string) {
|
||||
kit.If(m.Option(mdb.TYPE) == web.WORKER && nfs.Exists(m, path.Join(ice.USR_LOCAL_WORK, m.Option(mdb.NAME), ice.SRC_MAIN_GO)), func() {
|
||||
kit.If(cli.SystemFind(m, GO), func() { m.PushButton(kit.Dict(m.CommandKey(), "构建")) })
|
||||
kit.If(cli.SystemFindGo(m), func() { m.PushButton(kit.Dict(m.CommandKey(), m.Commands("").Help)) })
|
||||
})
|
||||
}},
|
||||
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) {
|
||||
}, web.DreamTablesAction(), 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) {
|
||||
main, file, goos, arch := _compile_target(m, arg...)
|
||||
defer web.ToastProcess(m, file)(file)
|
||||
env := kit.Simple(cli.PATH, cli.BinPath(), cli.HOME, kit.Select(kit.Path(""), kit.Env(cli.HOME)), mdb.Configv(m, cli.ENV), m.Optionv(cli.ENV), cli.GOOS, goos, cli.GOARCH, arch)
|
||||
|
@ -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", Role: aaa.VOID, 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) {
|
||||
@ -153,7 +153,6 @@ func init() {
|
||||
nfs.SCRIPT: {Name: "script file*", Help: "脚本", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(nfs.DEFS, path.Join(m.Option(nfs.PATH), m.Option(nfs.FILE)), m.Cmdx("", TEMPLATE))
|
||||
}},
|
||||
nfs.REPOS: {Help: "仓库"}, web.SPACE: {Help: "空间"}, web.DREAM: {Help: "空间"},
|
||||
cli.OPENS: {Hand: func(m *ice.Message, arg ...string) { cli.Opens(m, arg...) }},
|
||||
cli.MAKE: {Hand: func(m *ice.Message, arg ...string) {
|
||||
defer web.ToastProcess(m)()
|
||||
@ -202,16 +201,13 @@ func init() {
|
||||
kit.If(m.Option(mdb.TYPE) == nfs.FILE, func() { m.Push(arg[0], ice.SRC_MAIN_SHY, ice.SRC_MAIN_GO, ice.SRC_MAIN_JS) })
|
||||
}
|
||||
}},
|
||||
ice.CTX_INIT: {Hand: web.DreamWhiteHandle},
|
||||
chat.FAVOR_TABLES: {Hand: func(m *ice.Message, arg ...string) {
|
||||
kit.If(m.Option(mdb.TYPE) == nfs.FILE, func() { m.PushButton(kit.Dict(m.CommandKey(), "源码")) })
|
||||
}},
|
||||
chat.FAVOR_ACTION: {Hand: func(m *ice.Message, arg ...string) {
|
||||
kit.If(m.Option(mdb.TYPE) == nfs.FILE, func() { ctx.ProcessField(m, m.PrefixKey(), nfs.SplitPath(m, m.Option(mdb.TEXT))) })
|
||||
}},
|
||||
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...) }},
|
||||
}, chat.FavorAction(), ctx.ConfAction(ctx.TOOLS, "xterm,compile,runtime")), Hand: func(m *ice.Message, arg ...string) {
|
||||
}, ctx.ConfAction(ctx.TOOLS, "xterm,compile,runtime"), chat.FavorAction(), web.DreamTablesAction()), 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, ice.APP)
|
||||
|
@ -69,7 +69,7 @@ const XTERM = "xterm"
|
||||
func init() {
|
||||
shell := kit.Env("SHELL", "/bin/sh")
|
||||
Index.MergeCommands(ice.Commands{
|
||||
XTERM: {Name: "xterm hash auto", Icon: "Terminal.png", Help: "命令行", Actions: ice.MergeActions(ice.Actions{
|
||||
XTERM: {Name: "xterm hash auto", Help: "终端", Icon: "Terminal.png", Actions: ice.MergeActions(ice.Actions{
|
||||
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
|
||||
kit.If(m.Cmd("").Length() == 0, func() {
|
||||
m.Cmd("", mdb.CREATE, mdb.TYPE, shell)
|
||||
@ -155,10 +155,10 @@ func init() {
|
||||
})
|
||||
}},
|
||||
web.DREAM_TABLES: {Hand: func(m *ice.Message, arg ...string) {
|
||||
kit.If(aaa.IsTechOrRoot(m), func() { m.PushButton(kit.Dict(m.CommandKey(), "终端")) })
|
||||
kit.If(aaa.IsTechOrRoot(m), func() { m.PushButton(kit.Dict(m.CommandKey(), m.Commands("").Help)) })
|
||||
}},
|
||||
web.DREAM_ACTION: {Hand: func(m *ice.Message, arg ...string) { web.DreamProcess(m, cli.Shell(m), arg...) }},
|
||||
}, chat.FavorAction(), mdb.HashAction(mdb.FIELD, "time,hash,type,name,text,path")), Hand: func(m *ice.Message, arg ...string) {
|
||||
web.DREAM_ACTION: {Hand: func(m *ice.Message, arg ...string) { web.DreamProcess(m, "", cli.Shell(m), arg...) }},
|
||||
}, web.DreamTablesAction(), chat.FavorAction(), 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) {
|
||||
m.Action(mdb.CREATE, mdb.PRUNES, ice.APP)
|
||||
|
@ -74,9 +74,7 @@ func init() {
|
||||
m.Cmdy(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...) }},
|
||||
}, ctx.ConfAction(mdb.TOOLS, "todo,epic"), TASK), Hand: func(m *ice.Message, arg ...string) {
|
||||
}, web.DreamTablesAction(), 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...)
|
||||
|
@ -70,8 +70,7 @@ const PORTAL = "portal"
|
||||
|
||||
func init() {
|
||||
Index.MergeCommands(ice.Commands{
|
||||
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) }},
|
||||
PORTAL: {Name: "portal path auto", Help: "官网", Role: aaa.VOID, Actions: ice.MergeActions(ice.Actions{
|
||||
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) {
|
||||
ctx.Run(m, arg...)
|
||||
@ -80,10 +79,8 @@ func init() {
|
||||
m.Copy(m.Spawn([]byte(m.Cmdx(nfs.CAT, p))))
|
||||
}
|
||||
}},
|
||||
ice.CTX_INIT: {Hand: web.DreamWhiteHandle},
|
||||
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("")), Hand: func(m *ice.Message, arg ...string) {
|
||||
web.DREAM_ACTION: {Hand: func(m *ice.Message, arg ...string) { web.DreamProcessIframe(m, arg...) }},
|
||||
}, web.ServeCmdAction(), web.DreamTablesAction()), Hand: func(m *ice.Message, arg ...string) {
|
||||
if m.Push(HEADER, m.Cmdx(WORD, path.Join(nfs.USR_LEARNING_PORTAL, 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.USR_LEARNING_PORTAL, path.Join(arg...), INDEX_SHY)))
|
||||
|
@ -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", Role: aaa.VOID, 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)
|
||||
@ -36,7 +36,6 @@ func init() {
|
||||
WordAlias(m, LABEL, CHART, LABEL)
|
||||
WordAlias(m, CHAIN, CHART, CHAIN)
|
||||
WordAlias(m, SEQUENCE, CHART, SEQUENCE)
|
||||
web.DreamWhiteHandle(m, arg...)
|
||||
}},
|
||||
mdb.SEARCH: {Hand: func(m *ice.Message, arg ...string) {
|
||||
if mdb.IsSearchPreview(m, arg) {
|
||||
@ -74,9 +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")
|
||||
}},
|
||||
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...) }},
|
||||
}, WikiAction("", nfs.SHY), mdb.HashAction(mdb.SHORT, nfs.PATH, mdb.FIELD, "time,path")), Hand: func(m *ice.Message, arg ...string) {
|
||||
}, WikiAction("", nfs.SHY), web.DreamTablesAction(), mdb.HashAction(mdb.SHORT, nfs.PATH, mdb.FIELD, "time,path")), Hand: func(m *ice.Message, arg ...string) {
|
||||
if len(arg) > 0 && !strings.HasPrefix(arg[0], nfs.USR_LEARNING_PORTAL) {
|
||||
mdb.HashCreate(m.Spawn(), nfs.PATH, arg[0])
|
||||
}
|
||||
|
11
data.go
11
data.go
@ -12,8 +12,15 @@ func (m *Message) ActionKey() string {
|
||||
action := strings.TrimPrefix(strings.TrimSuffix(m._sub, PS), PS)
|
||||
return kit.Select("", action, !kit.IsIn(action, LIST, SELECT))
|
||||
}
|
||||
func (m *Message) CommandKey() string { return strings.TrimPrefix(strings.TrimSuffix(m._key, PS), PS) }
|
||||
func (m *Message) PrefixKey() string { return m.Prefix(m.CommandKey()) }
|
||||
func (m *Message) CommandKey() string { return strings.TrimPrefix(strings.TrimSuffix(m._key, PS), PS) }
|
||||
func (m *Message) PrefixKey() string { return m.Prefix(m.CommandKey()) }
|
||||
func (m *Message) ShortKey() string {
|
||||
key := m.CommandKey()
|
||||
if p, ok := Info.Index[key].(*Context); ok && p == m.target {
|
||||
return key
|
||||
}
|
||||
return m.PrefixKey()
|
||||
}
|
||||
func (m *Message) Prefix(arg ...string) string { return m.Target().Prefix(arg...) }
|
||||
func (m *Message) Confv(arg ...Any) (val Any) { // key sub value
|
||||
run := func(conf *Config) {
|
||||
|
2
misc.go
2
misc.go
@ -159,7 +159,7 @@ func (m *Message) CmdAppend(arg ...Any) string {
|
||||
}
|
||||
func (m *Message) CmdMap(arg ...string) map[string]map[string]string {
|
||||
field, list := kit.Slice(arg, -1)[0], map[string]map[string]string{}
|
||||
m._command(kit.Slice(arg, 0, -1)).Table(func(value Maps) { list[value[field]] = value })
|
||||
m._command(kit.Slice(arg, 0, -1), Maps{MSG_FIELDS: ""}).Table(func(value Maps) { list[value[field]] = value })
|
||||
return list
|
||||
}
|
||||
func (m *Message) Toast(content string, arg ...string) { // title duration
|
||||
|
@ -634,13 +634,6 @@ func init() {
|
||||
})
|
||||
}
|
||||
}},
|
||||
web.SERVE_START: {Hand: func(m *ice.Message, arg ...string) {
|
||||
return
|
||||
m.Go(func() {
|
||||
m.Cmd("", CLONE, REMOTE, "node_modules", mdb.NAME, "", nfs.PATH, "")
|
||||
m.Cmd("", CLONE, REMOTE, "icons", mdb.NAME, "", nfs.PATH, "")
|
||||
})
|
||||
}},
|
||||
web.STATS_TABLES: {Hand: func(m *ice.Message, _ ...string) {
|
||||
if ice.Info.NodeType == web.SERVER {
|
||||
if msg := mdb.HashSelects(m.Spawn()); msg.Length() > 0 {
|
||||
|
@ -31,11 +31,10 @@ const STATUS = "status"
|
||||
|
||||
func init() {
|
||||
Index.MergeCommands(ice.Commands{
|
||||
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", "信息", "remote", "远程库"),
|
||||
),
|
||||
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", "信息", "remote", "远程库")),
|
||||
), Actions: ice.MergeActions(ice.Actions{
|
||||
ice.CTX_INIT: {Hand: web.DreamWhiteHandle},
|
||||
mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) {
|
||||
switch arg[0] {
|
||||
case aaa.EMAIL:
|
||||
@ -51,10 +50,14 @@ func init() {
|
||||
mdb.Config(m, aaa.USERNAME, m.Option(aaa.USERNAME))
|
||||
mdb.Config(m, aaa.EMAIL, m.Option(aaa.EMAIL))
|
||||
}},
|
||||
ice.CTX_INIT: {Hand: web.DreamWhiteHandle},
|
||||
STASH: {Help: "清空", Icon: "bi bi-trash", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmd(cli.SYSTEM, GIT, STASH)
|
||||
m.Cmd(cli.SYSTEM, GIT, CHECKOUT, ".")
|
||||
m.Go(func() { m.Sleep30ms(ice.QUIT, 1) })
|
||||
}},
|
||||
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, "").PushButton(kit.Dict(m.CommandKey(), "源码"))
|
||||
m.Push(mdb.TEXT, "").PushButton(kit.Dict(m.CommandKey(), m.Commands("").Help))
|
||||
return
|
||||
}
|
||||
text := []string{}
|
||||
@ -71,8 +74,7 @@ func init() {
|
||||
m.Push(mdb.TEXT, strings.Join(text, ", "))
|
||||
m.PushButton(kit.Dict(m.CommandKey(), "源码"))
|
||||
}},
|
||||
web.DREAM_ACTION: {Hand: func(m *ice.Message, arg ...string) { web.DreamProcess(m, nil, arg...) }},
|
||||
mdb.DEV_REQUEST: {Name: "dev.request origin*", Help: "授权"},
|
||||
mdb.DEV_REQUEST: {Name: "dev.request origin*", Help: "授权"},
|
||||
web.DEV_CREATE_TOKEN: {Hand: func(m *ice.Message, arg ...string) {
|
||||
const FILE = ".git-credentials"
|
||||
host, list := ice.Map{kit.ParseURL(m.Option(web.ORIGIN)).Host: true}, []string{strings.Replace(m.Option(web.ORIGIN), "://", kit.Format("://%s:%s@", m.Option(ice.MSG_USERNAME), m.Option(web.TOKEN)), 1)}
|
||||
@ -83,12 +85,7 @@ func init() {
|
||||
m.Cmd(CONFIGS, mdb.CREATE, "credential.helper", "store")
|
||||
m.ProcessClose()
|
||||
}},
|
||||
STASH: {Help: "清空", Icon: "bi bi-trash", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmd(cli.SYSTEM, GIT, STASH)
|
||||
m.Cmd(cli.SYSTEM, GIT, CHECKOUT, ".")
|
||||
m.Go(func() { m.Sleep30ms(ice.QUIT, 1) })
|
||||
}},
|
||||
}, web.DevTokenAction(web.ORIGIN, web.ORIGIN), ctx.ConfAction(ctx.TOOLS, "xterm,compile"), Prefix(REPOS)), Hand: func(m *ice.Message, arg ...string) {
|
||||
}, ctx.ConfAction(ctx.TOOLS, "xterm,compile"), web.DreamTablesAction(), web.DevTokenAction(web.ORIGIN, web.ORIGIN), 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) == "" {
|
||||
|
@ -60,11 +60,7 @@ func (m *Message) MergePod(pod string, arg ...Any) string {
|
||||
func (m *Message) MergePodCmd(pod, cmd string, arg ...Any) string {
|
||||
ls := []string{}
|
||||
kit.If(kit.Keys(m.Option(MSG_USERPOD), pod), func(p string) { ls = append(ls, "s", p) })
|
||||
if cmd == "" {
|
||||
p, ok := Info.Index[m.CommandKey()]
|
||||
cmd = kit.Select(m.PrefixKey(), m.CommandKey(), ok && p == m.target)
|
||||
}
|
||||
ls = append(ls, "c", cmd)
|
||||
ls = append(ls, "c", kit.Select(m.ShortKey(), cmd))
|
||||
return m.MergeLink(PS+path.Join(ls...), arg...)
|
||||
}
|
||||
func (m *Message) MergeLink(url string, arg ...Any) string {
|
||||
|
Loading…
x
Reference in New Issue
Block a user