forked from x/icebergs
add some
This commit is contained in:
parent
47f2092705
commit
532a2f8457
@ -74,7 +74,7 @@ func init() {
|
|||||||
SHARE: {Name: "share hash auto login", Help: "共享链", Actions: ice.MergeActions(ice.Actions{
|
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) {
|
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))) })
|
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())))
|
m.Option(mdb.LINK, _share_link(m, P(SHARE, m.Result())))
|
||||||
}},
|
}},
|
||||||
LOGIN: {Help: "登录", Hand: func(m *ice.Message, arg ...string) {
|
LOGIN: {Help: "登录", Hand: func(m *ice.Message, arg ...string) {
|
||||||
@ -87,7 +87,10 @@ func init() {
|
|||||||
}},
|
}},
|
||||||
ctx.RUN: {Hand: func(m *ice.Message, arg ...string) {
|
ctx.RUN: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
if msg := mdb.HashSelect(m.Spawn(), m.Option(SHARE)); !IsNotValidFieldShare(m, msg) {
|
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) {
|
nfs.PS: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
@ -103,7 +106,7 @@ func init() {
|
|||||||
case LOGIN:
|
case LOGIN:
|
||||||
m.RenderRedirect(msg.Append(mdb.TEXT), ice.MSG_SESSID, aaa.SessCreate(m, msg.Append(aaa.USERNAME)))
|
m.RenderRedirect(msg.Append(mdb.TEXT), ice.MSG_SESSID, aaa.SessCreate(m, msg.Append(aaa.USERNAME)))
|
||||||
case FIELD:
|
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:
|
case DOWNLOAD:
|
||||||
m.RenderDownload(msg.Append(mdb.TEXT))
|
m.RenderDownload(msg.Append(mdb.TEXT))
|
||||||
default:
|
default:
|
||||||
|
@ -184,7 +184,7 @@ func init() {
|
|||||||
m.Cmdy(nfs.DIR, ice.USR_ICONS, nfs.PATH).CutTo(nfs.PATH, arg[0])
|
m.Cmdy(nfs.DIR, ice.USR_ICONS, nfs.PATH).CutTo(nfs.PATH, arg[0])
|
||||||
case ctx.INDEX:
|
case ctx.INDEX:
|
||||||
if space := m.Option(SPACE); space != "" {
|
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 {
|
} else {
|
||||||
m.Cmdy(ctx.COMMAND)
|
m.Cmdy(ctx.COMMAND)
|
||||||
}
|
}
|
||||||
|
@ -7,14 +7,19 @@ import (
|
|||||||
kit "shylinux.com/x/toolkits"
|
kit "shylinux.com/x/toolkits"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
AREA = "area"
|
||||||
|
POPULATION = "population"
|
||||||
|
GDP = "gdp"
|
||||||
|
)
|
||||||
const REGION = "region"
|
const REGION = "region"
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Index.MergeCommands(ice.Commands{
|
Index.MergeCommands(ice.Commands{
|
||||||
REGION: {Help: "地区", Meta: kit.Dict(
|
REGION: {Help: "地区", Meta: kit.Dict(
|
||||||
ice.CTX_TRANS, kit.Dict(html.INPUT, kit.Dict(
|
ice.CTX_TRANS, kit.Dict(html.INPUT, kit.Dict(AREA, "面积(平方公里)", POPULATION, "人口(万人)", GDP, "产值(亿元)")),
|
||||||
"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))
|
||||||
), Actions: ice.MergeActions(mdb.ExportHashAction(mdb.SHORT, mdb.NAME, mdb.FIELD, "time,name,text,area,population,gdp"))},
|
}},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
6
meta.go
6
meta.go
@ -158,6 +158,12 @@ func (m *Message) Length() (max int) {
|
|||||||
func (m *Message) TablesLimit(count int, cb func(value Maps)) *Message {
|
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) }) })
|
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 {
|
func (m *Message) Table(cb Any) *Message {
|
||||||
n := m.Length()
|
n := m.Length()
|
||||||
if n == 0 {
|
if n == 0 {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user