From a12a4836b9bcc5724ae3a5d270951cde7d81cadf Mon Sep 17 00:00:00 2001 From: shy Date: Fri, 12 Jan 2024 17:02:43 +0800 Subject: [PATCH] opt some --- base/ctx/command.go | 12 ++++++------ base/web/dream.go | 2 +- base/web/space.go | 6 +++--- core/chat/action.go | 4 +++- core/chat/macos/desktop.js | 5 +++-- core/chat/river.go | 4 ++-- core/code/vimer.go | 7 +++---- core/code/xterm.go | 7 +++++-- core/wiki/word.go | 2 +- misc/git/repos.go | 4 ++++ 10 files changed, 31 insertions(+), 22 deletions(-) diff --git a/base/ctx/command.go b/base/ctx/command.go index cc2791a5..1bb4da0f 100644 --- a/base/ctx/command.go +++ b/base/ctx/command.go @@ -18,23 +18,23 @@ func _command_list(m *ice.Message, name string) *ice.Message { return m.Push(mdb.INDEX, name).Push(mdb.NAME, name).Push(mdb.HELP, "").Push(mdb.META, "").Push(mdb.LIST, "") } m.Spawn(m.Source()).Search(name, func(p *ice.Context, s *ice.Context, key string, cmd *ice.Command) { - // if _p, ok := ice.Info.Index[key].(*ice.Context); ok && _p.Prefix() == s.Prefix() { - // m.Push(mdb.INDEX, key) - // } else { - // m.Push(mdb.INDEX, kit.Keys(s.Prefix(), key)) - // } m.Push(mdb.INDEX, kit.Keys(s.Prefix(), key)) m.Push(mdb.NAME, kit.Format(cmd.Name)) m.Push(mdb.HELP, kit.Format(cmd.Help)) m.Push(mdb.LIST, kit.Format(cmd.List)) m.Push(mdb.META, kit.Format(cmd.Meta)) - m.Push("_help", GetCmdHelp(m, name)) + if _p, ok := ice.Info.Index[key].(*ice.Context); ok && _p.Prefix() == s.Prefix() { + m.Push("_command", key) + } else { + m.Push("_command", kit.Keys(s.Prefix(), key)) + } if !nfs.Exists(m, kit.Split(cmd.FileLine(), ":")[0], func(p string) { m.Push("_fileline", kit.MergeURL(FileURI(p), ice.POD, m.Option(ice.MSG_USERPOD))) }) { m.Push("_fileline", "") } m.Push("_role", kit.Select("", ice.OK, aaa.Right(m.Spawn(), name))) + m.Push("_help", GetCmdHelp(m, name)) }) return m } diff --git a/base/web/dream.go b/base/web/dream.go index 86feb115..1681ccec 100644 --- a/base/web/dream.go +++ b/base/web/dream.go @@ -162,7 +162,7 @@ func init() { }}, mdb.SEARCH: {Hand: func(m *ice.Message, arg ...string) { if mdb.IsSearchPreview(m, arg) { - mdb.HashSelects(m.Spawn()).Table(func(value ice.Maps) { m.PushSearch(mdb.TEXT, m.MergePod(value[mdb.NAME]), value) }) + mdb.HashSelects(m.Spawn()).Table(func(value ice.Maps) { m.PushSearch(mdb.TYPE, WORKER, mdb.TEXT, m.MergePod(value[mdb.NAME]), value) }) } }}, mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) { diff --git a/base/web/space.go b/base/web/space.go index 618862a9..a93c2e3d 100644 --- a/base/web/space.go +++ b/base/web/space.go @@ -288,8 +288,7 @@ func init() { } fallthrough case aaa.EMAIL: - m.Push(arg[0], "shy@shylinux.com") - m.Push(arg[0], "shylinux@163.com") + m.Push(arg[0], "shy@shylinux.com", "shylinux@163.com") case aaa.PASSWORD: m.SetAppend() case "origin": @@ -304,7 +303,8 @@ func init() { m.Cmd(SPACE, pod, SPIDE, ice.DEV, CACHE, SHARE_CACHE+ls[0]) } msg := m.Options(key, []string{}, ice.MSG_USERPOD, pod).Cmd(append(kit.List(ice.SPACE, pod), arg...)...) - kit.If(!msg.IsErr(), func() { m.Copy(msg) }) + m.Copy(msg) + // kit.If(!msg.IsErr(), func() { m.Copy(msg) }) return true } } diff --git a/core/chat/action.go b/core/chat/action.go index 83898b44..58f0ce7e 100644 --- a/core/chat/action.go +++ b/core/chat/action.go @@ -21,7 +21,9 @@ func _action_exec(m *ice.Message, river, storm, index string, arg ...string) { }).Length() == 0, ice.ErrNotRight, index, arg) { return } - kit.If(!ctx.PodCmd(m, index, arg), func() { m.Cmdy(index, arg) }) + kit.If(!ctx.PodCmd(m, index, arg), func() { + m.Cmdy(index, arg) + }) } func _action_auth(m *ice.Message, share string) *ice.Message { msg := m.Cmd(web.SHARE, share) diff --git a/core/chat/macos/desktop.js b/core/chat/macos/desktop.js index 88600f62..d5b969d6 100644 --- a/core/chat/macos/desktop.js +++ b/core/chat/macos/desktop.js @@ -3,7 +3,7 @@ Volcanos(chat.ONIMPORT, { _init: function(can, msg) { can.isCmdMode() && can.onappend.style(can, html.OUTPUT) can.onlayout.background(can, can.user.info.background||"/require/usr/icons/background.jpg", can._fields) can.onimport._menu(can), can.onimport._notifications(can), can.onimport._searchs(can), can.onimport._dock(can) - can.sup.onexport.link = function() { return can.misc.MergeURL(can, {pod: can.ConfSpace(), cmd: web.DESKTOP}) } + can.sup.onexport.link = function() { return can.misc.MergeURL(can, {pod: can.ConfSpace()||can.misc.Search(can, ice.POD), cmd: web.DESKTOP}) } }, _menu: function(can) { can.onappend.plugin(can, {index: "web.chat.macos.menu", style: html.OUTPUT}, function(sub) { can.ui.menu = sub var tabs = can.misc.sessionStorage(can, [can.ConfIndex(), html.TABS]) @@ -69,8 +69,9 @@ Volcanos(chat.ONIMPORT, { item.height = can.ConfHeight()-125, item.width = can.ConfWidth()-200, item.left = (can.ConfWidth()-item.width)/2, item.top = 25 if (can.ConfWidth() > 1400) { item.width = can.base.Min(can.ConfWidth()-600, 640, 1400), item.left = (can.ConfWidth()-item.width)/2 } if (can.ConfHeight() > 800) { item.height = can.base.Min(can.ConfHeight()-200, 320, 800), item.top = 50 } - if (can.user.isMobile) { item.left = 0, item.top = 25, item.height = can.ConfHeight()-125, item.width = can.ConfWidth() } + if (can.user.isMobile) { item.height = can.ConfHeight()-125, item.top = 25, item.width = can.ConfWidth(), item.left = 0 } item.height = can.base.Max(html.DESKTOP_HEIGHT, item.height), item.width = can.base.Max(html.DESKTOP_WIDTH, item.width) + if (can.base.isIn(item.index, "web.code.vimer")) { item.width = can.base.Max(1600, can.ConfWidth()), item.left = (can.ConfWidth()-item.width)/2 } can.onappend.plugin(can, item, function(sub) { can.ondetail.select(can, sub._target) var index = 0; can.core.Item({ close: {color: "#f95f57", inner: "x", onclick: function(event) { sub.onaction._close(event, sub) }}, diff --git a/core/chat/river.go b/core/chat/river.go index 59409776..6a2c2a9c 100644 --- a/core/chat/river.go +++ b/core/chat/river.go @@ -26,8 +26,8 @@ func _river_list(m *ice.Message) { return } } - m.Cmd(mdb.SELECT, m.PrefixKey(), "", mdb.HASH, ice.OptionFields(mdb.HASH, mdb.NAME, mdb.ICON), func(value ice.Maps) { - kit.If(_river_right(m, value[mdb.HASH]), func() { m.PushRecord(value, mdb.HASH, mdb.NAME, mdb.ICON) }) + m.Cmd(mdb.SELECT, m.PrefixKey(), "", mdb.HASH, ice.OptionFields(mdb.HASH, mdb.NAME, mdb.ICON, "main"), func(value ice.Maps) { + kit.If(_river_right(m, value[mdb.HASH]), func() { m.PushRecord(value, mdb.HASH, mdb.NAME, mdb.ICON, "main") }) }) m.Sort(mdb.NAME) } diff --git a/core/code/vimer.go b/core/code/vimer.go index a7d83db1..3006d331 100644 --- a/core/code/vimer.go +++ b/core/code/vimer.go @@ -79,10 +79,9 @@ func init() { ), Actions: ice.MergeActions(ice.Actions{ mdb.SEARCH: {Hand: func(m *ice.Message, arg ...string) { if mdb.IsSearchPreview(m, arg) { - m.PushSearch(mdb.TYPE, nfs.FILE, mdb.NAME, ice.MAIN, mdb.TEXT, ice.SRC_MAIN_SH) - m.PushSearch(mdb.TYPE, nfs.FILE, mdb.NAME, ice.MAIN, mdb.TEXT, ice.SRC_MAIN_SHY) - m.PushSearch(mdb.TYPE, nfs.FILE, mdb.NAME, ice.MAIN, mdb.TEXT, ice.SRC_MAIN_GO) - m.PushSearch(mdb.TYPE, nfs.FILE, mdb.NAME, ice.MAIN, mdb.TEXT, ice.SRC_MAIN_JS) + kit.For([]string{ice.SRC_MAIN_SHY, ice.SRC_MAIN_SH, ice.SRC_MAIN_GO, ice.SRC_MAIN_JS}, func(p string) { + m.PushSearch(mdb.TYPE, nfs.FILE, mdb.NAME, path.Base(p), mdb.TEXT, p) + }) } }}, mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) { diff --git a/core/code/xterm.go b/core/code/xterm.go index ae4bf4ca..afa37f0f 100644 --- a/core/code/xterm.go +++ b/core/code/xterm.go @@ -76,8 +76,11 @@ func init() { }) }}, mdb.SEARCH: {Hand: func(m *ice.Message, arg ...string) { - mdb.IsSearchPreview(m, arg, func() []string { return []string{ssh.SHELL, SH, shell} }) - mdb.IsSearchPreview(m, arg, func() []string { return []string{ssh.SHELL, ISH, "/bin/ish"} }) + if mdb.IsSearchPreview(m, arg) { + kit.For([]string{shell, "/bin/ish"}, func(p string) { + m.PushSearch(mdb.TYPE, ssh.SHELL, mdb.NAME, path.Base(p), mdb.TEXT, p) + }) + } }}, mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) { switch mdb.HashInputs(m, arg); arg[0] { diff --git a/core/wiki/word.go b/core/wiki/word.go index caf6911e..564f11f4 100644 --- a/core/wiki/word.go +++ b/core/wiki/word.go @@ -76,7 +76,7 @@ func init() { web.DREAM_TABLES: {Hand: func(m *ice.Message, arg ...string) { m.PushButton(kit.Dict(m.CommandKey(), "文档")) }}, web.DREAM_ACTION: {Hand: func(m *ice.Message, arg ...string) { web.DreamProcess(m, nil, arg...) }}, }, WikiAction("", nfs.SHY), mdb.HashAction(mdb.SHORT, nfs.PATH, mdb.FIELD, "time,path")), Hand: func(m *ice.Message, arg ...string) { - if len(arg) > 0 { + if len(arg) > 0 && !strings.HasPrefix(arg[0], nfs.SRC_DOCUMENT) { mdb.HashCreate(m.Spawn(), nfs.PATH, arg[0]) } if len(arg) > 0 && strings.Contains(arg[0], nfs.DF) { diff --git a/misc/git/repos.go b/misc/git/repos.go index db01d7fc..11d6b253 100644 --- a/misc/git/repos.go +++ b/misc/git/repos.go @@ -492,6 +492,10 @@ func init() { m.Sort(arg[0]) default: switch arg[0] { + case ORIGIN: + m.Cmd(web.SPIDE, ice.OptionFields(web.CLIENT_ORIGIN), func(value ice.Maps) { m.Push(arg[0], value[web.CLIENT_ORIGIN]+web.X(path.Base(kit.Path("")))) }) + m.Push(arg[0], kit.MergeURL2(web.UserHost(m), web.X(path.Base(kit.Path(""))))) + m.Sort(arg[0]) case MESSAGE: ls := kit.Split(m.Option(nfs.FILE), " /") m.Push(arg[0], kit.Select("", ls, -2))