forked from x/icebergs
add some
This commit is contained in:
parent
a77ddbe902
commit
c5190266c9
@ -50,10 +50,6 @@ func SessCheck(m *ice.Message, sessid string) bool {
|
||||
return sessid != "" && m.Cmdy(SESS, CHECK, sessid, logs.FileLineMeta(-1)).Option(ice.MSG_USERNAME) != ""
|
||||
}
|
||||
func SessAuth(m *ice.Message, value ice.Any, arg ...string) *ice.Message {
|
||||
switch val := value.(type) {
|
||||
case []string:
|
||||
value = kit.Dict(USERNICK, kit.Select("", val, 0), USERNAME, kit.Select("", val, 1), USERROLE, kit.Select("", val, 2))
|
||||
}
|
||||
return m.Auth(
|
||||
USERNICK, m.Option(ice.MSG_USERNICK, kit.Format(kit.Value(value, USERNICK))),
|
||||
USERNAME, m.Option(ice.MSG_USERNAME, kit.Format(kit.Value(value, USERNAME))),
|
||||
|
@ -102,6 +102,7 @@ func _serve_handle(key string, cmd *ice.Command, m *ice.Message, w http.Response
|
||||
}
|
||||
return m
|
||||
}
|
||||
_log("page", Referer, r.Header.Get(Referer))
|
||||
if u, e := url.Parse(r.Header.Get(Referer)); e == nil {
|
||||
add := func(k, v string) { _log(nfs.PATH, k, m.Option(k, v)) }
|
||||
switch arg := strings.Split(strings.TrimPrefix(u.Path, nfs.PS), nfs.PS); arg[0] {
|
||||
|
@ -25,7 +25,7 @@ func _share_link(m *ice.Message, p string, arg ...ice.Any) string {
|
||||
func _share_cache(m *ice.Message, arg ...string) {
|
||||
if m.Cmdy(CACHE, arg[0]); m.Length() == 0 {
|
||||
if pod := m.Option(ice.POD); pod != "" {
|
||||
msg := m.Options(ice.POD, "").Cmd(SPACE, pod, CACHE, arg[0])
|
||||
msg := m.Options(ice.POD, "", ice.MSG_USERROLE, aaa.TECH).Cmd(SPACE, pod, CACHE, arg[0])
|
||||
kit.If(kit.Format(msg.Append(nfs.FILE)), func() {
|
||||
m.RenderDownload(path.Join(ice.USR_LOCAL_WORK, pod, msg.Append(nfs.FILE)))
|
||||
}, func() {
|
||||
@ -87,9 +87,7 @@ func init() {
|
||||
}},
|
||||
ctx.RUN: {Hand: func(m *ice.Message, arg ...string) {
|
||||
if msg := mdb.HashSelect(m.Spawn(), m.Option(SHARE)); !IsNotValidFieldShare(m, msg) {
|
||||
m.Option(ice.MSG_USERNICK, msg.Append(aaa.USERNICK))
|
||||
m.Option(ice.MSG_USERNAME, msg.Append(aaa.USERNAME))
|
||||
m.Option(ice.MSG_USERROLE, msg.Append(aaa.USERROLE))
|
||||
aaa.SessAuth(m, kit.Dict(msg.AppendSimple(aaa.USERNICK, aaa.USERNAME, aaa.USERROLE)))
|
||||
m.Cmdy(Space(m, msg.Append(SPACE)), msg.Append(mdb.NAME), arg[1:])
|
||||
}
|
||||
}},
|
||||
|
@ -61,7 +61,8 @@ func _space_fork(m *ice.Message) {
|
||||
text = p
|
||||
}
|
||||
}
|
||||
args := kit.Simple(mdb.TYPE, kit.Select(WORKER, m.Option(mdb.TYPE)), mdb.NAME, name, mdb.TEXT, text, m.OptionSimple(nfs.MODULE, nfs.VERSION, cli.DAEMON, ice.MSG_USERUA))
|
||||
args := kit.Simple(mdb.TYPE, kit.Select(WORKER, m.Option(mdb.TYPE)), mdb.NAME, name, mdb.TEXT, text, m.OptionSimple(nfs.MODULE, nfs.VERSION, cli.DAEMON))
|
||||
args = append(args, aaa.UA, m.Option(ice.MSG_USERUA), aaa.IP, m.Option(ice.MSG_USERIP))
|
||||
if c, e := websocket.Upgrade(m.W, m.R); !m.Warn(e) {
|
||||
gdb.Go(m, func() {
|
||||
defer mdb.HashCreateDeferRemove(m, args, kit.Dict(mdb.TARGET, c))()
|
||||
@ -268,9 +269,12 @@ func init() {
|
||||
if len(arg) < 2 {
|
||||
defer m.StatusTimeCount(kit.Dict(ice.MAIN, mdb.Config(m, ice.MAIN)))
|
||||
m.Option(ice.MSG_USERWEB, tcp.PublishLocalhost(m, m.Option(ice.MSG_USERWEB)))
|
||||
mdb.HashSelect(m.Spawn(), arg...).Sort("").Table(func(index int, value ice.Maps, field []string) {
|
||||
kit.If(len(arg) > 0 && arg[0] != "", func() { m.OptionFields(ice.MSG_DETAIL) })
|
||||
mdb.HashSelect(m.Spawn(), arg...).Table(func(index int, value ice.Maps, field []string) {
|
||||
if m.Push("", value, kit.Split(mdb.Config(m, mdb.FIELD))); len(arg) > 0 && arg[0] != "" {
|
||||
m.Push(mdb.STATUS, value[mdb.STATUS])
|
||||
m.Push(aaa.UA, value[aaa.UA])
|
||||
m.Push(aaa.IP, value[aaa.IP])
|
||||
}
|
||||
if kit.IsIn(value[mdb.TYPE], WORKER, SERVER) {
|
||||
m.Push(mdb.LINK, m.MergePod(value[mdb.NAME]))
|
||||
@ -281,7 +285,7 @@ func init() {
|
||||
}
|
||||
m.PushButton(kit.Select(OPEN, LOGIN, value[mdb.TYPE] == LOGIN), mdb.REMOVE)
|
||||
})
|
||||
kit.If(len(arg) == 1, func() { m.EchoIFrame(m.MergePod(arg[0])) }, func() { m.Action(ice.MAIN) })
|
||||
// kit.If(len(arg) == 1, func() { m.EchoIFrame(m.MergePod(arg[0])) }, func() { m.Action(ice.MAIN) })
|
||||
} else {
|
||||
_space_send(m, arg[0], kit.Simple(kit.Split(arg[1]), arg[2:])...)
|
||||
}
|
||||
|
@ -7,10 +7,11 @@ import (
|
||||
"shylinux.com/x/icebergs/base/aaa"
|
||||
"shylinux.com/x/icebergs/base/cli"
|
||||
"shylinux.com/x/icebergs/base/gdb"
|
||||
"shylinux.com/x/icebergs/base/lex"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/nfs"
|
||||
"shylinux.com/x/icebergs/base/tcp"
|
||||
"shylinux.com/x/icebergs/base/web"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
)
|
||||
|
||||
const GRANT = "grant"
|
||||
@ -24,6 +25,9 @@ func init() {
|
||||
m.Sleep30ms(web.SPACE, m.Option(mdb.NAME), cli.PWD, m.Option(mdb.NAME), link, m.Cmdx(cli.QRCODE, link))
|
||||
})
|
||||
}},
|
||||
"home": {Help: "首页", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.ProcessOpen(web.MergeLink(m, "/chat/portal/"))
|
||||
}},
|
||||
aaa.CONFIRM: {Help: "授权", Hand: func(m *ice.Message, arg ...string) {
|
||||
if m.Warn(m.R.Method == http.MethodGet, ice.ErrNotAllow) {
|
||||
return
|
||||
@ -32,13 +36,21 @@ func init() {
|
||||
} else if msg := m.Cmd(web.SPACE, m.Option(web.SPACE)); m.Warn(msg.Append(mdb.TYPE) != aaa.LOGIN, ice.ErrNotFound, m.Option(web.SPACE)) {
|
||||
return
|
||||
} else {
|
||||
kit.If(m.Option(ice.MSG_SESSID) == "", func() { web.RenderCookie(m, aaa.SessCreate(m, m.Option(ice.MSG_USERNAME))) })
|
||||
m.Option(ice.MSG_USERUA, msg.Append(ice.MSG_USERUA))
|
||||
m.Cmd(web.SPACE, m.Option(web.SPACE), ice.MSG_SESSID, aaa.SessCreate(m, m.Option(ice.MSG_USERNAME)))
|
||||
m.ProcessLocation(web.MergeURL2(m, msg.Append(mdb.TEXT)))
|
||||
}
|
||||
}},
|
||||
}, aaa.RoleAction(aaa.CONFIRM), gdb.EventsAction(web.SPACE_LOGIN)), Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Echo("请授权: %s 访问设备: %s", arg[0], ice.Info.Hostname).Echo(lex.NL).EchoButton(aaa.CONFIRM)
|
||||
msg := m.Cmd(web.SPACE, m.Option(web.SPACE, arg[0]))
|
||||
m.Option(tcp.HOSTNAME, ice.Info.Hostname)
|
||||
m.Option(nfs.PATH, msg.Append(mdb.TEXT))
|
||||
m.Option(aaa.UA, msg.Append(aaa.UA))
|
||||
m.Option(aaa.IP, msg.Append(aaa.IP))
|
||||
if !m.Warn(m.Option(nfs.PATH) == "", ice.ErrNotFound, arg[0]) {
|
||||
m.Echo(nfs.Template(m, "auth.html"))
|
||||
}
|
||||
}},
|
||||
})
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
package chat
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/aaa"
|
||||
"shylinux.com/x/icebergs/base/cli"
|
||||
@ -69,6 +71,7 @@ func init() {
|
||||
aaa.White(m, HEADER)
|
||||
aaa.Black(m, kit.Keys(HEADER, ctx.ACTION, mdb.CREATE))
|
||||
aaa.Black(m, kit.Keys(HEADER, ctx.ACTION, mdb.REMOVE))
|
||||
aaa.Black(m, kit.Keys(HEADER, ctx.ACTION, mdb.MODIFY))
|
||||
}},
|
||||
web.SHARE: {Hand: _header_share},
|
||||
aaa.LOGIN: {Hand: func(m *ice.Message, arg ...string) {}},
|
||||
@ -93,8 +96,9 @@ func init() {
|
||||
m.Options(ice.MSG_USERWEB, kit.MergeURL(m.Option(ice.MSG_USERWEB), web.SHARE, m.Cmdx(web.SHARE, mdb.CREATE, mdb.TYPE, web.LOGIN)))
|
||||
m.Cmdy(aaa.EMAIL, aaa.SEND, arg, aaa.CONTENT, nfs.Template(m, "email.html"))
|
||||
}},
|
||||
mdb.CREATE: {Name: "create type*=oauth,plugin name* icons link order space index args", Hand: func(m *ice.Message, arg ...string) { mdb.HashCreate(m, m.OptionSimple()) }},
|
||||
mdb.CREATE: {Name: "create type*=oauth,plugin,qrcode name* icons link order space index args", Hand: func(m *ice.Message, arg ...string) { mdb.HashCreate(m, m.OptionSimple()) }},
|
||||
mdb.REMOVE: {Hand: func(m *ice.Message, arg ...string) { mdb.HashRemove(m, m.OptionSimple(mdb.NAME)) }},
|
||||
mdb.MODIFY: {Hand: func(m *ice.Message, arg ...string) { mdb.HashModify(m, m.OptionSimple(mdb.NAME), arg) }},
|
||||
}, web.ApiAction(), ctx.ConfAction(mdb.SHORT, mdb.NAME, mdb.FIELD, "time,name,icons,type,link,order,space,index,args")), Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Option("language.list", m.Cmd(nfs.DIR, nfs.TemplatePath(m, aaa.LANGUAGE)+nfs.PS, nfs.FILE).Appendv(nfs.FILE))
|
||||
m.Option("theme.list", m.Cmd(nfs.DIR, nfs.TemplatePath(m, aaa.THEME)+nfs.PS, nfs.FILE).Appendv(nfs.FILE))
|
||||
@ -102,11 +106,10 @@ func init() {
|
||||
m.Option("icon.lib", mdb.Conf(m, ICON, kit.Keym(nfs.PATH)))
|
||||
m.Option(MENUS, mdb.Config(m, MENUS))
|
||||
m.Echo(mdb.Config(m, TITLE))
|
||||
if mdb.HashSelect(m, arg...); m.Length() == 0 {
|
||||
if mdb.HashSelect(m, arg...).Sort("order", "int"); m.Length() < 2 {
|
||||
kit.If(GetSSO(m), func(p string) {
|
||||
m.Push(mdb.TIME, m.Time()).Push(mdb.NAME, web.SERVE).Push(mdb.ICONS, nfs.USR_ICONS_ICEBERGS).Push(mdb.TYPE, "oauth").Push(web.LINK, p)
|
||||
})
|
||||
m.Sort("order", "int")
|
||||
}
|
||||
if gdb.Event(m, HEADER_AGENT); !_header_check(m, arg...) {
|
||||
return
|
||||
@ -114,7 +117,10 @@ func init() {
|
||||
msg := m.Cmd(aaa.USER, m.Option(ice.MSG_USERNAME))
|
||||
kit.For([]string{aaa.USERNICK, aaa.LANGUAGE, aaa.EMAIL}, func(k string) { m.Option(k, msg.Append(k)) })
|
||||
kit.For([]string{aaa.AVATAR, aaa.BACKGROUND}, func(k string) { m.Option(k, web.RequireFile(m, msg.Append(k))) })
|
||||
kit.If(m.Option(aaa.LANGUAGE) == "", func() { m.Option(aaa.LANGUAGE, kit.Split(m.R.Header.Get(web.AcceptLanguage), ",;")[0]) })
|
||||
kit.If(m.Option(aaa.LANGUAGE) == "", func() {
|
||||
m.Option(aaa.LANGUAGE, kit.Select("", "zh-cn", strings.Contains(m.Option(ice.MSG_USERUA), "zh_CN")))
|
||||
kit.If(m.Option(aaa.LANGUAGE) == "", func() { m.Option(aaa.LANGUAGE, kit.Select("", kit.Split(m.R.Header.Get(web.AcceptLanguage), ",;"), 0)) })
|
||||
})
|
||||
}},
|
||||
})
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ func init() {
|
||||
m.Options(mdb.HASH, m.Cmdx(ORDER, mdb.CREATE, aaa.USERNAME, m.Option(ice.MSG_USERNAME), mdb.STATUS, ORDER_CONFIRM, AMOUNT, amount))
|
||||
msg.Table(func(value ice.Maps) { m.Cmd(ORDER, mdb.INSERT, kit.Simple(value)) })
|
||||
}},
|
||||
}, mdb.ExportHashAction(mdb.SHORT, aaa.USERNAME, mdb.FIELD, "time,username", mdb.FIELDS, "time,goods,count")), Hand: func(m *ice.Message, arg ...string) {
|
||||
}, aaa.RoleAction(), mdb.ExportHashAction(mdb.SHORT, aaa.USERNAME, mdb.FIELD, "time,username", mdb.FIELDS, "time,goods,count")), Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Options(mdb.SUBKEY, kit.KeyHash(m.Option(ice.MSG_USERNAME))).OptionFields(mdb.Config(m, mdb.FIELDS))
|
||||
mdb.HashSelect(m, arg...).Options(mdb.SUBKEY, "").Table(func(value ice.Maps) {
|
||||
m.Cmd(GOODS, value[GOODS], func(value ice.Maps) {
|
||||
|
@ -2,6 +2,7 @@ package mall
|
||||
|
||||
import (
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/aaa"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
)
|
||||
@ -37,7 +38,7 @@ func init() {
|
||||
RECEIVE: {Help: "收货", Hand: func(m *ice.Message, arg ...string) { mdb.HashModify(m, mdb.STATUS, ORDER_RECEIVED) }},
|
||||
RETURN: {Help: "退货", Hand: func(m *ice.Message, arg ...string) { mdb.HashModify(m, mdb.STATUS, ORDER_RETURNED) }},
|
||||
REFUND: {Help: "退钱", Hand: func(m *ice.Message, arg ...string) { mdb.HashModify(m, mdb.STATUS, ORDER_REFUNDED) }},
|
||||
}, mdb.ExportHashAction(mdb.FIELD, "time,hash,username,status,amount", mdb.FIELDS, "time,goods,price,count,units,name,text,image")), Hand: func(m *ice.Message, arg ...string) {
|
||||
}, aaa.RoleAction(), mdb.ExportHashAction(mdb.FIELD, "time,hash,username,status,amount", mdb.FIELDS, "time,goods,price,count,units,name,text,image")), Hand: func(m *ice.Message, arg ...string) {
|
||||
if len(arg) == 0 {
|
||||
stats := map[string]int{}
|
||||
mdb.HashSelect(m, arg...).Table(func(value ice.Maps) {
|
||||
|
@ -82,7 +82,7 @@ func init() {
|
||||
}
|
||||
m.Echo(msg.Append(TICKET)).Status(msg.AppendSimple(EXPIRE))
|
||||
}},
|
||||
web.SSO: {Name: "sso name*=微信授权", Help: "登录", Hand: func(m *ice.Message, arg ...string) {
|
||||
web.SSO: {Name: "sso name*=微信扫码", Help: "登录", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmd(web.CHAT_HEADER, mdb.CREATE, mdb.TYPE, mdb.PLUGIN, m.OptionSimple(mdb.NAME),
|
||||
ctx.INDEX, m.PrefixKey(), ctx.ARGS, kit.Join(kit.Simple(aaa.LOGIN, m.Option(ACCESS))))
|
||||
}},
|
||||
|
@ -6,6 +6,7 @@ import (
|
||||
"time"
|
||||
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/aaa"
|
||||
"shylinux.com/x/icebergs/base/ctx"
|
||||
"shylinux.com/x/icebergs/base/gdb"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
@ -41,7 +42,7 @@ 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) {
|
||||
}, aaa.RoleAction(), 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) {
|
||||
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)
|
||||
}},
|
||||
|
@ -1,6 +1,7 @@
|
||||
Volcanos(chat.ONIMPORT, {
|
||||
_init: function(can, msg) { msg.Option(ice.MSG_ACTION, ""), can.require([msg.Option(nfs.SCRIPT)], function(can) {
|
||||
wx.config({debug: msg.Option(log.DEBUG) == ice.TRUE, signature: msg.Option("signature"), timestamp: msg.Option("timestamp"), nonceStr: msg.Option("noncestr"), appId: msg.Option("appid"),
|
||||
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) })
|
||||
|
Loading…
x
Reference in New Issue
Block a user