diff --git a/base/aaa/sess.go b/base/aaa/sess.go index 32d0e1fb..02e08696 100644 --- a/base/aaa/sess.go +++ b/base/aaa/sess.go @@ -38,7 +38,7 @@ func init() { _sess_create(m, m.Option(USERNAME), UA, m.Option(ice.MSG_USERUA), IP, m.Option(ice.MSG_USERIP)) }}, CHECK: {Name: "check sessid*", Hand: func(m *ice.Message, arg ...string) { _sess_check(m, m.Option(ice.MSG_SESSID)) }}, - }, mdb.HashAction(mdb.EXPIRE, mdb.MONTH, mdb.SHORT, mdb.UNIQ, mdb.FIELD, "time,hash,usernick,username,userrole,ua,ip"), mdb.ImportantHashAction())}, + }, mdb.ImportantHashAction(mdb.EXPIRE, mdb.MONTH, mdb.SHORT, mdb.UNIQ, mdb.FIELD, "time,hash,usernick,username,userrole,ua,ip"))}, }) } diff --git a/base/aaa/user.go b/base/aaa/user.go index 056fda46..4e9da889 100644 --- a/base/aaa/user.go +++ b/base/aaa/user.go @@ -48,7 +48,7 @@ func init() { mdb.CREATE: {Name: "create usernick username* userrole=void,tech userzone background", Hand: func(m *ice.Message, arg ...string) { _user_create(m, m.Option(USERNAME), m.OptionSimple(USERNICK, USERROLE, USERZONE, BACKGROUND)...) }}, - }, mdb.HashAction(mdb.SHORT, USERNAME, mdb.FIELD, "time,usernick,username,userrole,userzone"), mdb.ImportantHashAction())}, + }, mdb.ImportantHashAction(mdb.SHORT, USERNAME, mdb.FIELD, "time,usernick,username,userrole,userzone"))}, }) } diff --git a/base/mdb/mdb.go b/base/mdb/mdb.go index 773439f8..fde33ac2 100644 --- a/base/mdb/mdb.go +++ b/base/mdb/mdb.go @@ -265,8 +265,8 @@ func ImportantZoneAction() ice.Actions { }}, } } -func ImportantHashAction() ice.Actions { - return ice.Actions{ +func ImportantHashAction(arg ...Any) ice.Actions { + return ice.MergeActions(ice.Actions{ ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { Config(m, "important", ice.TRUE) HashImport(m) @@ -274,7 +274,7 @@ func ImportantHashAction() ice.Actions { ice.CTX_EXIT: {Hand: func(m *ice.Message, arg ...string) { HashExport(m) }}, - } + }, HashAction(arg...)) } func saveImportant(m *ice.Message, key, sub string, arg ...string) { kit.If(m.Conf(key, kit.Keys(META, "important")) == ice.TRUE, func() { ice.SaveImportant(m, arg...) }) diff --git a/base/web/dream.go b/base/web/dream.go index 803384b1..4cfc920c 100644 --- a/base/web/dream.go +++ b/base/web/dream.go @@ -20,21 +20,30 @@ import ( func _dream_list(m *ice.Message) *ice.Message { list := m.CmdMap(SPACE, mdb.NAME) - m.Cmdy(nfs.DIR, ice.USR_LOCAL_WORK, "time,size,name").Table(func(value ice.Maps) { + stats := map[string]int{} + mdb.HashSelect(m).Table(func(value ice.Maps) { if space, ok := list[value[mdb.NAME]]; ok { msg := gdb.Event(m.Spawn(value, space), DREAM_TABLES).Copy(m.Spawn().PushButton(cli.STOP)) m.Push(mdb.TYPE, space[mdb.TYPE]) m.Push(cli.STATUS, cli.START) m.Push(mdb.TEXT, msg.Append(mdb.TEXT)) m.PushButton(strings.Join(msg.Appendv(ctx.ACTION), "")) - } else { + stats[cli.START]++ + } else if nfs.Exists(m, path.Join(ice.USR_LOCAL_WORK, value[mdb.NAME])) { m.Push(mdb.TYPE, WORKER) m.Push(cli.STATUS, cli.STOP) m.Push(mdb.TEXT, "") m.PushButton(cli.START, nfs.TRASH) + stats[cli.STOP]++ + } else { + m.Push(mdb.TYPE, WORKER) + m.Push(cli.STATUS, cli.STOP) + m.Push(mdb.TEXT, "") + m.PushButton(cli.START, mdb.REMOVE) + stats[ice.INIT]++ } }) - return m.Sort("status,type,name", ice.STR, ice.STR, ice.STR_R).StatusTimeCount(cli.START, len(list)) + return m.Sort("status,type,name", ice.STR, ice.STR, ice.STR_R).StatusTimeCount(stats) } func _dream_start(m *ice.Message, name string) { if m.Warn(name == "", ice.ErrNotValid, mdb.NAME) { @@ -123,7 +132,8 @@ func init() { }}, mdb.CREATE: {Name: "create name*=hi repos binary template", Hand: func(m *ice.Message, arg ...string) { m.Option(nfs.REPOS, kit.Select("", kit.Slice(kit.Split(m.Option(nfs.REPOS)), -1), 0)) - _dream_start(m, m.OptionDefault(mdb.NAME, path.Base(m.Option(nfs.REPOS)))) + mdb.HashCreate(m) + // _dream_start(m, m.OptionDefault(mdb.NAME, path.Base(m.Option(nfs.REPOS)))) }}, cli.START: {Hand: func(m *ice.Message, arg ...string) { _dream_start(m, m.Option(mdb.NAME)) }}, cli.STOP: {Hand: func(m *ice.Message, arg ...string) { @@ -141,7 +151,7 @@ func init() { kit.Switch(m.Option(mdb.TYPE), []string{SERVER, WORKER}, func() { m.PushButton(OPEN) }) }}, OPEN: {Hand: func(m *ice.Message, arg ...string) { ctx.ProcessOpen(m, m.MergePod(m.Option(mdb.NAME))) }}, - }, ctx.CmdAction(), DreamAction()), Hand: func(m *ice.Message, arg ...string) { + }, ctx.CmdAction(), DreamAction(), mdb.ImportantHashAction(mdb.SHORT, mdb.NAME, mdb.FIELD, "time,name,repos,binary,template")), Hand: func(m *ice.Message, arg ...string) { if len(arg) == 0 { _dream_list(m) ctx.DisplayTableCard(m) diff --git a/base/web/share.go b/base/web/share.go index 86eb23cb..275ca786 100644 --- a/base/web/share.go +++ b/base/web/share.go @@ -69,7 +69,7 @@ func init() { Index.MergeCommands(ice.Commands{ SHARE: {Name: "share hash auto login prunes", Help: "共享链", Actions: ice.MergeActions(ice.Actions{ mdb.CREATE: {Name: "create type name text", Hand: func(m *ice.Message, arg ...string) { - mdb.HashCreate(m, arg, aaa.USERNICK, m.Option(ice.MSG_USERNICK), aaa.USERNAME, m.Option(ice.MSG_USERNAME), aaa.USERROLE, m.Option(ice.MSG_USERROLE)) + mdb.HashCreate(m, arg, m.OptionSimple(ice.CMD), aaa.USERNICK, m.Option(ice.MSG_USERNICK), aaa.USERNAME, m.Option(ice.MSG_USERNAME), aaa.USERROLE, m.Option(ice.MSG_USERROLE)) m.Option(mdb.LINK, _share_link(m, P(SHARE, m.Result()))) }}, LOGIN: {Hand: func(m *ice.Message, arg ...string) { @@ -86,9 +86,17 @@ func init() { } switch msg.Append(mdb.TYPE) { case LOGIN: - m.RenderRedirect(nfs.PS, ice.MSG_SESSID, aaa.SessCreate(m, msg.Append(aaa.USERNAME))) + if msg.Append(ice.CMD) != "" { + m.RenderRedirect(m.MergePodCmd("", msg.Append(ice.CMD)), ice.MSG_SESSID, aaa.SessCreate(m, msg.Append(aaa.USERNAME))) + } else { + m.RenderRedirect(nfs.PS, ice.MSG_SESSID, aaa.SessCreate(m, msg.Append(aaa.USERNAME))) + } default: - RenderMain(m) + if msg.Append(ice.CMD) != "" { + RenderCmd(m, msg.Append(ice.CMD)) + } else { + RenderMain(m) + } } }}, }, mdb.HashAction(mdb.FIELD, "time,hash,type,name,text,river,storm,usernick,username,userrole", mdb.EXPIRE, mdb.DAYS), aaa.WhiteAction()), Hand: func(m *ice.Message, arg ...string) { diff --git a/core/chat/favor.go b/core/chat/favor.go index fcb3ed45..59405835 100644 --- a/core/chat/favor.go +++ b/core/chat/favor.go @@ -100,7 +100,7 @@ func init() { m.Option(mdb.TYPE, mdb.HashSelects(m.Spawn(), m.Option(mdb.HASH)).Append(mdb.TYPE)) ctx.Run(m, arg...) }}, - }, ctx.CmdAction(), mdb.ImportantHashAction(), mdb.HashAction()), Hand: func(m *ice.Message, arg ...string) { + }, ctx.CmdAction(), mdb.ImportantHashAction()), 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/macos/desktop.go b/core/chat/macos/desktop.go index d71b05ba..c6ba4557 100644 --- a/core/chat/macos/desktop.go +++ b/core/chat/macos/desktop.go @@ -25,7 +25,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(), "桌面")) }) }}, - }, web.DreamAction(), mdb.ImportantHashAction(), CmdHashAction())}, + }, web.DreamAction(), CmdHashAction(), mdb.ImportantHashAction())}, }) } diff --git a/core/chat/macos/dock.go b/core/chat/macos/dock.go index 40b13977..6d52c02e 100644 --- a/core/chat/macos/dock.go +++ b/core/chat/macos/dock.go @@ -18,7 +18,7 @@ func init() { DockAppend(m, "", web.CODE_VIMER) } }}, - }, mdb.ImportantHashAction(), CmdHashAction())}}) + }, CmdHashAction(), mdb.ImportantHashAction())}}) } func DockAppend(m *ice.Message, name, index string, arg ...string) { diff --git a/core/chat/macos/menu.go b/core/chat/macos/menu.go index e508666c..f998bda2 100644 --- a/core/chat/macos/menu.go +++ b/core/chat/macos/menu.go @@ -9,7 +9,7 @@ const MENU = "menu" func init() { Index.MergeCommands(ice.Commands{ - MENU: {Actions: ice.MergeActions(mdb.ImportantHashAction(), CmdHashAction())}, + MENU: {Actions: ice.MergeActions(CmdHashAction(), mdb.ImportantHashAction())}, }) } func MenuAppend(m *ice.Message, name, index string, arg ...string) { diff --git a/core/chat/macos/session.go b/core/chat/macos/session.go index 168b9a37..168d2ebf 100644 --- a/core/chat/macos/session.go +++ b/core/chat/macos/session.go @@ -9,7 +9,7 @@ const SESSION = "session" func init() { Index.MergeCommands(ice.Commands{ - SESSION: {Actions: ice.MergeActions(mdb.ImportantHashAction(), CmdHashAction(mdb.NAME)), Hand: func(m *ice.Message, arg ...string) { + SESSION: {Actions: ice.MergeActions(CmdHashAction(mdb.NAME), mdb.ImportantHashAction()), Hand: func(m *ice.Message, arg ...string) { if mdb.HashSelect(m, arg...); len(arg) > 0 { m.EchoIFrame(m.MergePodCmd("", DESKTOP, SESSION, arg[0])) } diff --git a/core/chat/river.go b/core/chat/river.go index b066f9ae..18277704 100644 --- a/core/chat/river.go +++ b/core/chat/river.go @@ -55,7 +55,7 @@ func init() { } gdb.Event(m, RIVER_CREATE, RIVER, m.Option(ice.MSG_RIVER, h), arg) }}, - }, mdb.ImportantHashAction(), mdb.HashAction(mdb.FIELD, "time,hash,type,name,text,template"), aaa.WhiteAction()), Hand: func(m *ice.Message, arg ...string) { + }, aaa.WhiteAction(), mdb.ImportantHashAction(mdb.FIELD, "time,hash,type,name,text,template")), 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/code/xterm.go b/core/code/xterm.go index 73772b5c..33d933a7 100644 --- a/core/code/xterm.go +++ b/core/code/xterm.go @@ -133,7 +133,7 @@ func init() { ctx.PROCESS: {Hand: func(m *ice.Message, arg ...string) { ctx.ProcessField(m, m.PrefixKey(), func() string { return m.Cmdx("", mdb.CREATE, arg) }, arg...) }}, - }, ctx.CmdAction(), ctx.ProcessAction(), web.DreamAction(), mdb.ImportantHashAction(), mdb.HashAction(mdb.FIELD, "time,hash,type,name,text,path,theme,daemon")), Hand: func(m *ice.Message, arg ...string) { + }, ctx.CmdAction(), ctx.ProcessAction(), web.DreamAction(), 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)