1
0
forked from x/icebergs
This commit is contained in:
IT 老营长 @云轩领航-创始人 2023-11-01 19:35:49 +08:00
parent 47f2092705
commit 532a2f8457
4 changed files with 22 additions and 8 deletions

View File

@ -74,7 +74,7 @@ func init() {
SHARE: {Name: "share hash auto login", Help: "共享链", Actions: ice.MergeActions(ice.Actions{
mdb.CREATE: {Name: "create type name text", Hand: func(m *ice.Message, arg ...string) {
kit.If(m.Option(mdb.TYPE) == LOGIN, func() { arg = append(arg, mdb.TEXT, tcp.PublishLocalhost(m, m.Option(mdb.TEXT))) })
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, SPACE, m.Option(ice.MSG_USERPOD), 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: {Help: "登录", Hand: func(m *ice.Message, arg ...string) {
@ -87,7 +87,10 @@ func init() {
}},
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:])
m.Option(ice.MSG_USERNICK, msg.Append(aaa.USERNICK))
m.Option(ice.MSG_USERNAME, msg.Append(aaa.USERNAME))
m.Option(ice.MSG_USERROLE, msg.Append(aaa.USERROLE))
m.Cmdy(Space(m, msg.Append(SPACE)), msg.Append(mdb.NAME), arg[1:])
}
}},
nfs.PS: {Hand: func(m *ice.Message, arg ...string) {
@ -103,7 +106,7 @@ func init() {
case LOGIN:
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)))
RenderPodCmd(m, msg.Append(SPACE), msg.Append(mdb.NAME), kit.UnMarshal(msg.Append(mdb.TEXT)))
case DOWNLOAD:
m.RenderDownload(msg.Append(mdb.TEXT))
default:

View File

@ -184,7 +184,7 @@ func init() {
m.Cmdy(nfs.DIR, ice.USR_ICONS, nfs.PATH).CutTo(nfs.PATH, arg[0])
case ctx.INDEX:
if space := m.Option(SPACE); space != "" {
m.Options(SPACE, []string{}).Cmdy(SPACE, space, mdb.INPUTS, arg)
m.Options(SPACE, []string{}).Cmdy(SPACE, space, ctx.COMMAND)
} else {
m.Cmdy(ctx.COMMAND)
}

View File

@ -7,14 +7,19 @@ import (
kit "shylinux.com/x/toolkits"
)
const (
AREA = "area"
POPULATION = "population"
GDP = "gdp"
)
const REGION = "region"
func init() {
Index.MergeCommands(ice.Commands{
REGION: {Help: "地区", Meta: kit.Dict(
ice.CTX_TRANS, kit.Dict(html.INPUT, kit.Dict(
"area", "面积", "population", "人口", "gdp", "产值",
)),
), Actions: ice.MergeActions(mdb.ExportHashAction(mdb.SHORT, mdb.NAME, mdb.FIELD, "time,name,text,area,population,gdp"))},
ice.CTX_TRANS, kit.Dict(html.INPUT, kit.Dict(AREA, "面积(平方公里)", POPULATION, "人口(万人)", GDP, "产值(亿元)")),
), Actions: ice.MergeActions(mdb.ExportHashAction(mdb.SHORT, mdb.NAME, mdb.FIELD, "time,name,gdp,population,area,text")), Hand: func(m *ice.Message, arg ...string) {
mdb.HashSelect(m, arg...).SortIntR(GDP).StatusTimeCount(m.Stats(GDP, POPULATION, AREA))
}},
})
}

View File

@ -158,6 +158,12 @@ func (m *Message) Length() (max int) {
func (m *Message) TablesLimit(count int, cb func(value Maps)) *Message {
return m.Table(func(index int, value Maps) { kit.If(index < count, func() { cb(value) }) })
}
func (m *Message) Stats(arg ...string) (res []string) {
stats := map[string]float64{}
m.Table(func(value Maps) { kit.For(arg, func(k string) { stats[k] += kit.Float(value[k]) }) })
kit.For(arg, func(k string) { res = append(res, k, kit.Format("%0.2f", stats[k])) })
return
}
func (m *Message) Table(cb Any) *Message {
n := m.Length()
if n == 0 {