From 8fe47b6ca7b5929ad6b352f0a57423d7fd83bfae Mon Sep 17 00:00:00 2001 From: shy Date: Thu, 22 Feb 2024 13:27:49 +0800 Subject: [PATCH] add some --- base/web/dream.go | 19 ++++++++++++++++--- base/web/space.go | 5 ++++- conf.go | 1 + core/chat/header.go | 2 +- render.go | 3 +++ 5 files changed, 25 insertions(+), 5 deletions(-) diff --git a/base/web/dream.go b/base/web/dream.go index 7172cfaf..d819e0eb 100644 --- a/base/web/dream.go +++ b/base/web/dream.go @@ -386,7 +386,13 @@ func init() { nfs.Trash(m, path.Join(ice.USR_LOCAL_WORK, m.Option(mdb.NAME))) }}, OPEN: {Role: aaa.VOID, Hand: func(m *ice.Message, arg ...string) { - ProcessIframe(m, m.Option(mdb.NAME), kit.Select(S(m.Option(mdb.NAME)), SpideOrigin(m, m.Option(mdb.NAME)), m.Option(mdb.TYPE) == MASTER), arg...) + m.Debug("what %v", m.Option(ice.MSG_USERHOST)) + m.Debug("what %v", m.Option(ice.MSG_USERWEB)) + if m.Option(mdb.TYPE) == MASTER && m.IsLocalhost() { + m.ProcessOpen(SpideOrigin(m, m.Option(mdb.NAME))) + } else { + ProcessIframe(m, m.Option(mdb.NAME), kit.Select(S(m.Option(mdb.NAME)), SpideOrigin(m, m.Option(mdb.NAME)), m.Option(mdb.TYPE) == MASTER), arg...) + } }}, GRANT: {Hand: func(m *ice.Message, arg ...string) { m.Cmd(CHAT_GRANT, aaa.CONFIRM, kit.Dict(SPACE, m.Option(mdb.NAME))) @@ -463,12 +469,19 @@ func DreamWhiteHandle(m *ice.Message, arg ...string) { aaa.White(m, kit.Keys(m.ShortKey(), ctx.ACTION, DREAM_ACTION)) } func DreamProcessIframe(m *ice.Message, arg ...string) { - if kit.HasPrefixList(arg, ctx.ACTION, m.CommandKey()) && len(arg) == 2 { + if !kit.HasPrefixList(arg, ctx.ACTION, m.ShortKey()) && !kit.HasPrefixList(arg, ctx.ACTION, m.CommandKey()) { + return + } + if m.Option(mdb.TYPE) == MASTER && m.IsLocalhost() { + m.ProcessOpen(SpideOrigin(m, m.Option(mdb.NAME)) + C(m.ShortKey())) + return + } + if len(arg) == 2 { defer m.Push(TITLE, kit.Keys(m.Option(mdb.NAME), m.ShortKey())) } DreamProcess(m, CHAT_IFRAME, func() string { if m.Option(mdb.TYPE) == MASTER { - return SpideOrigin(m, kit.Keys(m.Option(ice.MSG_USERPOD), m.Option(mdb.NAME))) + C(m.ShortKey()) + return SpideOrigin(m, m.Option(mdb.NAME)) + C(m.ShortKey()) } return S(kit.Keys(m.Option(ice.MSG_USERPOD), m.Option(mdb.NAME))) + C(m.ShortKey()) }, arg...) diff --git a/base/web/space.go b/base/web/space.go index 8b910e45..f2a4a8e4 100644 --- a/base/web/space.go +++ b/base/web/space.go @@ -293,6 +293,9 @@ func init() { m.Options(ice.MSG_USERIP, msg.Append(aaa.IP), ice.MSG_USERUA, msg.Append(aaa.UA)) m.Cmd("", kit.Select(m.Option(mdb.NAME), arg, 0), ice.MSG_SESSID, aaa.SessCreate(m, m.Option(ice.MSG_USERNAME))) }}, + SPACE_LOGIN: {Hand: func(m *ice.Message, arg ...string) { + kit.If(m.Option(ice.FROM_DAEMON), func(p string) { m.Cmd("", p, GRANT, m.Option(mdb.NAME), -1) }) + }}, OPEN: {Hand: func(m *ice.Message, arg ...string) { switch m.Option(mdb.TYPE) { case MASTER: @@ -302,7 +305,7 @@ func init() { } }}, nfs.PS: {Hand: func(m *ice.Message, arg ...string) { _space_fork(m) }}, - }, mdb.HashAction(mdb.LIMIT, 1000, mdb.LEAST, 500, mdb.SHORT, mdb.NAME, mdb.FIELD, "time,type,name,text,module,version,agent,system,ip,usernick,username,userrole", ctx.ACTION, OPEN, REDIAL, kit.Dict("a", 3000, "b", 1000, "c", 1000)), mdb.ClearOnExitHashAction()), Hand: func(m *ice.Message, arg ...string) { + }, gdb.EventsAction(SPACE_LOGIN), mdb.HashAction(mdb.LIMIT, 1000, mdb.LEAST, 500, mdb.SHORT, mdb.NAME, mdb.FIELD, "time,type,name,text,module,version,agent,system,ip,usernick,username,userrole", ctx.ACTION, OPEN, REDIAL, kit.Dict("a", 3000, "b", 1000, "c", 1000)), mdb.ClearOnExitHashAction()), Hand: func(m *ice.Message, arg ...string) { if len(arg) < 2 { if len(arg) == 1 && strings.Contains(arg[0], nfs.PT) { ls := kit.Split(arg[0], nfs.PT) diff --git a/conf.go b/conf.go index 9615177b..3b607167 100644 --- a/conf.go +++ b/conf.go @@ -241,6 +241,7 @@ const ( // MSG LOG_TRACEID = "log.id" MSG_NODETYPE = "node.type" + FROM_DAEMON = "from.daemon" TABLE_CHECKBOX = "table.checkbox" TOAST_DURATION = "toast.duration" ) diff --git a/core/chat/header.go b/core/chat/header.go index 05e7f6f6..ff1e9438 100644 --- a/core/chat/header.go +++ b/core/chat/header.go @@ -104,7 +104,7 @@ func init() { aaa.LOGOUT: {Hand: aaa.SessLogout}, cli.QRCODE: {Hand: func(m *ice.Message, arg ...string) { link := tcp.PublishLocalhost(m, m.Option(ice.MSG_USERWEB)) - m.Push(mdb.NAME, link).PushQRCode(mdb.TEXT, link) + m.Push(mdb.NAME, link).PushQRCode(mdb.TEXT, kit.MergeURL(link, ice.FROM_DAEMON, m.Option(ice.MSG_DAEMON))) }}, mdb.CREATE: {Name: "create type*=plugin,qrcode,oauth name* help 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)) }}, diff --git a/render.go b/render.go index f3aa17ce..07c5a952 100644 --- a/render.go +++ b/render.go @@ -138,6 +138,9 @@ func (m *Message) IsMetaKey() bool { func (m *Message) IsGetMethod() bool { return m.Option(MSG_METHOD) == http.MethodGet } +func (m *Message) IsLocalhost() bool { + return strings.HasPrefix(m.Option(MSG_USERWEB), "http://localhost:9020") +} func (m *Message) PushSearch(arg ...Any) { data := kit.Dict(arg...) kit.For(arg, func(k, v Any) {