diff --git a/base/aaa/role.go b/base/aaa/role.go index edf7c0aa..88b37b34 100644 --- a/base/aaa/role.go +++ b/base/aaa/role.go @@ -111,6 +111,11 @@ func WhiteAction(key ...string) ice.Actions { }}} } func Right(m *ice.Message, key ...ice.Any) bool { + if key := kit.Simple(key); len(key) > 2 && key[1] == "action" && kit.IsIn(kit.Format(key[2]), "run", "command") { + return true + } else if len(key) > 0 && key[0] == "etc/path" { + return true + } return m.Option(ice.MSG_USERROLE) == ROOT || !m.Warn(m.Cmdx(ROLE, RIGHT, m.Option(ice.MSG_USERROLE), key, logs.FileLineMeta(-1)) != ice.OK, ice.ErrNotRight, kit.Keys(key...), USERROLE, m.Option(ice.MSG_USERROLE), logs.FileLineMeta(-1)) } diff --git a/base/cli/runtime.go b/base/cli/runtime.go index 0609317f..e7f2b4c1 100644 --- a/base/cli/runtime.go +++ b/base/cli/runtime.go @@ -157,7 +157,7 @@ const RUNTIME = "runtime" func init() { Index.MergeCommands(ice.Commands{ - RUNTIME: {Name: "runtime info=bootinfo,ifconfig,diskinfo,hostinfo,userinfo,procstat,procinfo,bootinfo,role,api,cli,cmd,mod,env,path,chain,routine auto upgrade restart logs conf", Icon: "usr/icons/Infomation.png", Help: "运行环境", Actions: ice.MergeActions(ice.Actions{ + RUNTIME: {Name: "runtime info=bootinfo,ifconfig,diskinfo,hostinfo,userinfo,procstat,procinfo,bootinfo,role,api,cli,cmd,mod,env,path,chain,routine auto upgrade restart logs conf", Icon: "Infomation.png", Help: "运行环境", Actions: ice.MergeActions(ice.Actions{ ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { aaa.White(m, ice.ETC_PATH) aaa.White(m, ice.LICENSE) @@ -261,7 +261,7 @@ func init() { "conf": {Help: "配置", Hand: func(m *ice.Message, arg ...string) { OpenCmds(m, kit.Format("cd %s", kit.Path("")), "vim etc/init.shy") }}, - }, ctx.CmdAction(), ctx.ConfAction("")), Hand: func(m *ice.Message, arg ...string) { + }, ctx.ConfAction("")), Hand: func(m *ice.Message, arg ...string) { kit.If(len(arg) > 0 && arg[0] == BOOTINFO, func() { arg = arg[1:] }) m.Cmdy(ctx.CONFIG, RUNTIME, arg) ctx.DisplayStoryJSON(m) diff --git a/base/ctx/command.go b/base/ctx/command.go index d20e40e1..c5d76662 100644 --- a/base/ctx/command.go +++ b/base/ctx/command.go @@ -64,6 +64,17 @@ func init() { COMMAND: {Name: "command key auto", Help: "命令", Actions: ice.MergeActions(ice.Actions{ ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { TravelCmd(m, func(key, file, line string) { AddFileCmd(file, key) }) + m.Travel(func(p *ice.Context, c *ice.Context, key string, cmd *ice.Command) { + if cmd.Actions == nil { + return + } + if _, ok := cmd.Actions[COMMAND]; !ok { + cmd.Actions[COMMAND] = &ice.Action{Hand: Command} + } + if _, ok := cmd.Actions[RUN]; !ok { + cmd.Actions[RUN] = &ice.Action{Hand: Run} + } + }) }}, mdb.SEARCH: {Hand: func(m *ice.Message, arg ...string) { if arg[0] == m.CommandKey() || len(arg) > 1 && arg[1] != "" { @@ -85,7 +96,7 @@ func init() { m.Echo(`%s %s %s;" f`+lex.NL, value[mdb.NAME], value[nfs.FILE], value[nfs.LINE]) }).Cmd(nfs.SAVE, nfs.TAGS, m.Result()) }}, - }, CmdAction(), aaa.RoleAction()), Hand: func(m *ice.Message, arg ...string) { + }, aaa.RoleAction()), Hand: func(m *ice.Message, arg ...string) { if len(arg) == 0 { m.Cmdy("", mdb.SEARCH, COMMAND, ice.OptionFields(INDEX)).StatusTimeCount() DisplayStory(m.Options(nfs.DIR_ROOT, "ice."), "spide.js?split=.") @@ -96,18 +107,8 @@ func init() { }) } -var Upload = func(*ice.Message) []string { return nil } +var PodCmd = func(m *ice.Message, arg ...ice.Any) bool { return false } -func PodCmd(m *ice.Message, arg ...ice.Any) bool { - Upload(m) - for _, key := range []string{ice.POD} { - if pod := m.Option(key); pod != "" { - m.Options(key, []string{}, ice.MSG_USERPOD, pod).Cmdy(append(kit.List(ice.SPACE, pod), arg...)...) - return true - } - } - return false -} func Run(m *ice.Message, arg ...string) { kit.If(!PodCmd(m, arg) && aaa.Right(m, arg), func() { m.Cmdy(arg) }) } diff --git a/base/nfs/dir.go b/base/nfs/dir.go index 8008932c..08b298c3 100644 --- a/base/nfs/dir.go +++ b/base/nfs/dir.go @@ -180,7 +180,7 @@ const DIR = "dir" func init() { Index.MergeCommands(ice.Commands{ - DIR: {Name: "dir path auto upload app", Icon: "usr/icons/dir.png", Help: "目录", Actions: ice.Actions{ + DIR: {Name: "dir path auto upload app", Icon: "dir.png", Help: "目录", Actions: ice.Actions{ ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { aaa.White(m, ice.SRC, ice.BIN, ice.USR) aaa.Black(m, ice.USR_LOCAL) @@ -250,11 +250,13 @@ func DirDeepAll(m *ice.Message, root, dir string, cb func(ice.Maps), arg ...stri } } func Show(m *ice.Message, file string) bool { + p := "/share/local/" + file + kit.If(m.Option(ice.MSG_USERPOD), func(pod string) { p += "?pod=" + pod }) switch strings.ToLower(kit.Ext(file)) { case "png", "jpg": - m.EchoImages("/share/local/" + file) + m.EchoImages(p) case "mp4", "mov": - m.EchoVideos("/share/local/" + file) + m.EchoVideos(p) default: if IsSourceFile(m, kit.Ext(file)) { m.Cmdy(CAT, file) diff --git a/base/nfs/pack.go b/base/nfs/pack.go index 9d71b2c0..3630bdc1 100644 --- a/base/nfs/pack.go +++ b/base/nfs/pack.go @@ -127,8 +127,11 @@ func Link(m optionMessage, oldname string, newname string) error { return OptionFiles(m).Link(oldname, newname) } -func Exists(m optionMessage, p string) bool { +func Exists(m optionMessage, p string, cb ...func(string)) bool { if _, e := OptionFiles(m).StatFile(p); e == nil { + for _, cb := range cb { + cb(p) + } return true } return false diff --git a/base/nfs/trash.go b/base/nfs/trash.go index 864ad461..c1a9a6b7 100644 --- a/base/nfs/trash.go +++ b/base/nfs/trash.go @@ -38,7 +38,8 @@ func init() { mdb.HashRemove(m, m.OptionSimple(mdb.HASH)) }}, mdb.REVERT: {Hand: func(m *ice.Message, arg ...string) { - Rename(m, m.Option(FILE), m.Option(FROM)) + msg := mdb.HashSelect(m.Spawn(), m.Option(mdb.HASH)) + Rename(m, msg.Append(FILE), msg.Append(FROM)) mdb.HashRemove(m, m.OptionSimple(mdb.HASH)) }}, mdb.PRUNES: {Hand: func(m *ice.Message, arg ...string) { diff --git a/base/web/cache.go b/base/web/cache.go index 5e483255..965e5fef 100644 --- a/base/web/cache.go +++ b/base/web/cache.go @@ -168,7 +168,6 @@ func init() { }, action.Hand) } }) - ctx.Upload = Upload } func Upload(m *ice.Message) []string { if up := kit.Simple(m.Optionv(ice.MSG_UPLOAD)); len(up) == 1 { diff --git a/base/web/count.go b/base/web/count.go index 4c25e16e..ea49171a 100644 --- a/base/web/count.go +++ b/base/web/count.go @@ -45,7 +45,7 @@ func init() { mdb.CREATE: {Name: "create type name text", Hand: func(m *ice.Message, arg ...string) { mdb.HashSelectUpdate(m, mdb.HashCreate(m), func(value ice.Map) { value[mdb.COUNT] = kit.Int(value[mdb.COUNT]) + 1 }) }}, - }, ctx.CmdAction(), mdb.HashAction(mdb.LIMIT, 1000, mdb.LEAST, 500, mdb.SHORT, "type,name", mdb.FIELD, "time,hash,count,type,name,text")), Hand: func(m *ice.Message, arg ...string) { + }, mdb.HashAction(mdb.LIMIT, 1000, mdb.LEAST, 500, mdb.SHORT, "type,name", mdb.FIELD, "time,hash,count,type,name,text")), Hand: func(m *ice.Message, arg ...string) { mdb.HashSelect(m, arg...).Sort("type,name,text") }}, }) diff --git a/base/web/dream.go b/base/web/dream.go index 203f9b31..c3299233 100644 --- a/base/web/dream.go +++ b/base/web/dream.go @@ -134,7 +134,7 @@ const DREAM = "dream" func init() { Index.MergeCommands(ice.Commands{ - DREAM: {Name: "dream name@key auto create repos startall stopall build cmd cat", Icon: "usr/icons/Launchpad.png", Help: "梦想家", Actions: ice.MergeActions(ice.Actions{ + DREAM: {Name: "dream name@key auto create repos startall stopall build cmd cat", Icon: "Launchpad.png", Help: "梦想家", Actions: ice.MergeActions(ice.Actions{ ctx.CONFIG: {Hand: func(m *ice.Message, arg ...string) { for _, cmd := range kit.Reverse(arg) { m.Cmd(gdb.EVENT, gdb.LISTEN, gdb.EVENT, DREAM_TABLES, ice.CMD, cmd) @@ -165,7 +165,7 @@ func init() { gdb.Event(m, DREAM_INPUTS, arg) } }}, - mdb.CREATE: {Name: "create name*=hi repos binary template", Hand: func(m *ice.Message, arg ...string) { + mdb.CREATE: {Name: "create name*=hi icon@icon repos binary template", Hand: func(m *ice.Message, arg ...string) { m.OptionDefault(mdb.ICON, nfs.USR_ICONS_ICEBERGS) m.Option(nfs.REPOS, kit.Select("", kit.Slice(kit.Split(m.Option(nfs.REPOS)), -1), 0)) 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)) }) @@ -281,7 +281,7 @@ func init() { DREAM_TABLES: {Hand: func(m *ice.Message, arg ...string) { kit.Switch(m.Option(mdb.TYPE), []string{WORKER, SERVER}, func() { m.PushButton(OPEN, ice.MAIN) }) }}, - }, DreamAction(), ctx.CmdAction(), mdb.ImportantHashAction(mdb.SHORT, mdb.NAME, mdb.FIELD, "time,name,icon,repos,binary,template")), Hand: func(m *ice.Message, arg ...string) { + }, DreamAction(), mdb.ImportantHashAction(mdb.SHORT, mdb.NAME, mdb.FIELD, "time,name,icon,repos,binary,template")), Hand: func(m *ice.Message, arg ...string) { if len(arg) == 0 { _dream_list(m) m.RewriteAppend(func(value, key string, index int) string { diff --git a/base/web/route.go b/base/web/route.go index 29dfaf6f..ff35db77 100644 --- a/base/web/route.go +++ b/base/web/route.go @@ -59,7 +59,7 @@ const ROUTE = "route" func init() { Index.MergeCommands(ice.Commands{ - ROUTE: {Name: "route space:text cmds:text auto spide cmds build travel prunes", Icon: "usr/icons/Podcasts.png", Help: "路由表", Actions: ice.MergeActions(ice.Actions{ + ROUTE: {Name: "route space:text cmds:text auto spide cmds build travel prunes", Icon: "Podcasts.png", Help: "路由表", Actions: ice.MergeActions(ice.Actions{ ice.MAIN: {Help: "首页", Hand: func(m *ice.Message, arg ...string) { ctx.ProcessField(m, CHAT_IFRAME, m.MergePod(""), arg...) }}, @@ -118,7 +118,7 @@ func init() { PushPodCmd(m, "", m.ActionKey()) m.Table(func(value ice.Maps) { kit.If(value[SPACE], func() { mdb.HashCreate(m.Spawn(), kit.Simple(value)) }) }) }}, - }, ctx.CmdAction(), mdb.HashAction(mdb.SHORT, SPACE, mdb.FIELD, "time,space,type,module,version,md5,size,path,hostname", mdb.SORT, "type,space", mdb.ACTION, ice.MAIN)), Hand: func(m *ice.Message, arg ...string) { + }, mdb.HashAction(mdb.SHORT, SPACE, mdb.FIELD, "time,space,type,module,version,md5,size,path,hostname", mdb.SORT, "type,space", mdb.ACTION, ice.MAIN)), Hand: func(m *ice.Message, arg ...string) { if len(arg) > 1 { _route_match(m, arg[0], func(value ice.Maps, i int, list []ice.Maps) { _route_push(m, value[SPACE], m.Cmd(SPACE, value[SPACE], arg[1:])) diff --git a/base/web/serve.go b/base/web/serve.go index aace6a6b..874dbb7e 100644 --- a/base/web/serve.go +++ b/base/web/serve.go @@ -119,7 +119,7 @@ func _serve_handle(key string, cmd *ice.Command, m *ice.Message, w http.Response }() m.Option(ice.MSG_OPTS, kit.Simple(m.Optionv(ice.MSG_OPTION), func(k string) bool { return !strings.HasPrefix(k, ice.MSG_SESSID) })) if m.Detailv(m.PrefixKey(), cmds); len(cmds) > 1 && cmds[0] == ctx.ACTION { - if !kit.IsIn(cmds[1], ctx.RUN, ctx.COMMAND) && m.Warn(r.Method == http.MethodGet, ice.ErrNotAllow) { + if !kit.IsIn(cmds[1], aaa.LOGIN, ctx.RUN, ctx.COMMAND) && m.Warn(r.Method == http.MethodGet, ice.ErrNotAllow) { return } m.ActionHand(cmd, key, cmds[1], cmds[2:]...) @@ -215,7 +215,7 @@ func init() { } kit.If(action.Hand == nil, func() { action.Hand = cmd.Hand }) sub = kit.Select(P(key, sub), PP(key, sub), strings.HasSuffix(sub, nfs.PS)) - c.Commands[sub] = &ice.Command{Name: kit.Select(cmd.Name, action.Name), Actions: ice.MergeActions(actions, ctx.CmdAction()), Hand: func(m *ice.Message, arg ...string) { + c.Commands[sub] = &ice.Command{Name: kit.Select(cmd.Name, action.Name), Actions: actions, Hand: func(m *ice.Message, arg ...string) { msg := m.Spawn(c, key, cmd) action.Hand(msg, arg...) m.Copy(msg) diff --git a/base/web/share.go b/base/web/share.go index 7a480bb4..fe0e2985 100644 --- a/base/web/share.go +++ b/base/web/share.go @@ -56,6 +56,7 @@ const ( TOAST = "toast" SHARE_LOCAL = "/share/local/" + SHARE_CACHE = "/share/cache/" ) const SHARE = "share" @@ -70,6 +71,16 @@ func init() { LOGIN: {Help: "登录", Hand: func(m *ice.Message, arg ...string) { m.EchoQRCode(m.Cmd(SHARE, mdb.CREATE, mdb.TYPE, LOGIN).Option(mdb.LINK)).ProcessInner() }}, + ctx.COMMAND: {Hand: func(m *ice.Message, arg ...string) { + if msg := mdb.HashSelect(m.Spawn(), m.Option(SHARE)); !IsNotValidFieldShare(m, msg) { + m.Cmdy(ctx.COMMAND, msg.Append(mdb.NAME)) + } + }}, + ctx.RUN: {Hand: func(m *ice.Message, arg ...string) { + if msg := mdb.HashSelect(m.Spawn(), m.Option(SHARE)); !IsNotValidFieldShare(m, msg) { + m.Cmdy(msg.Append(mdb.NAME), arg[1:]) + } + }}, nfs.PS: {Hand: func(m *ice.Message, arg ...string) { if m.Warn(len(arg) == 0 || arg[0] == "", ice.ErrNotValid, SHARE) { return @@ -84,21 +95,13 @@ func init() { m.RenderRedirect(msg.Append(mdb.TEXT), ice.MSG_SESSID, aaa.SessCreate(m, msg.Append(aaa.USERNAME))) case FIELD: RenderCmd(m, msg.Append(mdb.NAME), kit.UnMarshal(msg.Append(mdb.TEXT))) + case DOWNLOAD: + m.RenderDownload(msg.Append(mdb.TEXT)) default: RenderMain(m) } }}, - ctx.COMMAND: {Hand: func(m *ice.Message, arg ...string) { - if msg := mdb.HashSelect(m.Spawn(), m.Option(SHARE)); !IsNotValidFieldShare(m, msg) { - m.Cmdy(ctx.COMMAND, msg.Append(mdb.NAME)) - } - }}, - ctx.RUN: {Hand: func(m *ice.Message, arg ...string) { - if msg := mdb.HashSelect(m.Spawn(), m.Option(SHARE)); !IsNotValidFieldShare(m, msg) { - m.Cmdy(msg.Append(mdb.NAME), arg[1:]) - } - }}, - }, aaa.WhiteAction(ctx.COMMAND, ctx.RUN), mdb.HashAction(mdb.FIELD, "time,hash,type,name,text,usernick,username,userrole", mdb.EXPIRE, mdb.DAYS)), Hand: func(m *ice.Message, arg ...string) { + }, aaa.WhiteAction(), mdb.HashAction(mdb.FIELD, "time,hash,type,name,text,usernick,username,userrole", mdb.EXPIRE, mdb.DAYS)), Hand: func(m *ice.Message, arg ...string) { if kit.IsIn(m.Option(ice.MSG_USERROLE), aaa.ROOT, aaa.TECH) || len(arg) > 0 && arg[0] != "" { mdb.HashSelect(m, arg...) } @@ -137,15 +140,16 @@ func ShareLocalFile(m *ice.Message, arg ...string) { } if m.Option(ice.POD) == "" { m.RenderDownload(p) - return } else if pp := kit.Path(ice.USR_LOCAL_WORK, m.Option(ice.POD), p); nfs.Exists(m, pp) { m.RenderDownload(pp) - return } else if pp := kit.Path(ice.USR_LOCAL_WORK, m.Option(ice.POD)); nfs.Exists(m, pp) { m.RenderDownload(p) - return + } else { + m.RenderDownload(ProxyUpload(m, m.Option(ice.POD), p)) } - pp := path.Join(ice.VAR_PROXY, m.Option(ice.POD), p) +} +func ProxyUpload(m *ice.Message, pod string, p string) string { + pp := path.Join(ice.VAR_PROXY, pod, p) size, cache := int64(0), time.Now().Add(-time.Hour*24) if s, e := file.StatFile(pp); e == nil { size, cache = s.Size(), s.ModTime() @@ -153,9 +157,9 @@ func ShareLocalFile(m *ice.Message, arg ...string) { size, cache = s.Size(), s.ModTime() } kit.If(p == ice.BIN_ICE_BIN, func() { m.Option(ice.MSG_USERROLE, aaa.TECH) }) - share := m.Cmdx(SHARE, mdb.CREATE, mdb.TYPE, PROXY, mdb.NAME, p, mdb.TEXT, m.Option(ice.POD)) + share := m.Cmdx(SHARE, mdb.CREATE, mdb.TYPE, PROXY, mdb.NAME, p, mdb.TEXT, pod) defer m.Cmd(SHARE, mdb.REMOVE, mdb.HASH, share) url := tcp.PublishLocalhost(m, MergeLink(m, PP(SHARE, PROXY), SHARE, share)) - m.Cmd(SPACE, m.Option(ice.POD), SPIDE, PROXY, URL, url, nfs.SIZE, size, CACHE, cache.Format(ice.MOD_TIME), UPLOAD, mdb.AT+p) - m.RenderDownload(kit.Select(p, pp, file.ExistsFile(pp))) + m.Cmd(SPACE, pod, SPIDE, PROXY, URL, url, nfs.SIZE, size, CACHE, cache.Format(ice.MOD_TIME), UPLOAD, mdb.AT+p) + return kit.Select(p, pp, file.ExistsFile(pp)) } diff --git a/base/web/space.go b/base/web/space.go index 088f09d2..0740ac05 100644 --- a/base/web/space.go +++ b/base/web/space.go @@ -195,6 +195,19 @@ func init() { } } }) + ctx.PodCmd = func(m *ice.Message, arg ...ice.Any) bool { + Upload(m) + for _, key := range []string{ice.POD} { + if pod := m.Option(key); pod != "" { + if ls := kit.Simple(m.Optionv(ice.MSG_UPLOAD)); len(ls) > 1 { + m.Cmd(SPACE, pod, SPIDE, ice.DEV, CACHE, SHARE_CACHE+ls[0]) + } + m.Options(key, []string{}, ice.MSG_USERPOD, pod).Cmdy(append(kit.List(ice.SPACE, pod), arg...)...) + return true + } + } + return false + } 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) }}, diff --git a/base/web/web.go b/base/web/web.go index f40d0618..12225598 100644 --- a/base/web/web.go +++ b/base/web/web.go @@ -8,6 +8,7 @@ import ( "strings" 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/gdb" @@ -80,6 +81,9 @@ func init() { } func ApiAction(arg ...string) ice.Actions { return ice.Actions{kit.Select(nfs.PS, arg, 0): {}} } +func ApiWhiteAction() ice.Actions { + return ice.MergeActions(ApiAction(), aaa.WhiteAction()) +} func Prefix(arg ...string) string { for i, k := range arg { switch k { diff --git a/core/chat/action.go b/core/chat/action.go index 102860df..2151d02c 100644 --- a/core/chat/action.go +++ b/core/chat/action.go @@ -73,7 +73,7 @@ func init() { m.Cmdy(mdb.MODIFY, RIVER, _storm_key(m), mdb.LIST, m.OptionSimple(mdb.ID), arg) }}, web.SHARE: {Hand: func(m *ice.Message, arg ...string) { _action_share(m, arg...) }}, - }, web.ApiAction(), aaa.WhiteAction(web.SHARE, ctx.RUN, ctx.COMMAND), ctx.CmdAction()), Hand: func(m *ice.Message, arg ...string) { + }, web.ApiAction(), aaa.WhiteAction(web.SHARE)), Hand: func(m *ice.Message, arg ...string) { if m.Warn(m.Option(ice.MSG_USERNAME) == "", ice.ErrNotLogin, arg) { return } else if m.Warn(!_river_right(m, arg[0]), ice.ErrNotRight, arg) { diff --git a/core/chat/cmd.go b/core/chat/cmd.go index b78d13f1..2623582a 100644 --- a/core/chat/cmd.go +++ b/core/chat/cmd.go @@ -5,19 +5,18 @@ import ( "shylinux.com/x/icebergs/base/aaa" "shylinux.com/x/icebergs/base/ctx" "shylinux.com/x/icebergs/base/web" + kit "shylinux.com/x/toolkits" ) const CMD = "cmd" func init() { Index.MergeCommands(ice.Commands{ - CMD: {Actions: ice.MergeActions(web.ApiAction(), aaa.WhiteAction(ctx.RUN), ctx.CmdAction()), Hand: func(m *ice.Message, arg ...string) { + CMD: {Actions: web.ApiWhiteAction(), Hand: func(m *ice.Message, arg ...string) { if len(arg[0]) == 0 || arg[0] == "" { web.RenderMain(m) } else if m.IsCliUA() { - if aaa.Right(m, arg) { - m.Cmdy(arg, m.Optionv(ice.ARG)).RenderResult() - } + kit.If(aaa.Right(m, arg), func() { m.Cmdy(arg, m.Optionv(ice.ARG)).RenderResult() }) } else if arg[0] == web.CHAT_PORTAL { web.RenderMain(m) } else if m.Cmdy(ctx.COMMAND, arg[0]); m.Length() > 0 { diff --git a/core/chat/favor.go b/core/chat/favor.go index 49167f1e..894c47a6 100644 --- a/core/chat/favor.go +++ b/core/chat/favor.go @@ -100,7 +100,7 @@ func init() { ctx.Run(m, arg...) }}, cli.OPENS: {Hand: func(m *ice.Message, arg ...string) { cli.Opens(m, m.Option(mdb.TEXT)) }}, - }, ctx.CmdAction(), mdb.ImportantHashAction(), mdb.ExportHashAction()), Hand: func(m *ice.Message, arg ...string) { + }, mdb.ImportantHashAction(), mdb.ExportHashAction()), Hand: func(m *ice.Message, arg ...string) { if len(arg) > 0 && arg[0] == ctx.ACTION { m.Option(mdb.TYPE, mdb.HashSelects(m.Spawn(), m.Option(mdb.HASH)).Append(mdb.TYPE)) gdb.Event(m, FAVOR_ACTION, arg) diff --git a/core/chat/flows.go b/core/chat/flows.go index bf152006..43695e97 100644 --- a/core/chat/flows.go +++ b/core/chat/flows.go @@ -2,7 +2,6 @@ package chat import ( ice "shylinux.com/x/icebergs" - "shylinux.com/x/icebergs/base/ctx" "shylinux.com/x/icebergs/base/mdb" kit "shylinux.com/x/toolkits" ) @@ -11,7 +10,7 @@ const FLOWS = "flows" func init() { Index.MergeCommands(ice.Commands{ - FLOWS: {Name: "flows zone hash auto", Icon: "usr/icons/Automator.png", Help: "工作流", Actions: ice.MergeActions(ice.Actions{ + FLOWS: {Name: "flows zone hash auto", Icon: "Automator.png", Help: "工作流", Actions: ice.MergeActions(ice.Actions{ mdb.SEARCH: {Hand: func(m *ice.Message, arg ...string) { if mdb.IsSearchPreview(m, arg) { mdb.HashSelect(m.Spawn(ice.OptionFields(""))).Table(func(value ice.Maps) { @@ -28,7 +27,7 @@ func init() { mdb.MODIFY: {Hand: func(m *ice.Message, arg ...string) { m.Cmdy(mdb.MODIFY, m.PrefixKey(), kit.KeyHash(m.Option(mdb.ZONE)), mdb.HASH, m.OptionSimple(mdb.HASH), arg) }}, - }, ctx.CmdAction(), mdb.ExportHashAction(), mdb.HashAction(mdb.SHORT, mdb.ZONE, mdb.FIELD, "time,zone", mdb.FIELDS, "time,hash,name,space,index,args,prev,from,status")), Hand: func(m *ice.Message, arg ...string) { + }, mdb.HashAction(mdb.SHORT, mdb.ZONE, mdb.FIELD, "time,zone", mdb.FIELDS, "time,hash,name,space,index,args,prev,from,status"), mdb.ExportHashAction()), Hand: func(m *ice.Message, arg ...string) { if arg = kit.Slice(arg, 0, 2); len(arg) == 0 || arg[0] == "" { mdb.HashSelect(m) } else { diff --git a/core/chat/footer.go b/core/chat/footer.go index 28aef294..5ac945cb 100644 --- a/core/chat/footer.go +++ b/core/chat/footer.go @@ -37,7 +37,7 @@ func init() { } } }}, - }, web.ApiAction(), aaa.WhiteAction(ctx.RUN, ctx.COMMAND), ctx.CmdAction()), Hand: func(m *ice.Message, arg ...string) { + }, web.ApiWhiteAction()), Hand: func(m *ice.Message, arg ...string) { m.Result(kit.Select(ice.Info.Make.Email, mdb.Config(m, TITLE))) }}, }) diff --git a/core/chat/iframe.go b/core/chat/iframe.go index 20658a94..2585adac 100644 --- a/core/chat/iframe.go +++ b/core/chat/iframe.go @@ -14,7 +14,7 @@ const IFRAME = "iframe" func init() { Index.MergeCommands(ice.Commands{ - IFRAME: {Name: "iframe hash@key auto safari", Help: "浏览器", Icon: "usr/icons/Safari.png", Actions: ice.MergeActions(ice.Actions{ + IFRAME: {Name: "iframe hash@key auto app", Help: "浏览器", Icon: "Safari.png", Actions: ice.MergeActions(ice.Actions{ mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) { switch mdb.HashInputs(m, arg); arg[0] { case mdb.NAME: @@ -33,6 +33,15 @@ func init() { mdb.CREATE: {Name: "create type name link", Hand: func(m *ice.Message, arg ...string) { m.ProcessRewrite(mdb.HASH, mdb.HashCreate(m, mdb.TYPE, web.LINK, mdb.NAME, kit.ParseURL(m.Option(web.LINK)).Host, m.OptionSimple())) }}, + web.OPEN: {Hand: func(m *ice.Message, arg ...string) { m.ProcessOpen(m.Option(web.LINK)) }}, + ice.APP: {Help: "本机", Icon: "bi bi-browser-chrome", Hand: func(m *ice.Message, arg ...string) { + defer m.ProcessHold() + if h := kit.Select(m.Option(mdb.HASH), arg, 0); h != "" { + cli.Opens(m, m.Cmd("", h).Append(mdb.LINK)) + } else { + cli.Opens(m, "Safari.app") + } + }}, FAVOR_INPUTS: {Hand: func(m *ice.Message, arg ...string) { switch arg[0] { case mdb.TYPE: @@ -64,14 +73,6 @@ func init() { ctx.ProcessField(m, m.PrefixKey(), []string{m.Option(mdb.TEXT)}, arg...) } }}, - web.OPEN: {Hand: func(m *ice.Message, arg ...string) { m.ProcessOpen(m.Option(web.LINK)) }}, - "safari": {Help: "本机", Hand: func(m *ice.Message, arg ...string) { - if h := kit.Select(m.Option(mdb.HASH), arg, 0); h == "" { - cli.Opens(m, "Safari.app") - } else { - cli.Opens(m, m.Cmd("", h).Append(mdb.LINK)) - } - }}, }, FavorAction(), mdb.HashAction(mdb.SHORT, web.LINK, mdb.FIELD, "time,hash,type,name,link")), Hand: func(m *ice.Message, arg ...string) { list := []string{m.MergePodCmd("", web.WIKI_PORTAL, log.DEBUG, m.Option(log.DEBUG))} list = append(list, web.MergeLink(m, "/chat/portal/", ice.POD, m.Option(ice.MSG_USERPOD), log.DEBUG, m.Option(log.DEBUG))) @@ -82,9 +83,9 @@ func init() { } } if m.Length() == 0 { - m.Action(mdb.CREATE) + m.Action(mdb.CREATE, ice.APP) } else { - m.PushAction(web.OPEN, mdb.REMOVE).Action(mdb.CREATE, mdb.PRUNES) + m.PushAction(web.OPEN, mdb.REMOVE).Action(mdb.CREATE, mdb.PRUNES, ice.APP) } } else { kit.If(m.Length() == 0, func() { @@ -96,7 +97,7 @@ func init() { } m.Append(web.LINK, arg[0]) }) - m.Action(web.FULL, web.OPEN).StatusTime(m.AppendSimple(web.LINK)) + m.Action(web.FULL, web.OPEN, ice.APP).StatusTime(m.AppendSimple(web.LINK)) ctx.DisplayLocal(m, "") } }}, diff --git a/core/chat/location.go b/core/chat/location.go index 9e8526c7..c88dd65b 100644 --- a/core/chat/location.go +++ b/core/chat/location.go @@ -72,7 +72,7 @@ func init() { "district": {Name: "district", Help: "地区", Hand: func(m *ice.Message, arg ...string) { m.Echo(get(m, "district/v1/getchildren", m.OptionSimple(mdb.ID))) }}, - }, mdb.HashAction(mdb.FIELD, "time,hash,type,name,text,latitude,longitude,extra"), ctx.CmdAction(), FavorAction()), Hand: func(m *ice.Message, arg ...string) { + }, FavorAction(), mdb.HashAction(mdb.FIELD, "time,hash,type,name,text,latitude,longitude,extra")), Hand: func(m *ice.Message, arg ...string) { mdb.HashSelect(m, kit.Slice(arg, 0, 1)...) ctx.DisplayLocal(m, "", ctx.ConfigSimple(m, aaa.TOKEN)) m.Option(LOCATION, get(m, "location/v1/ip", aaa.IP, m.Option(ice.MSG_USERIP))) diff --git a/core/chat/macos/applications.go b/core/chat/macos/applications.go index a2419785..d02f54f0 100644 --- a/core/chat/macos/applications.go +++ b/core/chat/macos/applications.go @@ -21,7 +21,17 @@ func init() { ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { FinderAppend(m, "Applications", m.PrefixKey()) m.Travel(func(p *ice.Context, c *ice.Context, key string, cmd *ice.Command) { - kit.If(cmd.Icon, func() { AppInstall(m, cmd.Icon, m.PrefixKey()) }) + kit.If(cmd.Icon, func() { + if !kit.HasPrefix(cmd.Icon, nfs.PS, web.HTTP) { + if !nfs.Exists(m, cmd.Icon) { + nfs.Exists(m, ice.USR_ICONS+cmd.Icon, func(p string) { cmd.Icon = p }) + } + if !nfs.Exists(m, cmd.Icon) { + nfs.Exists(m, ctx.GetCmdFile(m, m.PrefixKey()), func(p string) { cmd.Icon = path.Join(path.Dir(p), cmd.Icon) }) + } + } + AppInstall(m, cmd.Icon, m.PrefixKey()) + }) }) Notify(m, "usr/icons/Infomation.png", cli.RUNTIME, "系统启动成功", ctx.INDEX, cli.RUNTIME) }}, diff --git a/core/chat/macos/caculator.go b/core/chat/macos/caculator.go index 97e9db3c..1409a238 100644 --- a/core/chat/macos/caculator.go +++ b/core/chat/macos/caculator.go @@ -7,6 +7,6 @@ import ( func init() { const CACULATOR = "caculator" Index.MergeCommands(ice.Commands{ - CACULATOR: {Name: "caculator refresh", Icon: "usr/icons/Caculator.png", Hand: func(m *ice.Message, arg ...string) { m.Display("") }}, + CACULATOR: {Name: "caculator refresh", Icon: "Caculator.png", Hand: func(m *ice.Message, arg ...string) { m.Display("") }}, }) } diff --git a/core/chat/macos/clock.go b/core/chat/macos/clock.go index de9d1223..9da0b1b0 100644 --- a/core/chat/macos/clock.go +++ b/core/chat/macos/clock.go @@ -7,6 +7,6 @@ import ( func init() { const CLOCK = "clock" Index.MergeCommands(ice.Commands{ - CLOCK: {Name: "clock refresh", Icon: "usr/icons/Clock.png", Hand: func(m *ice.Message, arg ...string) { m.Display("") }}, + CLOCK: {Name: "clock refresh", Icon: "Clock.png", Hand: func(m *ice.Message, arg ...string) { m.Display("") }}, }) } diff --git a/core/chat/macos/desktop.go b/core/chat/macos/desktop.go index f80b0274..c843f3e1 100644 --- a/core/chat/macos/desktop.go +++ b/core/chat/macos/desktop.go @@ -3,7 +3,6 @@ package macos import ( ice "shylinux.com/x/icebergs" "shylinux.com/x/icebergs/base/aaa" - "shylinux.com/x/icebergs/base/ctx" "shylinux.com/x/icebergs/base/mdb" "shylinux.com/x/icebergs/base/web" kit "shylinux.com/x/toolkits" @@ -27,7 +26,7 @@ func init() { kit.Switch(m.Option(mdb.TYPE), kit.Simple(web.SERVER, web.WORKER), func() { m.PushButton(kit.Dict(m.CommandKey(), "桌面")) }) }}, web.DREAM_ACTION: {Hand: func(m *ice.Message, arg ...string) { web.DreamProcess(m, []string{}, arg...) }}, - }, aaa.RoleAction(ctx.COMMAND, ctx.RUN), PodCmdAction(), CmdHashAction(), mdb.ImportantHashAction())}, + }, aaa.RoleAction(), PodCmdAction(), CmdHashAction(), mdb.ImportantHashAction())}, }) } diff --git a/core/chat/macos/finder.go b/core/chat/macos/finder.go index 33448d7b..954b633e 100644 --- a/core/chat/macos/finder.go +++ b/core/chat/macos/finder.go @@ -10,7 +10,7 @@ const FINDER = "finder" func init() { Index.MergeCommands(ice.Commands{FINDER: {Name: "finder list insert", Help: "应用", Actions: ice.MergeActions(ice.Actions{ mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) { m.Cmdy(APPLICATIONS, mdb.INPUTS, arg) }}, - mdb.INSERT: {Name: "insert space index* args name* icon*", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(APPLICATIONS, mdb.CREATE, arg) }}, + mdb.INSERT: {Name: "insert space index* args name* icon*@icon", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(APPLICATIONS, mdb.CREATE, arg) }}, }, CmdHashAction(mdb.NAME))}}) } diff --git a/core/chat/macos/macos.go b/core/chat/macos/macos.go index b24c1e44..e4b23dda 100644 --- a/core/chat/macos/macos.go +++ b/core/chat/macos/macos.go @@ -55,5 +55,5 @@ func CmdHashAction(arg ...string) ice.Actions { mdb.SELECT: {Name: "list hash auto create", Hand: func(m *ice.Message, arg ...string) { mdb.HashSelect(m, arg...).Sort(mdb.NAME).Display(ctx.FileURI(file)) }}, - }, ctx.CmdAction(), mdb.HashAction(mdb.SHORT, kit.Select("", arg, 0), mdb.FIELD, kit.Select("time,hash,icon,name,text,space,index,args", arg, 1), kit.Slice(arg, 2))) + }, mdb.HashAction(mdb.SHORT, kit.Select("", arg, 0), mdb.FIELD, kit.Select("time,hash,icon,name,text,space,index,args", arg, 1), kit.Slice(arg, 2))) } diff --git a/core/chat/oauth.bak/oauth.go b/core/chat/oauth.bak/oauth.go index 3c60275f..5ef7173e 100644 --- a/core/chat/oauth.bak/oauth.go +++ b/core/chat/oauth.bak/oauth.go @@ -8,7 +8,6 @@ import ( ice "shylinux.com/x/icebergs" "shylinux.com/x/icebergs/base/aaa" - "shylinux.com/x/icebergs/base/ctx" "shylinux.com/x/icebergs/base/lex" "shylinux.com/x/icebergs/base/mdb" "shylinux.com/x/icebergs/base/nfs" @@ -84,7 +83,7 @@ var Index = &ice.Context{Name: OAUTH, Help: "认证授权", Commands: ice.Comman REPLY: {Name: "reply hash auto create prunes", Help: "授权", Actions: mdb.HashAction(mdb.EXPIRE, mdb.MONTH, mdb.SHORT, mdb.UNIQ, mdb.FIELD, "time,hash,username,scope,offer")}, OFFER: {Name: "offer hash auto create prunes", Help: "访问", Actions: mdb.HashAction(mdb.EXPIRE, mdb.MONTH, mdb.SHORT, mdb.UNIQ, mdb.FIELD, "time,hash,username,scope,redirect_uri")}, - web.P(APPLY): {Name: "/apply scope redirect_uri", Help: "申请", Actions: ctx.CmdAction(), Hand: func(m *ice.Message, arg ...string) { + web.P(APPLY): {Name: "/apply scope redirect_uri", Help: "申请", Hand: func(m *ice.Message, arg ...string) { if m.Option(REDIRECT_URI) == "" { m.RenderStatusBadRequest() // 参数错误 @@ -92,7 +91,7 @@ var Index = &ice.Context{Name: OAUTH, Help: "认证授权", Commands: ice.Comman web.RenderCmd(m, m.Prefix(OAUTH), APPLY) } }}, - web.P(REPLY): {Name: "/reply scope offer", Help: "授权", Actions: ctx.CmdAction(), Hand: func(m *ice.Message, arg ...string) { + web.P(REPLY): {Name: "/reply scope offer", Help: "授权", Hand: func(m *ice.Message, arg ...string) { if m.Option(OFFER) == "" { m.RenderStatusBadRequest() // 参数错误 diff --git a/core/chat/oauth/client.go b/core/chat/oauth/client.go index 22e1fed6..012c2d68 100644 --- a/core/chat/oauth/client.go +++ b/core/chat/oauth/client.go @@ -39,7 +39,7 @@ type Client struct { ice.Hash short string `data:"domain,client_id"` field string `data:"time,hash,domain,client_id,client_secret,oauth_url,grant_url,token_url,users_url,api_prefix,token_prefix"` - sso string `name:"sso name* icon*" help:"登录"` + sso string `name:"sso name* icon*@icons" help:"登录"` auth string `name:"auth" help:"授权"` user string `name:"user" help:"用户"` orgs string `name:"orgs" help:"组织"` @@ -62,6 +62,13 @@ func init() { } func (s Client) Inputs(m *ice.Message, arg ...string) { + switch m.Option(ctx.ACTION) { + case web.SSO: + switch arg[0] { + case mdb.NAME: + case mdb.ICON: + } + } switch s.Hash.Inputs(m, arg...); arg[0] { case web.DOMAIN: m.Cmdy(web.SPIDE, mdb.INPUTS, arg) diff --git a/core/chat/pod.go b/core/chat/pod.go index 6471e482..5be355dd 100644 --- a/core/chat/pod.go +++ b/core/chat/pod.go @@ -5,9 +5,7 @@ import ( "strings" 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/web" @@ -18,7 +16,7 @@ const POD = "pod" func init() { Index.MergeCommands(ice.Commands{ - POD: {Actions: ice.MergeActions(web.ApiAction(), aaa.WhiteAction(), ctx.CmdAction()), Hand: func(m *ice.Message, arg ...string) { + POD: {Actions: web.ApiWhiteAction(), Hand: func(m *ice.Message, arg ...string) { if len(arg) == 0 || arg[0] == "" { web.RenderMain(m) } else if strings.HasPrefix(m.Option(ice.MSG_USERUA), "git/") { diff --git a/core/chat/portal.go b/core/chat/portal.go index b5b459eb..667476a9 100644 --- a/core/chat/portal.go +++ b/core/chat/portal.go @@ -9,8 +9,6 @@ const PORTAL = "portal" func init() { Index.MergeCommands(ice.Commands{ - PORTAL: {Actions: web.ApiAction(), Hand: func(m *ice.Message, arg ...string) { - web.RenderMain(m) - }}, + PORTAL: {Actions: web.ApiAction(), Hand: func(m *ice.Message, arg ...string) { web.RenderMain(m) }}, }) } diff --git a/core/chat/river.go b/core/chat/river.go index 5982082f..fc060aa2 100644 --- a/core/chat/river.go +++ b/core/chat/river.go @@ -46,7 +46,7 @@ func init() { kit.If(m.Option(mdb.TYPE) == aaa.VOID, func() { m.Cmd(aaa.ROLE, aaa.WHITE, aaa.VOID, kit.Keys(RIVER, h)) }) gdb.Event(m, RIVER_CREATE, RIVER, m.Option(ice.MSG_RIVER, h), arg) }}, - }, web.ApiAction(), aaa.WhiteAction(), mdb.ImportantHashAction(mdb.FIELD, "time,hash,type,icon,name,text,template"), mdb.ExportHashAction()), Hand: func(m *ice.Message, arg ...string) { + }, web.ApiWhiteAction(), mdb.ImportantHashAction(mdb.FIELD, "time,hash,type,icon,name,text,template"), mdb.ExportHashAction()), Hand: func(m *ice.Message, arg ...string) { if m.Warn(m.Option(ice.MSG_USERNAME) == "", ice.ErrNotLogin) || !aaa.Right(m, RIVER, arg) { return } else if len(arg) == 0 { diff --git a/core/chat/search.go b/core/chat/search.go index ea9c1f8c..18955a89 100644 --- a/core/chat/search.go +++ b/core/chat/search.go @@ -3,7 +3,6 @@ package chat import ( ice "shylinux.com/x/icebergs" "shylinux.com/x/icebergs/base/cli" - "shylinux.com/x/icebergs/base/ctx" "shylinux.com/x/icebergs/base/web" ) @@ -13,7 +12,7 @@ func init() { Index.MergeCommands(ice.Commands{ SEARCH: {Actions: ice.MergeActions(ice.Actions{ cli.OPENS: {Hand: func(m *ice.Message, arg ...string) { cli.Opens(m, arg...) }}, - }, web.ApiAction(), ctx.CmdAction()), Hand: func(m *ice.Message, arg ...string) { + }, web.ApiAction()), Hand: func(m *ice.Message, arg ...string) { m.Cmdy(web.Space(m, m.Option(ice.POD)), "mdb.search", arg).StatusTimeCount() }}, }) diff --git a/core/chat/sso.go b/core/chat/sso.go index 50d1533f..f8dcffd2 100644 --- a/core/chat/sso.go +++ b/core/chat/sso.go @@ -16,7 +16,7 @@ const SSO = "sso" func init() { Index.MergeCommands(ice.Commands{ - SSO: {Actions: ice.MergeActions(web.ApiAction(), aaa.WhiteAction()), Hand: func(m *ice.Message, arg ...string) { + SSO: {Actions: web.ApiWhiteAction(), Hand: func(m *ice.Message, arg ...string) { if m.Warn(m.Option(ice.MSG_USERNAME) == "", ice.ErrNotLogin) || m.Warn(m.Option(web.SPACE) == "", ice.ErrNotValid) || m.Warn(m.Option(cli.BACK) == "", ice.ErrNotValid) { web.RenderMain(m) return diff --git a/core/chat/storm.go b/core/chat/storm.go index 7c90f83b..2a02d0f8 100644 --- a/core/chat/storm.go +++ b/core/chat/storm.go @@ -16,7 +16,7 @@ const STORM = "storm" func init() { Index.MergeCommands(ice.Commands{ - STORM: {Name: "storm hash id auto insert create", Help: "应用", Actions: ice.Actions{ + STORM: {Name: "storm hash id auto", Help: "应用", Actions: ice.Actions{ mdb.CREATE: {Name: "create name=hi text=hello", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(mdb.INSERT, RIVER, _river_key(m), mdb.HASH, arg) }}, @@ -39,8 +39,10 @@ func init() { }, Hand: func(m *ice.Message, arg ...string) { if m.Option(ice.MSG_STORM) == "" { m.Cmdy(mdb.SELECT, RIVER, _river_key(m), mdb.HASH, ice.OptionFields("time,hash,icon,name,text,count")) + m.Action(mdb.CREATE) } else if len(arg) == 0 || kit.Int(arg[0]) > 0 { m.Cmdy(mdb.SELECT, RIVER, _storm_key(m), mdb.LIST, mdb.ID, arg, ice.OptionFields("time,id,space,icon,index,args,style,display,deleted")).SortInt(mdb.ID) + m.Action(mdb.INSERT) } else if aaa.Right(m, arg) { m.Push(ctx.INDEX, arg[0]) } diff --git a/core/chat/trans.go b/core/chat/trans.go index 94fa508a..53cac39f 100644 --- a/core/chat/trans.go +++ b/core/chat/trans.go @@ -21,35 +21,28 @@ func init() { TO = "to" ) Index.MergeCommands(ice.Commands{ - TRANS: {Name: "trans from to auto", Help: "传输", Actions: ice.MergeActions(ice.Actions{ - SEND: {Name: "send", Help: "发送", Hand: func(m *ice.Message, arg ...string) { - m.Cmdy(web.SPACE, m.Option(TO), web.SPIDE, ice.DEV, web.SPIDE_SAVE, kit.Select(nfs.PWD, m.Option("to_path")), - web.MergeURL2(m, path.Join(web.SHARE_LOCAL, m.Option("from_path")), ice.POD, m.Option(FROM), - web.SHARE, m.Cmdx(web.SHARE, mdb.CREATE, mdb.TYPE, web.LOGIN), - ), - ).ProcessHold() - web.ToastSuccess(m, SEND) + TRANS: {Name: "trans from@key to@key auto", Help: "传输", Icon: "Migration.png", Actions: ice.Actions{ + SEND: {Hand: func(m *ice.Message, arg ...string) { + defer web.ToastProcess(m)() + p := web.ProxyUpload(m, m.Option(FROM), m.Option(nfs.PATH)) + h := m.Cmdx(web.SHARE, mdb.CREATE, mdb.TYPE, web.DOWNLOAD, mdb.TEXT, p) + defer m.Cmd(web.SHARE, mdb.REMOVE, mdb.HASH, h) + m.Cmdy(web.SPACE, m.Option(TO), web.SPIDE, ice.DEV, web.SPIDE_SAVE, path.Join(m.Option("to_path"), path.Base(m.Option(nfs.PATH))), web.MergeLink(m, "/share/"+h)) }}, - ctx.RUN: {Name: "run", Help: "执行", Hand: func(m *ice.Message, arg ...string) { - m.Option(ice.POD, m.Option("_pod")) - m.Option(ice.MSG_USERPOD, m.Option("_pod")) - if aaa.Right(m, arg) && !ctx.PodCmd(m, arg) { - m.Cmdy(arg) - } - if arg[0] == nfs.DIR && m.Length() > 0 { - m.PushAction(SEND, nfs.TRASH) - } + ctx.RUN: {Hand: func(m *ice.Message, arg ...string) { + m.Options(ice.MSG_USERPOD, m.Option(FROM), ice.POD, m.Option(FROM)) + kit.If(!ctx.PodCmd(m, arg) && aaa.Right(m, arg), func() { m.Cmdy(arg) }) + kit.If(arg[0] == nfs.DIR && len(arg) < 3, func() { m.PushAction(SEND, mdb.SHOW, nfs.TRASH) }) }}, - }, ctx.CmdAction()), Hand: func(m *ice.Message, arg ...string) { + }, Hand: func(m *ice.Message, arg ...string) { + defer m.Options(ice.MSG_ACTION, "") if len(arg) == 0 { - m.Cmdy(web.SPACE).RenameAppend(mdb.NAME, FROM) - return + m.Cmdy(web.SPACE).RenameAppend(mdb.NAME, FROM).Toast("请选择空间1") + } else if len(arg) == 1 { + m.Cmdy(web.SPACE).RenameAppend(mdb.NAME, TO).Toast("请选择空间2") + } else { + ctx.DisplayLocal(m, "") } - if len(arg) == 1 { - m.Cmdy(web.SPACE).RenameAppend(mdb.NAME, TO) - return - } - ctx.DisplayLocal(m, "") }}, }) } diff --git a/core/code/compile.go b/core/code/compile.go index be95a996..c089ca14 100644 --- a/core/code/compile.go +++ b/core/code/compile.go @@ -40,7 +40,7 @@ func init() { VERSION = "version" ) 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: "usr/icons/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", Icon: "go.png", Help: "编译", Actions: ice.MergeActions(ice.Actions{ ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { cli.IsAlpine(m, GO, "go git") }}, mdb.SEARCH: {Hand: func(m *ice.Message, arg ...string) { mdb.IsSearchPreview(m, arg, func() []string { diff --git a/core/code/inner.go b/core/code/inner.go index 1d3edeb6..c19de5e9 100644 --- a/core/code/inner.go +++ b/core/code/inner.go @@ -124,7 +124,7 @@ func init() { NAVIGATE: {Hand: func(m *ice.Message, arg ...string) { m.Cmdy(NAVIGATE, kit.Ext(m.Option(mdb.FILE)), m.Option(nfs.FILE), m.Option(nfs.PATH)) }}, - }, ctx.CmdAction(), aaa.RoleAction()), Hand: func(m *ice.Message, arg ...string) { + }, aaa.RoleAction()), Hand: func(m *ice.Message, arg ...string) { if kit.HasPrefix(arg[0], "/volcanos/", "/require/", "http") { m.Echo(m.Cmdx(web.SPIDE, ice.DEV, web.SPIDE_RAW, arg[0])) ctx.DisplayLocal(m, "") diff --git a/core/code/publish.go b/core/code/publish.go index ca5f1013..434156aa 100644 --- a/core/code/publish.go +++ b/core/code/publish.go @@ -122,7 +122,7 @@ func init() { nfs.TRASH: {Hand: func(m *ice.Message, arg ...string) { nfs.Trash(m, path.Join(ice.USR_PUBLISH, m.Option(nfs.PATH))) }}, }, ctx.ConfAction(mdb.FIELD, nfs.PATH), aaa.RoleAction()), Hand: func(m *ice.Message, arg ...string) { if m.Option(nfs.DIR_ROOT, ice.USR_PUBLISH); len(arg) == 0 { - _publish_list(m).Cmdy("", ice.CONTEXTS, "app") + _publish_list(m).Cmdy("", ice.CONTEXTS, ice.APP) } else { m.Cmdy(nfs.DIR, arg[0], "time,path,size,hash,link,action", ice.OptionFields(mdb.DETAIL)) web.PushImages(m, web.P(PUBLISH, arg[0])) diff --git a/core/code/vimer.go b/core/code/vimer.go index 53a19855..897e3263 100644 --- a/core/code/vimer.go +++ b/core/code/vimer.go @@ -50,7 +50,7 @@ const VIMER = "vimer" func init() { web.Index.MergeCommands(ice.Commands{ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { aaa.White(m, nfs.REQUIRE) }}, - ice.REQUIRE_SRC: {Actions: ctx.CmdAction(), Hand: func(m *ice.Message, arg ...string) { web.ShareLocalFile(m, ice.SRC, path.Join(arg...)) }}, + ice.REQUIRE_SRC: {Hand: func(m *ice.Message, arg ...string) { web.ShareLocalFile(m, ice.SRC, path.Join(arg...)) }}, ice.REQUIRE_USR: {Hand: func(m *ice.Message, arg ...string) { web.ShareLocalFile(m, ice.USR, path.Join(arg...)) }}, ice.REQUIRE_MODULES: {Hand: func(m *ice.Message, arg ...string) { p := path.Join(ice.USR_MODULES, path.Join(arg...)) @@ -59,7 +59,7 @@ func init() { }}, }) Index.MergeCommands(ice.Commands{ - VIMER: {Name: "vimer path=src/@key file=main.go@key line=1 list", Icon: "usr/icons/vimer.png", Help: "编辑器", Meta: kit.Dict(ctx.STYLE, INNER), Actions: ice.MergeActions(ice.Actions{ + VIMER: {Name: "vimer path=src/@key file=main.go@key line=1 list", Icon: "vimer.png", Help: "编辑器", Meta: kit.Dict(ctx.STYLE, INNER), Actions: ice.MergeActions(ice.Actions{ mdb.SEARCH: {Hand: func(m *ice.Message, arg ...string) { if mdb.IsSearchPreview(m, arg) { m.PushSearch(mdb.TYPE, nfs.FILE, mdb.NAME, "main", mdb.TEXT, ice.SRC_MAIN_SH) @@ -192,7 +192,7 @@ func init() { kit.Switch(m.Option(mdb.TYPE), kit.Simple(web.SERVER, web.WORKER), func() { m.PushButton(kit.Dict(m.CommandKey(), "编程")) }) }}, web.DREAM_ACTION: {Hand: func(m *ice.Message, arg ...string) { web.DreamProcess(m, []string{}, arg...) }}, - }, aaa.RoleAction(ctx.COMMAND), mdb.HashAction(mdb.SHORT, nfs.PATH, mdb.FIELD, "time,path", ctx.TOOLS, "xterm,compile,runtime")), Hand: func(m *ice.Message, arg ...string) { + }, aaa.RoleAction(), mdb.HashAction(mdb.SHORT, nfs.PATH, mdb.FIELD, "time,path", ctx.TOOLS, "xterm,compile,runtime")), Hand: func(m *ice.Message, arg ...string) { if m.Cmdy(INNER, arg); arg[0] != ctx.ACTION { kit.If(len(arg) > 1, func() { mdb.HashCreate(m.Spawn(), nfs.PATH, path.Join(kit.Slice(arg, 0, 2)...)) }) m.Action(nfs.SAVE, COMPILE, "show", "exec") diff --git a/core/code/xterm.go b/core/code/xterm.go index f8048c02..8038691a 100644 --- a/core/code/xterm.go +++ b/core/code/xterm.go @@ -75,7 +75,7 @@ const XTERM = "xterm" func init() { Index.MergeCommands(ice.Commands{ - XTERM: {Name: "xterm hash auto", Icon: "usr/icons/Terminal.png", Help: "命令行", Actions: ice.MergeActions(ice.Actions{ + XTERM: {Name: "xterm hash auto", Icon: "Terminal.png", Help: "命令行", 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, ISH) }) }}, @@ -150,7 +150,7 @@ func init() { } m.ProcessHold() }}, - }, ctx.CmdAction(), ctx.ProcessAction(), mdb.ImportantHashAction(mdb.FIELD, "time,hash,type,name,text,path,theme,daemon")), Hand: func(m *ice.Message, arg ...string) { + }, ctx.ProcessAction(), mdb.ImportantHashAction(mdb.FIELD, "time,hash,type,name,text,path,theme,daemon")), Hand: func(m *ice.Message, arg ...string) { if mdb.HashSelect(m, arg...); len(arg) == 0 { if m.Length() == 0 { m.Action(mdb.CREATE) diff --git a/core/mall/asset.go b/core/mall/asset.go index 1aa4fcb5..bfb9939c 100644 --- a/core/mall/asset.go +++ b/core/mall/asset.go @@ -2,7 +2,6 @@ package mall import ( ice "shylinux.com/x/icebergs" - "shylinux.com/x/icebergs/base/ctx" "shylinux.com/x/icebergs/base/mdb" "shylinux.com/x/icebergs/base/web" kit "shylinux.com/x/toolkits" @@ -92,7 +91,7 @@ func init() { } web.Toast(m, "核算成功") }}, - }, mdb.ZoneAction(), ctx.CmdAction()), Hand: func(m *ice.Message, arg ...string) { + }, mdb.ZoneAction()), Hand: func(m *ice.Message, arg ...string) { m.Fields(len(arg), "time,account,amount,count", mdb.ZoneField(m)) amount, count := 0, 0 if mdb.ZoneSelect(m, arg...); len(arg) == 0 { diff --git a/core/team/plan.go b/core/team/plan.go index 74b03265..0bc6f9e4 100644 --- a/core/team/plan.go +++ b/core/team/plan.go @@ -55,7 +55,7 @@ const PLAN = "plan" func init() { Index.MergeCommands(ice.Commands{ - PLAN: {Name: "plan scale=month,day,week,month,year,long begin_time@date list prev next", Icon: "usr/icons/Calendar.png", Help: "计划表", Actions: ice.MergeActions(ice.Actions{ + PLAN: {Name: "plan scale=month,day,week,month,year,long begin_time@date list prev next", Icon: "Calendar.png", Help: "计划表", Actions: ice.MergeActions(ice.Actions{ mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) { m.Cmdy(TODO, mdb.INPUTS, arg) }}, mdb.PLUGIN: {Name: "plugin extra.index extra.args", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(TASK, mdb.MODIFY, arg) }}, ctx.RUN: {Hand: func(m *ice.Message, arg ...string) { @@ -71,7 +71,7 @@ func init() { web.DREAM_TABLES: {Hand: func(m *ice.Message, arg ...string) { kit.Switch(m.Option(mdb.TYPE), kit.Simple(web.SERVER, web.WORKER), func() { m.PushButton(kit.Dict(m.CommandKey(), "计划")) }) }}, - }, aaa.RoleAction(ctx.COMMAND), ctx.CmdAction(), TASK), Hand: func(m *ice.Message, arg ...string) { + }, aaa.RoleAction(), 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...) diff --git a/core/wiki/draw.go b/core/wiki/draw.go index 185f1f31..f83e8c2b 100644 --- a/core/wiki/draw.go +++ b/core/wiki/draw.go @@ -5,7 +5,6 @@ import ( ice "shylinux.com/x/icebergs" "shylinux.com/x/icebergs/base/aaa" - "shylinux.com/x/icebergs/base/ctx" "shylinux.com/x/icebergs/base/mdb" "shylinux.com/x/icebergs/base/nfs" "shylinux.com/x/icebergs/base/web" @@ -16,7 +15,7 @@ const DRAW = "draw" func init() { Index.MergeCommands(ice.Commands{ - DRAW: {Name: "draw path=src/main.svg@key pid refresh save actions", Icon: "usr/icons/Grapher.png", Help: "思维导图", Actions: ice.MergeActions(ice.Actions{ + DRAW: {Name: "draw path=src/main.svg@key pid refresh save actions", Icon: "Grapher.png", Help: "思维导图", Actions: ice.MergeActions(ice.Actions{ ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { m.Cmd(mdb.RENDER, mdb.CREATE, mdb.TYPE, nfs.SVG, mdb.NAME, m.PrefixKey()) }}, @@ -27,7 +26,7 @@ func init() { web.DREAM_TABLES: {Hand: func(m *ice.Message, arg ...string) { kit.Switch(m.Option(mdb.TYPE), kit.Simple(web.SERVER, web.WORKER), func() { m.PushButton(kit.Dict(m.CommandKey(), "导图")) }) }}, - }, aaa.RoleAction(ctx.COMMAND, ctx.RUN), ctx.CmdAction(), WikiAction("", nfs.SVG)), Hand: func(m *ice.Message, arg ...string) { + }, aaa.RoleAction(), WikiAction("", nfs.SVG)), Hand: func(m *ice.Message, arg ...string) { kit.If(!_wiki_list(m, arg...), func() { _wiki_show(m, arg[0]) kit.If(m.IsErr(), func() { m.Option(ice.MSG_OUTPUT, "") }) diff --git a/core/wiki/feel.go b/core/wiki/feel.go index b8542a2b..6e37bf34 100644 --- a/core/wiki/feel.go +++ b/core/wiki/feel.go @@ -22,7 +22,7 @@ const FEEL = "feel" func init() { Index.MergeCommands(ice.Commands{ - FEEL: {Name: "feel path auto prev next record1 record2 upload actions", Icon: "usr/icons/Photos.png", Help: "影音媒体", Actions: ice.MergeActions(ice.Actions{ + FEEL: {Name: "feel path auto prev next record1 record2 upload actions", Icon: "Photos.png", Help: "影音媒体", Actions: ice.MergeActions(ice.Actions{ "record1": {Help: "截图"}, "record2": {Help: "录屏"}, web.UPLOAD: {Hand: func(m *ice.Message, arg ...string) { m.Option(nfs.PATH, _feel_path(m, m.Option(nfs.PATH))) diff --git a/core/wiki/field.go b/core/wiki/field.go index 900881bf..94ebf736 100644 --- a/core/wiki/field.go +++ b/core/wiki/field.go @@ -39,7 +39,7 @@ const FIELD = "field" func init() { Index.MergeCommands(ice.Commands{ - FIELD: {Name: "field name cmd", Help: "插件", Actions: ctx.CmdAction(), Hand: func(m *ice.Message, arg ...string) { + FIELD: {Name: "field name cmd", Help: "插件", Hand: func(m *ice.Message, arg ...string) { kit.If(kit.IsIn(kit.Select("", arg, 1), ctx.ARGS, ice.MSG_RESULT), func() { arg = kit.Simple("", arg) }) if arg = _name(m, arg); arg[0] == "inner" { arg = append([]string{"", web.CODE_INNER, ctx.ARGS, "src/ main.go", ice.MSG_RESULT, arg[1], "meta.display", "/plugin/local/code/inner.js", ctx.STYLE, "output"}, arg[2:]...) diff --git a/core/wiki/portal.go b/core/wiki/portal.go index 7b072606..49d17e29 100644 --- a/core/wiki/portal.go +++ b/core/wiki/portal.go @@ -85,7 +85,7 @@ func init() { kit.Switch(m.Option(mdb.TYPE), kit.Simple(web.SERVER, web.WORKER), func() { m.PushButton(ice.Maps{PORTAL: "官网"}) }) }}, web.DREAM_ACTION: {Hand: func(m *ice.Message, arg ...string) { web.DreamProcess(m, []string{}, arg...) }}, - }, aaa.WhiteAction(ctx.COMMAND, ctx.RUN), aaa.RoleAction(ctx.COMMAND, ctx.RUN), ctx.CmdAction()), Hand: func(m *ice.Message, arg ...string) { + }, aaa.WhiteAction(), aaa.RoleAction()), Hand: func(m *ice.Message, arg ...string) { if m.Push(HEADER, m.Cmdx(WORD, path.Join(nfs.SRC_DOCUMENT, 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.SRC_DOCUMENT, path.Join(arg...), INDEX_SHY))) diff --git a/core/wiki/word.go b/core/wiki/word.go index 256f64d5..c7a6a5bd 100644 --- a/core/wiki/word.go +++ b/core/wiki/word.go @@ -3,7 +3,6 @@ package wiki import ( ice "shylinux.com/x/icebergs" "shylinux.com/x/icebergs/base/aaa" - "shylinux.com/x/icebergs/base/ctx" "shylinux.com/x/icebergs/base/mdb" "shylinux.com/x/icebergs/base/nfs" "shylinux.com/x/icebergs/base/ssh" @@ -21,7 +20,7 @@ const WORD = "word" func init() { Index.MergeCommands(ice.Commands{ - WORD: {Name: "word path=src/main.shy@key auto play", Icon: "usr/icons/Books.png", Help: "上下文", Actions: ice.MergeActions(ice.Actions{ + WORD: {Name: "word path=src/main.shy@key auto play", Icon: "Books.png", Help: "上下文", 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) @@ -47,7 +46,7 @@ func init() { ls := kit.Split(m.Option(mdb.TEXT)) kit.If(kit.IsIn(ls[0], IMAGE, VIDEO, AUDIO), func() { m.Cmdy(FEEL).CutTo(nfs.PATH, mdb.NAME) }) }}, - }, aaa.RoleAction(ctx.COMMAND, ctx.RUN), ctx.CmdAction(), WikiAction("", nfs.SHY)), Hand: func(m *ice.Message, arg ...string) { + }, aaa.RoleAction(), WikiAction("", nfs.SHY)), Hand: func(m *ice.Message, arg ...string) { if m.Option(nfs.DIR_DEEP, ice.TRUE); len(arg) == 0 { arg = append(arg, nfs.SRC) } diff --git a/misc/git/spide.go b/misc/git/spide.go index 5e0372a6..fbf3f700 100644 --- a/misc/git/spide.go +++ b/misc/git/spide.go @@ -13,7 +13,7 @@ const SPIDE = "spide" func init() { Index.MergeCommands(ice.Commands{ - SPIDE: {Name: "spide repos auto", Help: "构架图", Actions: ctx.CmdAction(), Hand: func(m *ice.Message, arg ...string) { + SPIDE: {Name: "spide repos auto", Help: "构架图", Hand: func(m *ice.Message, arg ...string) { if len(kit.Slice(arg, 0, 1)) == 0 { m.Cmdy(REPOS) } else if len(arg) == 1 { diff --git a/misc/git/status.go b/misc/git/status.go index 1e5cb494..6c5c4e3d 100644 --- a/misc/git/status.go +++ b/misc/git/status.go @@ -103,7 +103,7 @@ const STATUS = "status" func init() { Index.MergeCommands(ice.Commands{ - STATUS: {Name: "status repos:text auto", Icon: "usr/icons/git.png", Help: "代码库", Actions: ice.MergeActions(ice.Actions{ + STATUS: {Name: "status repos:text auto", Icon: "git.png", Help: "代码库", Actions: ice.MergeActions(ice.Actions{ mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) { switch m.Option(ctx.ACTION) { case INIT: diff --git a/misc/git/trend.go b/misc/git/trend.go index ceec48b8..ef64d46f 100644 --- a/misc/git/trend.go +++ b/misc/git/trend.go @@ -13,7 +13,7 @@ const TREND = "trend" func init() { Index.MergeCommands(ice.Commands{ - TREND: {Name: "trend repos@key begin_time@date auto", Help: "趋势图", Actions: ice.MergeActions(ice.Actions{ + TREND: {Name: "trend repos@key begin_time@date auto", Help: "趋势图", Actions: ice.Actions{ mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) { m.Cmdy(REPOS, ice.OptionFields("repos,time")) }}, mdb.DETAIL: {Hand: func(m *ice.Message, arg ...string) { m.Cmdy("", code.INNER, m.Option(REPOS), MASTER, m.Option(mdb.HASH), m.Cmdv(REPOS, m.Option(REPOS), MASTER, m.Option(mdb.HASH), nfs.FILE)) @@ -22,7 +22,7 @@ func init() { m.Cmdy(REPOS, code.INNER, arg) ctx.DisplayLocal(m, "code/inner.js", "style", "float") }}, - }, ctx.CmdAction()), Hand: func(m *ice.Message, arg ...string) { + }, Hand: func(m *ice.Message, arg ...string) { if len(arg) == 0 { m.Cmdy(REPOS) } else { diff --git a/misc/github/oauth.go b/misc/github/oauth.go index 82a7bf2f..d2619e76 100644 --- a/misc/github/oauth.go +++ b/misc/github/oauth.go @@ -70,7 +70,7 @@ func init() { } } }}, - web.P(OAUTH): {Name: "/oauth", Help: "授权", Actions: ice.MergeActions(ice.Actions{}, ctx.CmdAction()), Hand: func(m *ice.Message, arg ...string) { + web.P(OAUTH): {Name: "/oauth", Help: "授权", Hand: func(m *ice.Message, arg ...string) { if m.Warn(m.Option(CODE) == "", ice.ErrNotValid) { return } diff --git a/misc/ssh/service.go b/misc/ssh/service.go index ebafc4f4..d2769a85 100644 --- a/misc/ssh/service.go +++ b/misc/ssh/service.go @@ -145,7 +145,7 @@ const SERVICE = "service" func init() { psh.Index.MergeCommands(ice.Commands{ - SERVICE: {Name: "service port id auto listen prunes", Icon: "usr/icons/ssh.png", Help: "服务", Actions: ice.MergeActions(ice.Actions{ + SERVICE: {Name: "service port id auto listen prunes", Icon: "ssh.png", Help: "服务", Actions: ice.MergeActions(ice.Actions{ ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { mdb.HashSelect(m).Table(func(value ice.Maps) { if value[mdb.STATUS] == tcp.OPEN { diff --git a/misc/tmux/session.go b/misc/tmux/session.go index 7963bd59..387df6dc 100644 --- a/misc/tmux/session.go +++ b/misc/tmux/session.go @@ -80,7 +80,7 @@ func init() { FIELDS, "id,tag,pane,tty,height,width,cmd", )}, }, Commands: ice.Commands{ - SESSION: {Name: "session session window pane cmds auto", Help: "会话", Actions: ice.MergeActions(ice.Actions{ + SESSION: {Name: "session session window pane cmds auto", Help: "会话", Actions: ice.Actions{ web.DREAM_CREATE: {Hand: func(m *ice.Message, arg ...string) { if !m.Warn(!nfs.Exists(m, path.Join(ice.USR_LOCAL_WORK, m.Option(mdb.NAME))), ice.ErrNotFound) { m.Cmd("", mdb.CREATE) @@ -165,7 +165,7 @@ func init() { }) }).Sleep30ms() }}, - }, ctx.CmdAction()), Hand: func(m *ice.Message, arg ...string) { + }, Hand: func(m *ice.Message, arg ...string) { if m.Action(SCRIPT); len(arg) > 3 { m.Cmd(CMD, _tmux_key(arg[0], arg[1], arg[2]), arg[3:]) } diff --git a/type.go b/type.go index 6a45084c..e6238785 100644 --- a/type.go +++ b/type.go @@ -37,6 +37,7 @@ type Config struct { type Action struct { Name string Help string + Icon string Hand Handler List List } @@ -168,14 +169,15 @@ func (c *Context) Merge(s *Context) *Context { kit.Value(cmd.Meta, kit.Keys("_title", sub), help[1]) } } + kit.Value(cmd.Meta, kit.Keys("_icons", sub), action.Icon) if action.Hand == nil { continue } 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 auto" }) - kit.If(strings.HasPrefix(cmd.Name, "list"), func() { cmd.Name = strings.Replace(cmd.Name, "list", key, 1) }) + kit.If(cmd.Name == "", func() { cmd.Name = "list list" }) + 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) }) } kit.If(c.Configs == nil, func() { c.Configs = Configs{} })