diff --git a/base/aaa/role.go b/base/aaa/role.go index f36b5b0a..a80f7b74 100644 --- a/base/aaa/role.go +++ b/base/aaa/role.go @@ -27,15 +27,15 @@ func _role_chain(arg ...string) string { } func _role_black(m *ice.Message, userrole, chain string, status bool) { m.Richs(ROLE, nil, userrole, func(key string, value map[string]interface{}) { - m.Log_CREATE(ROLE, userrole, BLACK, chain) list := value[BLACK].(map[string]interface{}) + m.Log_CREATE(ROLE, userrole, BLACK, chain) list[chain] = status }) } func _role_white(m *ice.Message, userrole, chain string, status bool) { m.Richs(ROLE, nil, userrole, func(key string, value map[string]interface{}) { - m.Log_CREATE(ROLE, userrole, WHITE, chain) list := value[WHITE].(map[string]interface{}) + m.Log_CREATE(ROLE, userrole, WHITE, chain) list[chain] = status }) } diff --git a/base/aaa/sess.go b/base/aaa/sess.go index f2b1653c..23d18d3b 100644 --- a/base/aaa/sess.go +++ b/base/aaa/sess.go @@ -24,7 +24,7 @@ func _sess_create(m *ice.Message, username string) string { if username == "" { return "" } - if m.Richs(USER, nil, username, nil) == nil { + if !_user_exists(m, username) { _user_create(m, kit.Select(TECH, VOID, m.Option(ice.MSG_USERROLE) == VOID), username, kit.Hashs()) } diff --git a/base/aaa/user.go b/base/aaa/user.go index bb96b3f1..22c71db8 100644 --- a/base/aaa/user.go +++ b/base/aaa/user.go @@ -6,9 +6,12 @@ import ( kit "shylinux.com/x/toolkits" ) +func _user_exists(m *ice.Message, name string) bool { + return m.Richs(USER, nil, name, nil) != nil +} func _user_login(m *ice.Message, name, word string) (ok bool) { - if m.Richs(USER, nil, name, nil) == nil { - _user_create(m, "", name, word) + if !_user_exists(m, name) { + _user_create(m, VOID, name, word) } m.Richs(USER, nil, name, func(key string, value map[string]interface{}) { @@ -17,6 +20,9 @@ func _user_login(m *ice.Message, name, word string) (ok bool) { return ok } func _user_create(m *ice.Message, role, name, word string) { + if word == "" { + word = kit.Hashs() + } m.Rich(USER, nil, kit.Dict( USERROLE, role, USERNAME, name, PASSWORD, word, USERNICK, name, USERZONE, m.Option(ice.MSG_USERZONE), @@ -37,8 +43,8 @@ func UserRoot(m *ice.Message) { m.Option(ice.MSG_USERROLE, ROOT) m.Option(ice.MSG_USERNAME, ice.Info.UserName) - if m.Richs(USER, "", ice.Info.UserName, nil) == nil { - _user_create(m, ROOT, ice.Info.UserName, kit.Hashs()) + if !_user_exists(m, ice.Info.UserName) { + _user_create(m, ROOT, ice.Info.UserName, "") } } func UserRole(m *ice.Message, username interface{}) (role string) { @@ -84,8 +90,8 @@ const ( CITY = "city" COUNTRY = "country" - PROVINCE = "province" LANGUAGE = "language" + PROVINCE = "province" ) const ( USERROLE = "userrole" @@ -119,6 +125,9 @@ func init() { } }}, mdb.CREATE: {Name: "create userrole=void,tech username password", Help: "创建", Hand: func(m *ice.Message, arg ...string) { + if _user_exists(m, m.Option(USERNAME)) { + return + } _user_create(m, m.Option(USERROLE), m.Option(USERNAME), m.Option(PASSWORD)) }}, }, mdb.HashAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { diff --git a/base/cli/daemon.go b/base/cli/daemon.go index 88255d7b..ea864ea9 100644 --- a/base/cli/daemon.go +++ b/base/cli/daemon.go @@ -43,10 +43,10 @@ func _daemon_exec(m *ice.Message, cmd *exec.Cmd) { switch cb := m.Optionv(kit.Keycb(DAEMON)).(type) { case func(string): - m.Sleep("1s") + m.Sleep300ms() cb(m.Conf(DAEMON, kit.Keys(mdb.HASH, h, kit.Keym(STATUS)))) case func(): - m.Sleep("1s") + m.Sleep300ms() cb() } @@ -114,7 +114,7 @@ func init() { }}, RESTART: {Name: "restart", Help: "重启", Hand: func(m *ice.Message, arg ...string) { m.Cmd(DAEMON, STOP) - m.Sleep("3s") + m.Sleep3s() m.Cmdy(DAEMON, START) }}, STOP: {Name: "stop", Help: "停止", Hand: func(m *ice.Message, arg ...string) { diff --git a/base/cli/qrcode.go b/base/cli/qrcode.go index 80590445..e9f23640 100644 --- a/base/cli/qrcode.go +++ b/base/cli/qrcode.go @@ -130,12 +130,13 @@ func init() { Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ QRCODE: {Name: QRCODE, Help: "二维码", Value: kit.Data()}, }, Commands: map[string]*ice.Command{ - ice.CTX_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { - ice.AddRender(ice.RENDER_QRCODE, func(m *ice.Message, cmd string, args ...interface{}) string { - return m.Cmd(QRCODE, kit.Simple(args...)).Result() - }) - }}, - QRCODE: {Name: "qrcode text fg bg size auto", Help: "二维码", Action: map[string]*ice.Action{}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + QRCODE: {Name: "qrcode text fg bg size auto", Help: "二维码", Action: map[string]*ice.Action{ + ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { + ice.AddRender(ice.RENDER_QRCODE, func(m *ice.Message, cmd string, args ...interface{}) string { + return m.Cmd(QRCODE, kit.Simple(args...)).Result() + }) + }}, + }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { m.Option(SIZE, kit.Select("240", arg, 3)) m.Option(BG, kit.Select(WHITE, arg, 2)) m.Option(FG, kit.Select(BLUE, arg, 1)) diff --git a/base/cli/system.go b/base/cli/system.go index 369c09ad..50230d13 100644 --- a/base/cli/system.go +++ b/base/cli/system.go @@ -5,10 +5,8 @@ import ( "io" "os" "os/exec" - "strings" ice "shylinux.com/x/icebergs" - "shylinux.com/x/icebergs/base/ctx" "shylinux.com/x/icebergs/base/mdb" kit "shylinux.com/x/toolkits" ) @@ -80,21 +78,6 @@ func _system_exec(m *ice.Message, cmd *exec.Cmd) { func IsSuccess(m *ice.Message) bool { return m.Append(kit.MDB_CODE) == "0" || m.Append(kit.MDB_CODE) == "" } -func Inputs(m *ice.Message, field string) bool { - switch strings.TrimPrefix(field, "extra.") { - case ice.POD: - m.Cmdy("route") - case ice.CTX: - m.Cmdy(ctx.CONTEXT) - case ice.CMD: - m.Cmdy(ctx.CONTEXT, kit.Select(m.Option(ice.CTX), m.Option(kit.Keys(kit.MDB_EXTRA, ice.CTX))), ctx.COMMAND) - case ice.ARG: - - default: - return false - } - return true -} const ( CMD_DIR = "cmd_dir" diff --git a/base/ctx/command.go b/base/ctx/command.go index 205d5313..cfb2ab4f 100644 --- a/base/ctx/command.go +++ b/base/ctx/command.go @@ -42,7 +42,7 @@ func _command_search(m *ice.Message, kind, name, text string) { } m.PushSearch(ice.CTX, kit.PathName(1), ice.CMD, kit.FileName(1), - kit.MDB_TYPE, s.Cap(ice.CTX_FOLLOW), kit.MDB_NAME, cmd.Name, kit.MDB_TEXT, cmd.Help, + kit.SimpleKV("", s.Cap(ice.CTX_FOLLOW), cmd.Name, cmd.Help), CONTEXT, s.Cap(ice.CTX_FOLLOW), COMMAND, key, ) }) @@ -70,10 +70,10 @@ const COMMAND = "command" func init() { Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ - ice.CTX_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { - m.Cmd(mdb.SEARCH, mdb.CREATE, COMMAND, m.Prefix(COMMAND)) - }}, COMMAND: {Name: "command key auto", Help: "命令", Action: map[string]*ice.Action{ + ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { + m.Cmd(mdb.SEARCH, mdb.CREATE, COMMAND, m.PrefixKey()) + }}, mdb.SEARCH: {Name: "search type name text", Help: "搜索", Hand: func(m *ice.Message, arg ...string) { if arg[0] == COMMAND || arg[1] != "" { _command_search(m, arg[0], arg[1], arg[2]) @@ -81,7 +81,7 @@ func init() { }}, }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { if len(arg) == 0 { - _command_list(m, "") + arg = append(arg, "") } for _, key := range arg { _command_list(m, key) diff --git a/base/ctx/config.go b/base/ctx/config.go index bd281c38..14a88b30 100644 --- a/base/ctx/config.go +++ b/base/ctx/config.go @@ -7,6 +7,8 @@ import ( "strings" ice "shylinux.com/x/icebergs" + "shylinux.com/x/icebergs/base/mdb" + "shylinux.com/x/icebergs/base/nfs" kit "shylinux.com/x/toolkits" ) @@ -16,14 +18,14 @@ func _config_list(m *ice.Message) { continue // 内部配置 } - m.Push(kit.MDB_KEY, k) - m.Push(kit.MDB_NAME, v.Name) - m.Push(kit.MDB_VALUE, kit.Format(v.Value)) + m.Push(mdb.KEY, k) + m.Push(mdb.NAME, v.Name) + m.Push(mdb.VALUE, kit.Format(v.Value)) } - m.Sort(kit.MDB_KEY) + m.Sort(mdb.KEY) } func _config_save(m *ice.Message, name string, arg ...string) { - name = path.Join(m.Conf(CONFIG, kit.META_PATH), name) + name = path.Join(m.Config(nfs.PATH), name) if f, p, e := kit.Create(name); m.Assert(e) { defer f.Close() @@ -38,14 +40,14 @@ func _config_save(m *ice.Message, name string, arg ...string) { // 保存配置 if s, e := json.MarshalIndent(data, "", " "); m.Assert(e) { if n, e := f.Write(s); m.Assert(e) { - m.Log_EXPORT(CONFIG, name, kit.MDB_FILE, p, kit.MDB_SIZE, n) + m.Log_EXPORT(CONFIG, name, nfs.FILE, p, nfs.SIZE, n) } } m.Echo(p) } } func _config_load(m *ice.Message, name string, arg ...string) { - name = path.Join(m.Conf(CONFIG, kit.META_PATH), name) + name = path.Join(m.Config(nfs.PATH), name) if f, e := os.Open(name); e == nil { defer f.Close() @@ -56,7 +58,7 @@ func _config_load(m *ice.Message, name string, arg ...string) { // 加载配置 for k, v := range data { msg.Search(k, func(p *ice.Context, s *ice.Context, key string) { - m.Log_IMPORT(CONFIG, kit.Keys(s.Name, key), kit.MDB_FILE, name) + m.Log_IMPORT(CONFIG, kit.Keys(s.Name, key), nfs.FILE, name) s.Configs[key].Value = v }) } @@ -66,7 +68,7 @@ func _config_make(m *ice.Message, key string, arg ...string) { msg := m.Spawn(m.Source()) if len(arg) > 1 { if strings.HasPrefix(arg[1], "@") { - arg[1] = msg.Cmdx("nfs.cat", arg[1][1:]) + arg[1] = msg.Cmdx(nfs.CAT, arg[1][1:]) } // 修改配置 msg.Confv(key, arg[0], kit.Parse(nil, "", arg[1:]...)) @@ -95,7 +97,7 @@ const CONFIG = "config" func init() { Index.Merge(&ice.Context{Configs: map[string]*ice.Config{ - CONFIG: {Name: CONFIG, Help: "配置", Value: kit.Data(kit.MDB_PATH, ice.VAR_CONF)}, + CONFIG: {Name: CONFIG, Help: "配置", Value: kit.Data(nfs.PATH, ice.VAR_CONF)}, }, Commands: map[string]*ice.Command{ CONFIG: {Name: "config key auto", Help: "配置", Action: map[string]*ice.Action{ SAVE: {Name: "save", Help: "保存", Hand: func(m *ice.Message, arg ...string) { diff --git a/base/ctx/context.go b/base/ctx/context.go index 5bce8a39..4d5ac627 100644 --- a/base/ctx/context.go +++ b/base/ctx/context.go @@ -9,7 +9,7 @@ import ( func _context_list(m *ice.Message, sub *ice.Context, name string) { m.Travel(func(p *ice.Context, s *ice.Context) { - if name != "" && name != "ice" && !strings.HasPrefix(s.Cap(ice.CTX_FOLLOW), name+ice.PT) { + if name != "" && name != ice.ICE && !strings.HasPrefix(s.Cap(ice.CTX_FOLLOW), name+ice.PT) { return } m.Push(kit.MDB_NAME, s.Cap(ice.CTX_FOLLOW)) @@ -18,6 +18,21 @@ func _context_list(m *ice.Message, sub *ice.Context, name string) { m.Push(kit.MDB_HELP, s.Help) }) } +func Inputs(m *ice.Message, field string) bool { + switch strings.TrimPrefix(field, "extra.") { + case ice.POD: + m.Cmdy("route") + case ice.CTX: + m.Cmdy(CONTEXT) + case ice.CMD: + m.Cmdy(CONTEXT, kit.Select(m.Option(ice.CTX), m.Option(kit.Keys(kit.MDB_EXTRA, ice.CTX))), COMMAND) + case ice.ARG: + + default: + return false + } + return true +} const CONTEXT = "context" @@ -39,13 +54,16 @@ func init() { } }}, }, CmdAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { - m.Search(kit.Select(ice.ICE, arg, 0)+ice.PT, func(p *ice.Context, s *ice.Context, key string) { + if len(arg) == 0 { + arg = append(arg, m.Source().Cap(ice.CTX_FOLLOW)) + } + m.Search(arg[0]+ice.PT, func(p *ice.Context, s *ice.Context, key string) { msg := m.Spawn(s) defer m.Copy(msg) switch kit.Select(CONTEXT, arg, 1) { case CONTEXT: - _context_list(msg, s, kit.Select("", arg, 0)) + _context_list(msg, s, arg[0]) case COMMAND: msg.Cmdy(COMMAND, arg[2:]) case CONFIG: diff --git a/base/ctx/message.go b/base/ctx/message.go index 2a1fbff9..12973d3f 100644 --- a/base/ctx/message.go +++ b/base/ctx/message.go @@ -5,6 +5,7 @@ import ( "strings" ice "shylinux.com/x/icebergs" + "shylinux.com/x/icebergs/base/mdb" kit "shylinux.com/x/toolkits" ) @@ -17,8 +18,8 @@ func init() { for i := 0; i < t.NumMethod(); i++ { method := t.Method(i) p := kit.FileLine(method.Func.Interface(), 4) - m.Push(kit.MDB_NAME, method.Name) - m.Push(kit.MDB_TEXT, strings.Split(p, ice.ICEBERGS+"/")[1]) + m.Push(mdb.NAME, method.Name) + m.Push(mdb.TEXT, strings.Split(p, ice.ICEBERGS+"/")[1]) } }}, }}) diff --git a/base/mdb/mdb.go b/base/mdb/mdb.go index bd915bf1..02d550cf 100644 --- a/base/mdb/mdb.go +++ b/base/mdb/mdb.go @@ -32,6 +32,8 @@ const ( NAME = "name" TEXT = "text" + VALUE = "value" + LINK = "link" SCAN = "scan" diff --git a/base/web/render.go b/base/web/render.go index 65d9db8a..80e5ced2 100644 --- a/base/web/render.go +++ b/base/web/render.go @@ -4,11 +4,13 @@ import ( "fmt" "net/http" "path" + "strings" "time" ice "shylinux.com/x/icebergs" "shylinux.com/x/icebergs/base/aaa" "shylinux.com/x/icebergs/base/cli" + "shylinux.com/x/icebergs/base/tcp" kit "shylinux.com/x/toolkits" ) @@ -33,6 +35,10 @@ func Render(msg *ice.Message, cmd string, args ...interface{}) { http.Redirect(msg.W, msg.R, kit.MergeURL(arg[0], arg[1:]), 307) case ice.RENDER_DOWNLOAD: // file [type [name]] + if strings.HasPrefix(arg[0], "http") { + http.Redirect(msg.W, msg.R, arg[0], 307) + break + } msg.W.Header().Set("Content-Disposition", fmt.Sprintf("filename=%s", kit.Select(path.Base(kit.Select(arg[0], msg.Option("filename"))), arg, 2))) if RenderType(msg.W, arg[0], kit.Select("", arg, 1)); !ice.Dump(msg.W, arg[0], nil) { http.ServeFile(msg.W, msg.R, kit.Path(arg[0])) @@ -74,9 +80,13 @@ func RenderStatus(msg *ice.Message, code int, text string) { msg.W.WriteHeader(code) msg.W.Write([]byte(text)) } +func CookieName(url string) string { + return ice.MSG_SESSID + "_" + kit.ReplaceAll(kit.ParseURLMap(url)[tcp.HOST], ".", "_", ":", "_") +} func RenderCookie(msg *ice.Message, value string, arg ...string) { // name path expire expire := time.Now().Add(kit.Duration(kit.Select(msg.Conf(aaa.SESS, "meta.expire"), arg, 2))) - http.SetCookie(msg.W, &http.Cookie{Value: value, Name: kit.Select(ice.MSG_SESSID, arg, 0), Path: kit.Select("/", arg, 1), Expires: expire}) + http.SetCookie(msg.W, &http.Cookie{Value: value, + Name: kit.Select(ice.MSG_SESSID, arg, 0), Path: kit.Select("/", arg, 1), Expires: expire}) } func RenderMeta(msg *ice.Message, name, content string) { msg.W.Write([]byte(kit.Format(``, name, content))) diff --git a/base/web/serve.go b/base/web/serve.go index aeeffb04..862ab6c9 100644 --- a/base/web/serve.go +++ b/base/web/serve.go @@ -125,8 +125,7 @@ func _serve_handle(key string, cmd *ice.Command, msg *ice.Message, w http.Respon msg.Option(ice.MSG_USERADDR, msg.Option(ice.MSG_USERIP)) } - cookie := ice.MSG_SESSID + "_" + strings.ReplaceAll(strings.ReplaceAll(kit.ParseURLMap(msg.Option(ice.MSG_USERWEB))["host"], ".", "_"), ":", "_") - if sessid := msg.Option(cookie); sessid != "" { + if sessid := msg.Option(CookieName(msg.Option(ice.MSG_USERWEB))); sessid != "" { msg.Option(ice.MSG_SESSID, sessid) } @@ -177,6 +176,7 @@ func _serve_handle(key string, cmd *ice.Command, msg *ice.Message, w http.Respon } } + msg.Debug("what %v", msg.FormatMeta()) // 执行命令 if cmds, ok := _serve_login(msg, key, kit.Simple(msg.Optionv(ice.MSG_CMDS)), w, r); ok { msg.Option(ice.MSG_OPTS, msg.Optionv(ice.MSG_OPTION)) @@ -191,6 +191,7 @@ func _serve_login(msg *ice.Message, key string, cmds []string, w http.ResponseWr msg.Option(ice.MSG_USERROLE, aaa.VOID) msg.Option(ice.MSG_USERNAME, "") + msg.Debug("what %v", msg.FormatMeta()) if msg.Option(ice.MSG_SESSID) != "" { aaa.SessCheck(msg, msg.Option(ice.MSG_SESSID)) // 会话认证 diff --git a/core/chat/storm.go b/core/chat/storm.go index 1464232a..ce9aa12e 100644 --- a/core/chat/storm.go +++ b/core/chat/storm.go @@ -2,7 +2,6 @@ package chat import ( ice "shylinux.com/x/icebergs" - "shylinux.com/x/icebergs/base/cli" "shylinux.com/x/icebergs/base/ctx" "shylinux.com/x/icebergs/base/mdb" kit "shylinux.com/x/toolkits" @@ -18,7 +17,7 @@ func init() { Index.Merge(&ice.Context{Commands: map[string]*ice.Command{ STORM: {Name: "storm hash id auto insert create", Help: "工具", Action: map[string]*ice.Action{ mdb.INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) { - if cli.Inputs(m, arg[0]) { + if ctx.Inputs(m, arg[0]) { return } switch arg[0] { diff --git a/misc/lark/sso.go b/misc/lark/sso.go index 1b84badb..c164f695 100644 --- a/misc/lark/sso.go +++ b/misc/lark/sso.go @@ -18,23 +18,26 @@ func init() { return } + appid := m.Cmd(APP).Append(APPID) home := m.MergeURL2("/chat/lark/sso") if m.Option(kit.MDB_CODE) != "" { // 登录成功 msg := m.Cmd(web.SPIDE, LARK, "/open-apis/authen/v1/access_token", "grant_type", "authorization_code", - kit.MDB_CODE, m.Option(kit.MDB_CODE), "app_access_token", m.Cmdx(APP, TOKEN, m.Cmd(APP).Append(APPID))) - - // 创建会话 - m.Option(aaa.USERNAME, msg.Append("data.open_id")) - web.RenderCookie(m, aaa.SessCreate(m, m.Option(aaa.USERNAME))) - m.RenderRedirect(kit.Select(home, m.Option(kit.MDB_BACK))) + kit.MDB_CODE, m.Option(kit.MDB_CODE), "app_access_token", m.Cmdx(APP, TOKEN, appid)) // 更新用户 - msg = m.Cmd(EMPLOYEE, m.Option(aaa.USERNAME)) - m.Cmd(aaa.USER, mdb.MODIFY, aaa.USERZONE, LARK, aaa.USERNICK, msg.Append(kit.MDB_NAME), + m.Option(aaa.USERNAME, msg.Append("data.open_id")) + msg = m.Cmd(EMPLOYEE, appid, m.Option(aaa.USERNAME)) + userrole := kit.Select(aaa.VOID, aaa.TECH, msg.Append("is_tenant_manager") == ice.TRUE) + m.Cmd(aaa.USER, mdb.CREATE, userrole, m.Option(aaa.USERNAME)) + m.Cmd(aaa.USER, mdb.MODIFY, aaa.USERROLE, userrole, + aaa.USERNICK, msg.Append(kit.MDB_NAME), aaa.USERZONE, LARK, aaa.AVATAR, msg.Append("avatar_url"), aaa.GENDER, kit.Select("女", "男", msg.Append(aaa.GENDER) == "1"), - aaa.COUNTRY, msg.Append(aaa.COUNTRY), aaa.CITY, msg.Append(aaa.CITY), - aaa.MOBILE, msg.Append(aaa.MOBILE), + msg.AppendSimple(aaa.MOBILE, aaa.EMAIL, aaa.CITY, aaa.COUNTRY), ) + + // 创建会话 + web.RenderCookie(m, aaa.SessCreate(m, m.Option(aaa.USERNAME)), web.CookieName(m.Option(kit.MDB_BACK))) + m.RenderRedirect(kit.Select(home, m.Option(kit.MDB_BACK))) return } diff --git a/misc/mp/login.go b/misc/mp/login.go index a2ccc0be..1756fc96 100644 --- a/misc/mp/login.go +++ b/misc/mp/login.go @@ -48,10 +48,11 @@ func init() { }}, aaa.USER: {Name: "user", Help: "用户", Hand: func(m *ice.Message, arg ...string) { m.Option(aaa.USERNAME, m.Option(ice.MSG_USERNAME)) - m.Cmd(aaa.USER, mdb.MODIFY, aaa.USERZONE, MP, aaa.USERNICK, m.Option("nickName"), + m.Debug("what %v", m.FormatMeta()) + m.Cmd(aaa.USER, mdb.MODIFY, + aaa.USERNICK, m.Option("nickName"), aaa.USERZONE, MP, aaa.AVATAR, m.Option("avatarUrl"), aaa.GENDER, kit.Select("女", "男", m.Option(aaa.GENDER) == "1"), - aaa.COUNTRY, m.Option(aaa.COUNTRY), aaa.LANGUAGE, m.Option(aaa.LANGUAGE), - aaa.CITY, m.Option(aaa.CITY), aaa.PROVINCE, m.Option(aaa.PROVINCE), + m.OptionSimple(aaa.CITY, aaa.COUNTRY, aaa.LANGUAGE, aaa.PROVINCE), ) }}, chat.SCAN: {Name: "scan", Help: "扫码", Hand: func(m *ice.Message, arg ...string) { diff --git a/misc/wx/login.go b/misc/wx/login.go index e28d8e62..4651ae1b 100644 --- a/misc/wx/login.go +++ b/misc/wx/login.go @@ -99,5 +99,13 @@ func init() { m.Cmdy(MENU, "home") } }}, + LOGIN: {Name: "login", Help: "登录", Action: map[string]*ice.Action{ + mdb.CREATE: {Name: "create appid appmm token", Help: "创建", Hand: func(m *ice.Message, arg ...string) { + m.Conf(ACCESS, kit.Keym(APPID), m.Option(APPID)) + m.Conf(ACCESS, kit.Keym(APPMM), m.Option(APPMM)) + m.Conf(ACCESS, kit.Keym(TOKEN), m.Option(TOKEN)) + }}, + }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }}, }}) }