From 5b3b3df314abd8357b3e0d0b7d840f36ce0c7cf7 Mon Sep 17 00:00:00 2001 From: harveyshao Date: Mon, 14 Nov 2022 23:19:17 +0800 Subject: [PATCH] opt some --- base/nfs/cat.go | 2 +- base/web/render.go | 30 +++++++++++++++++++++++++----- base/web/serve.go | 11 +++++------ conf.go | 2 +- core/code/favor.go | 3 +++ 5 files changed, 35 insertions(+), 13 deletions(-) diff --git a/base/nfs/cat.go b/base/nfs/cat.go index 6b605b8e..30749dba 100644 --- a/base/nfs/cat.go +++ b/base/nfs/cat.go @@ -147,7 +147,7 @@ func init() { )}, }, Commands: ice.Commands{ CAT: {Name: "cat path auto", Help: "文件", Actions: ice.Actions{ - ctx.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { + ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { m.Cmd(aaa.ROLE, aaa.WHITE, aaa.VOID, ice.SRC_MAIN_SHY) m.Cmd(aaa.ROLE, aaa.WHITE, aaa.VOID, ice.SRC_MAIN_GO) m.Cmd(aaa.ROLE, aaa.WHITE, aaa.VOID, ice.USR_PUBLISH) diff --git a/base/web/render.go b/base/web/render.go index 650ea6b0..d6a5ff7c 100644 --- a/base/web/render.go +++ b/base/web/render.go @@ -23,7 +23,7 @@ const ( STATUS = "status" ) -func Render(m *ice.Message, cmd string, args ...ice.Any) { +func Render(m *ice.Message, cmd string, args ...ice.Any) bool { if cmd != "" { defer func() { m.Logs(mdb.EXPORT, cmd, args) }() } @@ -84,6 +84,7 @@ func Render(m *ice.Message, cmd string, args ...ice.Any) { fmt.Fprint(m.W, m.FormatsMeta()) // fmt.Fprint(m.W, m.FormatMeta()) } + return true } func RenderType(w http.ResponseWriter, name, mime string) { @@ -163,15 +164,34 @@ func RenderCmd(m *ice.Message, index string, args ...ice.Any) { mdb.LIST, kit.UnMarshal(msg.Append(mdb.LIST)), mdb.META, kit.UnMarshal(msg.Append(mdb.META)), ))) } - m.Echo(kit.Format(_cans, list)) - m.RenderResult() + m.Echo(kit.Format(_cmd_template, list)).RenderResult() +} +func RenderMain(m *ice.Message, index string, args ...ice.Any) *ice.Message { + return m.Echo(kit.Format(_main_template, m.Cmdx(nfs.CAT, index))).RenderResult() } -var _cans = ` - +var _cmd_template = ` + + + ` +var _main_template = ` + + + + volcanos + + + + + + + + + +` diff --git a/base/web/serve.go b/base/web/serve.go index b890f34a..74347c27 100644 --- a/base/web/serve.go +++ b/base/web/serve.go @@ -36,16 +36,15 @@ func _serve_rewrite(m *ice.Message) { switch r.URL.Path { case ice.PS: if repos == ice.VOLCANOS { - if nfs.ExistsFile(ice.SRC_MAIN_JS) { - return + if nfs.ExistsFile(m, ice.SRC_MAIN_JS) { + RenderMain(msg, ice.SRC_MAIN_JS) + return Render(msg, ice.RENDER_RESULT, msg.Result()) } if s := msg.Cmdx("web.chat.website", lex.PARSE, ice.INDEX_IML, "Header", "", "River", "", "Footer", ""); s != "" { - Render(msg, ice.RENDER_RESULT, s) - return true // 定制主页 + return Render(msg, ice.RENDER_RESULT, s) } } - Render(msg, ice.RENDER_DOWNLOAD, path.Join(msg.Config(kit.Keys(repos, nfs.PATH)), msg.Config(kit.Keys(repos, INDEX)))) - return true // 默认主页 + return Render(msg, ice.RENDER_DOWNLOAD, path.Join(msg.Config(kit.Keys(repos, nfs.PATH)), msg.Config(kit.Keys(repos, INDEX)))) case PP(ice.HELP): r.URL.Path = P(ice.HELP, ice.TUTOR_SHY) diff --git a/conf.go b/conf.go index ea33aafc..5562d3b0 100644 --- a/conf.go +++ b/conf.go @@ -139,8 +139,8 @@ const ( // DIR SRC_HELP = "src/help" SRC_DEBUG = "src/debug" SRC_RELEASE = "src/release" + SRC_MAIN_JS = "src/main.js" SRC_MAIN_GO = "src/main.go" - SRC_MAIN_GO = "src/main.js" SRC_MAIN_SHY = "src/main.shy" SRC_MAIN_SVG = "src/main.svg" SRC_VERSION_GO = "src/version.go" diff --git a/core/code/favor.go b/core/code/favor.go index 5f76faef..11a05318 100644 --- a/core/code/favor.go +++ b/core/code/favor.go @@ -27,6 +27,9 @@ func init() { }, mdb.ZoneAction(mdb.SHORT, mdb.ZONE, mdb.FIELD, "time,id,type,name,text,path,file,line")), Hand: func(m *ice.Message, arg ...string) { m.Option(mdb.CACHE_LIMIT, "30") if mdb.ZoneSelectPage(m, arg...); len(arg) > 0 && arg[0] != "" { + if arg[0] == "_recent_file" { + m.Sort(nfs.FILE) + } m.Tables(func(value ice.Maps) { m.PushButton(kit.Select(INNER, XTERM, value[mdb.TEXT] == "" || value[nfs.FILE] == "")) }).Option(ctx.STYLE, arg[0])