mirror of
https://shylinux.com/x/icebergs
synced 2025-04-26 17:44:05 +08:00
opt some
This commit is contained in:
parent
5b41af897b
commit
de6f46f718
@ -12,7 +12,7 @@ import (
|
|||||||
|
|
||||||
func _user_list(m *ice.Message) {
|
func _user_list(m *ice.Message) {
|
||||||
m.Richs(USER, nil, kit.MDB_FOREACH, func(key string, value map[string]interface{}) {
|
m.Richs(USER, nil, kit.MDB_FOREACH, func(key string, value map[string]interface{}) {
|
||||||
m.Push(key, value, []string{kit.MDB_TIME, USERNAME, USERNICK})
|
m.Push(key, value, []string{kit.MDB_TIME, USERNICK, USERNAME})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
func _user_login(m *ice.Message, name, word string) (ok bool) {
|
func _user_login(m *ice.Message, name, word string) (ok bool) {
|
||||||
|
@ -83,6 +83,20 @@ func init() {
|
|||||||
_system_show(m, cmd)
|
_system_show(m, cmd)
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
|
"ssh_user": {Name: "ssh_user", Help: "ssh_user", Hand: func(m *ice.Message, c *ice.Context, key string, arg ...string) {
|
||||||
|
msg := m.Cmd(SYSTEM, "who")
|
||||||
|
msg.Split(msg.Result(), "name term begin", " \t", "\n")
|
||||||
|
msg.Table(func(index int, value map[string]string, head []string) {
|
||||||
|
m.Push("name", value["name"])
|
||||||
|
m.Push("term", value["term"])
|
||||||
|
ls := strings.Split(value["begin"], " (")
|
||||||
|
t, _ := time.Parse("Jan 2 15:04", ls[0])
|
||||||
|
m.Push("begin", t.Format("2006-01-02 15:04:05"))
|
||||||
|
|
||||||
|
m.Push("ip", value["ip"])
|
||||||
|
m.Push("duration", value["duration"])
|
||||||
|
})
|
||||||
|
}},
|
||||||
},
|
},
|
||||||
}, nil)
|
}, nil)
|
||||||
}
|
}
|
||||||
|
@ -2,47 +2,26 @@ package code
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
ice "github.com/shylinux/icebergs"
|
ice "github.com/shylinux/icebergs"
|
||||||
|
"github.com/shylinux/icebergs/base/mdb"
|
||||||
kit "github.com/shylinux/toolkits"
|
kit "github.com/shylinux/toolkits"
|
||||||
|
|
||||||
"os"
|
|
||||||
|
|
||||||
qrs "github.com/skip2/go-qrcode"
|
|
||||||
"github.com/tuotoo/qrcode"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Index.Register(&ice.Context{Name: "qrc", Help: "二维码",
|
Index.Register(&ice.Context{Name: QRCODE, Help: "二维码",
|
||||||
Configs: map[string]*ice.Config{
|
Configs: map[string]*ice.Config{
|
||||||
QRCODE: {Name: "qrcode", Help: "二维码", Value: kit.Data(
|
QRCODE: {Name: "qrcode", Help: "二维码", Value: kit.Data()},
|
||||||
"plug", `{"display": {"height": "400px"}}`,
|
|
||||||
)},
|
|
||||||
},
|
},
|
||||||
Commands: map[string]*ice.Command{
|
Commands: map[string]*ice.Command{
|
||||||
"list": {Name: "list name", Help: "列表", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
QRCODE: {Name: "qrcode", Help: "二维码", Action: map[string]*ice.Action{
|
||||||
if f, e := os.Open(arg[0]); e == nil {
|
mdb.INSERT: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
defer f.Close()
|
m.Grow(QRCODE, kit.Keys(m.Option(ice.MSG_RIVER), m.Option(ice.MSG_STORM)), func(index int, value map[string]interface{}) {
|
||||||
if q, e := qrcode.Decode(f); e == nil {
|
m.Push("", value, []string{kit.MDB_TIME, kit.MDB_TEXT})
|
||||||
m.Echo(q.Content)
|
})
|
||||||
return
|
}},
|
||||||
}
|
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
}
|
m.Grow(QRCODE, kit.Keys(m.Option(ice.MSG_RIVER), m.Option(ice.MSG_STORM)), func(index int, value map[string]interface{}) {
|
||||||
m.Echo("hello world")
|
m.Push("", value, []string{kit.MDB_TIME, kit.MDB_TEXT})
|
||||||
}},
|
})
|
||||||
"save": {Name: "save name text", Help: "保存", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
|
||||||
if qr, e := qrs.New(kit.Select(m.Option("content"), arg, 1), qrs.Medium); m.Assert(e) {
|
|
||||||
if f, e := os.Create(arg[0]); m.Assert(e) {
|
|
||||||
defer f.Close()
|
|
||||||
m.Debug(m.Option("content"))
|
|
||||||
m.Assert(qr.Write(kit.Int(kit.Select("256", arg, 2)), f))
|
|
||||||
m.Echo(arg[0])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}},
|
|
||||||
"plug": {Name: "plug name text", Help: "插件", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
|
||||||
m.Echo(m.Conf(QRCODE, "meta.plug"))
|
|
||||||
}},
|
|
||||||
"show": {Name: "show name", Help: "渲染", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
|
||||||
m.Echo(`<img src="/share/local/%s?pod=%s">`, arg[0], m.Option(ice.MSG_USERPOD))
|
|
||||||
}},
|
}},
|
||||||
},
|
},
|
||||||
}, nil)
|
}, nil)
|
||||||
|
@ -358,7 +358,7 @@ func init() {
|
|||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
_field_show(m, arg[0], arg[1], arg[2:]...)
|
_field_show(m, strings.ReplaceAll(arg[0], " ", "_"), arg[1], arg[2:]...)
|
||||||
}},
|
}},
|
||||||
SHELL: {Name: "shell [name] cmd", Help: "命令", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
SHELL: {Name: "shell [name] cmd", Help: "命令", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
if len(arg) == 1 {
|
if len(arg) == 1 {
|
||||||
|
@ -56,6 +56,7 @@ var Index = &ice.Context{Name: "mp", Help: "小程序",
|
|||||||
), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
m.Echo(arg[0])
|
m.Echo(arg[0])
|
||||||
}},
|
}},
|
||||||
|
|
||||||
"/login/": {Name: "/login/", Help: "登录", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
"/login/": {Name: "/login/", Help: "登录", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
switch arg[0] {
|
switch arg[0] {
|
||||||
case "code":
|
case "code":
|
||||||
@ -67,17 +68,15 @@ var Index = &ice.Context{Name: "mp", Help: "小程序",
|
|||||||
|
|
||||||
case "info":
|
case "info":
|
||||||
// 用户信息
|
// 用户信息
|
||||||
m.Richs(aaa.SESS, nil, m.Option(ice.MSG_SESSID), func(key string, value map[string]interface{}) {
|
m.Cmd(aaa.USER, mdb.MODIFY, m.Option(ice.MSG_USERNAME),
|
||||||
m.Richs(aaa.USER, nil, value["username"], func(key string, value map[string]interface{}) {
|
"gender", m.Option("gender"),
|
||||||
value["gender"] = m.Option("gender")
|
"avatar", m.Option("avatarUrl"),
|
||||||
value["avatar"] = m.Option("avatarUrl")
|
"usernick", m.Option("nickName"),
|
||||||
value["nickname"] = m.Option("nickName")
|
"language", m.Option("language"),
|
||||||
value["language"] = m.Option("language")
|
"province", m.Option("province"),
|
||||||
value["province"] = m.Option("province")
|
"country", m.Option("country"),
|
||||||
value["country"] = m.Option("country")
|
"city", m.Option("city"),
|
||||||
value["city"] = m.Option("city")
|
)
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
case "scan":
|
case "scan":
|
||||||
m.Cmd(web.FAVOR, "device", "scan", m.Option("name"), m.Option("text"))
|
m.Cmd(web.FAVOR, "device", "scan", m.Option("name"), m.Option("text"))
|
||||||
|
@ -6,8 +6,11 @@ refer "" `
|
|||||||
源码 https://github.com/shylinux/icebergs/blob/master/misc/mp/mp.go
|
源码 https://github.com/shylinux/icebergs/blob/master/misc/mp/mp.go
|
||||||
`
|
`
|
||||||
|
|
||||||
field "用户" user
|
chapter "应用"
|
||||||
|
section "二维码"
|
||||||
|
field "qrcode 源码" web.code.inner args `[ usr/icebergs core/code/qrcode.go 1 ]`
|
||||||
|
|
||||||
|
chapter "项目"
|
||||||
section "icebergs"
|
section "icebergs"
|
||||||
field "icebergs_统计" web.code.git.trend args `[ icebergs ]` action `{ height 200 speed 20 }`
|
field "icebergs_统计" web.code.git.trend args `[ icebergs ]` action `{ height 200 speed 20 }`
|
||||||
field "icebergs_源码" web.code.inner args `[ usr/icebergs misc/mp/mp.go 1 ]`
|
field "icebergs_源码" web.code.inner args `[ usr/icebergs misc/mp/mp.go 1 ]`
|
||||||
|
Loading…
x
Reference in New Issue
Block a user