mirror of
https://shylinux.com/x/icebergs
synced 2025-04-26 01:24:05 +08:00
add some
This commit is contained in:
parent
99a42fe3a7
commit
eb5b405e8e
@ -19,44 +19,45 @@ type displayMessage interface {
|
||||
func isLocalFile(p string) bool {
|
||||
return !strings.HasPrefix(p, nfs.PS) && !strings.HasPrefix(p, ice.HTTP)
|
||||
}
|
||||
func Display(m displayMessage, file string, arg ...ice.Any) displayMessage {
|
||||
func Display(m *ice.Message, file string, arg ...ice.Any) *ice.Message {
|
||||
kit.If(file == "", func() { file = kit.Keys(kit.FileName(5), nfs.JS) })
|
||||
kit.If(isLocalFile(file), func() { file = path.Join(nfs.PS, path.Join(path.Dir(FileURI(logs.FileLines(2))), file)) })
|
||||
return DisplayBase(m, file, arg...)
|
||||
}
|
||||
func DisplayTable(m displayMessage, arg ...ice.Any) displayMessage {
|
||||
func DisplayTable(m *ice.Message, arg ...ice.Any) *ice.Message {
|
||||
return DisplayBase(m, ice.PLUGIN_TABLE_JS, arg...)
|
||||
}
|
||||
func DisplayTableCard(m displayMessage, arg ...ice.Any) displayMessage {
|
||||
func DisplayTableCard(m *ice.Message, arg ...ice.Any) *ice.Message {
|
||||
return DisplayTable(m, STYLE, "card")
|
||||
}
|
||||
func DisplayStory(m displayMessage, file string, arg ...ice.Any) displayMessage {
|
||||
func DisplayStory(m *ice.Message, file string, arg ...ice.Any) *ice.Message {
|
||||
kit.If(file == "", func() { file = kit.Keys(kit.FileName(5), nfs.JS) })
|
||||
kit.If(isLocalFile(file), func() { file = path.Join(ice.PLUGIN_STORY, file) })
|
||||
return DisplayBase(m, file, arg...)
|
||||
}
|
||||
func DisplayStoryJSON(m displayMessage, arg ...ice.Any) displayMessage {
|
||||
func DisplayStoryJSON(m *ice.Message, arg ...ice.Any) *ice.Message {
|
||||
return DisplayStory(m, "json", arg...)
|
||||
}
|
||||
func DisplayStorySpide(m displayMessage, arg ...ice.Any) displayMessage {
|
||||
func DisplayStorySpide(m *ice.Message, arg ...ice.Any) *ice.Message {
|
||||
return DisplayStory(m, "spide", arg...)
|
||||
}
|
||||
func DisplayStudio(m *ice.Message, cmd ...string) displayMessage {
|
||||
func DisplayStudio(m *ice.Message, cmd ...string) *ice.Message {
|
||||
for i, k := range cmd {
|
||||
kit.If(!strings.Contains(cmd[i], nfs.PT), func() { cmd[i] = m.Prefix(k) })
|
||||
}
|
||||
return DisplayStory(m.Cmdy(COMMAND, cmd), "studio.js")
|
||||
}
|
||||
func DisplayLocal(m displayMessage, file string, arg ...ice.Any) displayMessage {
|
||||
func DisplayLocal(m *ice.Message, file string, arg ...ice.Any) *ice.Message {
|
||||
kit.If(file == "", func() { file = path.Join(kit.PathName(5), kit.Keys(kit.FileName(5), nfs.JS)) })
|
||||
kit.If(isLocalFile(file), func() { file = path.Join(ice.PLUGIN_LOCAL, file) })
|
||||
return DisplayBase(m, file, arg...)
|
||||
}
|
||||
func DisplayLocalInner(m displayMessage, arg ...ice.Any) displayMessage {
|
||||
func DisplayLocalInner(m *ice.Message, arg ...ice.Any) *ice.Message {
|
||||
return DisplayLocal(m, "code/inner.js", arg...)
|
||||
}
|
||||
func DisplayBase(m displayMessage, file string, arg ...ice.Any) displayMessage {
|
||||
func DisplayBase(m *ice.Message, file string, arg ...ice.Any) *ice.Message {
|
||||
m.Option(ice.MSG_DISPLAY, kit.MergeURL(kit.Select(kit.ExtChange(file, nfs.JS), file, strings.Contains(file, mdb.QS)), arg...))
|
||||
Toolkit(m, "")
|
||||
return m
|
||||
}
|
||||
func Toolkit(m *ice.Message, arg ...string) {
|
||||
|
@ -209,3 +209,24 @@ func RenderCache(m *ice.Message, h string) {
|
||||
m.RenderDownload(msg.Append(mdb.FILE), msg.Append(mdb.TYPE), msg.Append(mdb.NAME))
|
||||
}
|
||||
}
|
||||
func ExportCacheAction(field string) ice.Actions {
|
||||
return ice.Actions{
|
||||
ice.CTX_EXIT: {Hand: func(m *ice.Message, arg ...string) {
|
||||
mdb.HashSelect(m.Spawn(kit.Dict(ice.MSG_FIELDS, field))).Table(func(value ice.Maps) {
|
||||
kit.For(kit.Split(value[field]), func(h string) {
|
||||
msg := m.Cmd(CACHE, h)
|
||||
m.Cmd(nfs.LINK, kit.Keys(path.Join(ice.USR_LOCAL_EXPORT, m.PrefixKey(), field, h), kit.Select("", kit.Split(msg.Append(mdb.TYPE), nfs.PS), -1)), msg.Append(nfs.FILE))
|
||||
})
|
||||
})
|
||||
}},
|
||||
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
|
||||
list := map[string]string{}
|
||||
m.Cmd(nfs.DIR, path.Join(ice.USR_LOCAL_EXPORT, m.PrefixKey(), field), func(value ice.Maps) {
|
||||
list[kit.TrimExt(value[nfs.PATH])] = m.Cmd(CACHE, CATCH, value[nfs.PATH]).Append(mdb.HASH)
|
||||
})
|
||||
mdb.HashSelectUpdate(m, "", func(value ice.Map) {
|
||||
value[field] = kit.Join(kit.Simple(kit.For(kit.Split(kit.Format(value[field])), func(p string) string { return kit.Select(p, list[p]) })))
|
||||
})
|
||||
}},
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ const ADMIN = "admin"
|
||||
|
||||
func init() {
|
||||
Index.MergeCommands(ice.Commands{
|
||||
ADMIN: {Name: "admin hash auto", Help: "管理", Meta: kit.Dict(
|
||||
ADMIN: {Help: "管理", Meta: kit.Dict(
|
||||
ctx.TRANS, kit.Dict(html.INPUT, kit.Dict(mdb.TYPE, "单位", PRICE, "价格", AMOUNT, "总价")),
|
||||
), Actions: ice.MergeActions(ice.Actions{
|
||||
web.UPLOAD: {Hand: func(m *ice.Message, arg ...string) { m.Echo(m.Append(mdb.HASH)) }},
|
||||
@ -24,14 +24,17 @@ func init() {
|
||||
kit.If(m.IsMobileUA(), func() { m.Action(mdb.CREATE) }, func() { m.Action(mdb.CREATE, "filter:text") })
|
||||
kit.If(len(arg) > 0, func() {
|
||||
kit.For(kit.Split(m.Append(nfs.IMAGE)), func(p string) {
|
||||
m.EchoImages(web.MergeURL2(m, web.SHARE_CACHE+p))
|
||||
m.EchoImages(web.MergeURL2(m, web.SHARE_CACHE+p, ice.POD, m.Append(web.SPACE)))
|
||||
})
|
||||
})
|
||||
ctx.DisplayTable(m)
|
||||
ctx.Toolkit(m, "")
|
||||
var total float64
|
||||
m.Table(func(value ice.Maps) { total += kit.Float(value[PRICE]) * kit.Float(value[mdb.COUNT]) })
|
||||
m.StatusTimeCount(AMOUNT, kit.Format("%0.2f", total))
|
||||
_status_amount(m)
|
||||
}},
|
||||
})
|
||||
}
|
||||
|
||||
func _status_amount(m *ice.Message) (total float64) {
|
||||
m.Table(func(value ice.Maps) { total += kit.Float(value[PRICE]) * kit.Float(value[mdb.COUNT]) })
|
||||
m.StatusTimeCount(AMOUNT, kit.Format("%0.2f", total))
|
||||
return
|
||||
}
|
||||
|
@ -1,8 +1,6 @@
|
||||
package mall
|
||||
|
||||
import (
|
||||
"path"
|
||||
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/ctx"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
@ -19,40 +17,18 @@ const GOODS = "goods"
|
||||
|
||||
func init() {
|
||||
Index.MergeCommands(ice.Commands{
|
||||
GOODS: {Name: "goods list", Icon: "mall.png", Help: "商品", Meta: kit.Dict(
|
||||
GOODS: {Help: "商品", Icon: "mall.png", Meta: kit.Dict(
|
||||
ctx.TRANS, kit.Dict(html.INPUT, kit.Dict(mdb.TYPE, "单位", PRICE, "价格", AMOUNT, "总价")),
|
||||
), Actions: ice.MergeActions(ice.Actions{
|
||||
ice.CTX_EXIT: {Hand: func(m *ice.Message, arg ...string) {
|
||||
mdb.HashSelect(m.Spawn(kit.Dict(ice.MSG_FIELDS, nfs.IMAGE))).Table(func(value ice.Maps) {
|
||||
kit.For(kit.Split(value[nfs.IMAGE]), func(h string) {
|
||||
msg := m.Cmd(web.CACHE, h)
|
||||
m.Cmd(nfs.LINK, kit.Keys(path.Join(ice.USR_LOCAL_EXPORT, m.PrefixKey(), nfs.IMAGE, h), kit.Select("", kit.Split(msg.Append(mdb.TYPE), nfs.PS), -1)), msg.Append(nfs.FILE))
|
||||
})
|
||||
})
|
||||
}},
|
||||
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
|
||||
list := map[string]string{}
|
||||
m.Cmd(nfs.DIR, path.Join(ice.USR_LOCAL_EXPORT, m.PrefixKey(), nfs.IMAGE), func(value ice.Maps) {
|
||||
list[kit.TrimExt(value[nfs.PATH])] = m.Cmd(web.CACHE, web.CATCH, value[nfs.PATH]).Append(mdb.HASH)
|
||||
})
|
||||
mdb.HashSelectUpdate(m, "", func(value ice.Map) {
|
||||
value[nfs.IMAGE] = kit.Join(kit.Simple(kit.For(kit.Split(kit.Format(value[nfs.IMAGE])), func(p string) string { return kit.Select(p, list[p]) })))
|
||||
})
|
||||
}},
|
||||
mdb.CREATE: {Name: "create zone* name* text price* count*=1 type*=件,个,份,斤 image*=4@img"},
|
||||
mdb.MODIFY: {Name: "modify zone* name* text price* count*=1 type*=件,个,份,斤 image*=4@img"},
|
||||
nfs.IMAGE: {Name: "image image*=4@img", Help: "图片", Hand: func(m *ice.Message, arg ...string) { mdb.HashModify(m, arg) }},
|
||||
ORDER: {Name: "order count*=1", Help: "选购", Hand: func(m *ice.Message, arg ...string) {}},
|
||||
}, mdb.ExportHashAction(ctx.TOOLS, Prefix(ORDER), mdb.FIELD, "time,hash,zone,name,text,price,count,type,image")), Hand: func(m *ice.Message, arg ...string) {
|
||||
}, web.ExportCacheAction(nfs.IMAGE), mdb.ExportHashAction(ctx.TOOLS, Prefix(ORDER), mdb.FIELD, "time,hash,zone,name,text,price,count,type,image")), Hand: func(m *ice.Message, arg ...string) {
|
||||
kit.If(len(arg) == 0 && m.IsMobileUA(), func() { m.OptionDefault(ice.MSG_FIELDS, "zone,name,price,count,type,text,hash,time,image") })
|
||||
mdb.HashSelect(m, arg...).PushAction(ORDER).Action("filter:text")
|
||||
web.PushPodCmd(m, "", arg...)
|
||||
web.PushPodCmd(m, "", arg...).Sort("zone,name")
|
||||
ctx.DisplayLocal(m, "")
|
||||
ctx.Toolkit(m, "")
|
||||
m.Sort("zone,name")
|
||||
var total float64
|
||||
m.Table(func(value ice.Maps) { total += kit.Float(value[PRICE]) * kit.Float(value[mdb.COUNT]) })
|
||||
m.StatusTimeCount(AMOUNT, kit.Format("%0.2f", total))
|
||||
_status_amount(m)
|
||||
}},
|
||||
})
|
||||
}
|
||||
|
@ -589,7 +589,6 @@ func init() {
|
||||
p = strings.Split(p, mdb.QS)[0]
|
||||
kit.If(!strings.Contains(p, "://"), func() { p = web.UserHost(m) + "/x/" + p })
|
||||
kit.If(ice.Info.System == cli.LINUX, func() { p = strings.Replace(p, ice.HTTPS, ice.HTTP, 1) })
|
||||
web.Toast(m, CLONE+" "+p)
|
||||
m.Cmd("", CLONE, ORIGIN, p, nfs.PATH, m.Option(cli.CMD_DIR), ice.Maps{cli.CMD_DIR: ""})
|
||||
})
|
||||
}},
|
||||
|
Loading…
x
Reference in New Issue
Block a user