diff --git a/base/aaa/user.go b/base/aaa/user.go index da988113..f81e6f5e 100644 --- a/base/aaa/user.go +++ b/base/aaa/user.go @@ -12,7 +12,7 @@ import ( func _user_list(m *ice.Message) { 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) { diff --git a/base/cli/system.go b/base/cli/system.go index 3384950c..91f5cf7a 100644 --- a/base/cli/system.go +++ b/base/cli/system.go @@ -83,6 +83,20 @@ func init() { _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) } diff --git a/core/code/qrcode.go b/core/code/qrcode.go index 85682460..75a24209 100644 --- a/core/code/qrcode.go +++ b/core/code/qrcode.go @@ -2,47 +2,26 @@ package code import ( ice "github.com/shylinux/icebergs" + "github.com/shylinux/icebergs/base/mdb" kit "github.com/shylinux/toolkits" - - "os" - - qrs "github.com/skip2/go-qrcode" - "github.com/tuotoo/qrcode" ) func init() { - Index.Register(&ice.Context{Name: "qrc", Help: "二维码", + Index.Register(&ice.Context{Name: QRCODE, Help: "二维码", Configs: map[string]*ice.Config{ - QRCODE: {Name: "qrcode", Help: "二维码", Value: kit.Data( - "plug", `{"display": {"height": "400px"}}`, - )}, + QRCODE: {Name: "qrcode", Help: "二维码", Value: kit.Data()}, }, Commands: map[string]*ice.Command{ - "list": {Name: "list name", Help: "列表", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { - if f, e := os.Open(arg[0]); e == nil { - defer f.Close() - if q, e := qrcode.Decode(f); e == nil { - m.Echo(q.Content) - return - } - } - m.Echo("hello world") - }}, - "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(``, arg[0], m.Option(ice.MSG_USERPOD)) + QRCODE: {Name: "qrcode", Help: "二维码", Action: map[string]*ice.Action{ + mdb.INSERT: {Hand: func(m *ice.Message, 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.Push("", value, []string{kit.MDB_TIME, kit.MDB_TEXT}) + }) + }}, + }, 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.Push("", value, []string{kit.MDB_TIME, kit.MDB_TEXT}) + }) }}, }, }, nil) diff --git a/core/wiki/word.go b/core/wiki/word.go index ed7866f6..9ebfa8f4 100644 --- a/core/wiki/word.go +++ b/core/wiki/word.go @@ -358,7 +358,7 @@ func init() { } }}, }, 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) { if len(arg) == 1 { diff --git a/misc/mp/mp.go b/misc/mp/mp.go index c864e536..3963c27b 100644 --- a/misc/mp/mp.go +++ b/misc/mp/mp.go @@ -56,6 +56,7 @@ var Index = &ice.Context{Name: "mp", Help: "小程序", ), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { m.Echo(arg[0]) }}, + "/login/": {Name: "/login/", Help: "登录", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { switch arg[0] { case "code": @@ -67,17 +68,15 @@ var Index = &ice.Context{Name: "mp", Help: "小程序", case "info": // 用户信息 - m.Richs(aaa.SESS, nil, m.Option(ice.MSG_SESSID), func(key string, value map[string]interface{}) { - m.Richs(aaa.USER, nil, value["username"], func(key string, value map[string]interface{}) { - value["gender"] = m.Option("gender") - value["avatar"] = m.Option("avatarUrl") - value["nickname"] = m.Option("nickName") - value["language"] = m.Option("language") - value["province"] = m.Option("province") - value["country"] = m.Option("country") - value["city"] = m.Option("city") - }) - }) + m.Cmd(aaa.USER, mdb.MODIFY, m.Option(ice.MSG_USERNAME), + "gender", m.Option("gender"), + "avatar", m.Option("avatarUrl"), + "usernick", m.Option("nickName"), + "language", m.Option("language"), + "province", m.Option("province"), + "country", m.Option("country"), + "city", m.Option("city"), + ) case "scan": m.Cmd(web.FAVOR, "device", "scan", m.Option("name"), m.Option("text")) diff --git a/misc/mp/mp.shy b/misc/mp/mp.shy index 794ef9ab..d9785cae 100644 --- a/misc/mp/mp.shy +++ b/misc/mp/mp.shy @@ -6,8 +6,11 @@ refer "" ` 源码 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" 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 ]`