From 305b5845acb333c1f55260bfa9287fbcc0a82022 Mon Sep 17 00:00:00 2001 From: shylinux Date: Thu, 5 Aug 2021 09:56:45 +0800 Subject: [PATCH] opt share --- base/web/serve.go | 12 ++++++++++++ base/web/share.go | 3 +++ core/chat/cmd.go | 18 +++++++++++++----- core/chat/header.go | 2 +- core/code/webpack.go | 4 ++-- 5 files changed, 31 insertions(+), 8 deletions(-) diff --git a/base/web/serve.go b/base/web/serve.go index 5bad47f9..d94fe57d 100644 --- a/base/web/serve.go +++ b/base/web/serve.go @@ -79,12 +79,24 @@ func _serve_handle(key string, cmd *ice.Command, msg *ice.Message, w http.Respon msg.Option(v.Name, v.Value) } + if ls := strings.Split(r.URL.Path, "/"); len(ls) > 2 && ls[1] == "share" { + msg.Logs("refer", ls[1], ls[2]) + msg.Option(ls[1], ls[2]) + } else { + msg.Debug("%v", ls) + } // 请求变量 if u, e := url.Parse(r.Header.Get("Referer")); e == nil { for k, v := range u.Query() { msg.Logs("refer", k, v) msg.Option(k, v) } + if ls := strings.Split(u.Path, "/"); len(ls) > 2 && ls[1] == "share" { + msg.Logs("refer", ls[1], ls[2]) + msg.Option(ls[1], ls[2]) + } else { + msg.Debug("%v", ls) + } } // 请求地址 diff --git a/base/web/share.go b/base/web/share.go index 6417f3e9..aa7e7e99 100644 --- a/base/web/share.go +++ b/base/web/share.go @@ -208,6 +208,9 @@ func init() { case STORM: m.RenderRedirect("/page/share.html", SHARE, m.Option(SHARE)) + + case FIELD: + m.RenderDownload(path.Join(m.Conf(SERVE, kit.Keym(ice.VOLCANOS, kit.MDB_PATH)), "/page/index.html")) } }}, diff --git a/core/chat/cmd.go b/core/chat/cmd.go index f2b9e161..4649bc85 100644 --- a/core/chat/cmd.go +++ b/core/chat/cmd.go @@ -37,7 +37,12 @@ func init() { }, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { if strings.HasSuffix(m.R.URL.Path, "/") { m.RenderDownload(path.Join(m.Conf(web.SERVE, kit.Keym(ice.VOLCANOS, kit.MDB_PATH)), m.Conf(CMD, kit.Keym(kit.MDB_INDEX)))) - return + return // 目录 + } + + if msg := m.Cmd(ctx.COMMAND, arg[0]); msg.Append("meta") != "" { + _cmd_render(m, arg[0]) + return // 命令 } switch p := path.Join(m.Conf(CMD, kit.META_PATH), path.Join(arg...)); kit.Ext(p) { @@ -85,10 +90,13 @@ func init() { }, Configs: map[string]*ice.Config{ CMD: {Name: CMD, Help: "命令", Value: kit.Data( - kit.MDB_PATH, "./", kit.MDB_INDEX, "page/cmd.html", kit.MDB_TEMPLATE, ` - - - + kit.MDB_PATH, "./", kit.MDB_INDEX, "page/cmd.html", kit.MDB_TEMPLATE, ` + + + + + + `, )}, diff --git a/core/chat/header.go b/core/chat/header.go index 5993e6d8..217d5afb 100644 --- a/core/chat/header.go +++ b/core/chat/header.go @@ -32,7 +32,7 @@ func _header_check(m *ice.Message, arg ...string) { func _header_share(m *ice.Message, arg ...string) { if m.Option(kit.MDB_LINK) == "" { share := m.Cmdx(web.SHARE, mdb.CREATE, kit.MDB_TYPE, web.LOGIN, arg) - m.Option(kit.MDB_LINK, kit.MergeURL(m.Option(ice.MSG_USERWEB), web.SHARE, share)) + m.Option(kit.MDB_LINK, kit.MergeURL2(m.Option(ice.MSG_USERWEB), "/share/"+share)) } link := tcp.ReplaceLocalhost(m, m.Option(kit.MDB_LINK)) diff --git a/core/code/webpack.go b/core/code/webpack.go index 8d26648b..e266330b 100644 --- a/core/code/webpack.go +++ b/core/code/webpack.go @@ -83,8 +83,8 @@ func init() { m.Echo(p) } - m.Cmd(nfs.COPY, _volcanos("page/can.css"), _volcanos("page/index.css"), _volcanos("page/cache.css")) - m.Cmd(nfs.COPY, _volcanos("page/can.js"), _volcanos("proto.js"), _volcanos("page/cache.js")) + m.Cmd(nfs.COPY, _volcanos("page/cmd.css"), _volcanos("page/index.css"), _volcanos("page/cache.css")) + m.Cmd(nfs.COPY, _volcanos("page/cmd.js"), _volcanos("proto.js"), _volcanos("page/cache.js")) }}, mdb.PRUNES: {Name: "prunes", Help: "清理", Hand: func(m *ice.Message, arg ...string) { m.Cmd(nfs.SAVE, path.Join(ice.USR_VOLCANOS, "page/cache.css"), "")