From 8328b4cb698bc3a9428ce45ca46b42b801fc9ca9 Mon Sep 17 00:00:00 2001 From: shy Date: Mon, 15 Jul 2024 09:36:47 +0800 Subject: [PATCH] add some --- base/nfs/dir.go | 1 + base/web/serve.go | 12 +-- core/chat/header.go | 5 +- core/chat/oauth/client.go | 41 +++++---- misc/wx/access.go | 16 +++- misc/wx/agent.go | 10 ++- misc/wx/agent.js | 179 ++++++++++++++++++++------------------ misc/wx/events.go | 10 +++ misc/wx/menu.go | 8 +- option.go | 2 +- 10 files changed, 171 insertions(+), 113 deletions(-) diff --git a/base/nfs/dir.go b/base/nfs/dir.go index e79b45f9..6dce9dde 100644 --- a/base/nfs/dir.go +++ b/base/nfs/dir.go @@ -151,6 +151,7 @@ const ( ETC_CERT_KEY = "etc/cert/cert.key" ETC_CERT_PEM = "etc/cert/cert.pem" SRC_DOCUMENT = "src/document/" + SRC_PRIVATE = "src/private/" SRC_TEMPLATE = ice.SRC_TEMPLATE USR_TOOLKITS = ice.USR_TOOLKITS USR_ICEBERGS = ice.USR_ICEBERGS diff --git a/base/web/serve.go b/base/web/serve.go index dc87b21d..49579201 100644 --- a/base/web/serve.go +++ b/base/web/serve.go @@ -96,16 +96,18 @@ func _serve_main(m *ice.Message, w http.ResponseWriter, r *http.Request) bool { } func _serve_static(msg *ice.Message, w http.ResponseWriter, r *http.Request) bool { ispod := kit.Contains(r.URL.String(), S(), "pod=") || kit.Contains(r.Header.Get(html.Referer), S(), "pod=") - if strings.HasPrefix(r.URL.Path, "/v/") { + if strings.HasPrefix(r.URL.Path, nfs.V) { return Render(msg, ice.RENDER_DOWNLOAD, path.Join(ice.USR_VOLCANOS, strings.TrimPrefix(r.URL.Path, nfs.V))) - } else if kit.HasPrefix(r.URL.Path, "/p/") { + } else if kit.HasPrefix(r.URL.Path, nfs.P) { if kit.Contains(r.URL.String(), "render=replace") { return false } - p := strings.TrimPrefix(r.URL.Path, "/p/") + p := strings.TrimPrefix(r.URL.Path, nfs.P) return (!ispod && kit.HasPrefix(p, nfs.SRC) || kit.HasPrefix(p, ice.USR_ICEBERGS, ice.USR_ICONS)) && nfs.Exists(msg, p) && Render(msg, ice.RENDER_DOWNLOAD, p) - } else if kit.HasPrefix(r.URL.Path, "/m/") { - p := nfs.USR_MODULES + strings.TrimPrefix(r.URL.Path, "/m/") + } else if kit.HasPrefix(path.Base(r.URL.Path), "MP_verify_") { + return Render(msg, ice.RENDER_DOWNLOAD, nfs.SRC_PRIVATE+path.Base(r.URL.Path)) + } else if kit.HasPrefix(r.URL.Path, nfs.M) { + p := nfs.USR_MODULES + strings.TrimPrefix(r.URL.Path, nfs.M) return nfs.Exists(msg, p) && Render(msg, ice.RENDER_DOWNLOAD, p) } else if p := path.Join(kit.Select(ice.USR_VOLCANOS, ice.USR_INTSHELL, msg.IsCliUA()), r.URL.Path); nfs.Exists(msg, p) { return Render(msg, ice.RENDER_DOWNLOAD, p) diff --git a/core/chat/header.go b/core/chat/header.go index bed14919..1419ac11 100644 --- a/core/chat/header.go +++ b/core/chat/header.go @@ -146,10 +146,11 @@ func init() { m.Option(ice.MSG_NODETYPE, ice.Info.NodeType) kit.If(m.Option(ice.MSG_USERPOD), func(p string) { m.Option(ice.MSG_NODETYPE, m.Cmdx(web.SPACE, p, cli.RUNTIME, ice.MSG_NODETYPE)) + m.Option("favicon", m.Cmd(web.SPACE, m.Option(ice.MSG_USERPOD), web.SPACE, ice.INFO).Append(mdb.ICONS)) }, func() { - m.Option("titles", ice.Info.Title()) + // m.Option("titles", ice.Info.Title()) + m.Option("favicon", ice.Info.NodeIcon) }) - m.Option("favicon", m.Cmd(web.SPACE, m.Option(ice.MSG_USERPOD), web.SPACE, ice.INFO).Append(mdb.ICONS)) m.Option(aaa.LANGUAGE, strings.ReplaceAll(strings.ToLower(kit.Select("", kit.Split(kit.GetValid( func() string { return kit.Select("", "zh-cn", strings.Contains(m.Option(ice.MSG_USERUA), "zh_CN")) }, func() string { return kit.Select("", kit.Split(m.R.Header.Get(html.AcceptLanguage), ",;"), 0) }, diff --git a/core/chat/oauth/client.go b/core/chat/oauth/client.go index bc85c20c..edd559c9 100644 --- a/core/chat/oauth/client.go +++ b/core/chat/oauth/client.go @@ -25,6 +25,7 @@ const ( USERS_URL = "users_url" USER_KEY = "user_key" NICK_KEY = "nick_key" + ICON_KEY = "icon_key" REDIRECT_URI = "redirect_uri" RESPONSE_TYPE = "response_type" @@ -42,15 +43,16 @@ const ( type Client struct { ice.Hash - short string `data:"domain,client_id"` - field string `data:"time,hash,domain,client_id,client_secret,oauth_url,grant_url,token_url,users_url,scope,user_key,nick_key,api_prefix,token_prefix"` - sso string `name:"sso name* icons*" help:"登录"` - auth string `name:"auth" help:"授权" icon:"bi bi-person-check"` - user string `name:"user" help:"用户" icon:"bi bi-person-vcard"` - orgs string `name:"orgs" help:"组织"` - repo string `name:"repo" help:"资源"` - list string `name:"list hash auto" help:"授权" icon:"oauth.png"` - login string `name:"login" role:"void"` + short string `data:"domain,client_id"` + field string `data:"time,hash,domain,client_id,client_secret,oauth_url,grant_url,token_url,users_url,scope,login,user_key,nick_key,icon_key,api_prefix,token_prefix"` + sso string `name:"sso name* help icons*" help:"登录"` + auth string `name:"auth" help:"授权" icon:"bi bi-person-check"` + user string `name:"user" help:"用户" icon:"bi bi-person-vcard"` + orgs string `name:"orgs" help:"组织"` + repo string `name:"repo" help:"资源"` + list string `name:"list hash auto" help:"授权" icon:"oauth.png"` + login string `name:"login" role:"void"` + login2 string `name:"login2" role:"void"` } var Inputs = map[string]map[string]string{} @@ -88,18 +90,24 @@ func (s Client) Inputs(m *ice.Message, arg ...string) { } } func (s Client) Sso(m *ice.Message, arg ...string) { - m.Cmd(web.CHAT_HEADER, mdb.CREATE, "oauth", m.Option(mdb.NAME), m.Option(mdb.ICONS), s.OAuthURL(m)) + m.Cmd(web.CHAT_HEADER, mdb.CREATE, "oauth", m.Option(mdb.NAME), m.Option(mdb.HELP), m.Option(mdb.ICONS), s.OAuthURL(m)) } func (s Client) Auth(m *ice.Message, arg ...string) { m.ProcessOpen(s.OAuthURL(m)) } +func (s Client) Link(m *ice.Message, arg ...string) { + m.Options(m.Cmd("", arg[0]).AppendSimple()) + m.Echo(s.OAuthURL(m)) +} func (s Client) User(m *ice.Message, arg ...string) { if res := s.Get(m, m.Option(mdb.HASH), m.Option(USERS_URL), arg...); res != nil { + m.Info("what %v", kit.Format(res)) m.Options(res).Cmd(aaa.USER, mdb.CREATE, aaa.USERROLE, kit.Select(aaa.VOID, aaa.TECH, m.Option("is_admin") == ice.TRUE), aaa.USERNAME, m.Option(aaa.USERNAME, m.Option(kit.Select(aaa.USERNAME, m.Option(USER_KEY)))), aaa.USERNICK, m.Option(kit.Select("full_name", m.Option(NICK_KEY))), - aaa.USERZONE, m.Option(web.DOMAIN), aaa.AVATAR, m.Option(aaa.AVATAR_URL), + aaa.USERZONE, m.Option(web.DOMAIN), + aaa.AVATAR, m.Option(kit.Select(aaa.AVATAR_URL, m.Option(ICON_KEY))), m.OptionSimple(aaa.LANGUAGE, aaa.EMAIL)) } } @@ -132,13 +140,16 @@ func (s Client) Login2(m *ice.Message, arg ...string) { if state, code := m.Option(STATE), m.Option(CODE); !m.WarnNotValid(state == "" || code == "") { s.Hash.List(m.Spawn(), m.Option(mdb.HASH, state)).Table(func(value ice.Maps) { m.Options(value) }) m.Options(GRANT_TYPE, AUTHORIZATION_CODE, REDIRECT_URI, s.RedirectURI(m)) - if res := s.Get(m, m.Option(mdb.HASH), m.Option(GRANT_URL), m.OptionSimple(GRANT_TYPE, CODE, CLIENT_ID, CLIENT_SECRET, REDIRECT_URI)...); !m.WarnNotValid(res == nil) { + if res := s.Get(m, m.Option(mdb.HASH), m.Option(GRANT_URL), kit.Simple(m.OptionSimple(GRANT_TYPE, CODE, CLIENT_ID), + "appid", m.Option(CLIENT_ID), "secret", m.Option(CLIENT_SECRET), + )...); !m.WarnNotValid(res == nil) { kit.Value(res, EXPIRES_IN, m.Time(kit.Format("%vs", kit.Int(kit.Value(res, EXPIRES_IN))))) + m.Info("what %v", kit.Format(res)) m.Options(res) - if s.User(m); !m.WarnNotValid(m.Option(aaa.USERNAME) == "") && m.R != nil { + if s.User(m, m.OptionSimple(ACCESS_TOKEN, "openid")...); !m.WarnNotValid(m.Option(aaa.USERNAME) == "") && m.R != nil { m.Cmd(aaa.USER, mdb.MODIFY, m.OptionSimple(aaa.USERNAME), kit.Simple(res)) web.RenderCookie(m.Message, aaa.SessCreate(m.Message, m.Option(aaa.USERNAME))) - m.ProcessHistory() + m.ProcessBack("-2") } else { m.ProcessClose() } @@ -149,7 +160,7 @@ func (s Client) OAuthURL(m *ice.Message) string { return kit.MergeURL2(m.Option(web.DOMAIN), m.Option(OAUTH_URL), RESPONSE_TYPE, CODE, m.OptionSimple(CLIENT_ID), REDIRECT_URI, s.RedirectURI(m), m.OptionSimple(SCOPE), STATE, m.Option(mdb.HASH)) } func (s Client) RedirectURI(m *ice.Message) string { - return strings.Split(m.MergeLink(web.ChatCmdPath(m.Message, m.ShortKey(), ctx.ACTION, aaa.LOGIN)), web.QS)[0] + return strings.Split(m.MergeLink(web.ChatCmdPath(m.Message, m.ShortKey(), ctx.ACTION, kit.Select(aaa.LOGIN, m.Option("login")))), web.QS)[0] } func (s Client) Get(m *ice.Message, hash, api string, arg ...string) ice.Any { diff --git a/misc/wx/access.go b/misc/wx/access.go index 9719314a..79c14f7f 100644 --- a/misc/wx/access.go +++ b/misc/wx/access.go @@ -86,6 +86,20 @@ func init() { AGENT: {Hand: func(m *ice.Message, arg ...string) { ctx.OptionFromConfig(m, ACCESS, APPID) }}, + "oauth": {Icon: "bi bi-shield-fill-check", Hand: func(m *ice.Message, arg ...string) { + oauth := m.Cmdx("web.chat.oauth.client", mdb.CREATE, + "domain", "https://api.weixin.qq.com", + "client_id", m.Option("appid"), "client_secret", m.Option("secret"), + "oauth_url", "https://open.weixin.qq.com/connect/oauth2/authorize?appid="+m.Option("appid"), + "grant_url", "/sns/oauth2/access_token", + "token_url", "/sns/oauth2/refresh_token", + "users_url", "/sns/userinfo", + "scope", "snsapi_userinfo", + "login", "login2", + "user_key", "openid", "nick_key", "nickname", "icon_key", "headimgurl", + ) + m.Cmd("agent", "oauth", m.Cmdx("web.chat.oauth.client", "link", oauth)) + }}, web.SSO: {Name: "sso name*=weixin help*=微信扫码 order=11 env=release,trial,develop wifi", Hand: func(m *ice.Message, arg ...string) { m.Cmd(web.CHAT_HEADER, mdb.CREATE, mdb.TYPE, mdb.PLUGIN, m.OptionSimple(mdb.NAME, mdb.HELP, mdb.ORDER), ctx.INDEX, m.PrefixKey(), ctx.ARGS, kit.Join(kit.Simple(aaa.LOGIN, m.Option(ACCESS), m.Option(ENV), m.Option(tcp.WIFI)))) @@ -113,7 +127,7 @@ func init() { }, gdb.EventsAction(web.SPACE_GRANT, web.SPACE_LOGIN_CLOSE), mdb.ExportHashAction( mdb.SHORT, ACCESS, mdb.FIELD, "time,type,access,icons,usernick,appid,secret,token", tcp.SERVER, CGI_BIN, )), Hand: func(m *ice.Message, arg ...string) { - mdb.HashSelect(m, arg...).PushAction(web.SSO, mdb.REMOVE).StatusTimeCount(mdb.ConfigSimple(m, ACCESS, APPID), web.SERVE, m.MergeLink("/chat/wx/login/")) + mdb.HashSelect(m, arg...).PushAction("oauth", web.SSO, mdb.REMOVE).StatusTimeCount(mdb.ConfigSimple(m, ACCESS, APPID), web.SERVE, m.MergeLink("/chat/wx/login/")) m.RewriteAppend(func(value, key string, index int) string { kit.If(key == cli.QRCODE, func() { value = ice.Render(m, ice.RENDER_QRCODE, value) }) return value diff --git a/misc/wx/agent.go b/misc/wx/agent.go index bc4cac5c..ec2b2ac5 100644 --- a/misc/wx/agent.go +++ b/misc/wx/agent.go @@ -42,9 +42,15 @@ func init() { }}, "getLocation": {Hand: func(m *ice.Message, arg ...string) { m.Cmdy(location.LOCATION, mdb.CREATE, arg) }}, "scanQRCode1": {Hand: func(m *ice.Message, arg ...string) { m.Cmdy(chat.FAVOR, mdb.CREATE, arg) }}, - }, gdb.EventsAction(chat.HEADER_AGENT), ctx.ConfAction(nfs.SCRIPT, "https://res.wx.qq.com/open/js/jweixin-1.6.0.js")), Hand: func(m *ice.Message, arg ...string) { + "oauth": {Hand: func(m *ice.Message, arg ...string) { + mdb.Config(m, "oauth", arg[0]) + }}, + }, gdb.EventsAction(chat.HEADER_AGENT), ctx.ConfAction( + "oauth", "", + nfs.SCRIPT, "https://res.wx.qq.com/open/js/jweixin-1.6.0.js", + )), Hand: func(m *ice.Message, arg ...string) { m.Cmdy(ACCESS, AGENT).Options(SIGNATURE, _wx_sign(m, m.Option(NONCESTR, ice.Info.Pathname), m.Option(TIMESTAMP, kit.Format(time.Now().Unix())))).Display("") - ctx.OptionFromConfig(m, nfs.SCRIPT) + ctx.OptionFromConfig(m, nfs.SCRIPT, "oauth") }}, }) } diff --git a/misc/wx/agent.js b/misc/wx/agent.js index 5f444b13..85b8ddc0 100644 --- a/misc/wx/agent.js +++ b/misc/wx/agent.js @@ -1,96 +1,103 @@ Volcanos(chat.ONIMPORT, { - _init: function(can, msg) { msg.Option(ice.MSG_ACTION, ""), can.require([msg.Option(nfs.SCRIPT)], function(can) { - var debug = msg.isDebug() && can.user.info.userrole == aaa.TECH; debug && can.onmotion.toggle(can, can._fields, true) - wx.config({debug: debug, signature: msg.Option("signature"), timestamp: msg.Option("timestamp"), nonceStr: msg.Option("noncestr"), appId: msg.Option("appid"), - jsApiList: can.core.Item({ - getLocation: function(can, cb) { wx.getLocation({type: "gcj02", success: function (res) { - can.base.isFunc(cb) && cb({type: "gcj02", name: "当前位置", text: "当前位置", latitude: parseInt(res.latitude*100000), longitude: parseInt(res.longitude*100000) }) - } }) }, - openLocation: function(can, msg) { wx.openLocation({ - name: msg.Option(mdb.NAME), address: msg.Option(mdb.TEXT), infoUrl: msg.Option(web.LINK), - longitude: parseFloat(msg.Option(aaa.LONGITUDE)), latitude: parseFloat(msg.Option(aaa.LATITUDE)), scale: msg.Option("scale")||14, - }) }, - scanQRCode: function(can, cb) { wx.scanQRCode({needResult: cb? 1: 0, scanType: ["qrCode", "barCode"], success: function (res) { - can.base.isFunc(cb) && cb(can.base.ParseJSON(res.resultStr)) - } }) }, - chooseImage: function(can, cb, count) { wx.chooseImage({count: count||9, sourceType: ["camera", "album"], sizeType: ["original", "compressed"], success: function (res) { - can.base.isFunc(cb) && cb(res.localIds) - } }) }, - }, function(key, value) { return can.user.agent[key] = value, key }).concat([ - // "updateAppMessageShareData", "updateTimelineShareData", - ]), + _init: function(can, msg) { + if (!can.user.info.username && can.user.info._cmd != "web.chat.oauth.client" && msg.Option("oauth")) { + debugger + can.user.jumps(msg.Option("oauth")) + return + } + msg.Option(ice.MSG_ACTION, ""), can.require([msg.Option(nfs.SCRIPT)], function(can) { + var debug = msg.isDebug() && can.user.info.userrole == aaa.TECH; debug && can.onmotion.toggle(can, can._fields, true) + wx.config({debug: debug, signature: msg.Option("signature"), timestamp: msg.Option("timestamp"), nonceStr: msg.Option("noncestr"), appId: msg.Option("appid"), + jsApiList: can.core.Item({ + getLocation: function(can, cb) { wx.getLocation({type: "gcj02", success: function (res) { + can.base.isFunc(cb) && cb({type: "gcj02", name: "当前位置", text: "当前位置", latitude: parseInt(res.latitude*100000), longitude: parseInt(res.longitude*100000) }) + } }) }, + openLocation: function(can, msg) { wx.openLocation({ + name: msg.Option(mdb.NAME), address: msg.Option(mdb.TEXT), infoUrl: msg.Option(web.LINK), + longitude: parseFloat(msg.Option(aaa.LONGITUDE)), latitude: parseFloat(msg.Option(aaa.LATITUDE)), scale: msg.Option("scale")||14, + }) }, + scanQRCode: function(can, cb) { wx.scanQRCode({needResult: cb? 1: 0, scanType: ["qrCode", "barCode"], success: function (res) { + can.base.isFunc(cb) && cb(can.base.ParseJSON(res.resultStr)) + } }) }, + chooseImage: function(can, cb, count) { wx.chooseImage({count: count||9, sourceType: ["camera", "album"], sizeType: ["original", "compressed"], success: function (res) { + can.base.isFunc(cb) && cb(res.localIds) + } }) }, + }, function(key, value) { return can.user.agent[key] = value, key }).concat([ + // "updateAppMessageShareData", "updateTimelineShareData", + ]), + }) }) - }) }, + }, }) Volcanos(chat.ONACTION, {list: [ "getLocation", "openLocation", "openAddress", "scanQRCode", "scanQRCode1", "uploadImage", "chooseImage", "previewImage", "updateAppMessageShareData", "updateTimelineShareData", ], - getLocation: function(event, can, button) { - wx.getLocation({type: "gcj02", success: function (res) { - can.run(event, [ctx.ACTION, button, mdb.NAME, "current", aaa.LONGITUDE, res.longitude.toFixed(6), aaa.LATITUDE, res.latitude.toFixed(6)], function() {}) - can._output.innerHTML = JSON.stringify(res) +getLocation: function(event, can, button) { + wx.getLocation({type: "gcj02", success: function (res) { + can.run(event, [ctx.ACTION, button, mdb.NAME, "current", aaa.LONGITUDE, res.longitude.toFixed(6), aaa.LATITUDE, res.latitude.toFixed(6)], function() {}) + can._output.innerHTML = JSON.stringify(res) + } }) +}, +openLocation: function(event, can, button) { + wx.getLocation({type: "gcj02", success: function (res) { wx.openLocation(res) }}) +}, +openAddress: function(event, can, button) { + wx.openAddress({success: function (res) { + can._output.innerHTML = JSON.stringify(res) + var userName = res.userName; // 收货人姓名 + var cityName = res.cityName; // 国标收货地址第二级地址(市) + var provinceName = res.provinceName; // 国标收货地址第一级地址(省) + var countryName = res.countryName; // 国标收货地址第三级地址(国家) + var detailInfo = res.detailInfo; // 详细收货地址信息 + var nationalCode = res.nationalCode; // 收货地址国家码 + var postalCode = res.postalCode; // 邮编 + var telNumber = res.telNumber; // 收货人手机号码 + }}) +}, +scanQRCode: function(event, can, button) { + wx.scanQRCode({needResult: 0, scanType: ["qrCode","barCode"]}) +}, +scanQRCode1: function(event, can, button) { + wx.scanQRCode({needResult: 1, scanType: ["qrCode","barCode"], success: function (res) { + can.run(event, [ctx.ACTION, button, mdb.TEXT, res.resultStr], function() {}) + can._output.innerHTML = res.resultStr + } }) +}, +uploadImage: function(event, can, button) { + wx.chooseImage({success: function (res) { can.core.List(res.localIds, function(item) { + wx.uploadImage({localId: item, isShowProgressTips: 1, success: function (res) { + var serverId = res.serverId; + can._output.innerHTML = serverId } }) - }, - openLocation: function(event, can, button) { - wx.getLocation({type: "gcj02", success: function (res) { wx.openLocation(res) }}) - }, - openAddress: function(event, can, button) { - wx.openAddress({success: function (res) { - can._output.innerHTML = JSON.stringify(res) - var userName = res.userName; // 收货人姓名 - var cityName = res.cityName; // 国标收货地址第二级地址(市) - var provinceName = res.provinceName; // 国标收货地址第一级地址(省) - var countryName = res.countryName; // 国标收货地址第三级地址(国家) - var detailInfo = res.detailInfo; // 详细收货地址信息 - var nationalCode = res.nationalCode; // 收货地址国家码 - var postalCode = res.postalCode; // 邮编 - var telNumber = res.telNumber; // 收货人手机号码 - }}) - }, - scanQRCode: function(event, can, button) { - wx.scanQRCode({needResult: 0, scanType: ["qrCode","barCode"]}) - }, - scanQRCode1: function(event, can, button) { - wx.scanQRCode({needResult: 1, scanType: ["qrCode","barCode"], success: function (res) { - can.run(event, [ctx.ACTION, button, mdb.TEXT, res.resultStr], function() {}) - can._output.innerHTML = res.resultStr - } }) - }, - uploadImage: function(event, can, button) { - wx.chooseImage({success: function (res) { can.core.List(res.localIds, function(item) { - wx.uploadImage({localId: item, isShowProgressTips: 1, success: function (res) { - var serverId = res.serverId; - can._output.innerHTML = serverId - } }) - }) }}) - }, - chooseImage: function(event, can, button) { - wx.chooseImage({count: 9, sourceType: ["camera", "album"], sizeType: ["original", "compressed"], success: function (res) { - can.page.Append(can, can._output, can.core.List(res.localIds, function(item) { - return {img: item, style: {"max-width": can.ConfWidth()}} - })) - } }) - }, - previewImage: function(event, can, button) { - wx.previewImage({urls: [ - "https://2021.shylinux.com/share/local/usr/icons/timg.png", - "https://2021.shylinux.com/share/local/usr/icons/mall.png", - ]}) - }, - updateAppMessageShareData: function(event, can, button) { - wx.updateAppMessageShareData({ - title: document.title, desc: "工具系统", link: location.href, - imgUrl: "https://2021.shylinux.com/share/local/usr/icons/timg.png", - success: function (res) { can._output.innerHTML = JSON.stringify(res) }, - }) - }, - updateTimelineShareData: function(event, can, button) { - wx.updateTimelineShareData({ - title: document.title, desc: "工具系统", link: location.href, - imgUrl: "https://2021.shylinux.com/share/local/usr/icons/timg.png", - success: function (res) { can._output.innerHTML = JSON.stringify(res) }, - }) - }, + }) }}) +}, +chooseImage: function(event, can, button) { + wx.chooseImage({count: 9, sourceType: ["camera", "album"], sizeType: ["original", "compressed"], success: function (res) { + can.page.Append(can, can._output, can.core.List(res.localIds, function(item) { + return {img: item, style: {"max-width": can.ConfWidth()}} + })) + } }) +}, +previewImage: function(event, can, button) { + wx.previewImage({urls: [ + "https://2021.shylinux.com/share/local/usr/icons/timg.png", + "https://2021.shylinux.com/share/local/usr/icons/mall.png", + ]}) +}, +updateAppMessageShareData: function(event, can, button) { + wx.updateAppMessageShareData({ + title: document.title, desc: "工具系统", link: location.href, + imgUrl: "https://2021.shylinux.com/share/local/usr/icons/timg.png", + success: function (res) { can._output.innerHTML = JSON.stringify(res) }, + }) +}, +updateTimelineShareData: function(event, can, button) { + wx.updateTimelineShareData({ + title: document.title, desc: "工具系统", link: location.href, + imgUrl: "https://2021.shylinux.com/share/local/usr/icons/timg.png", + success: function (res) { can._output.innerHTML = JSON.stringify(res) }, + }) +}, }) diff --git a/misc/wx/events.go b/misc/wx/events.go index 97ab4521..91f6d3c0 100644 --- a/misc/wx/events.go +++ b/misc/wx/events.go @@ -22,6 +22,9 @@ func init() { Index.MergeCommands(ice.Commands{ EVENTS: {Help: "事件", Actions: ice.Actions{ SUBSCRIBE: {Hand: func(m *ice.Message, arg ...string) { + m.Option(mdb.NAME, ice.Info.Titles) + m.Option(mdb.TEXT, "欢迎光临") + m.Option(mdb.ICONS, m.MergeLink(m.Resource(ice.Info.NodeIcon))) m.Cmdy(TEXT, web.LINK, m.MergeLink(nfs.PS)) }}, UNSUBSCRIBE: {Hand: func(m *ice.Message, arg ...string) { @@ -38,6 +41,13 @@ func init() { CLICK: {Hand: func(m *ice.Message, arg ...string) { msg := m.Cmd(MENU, m.Option(ACCESS), arg[0]) m.Options(mdb.ICONS, msg.Append(mdb.ICONS), mdb.NAME, msg.Append(mdb.NAME), mdb.TEXT, kit.Select(msg.Append(ctx.INDEX), msg.Append(mdb.TEXT))) + if m.Option(mdb.ICONS) == "" && msg.Append(ctx.INDEX) != "" { + m.Search(msg.Append(ctx.INDEX), func(key string, cmd *ice.Command) { + if cmd.Icon != "" { + m.Option(mdb.ICONS, m.MergeLink(m.Resource(cmd.Icon))) + } + }) + } if msg.Append(ctx.INDEX) == "" { m.Cmdy(TEXT, web.LINK, m.MergeLink(nfs.PS)) } else { diff --git a/misc/wx/menu.go b/misc/wx/menu.go index ef34b4d5..89091be5 100644 --- a/misc/wx/menu.go +++ b/misc/wx/menu.go @@ -2,6 +2,7 @@ package wx import ( ice "shylinux.com/x/icebergs" + "shylinux.com/x/icebergs/base/ctx" "shylinux.com/x/icebergs/base/mdb" "shylinux.com/x/icebergs/base/web" "shylinux.com/x/icebergs/base/web/html" @@ -29,7 +30,12 @@ func init() { if value[SCENE] == m.Option(SCENE) { key := kit.Keys("button", kit.Int(value[RIVER])-1) kit.If(value[STORM] != "1", func() { key = kit.Keys(key, "sub_button", kit.Int(value[STORM])-2) }) - kit.If(value[mdb.TYPE] == "view", func() { value[mdb.TEXT] = m.MergeLink(value[mdb.TEXT]) }) + kit.If(value[mdb.TYPE] == "view", func() { + if value[mdb.TEXT] == "" { + value[mdb.TEXT] = web.C(value[ctx.INDEX]) + } + value[mdb.TEXT] = m.MergeLink(value[mdb.TEXT]) + }) kit.Value(list, key, kit.Dict(mdb.TYPE, value[mdb.TYPE], mdb.NAME, value[mdb.NAME], mdb.KEY, value[mdb.HASH], web.URL, value[mdb.TEXT])) } }) diff --git a/option.go b/option.go index a987866a..2b5347d7 100644 --- a/option.go +++ b/option.go @@ -138,7 +138,7 @@ func (m *Message) ProcessField(arg ...Any) { m.Process(PROCESS_FIELD).Option(F func (m *Message) ProcessInner() *Message { return m.Process(PROCESS_INNER) } func (m *Message) ProcessAgain() { m.Process(PROCESS_AGAIN) } func (m *Message) ProcessHold(text ...Any) { m.Process(PROCESS_HOLD, text...) } -func (m *Message) ProcessBack() { m.Process(PROCESS_BACK) } +func (m *Message) ProcessBack(arg ...Any) { m.Process(PROCESS_BACK, arg...) } func (m *Message) ProcessRich(arg ...Any) { m.Process(PROCESS_RICH, arg...) } func (m *Message) ProcessGrow(arg ...Any) { m.Process(PROCESS_GROW, arg...) } func (m *Message) ProcessOpen(url string) { m.Process(PROCESS_OPEN, url) }