1
0
mirror of https://shylinux.com/x/icebergs synced 2025-04-25 17:18:05 +08:00

add goods

This commit is contained in:
harveyshao 2022-10-17 23:04:07 +08:00
parent 81b1bb8fc2
commit a54df18a51
5 changed files with 26 additions and 6 deletions

View File

@ -48,6 +48,7 @@ func _share_cache(m *ice.Message, arg ...string) {
}
} else {
msg := m.Cmd(CACHE, arg[0])
m.Debug("what %v", msg.FormatMeta())
m.RenderDownload(msg.Append(nfs.FILE), msg.Append(mdb.TYPE), msg.Append(mdb.NAME))
}
}

View File

@ -8,7 +8,7 @@ import (
"shylinux.com/x/icebergs/base/cli"
"shylinux.com/x/icebergs/base/mdb"
"shylinux.com/x/icebergs/base/nfs"
"shylinux.com/x/icebergs/base/web"
// "shylinux.com/x/icebergs/base/web"
kit "shylinux.com/x/toolkits"
)
@ -57,7 +57,7 @@ func init() {
_autogen_version(m.Spawn())
// 执行编译
web.PushStream(m)
// web.PushStream(m)
main, file, goos, arch := _compile_target(m, arg...)
m.Optionv(cli.CMD_ENV, kit.Simple(cli.HOME, kit.Env(cli.HOME), cli.PATH, kit.Env(cli.PATH), m.Configv(cli.ENV), m.Optionv(cli.ENV), cli.GOOS, goos, cli.GOARCH, arch))
m.Cmd(cli.SYSTEM, GO, "get", "shylinux.com/x/ice")

View File

@ -2,18 +2,27 @@ 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"
)
const GOODS = "goods"
func init() {
Index.MergeCommands(ice.Commands{
GOODS: {Name: "goods hash auto", Help: "商品", Actions: ice.MergeActions(ice.Actions{
}, mdb.HashAction(mdb.FIELD, "time,hash,type,name,text")), Hand: func(m *ice.Message, arg ...string) {
mdb.CREATE: {Name: "modify zone type name text price count image"},
mdb.MODIFY: {Name: "modify zone type name text price count image"},
web.UPLOAD: {Hand: func(m *ice.Message, arg ...string) { web.Upload(m) }},
}, mdb.HashAction(mdb.FIELD, "time,hash,zone,type,name,text,price,count,image")), Hand: func(m *ice.Message, arg ...string) {
if mdb.HashSelect(m, arg...); len(arg) == 0 || arg[0] == "" {
m.Action(mdb.CREATE)
m.Action(mdb.CREATE, mdb.EXPORT, mdb.IMPORT)
ctx.DisplayLocal(m, "")
} else {
m.EchoImages(web.MergeURL2(m, "/share/cache/"+m.Append("image")))
}
m.PushAction(mdb.MODIFY, mdb.REMOVE)
}},
})
}

View File

@ -407,6 +407,10 @@ func SplitCmd(name string, actions Actions) (list []Any) {
item = kit.Dict(TYPE, PASSWORD, NAME, ls[i])
list = append(list, item)
case "image":
item = kit.Dict(TYPE, TEXT, NAME, ls[i], ACTION, "img")
list = append(list, item)
case "*":
item["need"] = "must"
case DF:

View File

@ -29,7 +29,11 @@ func Render(m *Message, cmd string, args ...Any) string {
return kit.Join(list, SP)
case RENDER_IMAGES: // src [height]
return kit.Format(`<img src="%s" height=%s>`, arg[0], kit.Select("120", arg, 1))
m.Debug("what %v", m.Option(MSG_USERUA))
if strings.Contains(m.Option(MSG_USERUA), "Mobile") {
return kit.Format(`<img src="%s" width=%d>`, arg[0], kit.Int(kit.Select(kit.Select("120", m.Option("width")), arg, 1))-24)
}
return kit.Format(`<img src="%s" height=%d>`, arg[0], kit.Int(kit.Select(kit.Select("240", m.Option("height")), arg, 1))/2-24)
case RENDER_VIDEOS: // src [height]
return kit.Format(`<video src="%s" height=%s controls>`, arg[0], kit.Select("120", arg, 1))
@ -79,6 +83,8 @@ func (m *Message) RenderRedirect(args ...Any) *Message {
return m.Render(RENDER_REDIRECT, args...)
}
func (m *Message) RenderDownload(args ...Any) *Message {
m.Debug("what %v", kit.Format(args))
return m.Render(RENDER_DOWNLOAD, args...)
}
func (m *Message) RenderResult(args ...Any) *Message { // [fmt arg...]