From 623cb165e22ba6860a14b5b1fda90c861aecf8fe Mon Sep 17 00:00:00 2001 From: shaoying Date: Tue, 18 Oct 2022 09:28:58 +0800 Subject: [PATCH] opt some --- core/mall/goods.go | 9 +++++++-- misc.go | 3 +++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/core/mall/goods.go b/core/mall/goods.go index de8494c0..57dde2a0 100644 --- a/core/mall/goods.go +++ b/core/mall/goods.go @@ -14,15 +14,20 @@ func init() { GOODS: {Name: "goods hash auto", Help: "商品", Actions: ice.MergeActions(ice.Actions{ mdb.CREATE: {Name: "modify zone type name text price count image"}, mdb.MODIFY: {Name: "modify zone type name text price count image"}, + "copy": {Hand: func(m *ice.Message, arg ...string) { + m.Cmd("", mdb.CREATE, m.OptionSimple("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, mdb.EXPORT, mdb.IMPORT) + if !m.IsMobile() { + 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) + m.PushAction("copy", mdb.MODIFY, mdb.REMOVE) }}, }) } \ No newline at end of file diff --git a/misc.go b/misc.go index 12d5f5aa..83201826 100644 --- a/misc.go +++ b/misc.go @@ -137,6 +137,9 @@ func (m *Message) SetResult(arg ...string) *Message { return m.Set(MSG_RESULT, arg...) } +func (m *Message) IsMobile() bool { + return strings.Contains(m.Option(MSG_USERUA), "Mobile") +} func (m *Message) Design(action Any, help string, input ...Any) { list := kit.List() for _, input := range input {