From a54df18a51ae51af812f08eb2571215f94b6ca2c Mon Sep 17 00:00:00 2001 From: harveyshao Date: Mon, 17 Oct 2022 23:04:07 +0800 Subject: [PATCH] add goods --- base/web/share.go | 1 + core/code/compile.go | 4 ++-- core/mall/goods.go | 15 ++++++++++++--- misc.go | 4 ++++ render.go | 8 +++++++- 5 files changed, 26 insertions(+), 6 deletions(-) diff --git a/base/web/share.go b/base/web/share.go index 1644c2df..1c37db9a 100644 --- a/base/web/share.go +++ b/base/web/share.go @@ -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)) } } diff --git a/core/code/compile.go b/core/code/compile.go index 8975d6fc..ebcc0549 100644 --- a/core/code/compile.go +++ b/core/code/compile.go @@ -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") diff --git a/core/mall/goods.go b/core/mall/goods.go index 3c77853d..de8494c0 100644 --- a/core/mall/goods.go +++ b/core/mall/goods.go @@ -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) }}, }) } \ No newline at end of file diff --git a/misc.go b/misc.go index 08813afb..12d5f5aa 100644 --- a/misc.go +++ b/misc.go @@ -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: diff --git a/render.go b/render.go index 25fe2862..7dea81ed 100644 --- a/render.go +++ b/render.go @@ -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(``, 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(``, arg[0], kit.Int(kit.Select(kit.Select("120", m.Option("width")), arg, 1))-24) + } + return kit.Format(``, arg[0], kit.Int(kit.Select(kit.Select("240", m.Option("height")), arg, 1))/2-24) case RENDER_VIDEOS: // src [height] return kit.Format(`