From dc9dd86bba2593e893eda70b42188415e15d21db Mon Sep 17 00:00:00 2001 From: shy Date: Wed, 7 Feb 2024 17:45:11 +0800 Subject: [PATCH] add some --- base/ctx/display.go | 2 +- base/log/log.go | 17 +++++------------ base/web/spide.go | 6 +++++- info.go | 6 +++++- render.go | 2 +- 5 files changed, 17 insertions(+), 16 deletions(-) diff --git a/base/ctx/display.go b/base/ctx/display.go index 5bc975fb..706502f3 100644 --- a/base/ctx/display.go +++ b/base/ctx/display.go @@ -40,7 +40,7 @@ func DisplayStoryForm(m *ice.Message, arg ...ice.Any) *ice.Message { } } } - kit.For(args, func(v string) { m.Push("", v, kit.Split("type,name,value,values,need,action")) }) + kit.For(args, func(v ice.Map) { m.Push("", v, kit.Split("type,name,value,values,need,action")) }) return DisplayStory(m, "form") } func DisplayStoryJSON(m *ice.Message, arg ...ice.Any) *ice.Message { diff --git a/base/log/log.go b/base/log/log.go index bd42eade..b29be7c3 100644 --- a/base/log/log.go +++ b/base/log/log.go @@ -44,7 +44,8 @@ func (f *Frame) Start(m *ice.Message, arg ...string) { if file == "" { return } - bio := m.Confv(FILE, kit.Keys(file, FILE)).(*bufio.Writer) + conf := m.Confv(FILE, file) + bio := kit.Value(conf, FILE).(*bufio.Writer) if bio == nil { return } @@ -59,10 +60,7 @@ func (f *Frame) Start(m *ice.Message, arg ...string) { } } } -func (f *Frame) Close(m *ice.Message, arg ...string) { - ice.Info.Log = nil - close(f.p) -} +func (f *Frame) Close(m *ice.Message, arg ...string) { ice.Info.Log = nil; close(f.p) } const ( PREFIX = "prefix" @@ -112,10 +110,7 @@ var Index = &ice.Context{Name: LOG, Help: "日志模块", Configs: ice.Configs{ func init() { ice.Index.Register(Index, &Frame{}, TAIL) } -func init() { - ice.Info.Traceid = "short" - ice.Pulse.Option(ice.LOG_TRACEID, Traceid()) -} +func init() { ice.Info.Traceid = "short"; ice.Pulse.Option(ice.LOG_TRACEID, Traceid()) } var _trace_count int64 @@ -133,8 +128,6 @@ func Traceid() (traceid string) { ls = ls[:0] } }) - kit.If(len(ls) > 0, func() { - ls = append(ls, kit.Format(atomic.AddInt64(&_trace_count, 1))) - }) + kit.If(len(ls) > 0, func() { ls = append(ls, kit.Format(atomic.AddInt64(&_trace_count, 1))) }) return strings.Join(ls, "-") } diff --git a/base/web/spide.go b/base/web/spide.go index 33be5663..0a966ff0 100644 --- a/base/web/spide.go +++ b/base/web/spide.go @@ -285,12 +285,16 @@ func init() { if p := path.Join(ice.SRC_TEMPLATE, m.PrefixKey(), path.Join(arg...)); nfs.Exists(m, p) { return p + kit.Select("", nfs.PS, len(arg) == 0) } else { - return m.FileURI(path.Join(path.Dir(ctx.GetCmdFile(m, m.PrefixKey())), path.Join(arg...))) + m.Debug("what %v", p) + what := kit.MergeURL2(UserHost(m)+ctx.GetCmdFile(m, m.PrefixKey()), path.Join(arg...)) + m.Debug("what %v", what) + return what // return path.Join(path.Dir(ctx.GetCmdFile(m, m.PrefixKey())), path.Join(arg...)) + kit.Select("", nfs.PS, len(arg) == 0) } } nfs.TemplateText = func(m *ice.Message, p string) string { if p := kit.Select(nfs.TemplatePath(m, path.Base(p)), m.Option("_template")); kit.HasPrefix(p, "/require/", ice.HTTP) { + m.Debug("what %v", p) return m.Cmdx(SPIDE, ice.OPS, SPIDE_RAW, http.MethodGet, p) } else { return m.Cmdx(nfs.CAT, p) diff --git a/info.go b/info.go index 19e1a6be..40477811 100644 --- a/info.go +++ b/info.go @@ -318,9 +318,13 @@ func (m *Message) FileURI(dir string) string { } else if kit.HasPrefix(dir, PS, HTTP) { return dir } + m.Debug("what %v", m.Option(MSG_USERPOD)) if strings.HasPrefix(dir, USR_VOLCANOS) { return strings.TrimPrefix(dir, USR) } else { - return kit.MergeURL(path.Join(PS, REQUIRE, dir), POD, m.Option(MSG_USERPOD)) + m.Debug("what %v", m.Option(MSG_USERPOD)) + what := kit.MergeURL(path.Join(PS, REQUIRE, dir), POD, m.Option(MSG_USERPOD)) + m.Debug("what %v", what) + return what } } diff --git a/render.go b/render.go index 36d12cff..fafe168b 100644 --- a/render.go +++ b/render.go @@ -248,7 +248,7 @@ func (m *Message) EchoDownload(arg ...string) *Message { } func (m *Message) Display(file string, arg ...Any) *Message { file = m.resource(file) - m.Option(MSG_DISPLAY, m.MergeLink(kit.Select(kit.ExtChange(file, JS), file, strings.Contains(file, QS)), arg...)) + m.Option(MSG_DISPLAY, kit.MergeURL(kit.ExtChange(file, JS), arg...)) return m } func (m *Message) Resource(file string) string { return m.resource(file) }