From 53b2efc9fd6d341e7a365ca4ee14339ca084622b Mon Sep 17 00:00:00 2001 From: shylinux Date: Sat, 15 Jul 2023 15:21:08 +0800 Subject: [PATCH] opt some --- base/web/option.go | 3 +++ core/chat/cmd.go | 10 +++++----- core/chat/iframe.go | 19 ++++++++++++++++++- core/code/bench.go | 2 +- core/code/compile.go | 2 +- core/code/pprof.go | 2 +- core/code/publish.go | 7 ++++--- misc/git/service.go | 2 +- 8 files changed, 34 insertions(+), 13 deletions(-) diff --git a/base/web/option.go b/base/web/option.go index 676e3534..eadc9385 100644 --- a/base/web/option.go +++ b/base/web/option.go @@ -47,6 +47,9 @@ func MergeURL2(m Message, url string, arg ...ice.Any) string { return kit.MergeURL2(m.Option(ice.MSG_USERWEB), url, arg...) } func MergeLink(m Message, url string, arg ...ice.Any) string { + if m.Option(log.DEBUG) == ice.TRUE { + arg = append(arg, log.DEBUG, ice.TRUE) + } return kit.MergeURL(strings.Split(MergeURL2(m, url), mdb.QS)[0], arg...) } func ProcessPodCmd(m *ice.Message, pod, cmd string, arg ...ice.Any) { diff --git a/core/chat/cmd.go b/core/chat/cmd.go index 8c2ee586..a9a5fc63 100644 --- a/core/chat/cmd.go +++ b/core/chat/cmd.go @@ -43,15 +43,15 @@ func init() { ), Hand: func(m *ice.Message, arg ...string) { if _cmd_file(m, arg...) { return - } - if len(arg[0]) == 0 || arg[0] == "" { + } else if len(arg[0]) == 0 || arg[0] == "" { return - } - if m.IsCliUA() { + } else if m.IsCliUA() { m.Cmdy(arg, m.Optionv(ice.ARG)).RenderResult() return } - if m.Cmdy(ctx.COMMAND, arg[0]); m.Length() > 0 { + if arg[0] == "web.chat.portal" { + web.RenderMain(m) + } else if m.Cmdy(ctx.COMMAND, arg[0]); m.Length() > 0 { web.RenderCmd(m, m.Append(ctx.INDEX), arg[1:]) } }}, diff --git a/core/chat/iframe.go b/core/chat/iframe.go index 0dde3d91..20837d4e 100644 --- a/core/chat/iframe.go +++ b/core/chat/iframe.go @@ -71,14 +71,31 @@ func init() { m.Cmd("", mdb.CREATE, kit.Dict(web.LINK, m.MergePod(m.Option(mdb.NAME)))) }}, }, mdb.HashAction(mdb.SHORT, web.LINK, mdb.FIELD, "time,hash,type,name,link"), FavorAction()), Hand: func(m *ice.Message, arg ...string) { + list := []string{m.MergePodCmd("", "web.wiki.portal")} + if m.Option(ice.MSG_USERPOD) == "" { + list = append(list, web.MergeLink(m, "/chat/portal/")) + } else { + list = append(list, web.MergeLink(m, "/chat/portal/", ice.POD, m.Option(ice.MSG_USERPOD))) + } if mdb.HashSelect(m, arg...); len(arg) == 0 { + for _, link := range list { + m.Push("", kit.Dict(mdb.TIME, m.Time(), mdb.HASH, kit.Hashs(link), mdb.TYPE, web.LINK, web.LINK, link)) + } if m.Length() == 0 { m.Action(mdb.CREATE) } else { m.PushAction(web.OPEN, mdb.REMOVE).Action(mdb.CREATE, mdb.PRUNES) } } else { - kit.If(m.Length() == 0, func() { m.Append(web.LINK, arg[0]) }) + kit.If(m.Length() == 0, func() { + for _, link := range list { + if arg[0] == kit.Hashs(link) { + m.Append(web.LINK, link) + return + } + } + m.Append(web.LINK, arg[0]) + }) m.Action(web.FULL, web.OPEN).StatusTime(m.AppendSimple(web.LINK)) ctx.DisplayLocal(m, "") } diff --git a/core/code/bench.go b/core/code/bench.go index 6ab71830..8bd4b8d4 100644 --- a/core/code/bench.go +++ b/core/code/bench.go @@ -57,7 +57,7 @@ const BENCH = "bench" func init() { Index.MergeCommands(ice.Commands{ - BENCH: {Name: "bench zone id auto insert", Help: "性能压测", Actions: ice.MergeActions(ice.Actions{ + BENCH: {Name: "bench zone id auto insert", Help: "压测", Actions: ice.MergeActions(ice.Actions{ mdb.INSERT: {Name: "insert zone*=demo type*=http,redis name=demo text*='http://localhost:9020/chat/cmd/run/web.chat.favor' nconn=10 nreqs=100"}, ice.RUN: {Hand: func(m *ice.Message, arg ...string) { switch m.Option(mdb.TYPE) { diff --git a/core/code/compile.go b/core/code/compile.go index 7326cbc0..a906de7f 100644 --- a/core/code/compile.go +++ b/core/code/compile.go @@ -88,7 +88,7 @@ func init() { m.Logs(nfs.SAVE, nfs.TARGET, file, nfs.SOURCE, main) m.Cmdy(nfs.DIR, file, "time,path,size,hash,link") if !m.IsCliUA() { - kit.If(strings.Contains(file, ice.ICE), func() { m.Cmdy(PUBLISH, ice.CONTEXTS) }) + kit.If(strings.Contains(file, ice.ICE), func() { m.Cmdy(PUBLISH, ice.CONTEXTS, "app") }) } }}, }) diff --git a/core/code/pprof.go b/core/code/pprof.go index 5dab1911..a2d0b03e 100644 --- a/core/code/pprof.go +++ b/core/code/pprof.go @@ -29,7 +29,7 @@ func init() { http.DefaultServeMux.ServeHTTP(m.W, m.R) }}}) Index.MergeCommands(ice.Commands{ - PPROF: {Name: "pprof zone id auto", Help: "性能分析", Actions: ice.MergeActions(ice.Actions{ + PPROF: {Name: "pprof zone id auto", Help: "优化", Actions: ice.MergeActions(ice.Actions{ mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) { switch arg[0] { case BINNARY: diff --git a/core/code/publish.go b/core/code/publish.go index ad541457..31a17dcb 100644 --- a/core/code/publish.go +++ b/core/code/publish.go @@ -49,9 +49,10 @@ func _publish_contexts(m *ice.Message, arg ...string) { m.Option(web.DOMAIN, m.Cmd(web.SPIDE, ice.SHY).Append(web.CLIENT_ORIGIN)) case ice.CORE: m.Option(web.DOMAIN, m.Cmd(web.SPIDE, ice.DEV).Append(web.CLIENT_ORIGIN)) - case nfs.SOURCE: + case nfs.SOURCE, "dev": m.Options(nfs.SOURCE, ice.Info.Make.Remote) - case nfs.BINARY: + case nfs.BINARY, "app": + case "wget", "curl": case "manual": m.Options(nfs.BINARY, "ice.linux.amd64") @@ -117,7 +118,7 @@ func init() { nfs.TRASH: {Hand: func(m *ice.Message, arg ...string) { nfs.Trash(m, path.Join(ice.USR_PUBLISH, m.Option(nfs.PATH))) }}, }, ctx.ConfAction(mdb.FIELD, nfs.PATH), aaa.RoleAction()), Hand: func(m *ice.Message, arg ...string) { if m.Option(nfs.DIR_ROOT, ice.USR_PUBLISH); len(arg) == 0 { - _publish_list(m).Cmdy("", ice.CONTEXTS) + _publish_list(m).Cmdy("", ice.CONTEXTS, "app") } else { m.Cmdy(nfs.DIR, arg[0], "time,path,size,hash,link,action", ice.OptionFields(mdb.DETAIL)) web.PushImages(m, web.P(PUBLISH, arg[0])) diff --git a/misc/git/service.go b/misc/git/service.go index f3f54a83..baf76237 100644 --- a/misc/git/service.go +++ b/misc/git/service.go @@ -197,7 +197,7 @@ func init() { if len(arg) == 0 { mdb.HashSelect(m, arg...).Table(func(value ice.Maps) { m.PushScript(kit.Format("git clone %s", tcp.PublishLocalhost(m, kit.Split(web.MergeURL2(m, "/x/"+value[REPOS]+".git"), mdb.QS)[0]))) - }).Sort(REPOS).Echo(strings.ReplaceAll(m.Cmdx("web.code.publish", ice.CONTEXTS), "app username", "dev username")) + }).Sort(REPOS).Echo(strings.ReplaceAll(m.Cmdx("web.code.publish", ice.CONTEXTS, "dev"), "app username", "dev username")) m.Table(func(value ice.Maps) { m.Push(nfs.SIZE, kit.Split(m.Cmdx(cli.SYSTEM, "du", "-sh", path.Join(ice.USR_LOCAL_REPOS, value[REPOS])))[0]) })