diff --git a/base/web/serve.go b/base/web/serve.go index 927a8522..dfde22e5 100644 --- a/base/web/serve.go +++ b/base/web/serve.go @@ -57,15 +57,9 @@ func _serve_main(m *ice.Message, w http.ResponseWriter, r *http.Request) bool { // 主页接口 if r.Method == "GET" && r.URL.Path == "/" { - msg, repos := m.Spawn(), ice.INTSHELL - if msg.W, msg.R = w, r; strings.Contains(r.Header.Get("User-Agent"), "curl") { - repos = ice.INTSHELL - } else { - repos = ice.VOLCANOS - if ice.DumpBinPack(w, r.URL.Path, func(name string) { RenderType(w, name, "") }) { - return false - } - } + msg := m.Spawn() + msg.W, msg.R = w, r + repos := kit.Select(ice.INTSHELL, ice.VOLCANOS, strings.Contains(r.Header.Get("User-Agent"), "Mozilla/5.0")) Render(msg, ice.RENDER_DOWNLOAD, path.Join(m.Conf(SERVE, kit.Keym(repos, kit.SSH_PATH)), m.Conf(SERVE, kit.Keym(repos, kit.SSH_INDEX)))) return false } diff --git a/base/web/space.go b/base/web/space.go index a97dd6d5..c0d24854 100644 --- a/base/web/space.go +++ b/base/web/space.go @@ -253,10 +253,16 @@ func init() { m.Event(SPACE_START, args...) defer m.Event(SPACE_STOP, args...) } + switch kind { - case "chrome": + case CHROME: + if m.Option(ice.MSG_USERNAME) != "" { + break + } link := kit.MergeURL(m.Conf(SHARE, kit.Keym(kit.MDB_DOMAIN)), "auth", name) - m.Cmd(SPACE, name, "pwd", name, link, m.Cmdx(cli.QRCODE, link)) + go func() { + m.Sleep("100ms").Cmd(SPACE, name, "pwd", name, link, m.Cmdx(cli.QRCODE, link)) + }() } frame := m.Target().Server().(*Frame) diff --git a/base/web/spide.go b/base/web/spide.go index a2950598..880ee78d 100644 --- a/base/web/spide.go +++ b/base/web/spide.go @@ -121,7 +121,7 @@ func init() { }}, }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { if len(arg) < 2 || arg[0] == "" || (len(arg) > 3 && arg[3] == "") { - m.Option(mdb.FIELDS, kit.Select("time,client.name,client.method,client.url", mdb.DETAIL, len(arg) > 0 && arg[0] != "")) + m.Fields(len(arg) == 0 || arg[0] == "", "time,client.name,client.url") m.Cmdy(mdb.SELECT, SPIDE, "", mdb.HASH, "client.name", arg) m.PushAction(mdb.REMOVE) return diff --git a/core/chat/header.go b/core/chat/header.go index a7989e5d..728fcc91 100644 --- a/core/chat/header.go +++ b/core/chat/header.go @@ -60,6 +60,7 @@ func init() { return } + m.Cmd(aaa.ROLE, kit.Select(aaa.TECH, aaa.VOID, m.Option(ice.MSG_USERROLE) == aaa.VOID), m.Option(ice.MSG_USERNAME)) m.Cmd(web.SPACE, m.Option(web.SPACE), ice.MSG_SESSID, aaa.SessCreate(m, m.Option(ice.MSG_USERNAME))) }}, web.SHARE: {Name: "share type", Help: "共享", Hand: func(m *ice.Message, arg ...string) { diff --git a/misc.go b/misc.go index b1e83664..1758f978 100644 --- a/misc.go +++ b/misc.go @@ -109,8 +109,12 @@ func (m *Message) PushSearchWeb(cmd string, name string) { }) } +func (m *Message) IsTermUA() bool { + return m.Option(MSG_USERUA) == "" || strings.Contains(m.Option(MSG_USERUA), "curl") +} + func Render(m *Message, cmd string, args ...interface{}) string { - if m.Option(MSG_USERUA) == "" || strings.Contains(m.Option(MSG_USERUA), "curl") { + if m.IsTermUA() { switch arg := kit.Simple(args...); cmd { case RENDER_QRCODE: // text [size] return m.Cmdx("cli.qrcode", arg[0]) @@ -181,9 +185,15 @@ func (m *Message) PushDownload(key string, arg ...interface{}) { // [name] file m.Push(key, Render(m, RENDER_DOWNLOAD, arg...)) } func (m *Message) PushAnchor(arg ...interface{}) { // [name] link + if m.IsTermUA() { + return + } m.Push(kit.MDB_LINK, Render(m, RENDER_ANCHOR, arg...)) } func (m *Message) PushButton(arg ...string) { + if m.IsTermUA() { + return + } m.Push(kit.MDB_ACTION, Render(m, RENDER_BUTTON, strings.Join(arg, ","))) } func (m *Message) PushScript(arg ...string) *Message { // [type] text...