From 03f5c287cd0e045a9ce7b00c15b414fc629e68e3 Mon Sep 17 00:00:00 2001 From: shaoying Date: Sun, 19 Apr 2020 09:52:23 +0800 Subject: [PATCH] opt search --- base/nfs/nfs.go | 13 ++++++++----- core/chat/chat.go | 18 +++++++++++++++++- misc/vim/vim.go | 4 +--- misc/zsh/zsh.go | 11 +++++++++++ 4 files changed, 37 insertions(+), 9 deletions(-) diff --git a/base/nfs/nfs.go b/base/nfs/nfs.go index ed903fb5..cd546b13 100644 --- a/base/nfs/nfs.go +++ b/base/nfs/nfs.go @@ -157,6 +157,7 @@ func travel(m *ice.Message, root string, name string, cb func(name string)) { } if f.IsDir() { travel(m, root, path.Join(name, f.Name()), cb) + cb(path.Join(name, f.Name())) } else { cb(path.Join(name, f.Name())) } @@ -174,17 +175,19 @@ var Index = &ice.Context{Name: "nfs", Help: "存储模块", m.Cmd(ice.APP_SEARCH, "add", "dir", "base", m.AddCmd(&ice.Command{Name: "search word", Help: "搜索引擎", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { switch arg[0] { case "set": - m.Cmdy("nfs.cat", arg[5]) + m.Cmdy("nfs.dir", arg[5]) return } travel(m, "./", "", func(name string) { if strings.Contains(name, arg[0]) { + s, e := os.Stat(name) + m.Assert(e) m.Push("pod", m.Option(ice.MSG_USERPOD)) m.Push("engine", "dir") - m.Push("favor", "./") - m.Push("id", "") - m.Push("type", "file") + m.Push("favor", "file") + m.Push("id", kit.FmtSize(s.Size())) + m.Push("type", strings.TrimPrefix(path.Ext(name), ".")) m.Push("name", path.Base(name)) m.Push("text", name) } @@ -192,7 +195,7 @@ var Index = &ice.Context{Name: "nfs", Help: "存储模块", }})) }}, - "dir": {Name: "dir", Help: "目录", List: kit.List( + "dir": {Name: "dir name field auto", Help: "目录", List: kit.List( kit.MDB_INPUT, "text", "name", "path", "action", "auto", kit.MDB_INPUT, "button", "name", "查看", kit.MDB_INPUT, "button", "name", "返回", "cb", "Last", diff --git a/core/chat/chat.go b/core/chat/chat.go index 92dd161c..ca307ffc 100644 --- a/core/chat/chat.go +++ b/core/chat/chat.go @@ -94,7 +94,6 @@ var Index = &ice.Context{Name: "chat", Help: "聊天中心", m.Load() m.Watch(ice.SYSTEM_INIT, m.Prefix("init")) m.Watch(ice.USER_CREATE, m.Prefix("auto")) - }}, ice.ICE_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { m.Save("river") @@ -545,6 +544,11 @@ var Index = &ice.Context{Name: "chat", Help: "聊天中心", }}, "search": {Name: "search label pod engine word", Help: "搜索引擎", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + if len(arg) < 2 { + m.Cmdy(ice.WEB_LABEL, arg) + return + } + switch arg[0] { case "add": if m.Richs("search", nil, arg[1], nil) == nil { @@ -579,6 +583,18 @@ var Index = &ice.Context{Name: "chat", Help: "聊天中心", }) }) default: + if len(arg) == 2 { + m.Richs("search", nil, "*", func(key string, value map[string]interface{}) { + m.Push(key, value) + }) + break + } + if len(arg) == 3 { + m.Richs("search", nil, "*", func(key string, value map[string]interface{}) { + m.Push(key, value) + }) + break + } m.Cmdy(ice.WEB_LABEL, arg[0], arg[1], "web.chat.search", "get", arg[2:]) } }}, diff --git a/misc/vim/vim.go b/misc/vim/vim.go index d55ab781..8bb11b7c 100644 --- a/misc/vim/vim.go +++ b/misc/vim/vim.go @@ -29,7 +29,7 @@ var Index = &ice.Context{Name: "vim", Help: "编辑器", m.Conf(ice.WEB_FAVOR, "meta.render.vimrc", m.AddCmd(&ice.Command{Name: "render favor id", Help: "渲染引擎", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { value := m.Optionv("value").(map[string]interface{}) switch value["name"] { - case "read": + case "read", "write", "exec": p := path.Join(kit.Format(kit.Value(value, "extra.pwd")), kit.Format(kit.Value(value, "extra.buf"))) f, e := os.Open(p) m.Assert(e) @@ -37,8 +37,6 @@ var Index = &ice.Context{Name: "vim", Help: "编辑器", b, e := ioutil.ReadAll(f) m.Assert(e) m.Echo(string(b)) - case "write": - case "exec": } }})) }}, diff --git a/misc/zsh/zsh.go b/misc/zsh/zsh.go index 9cdb34ef..663cb3e2 100644 --- a/misc/zsh/zsh.go +++ b/misc/zsh/zsh.go @@ -17,6 +17,17 @@ var Index = &ice.Context{Name: "zsh", Help: "命令行", "zsh": {Name: "zsh", Help: "命令行", Value: kit.Data("history", "zsh.history")}, }, Commands: map[string]*ice.Command{ + ice.ICE_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + m.Conf(ice.WEB_FAVOR, "meta.render.shell", m.AddCmd(&ice.Command{Name: "render favor id", Help: "渲染引擎", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + value := m.Optionv("value").(map[string]interface{}) + m.Option("cmd_dir", kit.Value(value, "extra.pwd")) + m.Cmdy(ice.CLI_SYSTEM, value["text"]) + }})) + m.Conf(ice.WEB_FAVOR, "meta.render.cmd", m.AddCmd(&ice.Command{Name: "render favor id", Help: "渲染引擎", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + value := m.Optionv("value").(map[string]interface{}) + m.Cmdy(kit.Split(kit.Format(value["text"]))) + }})) + }}, ice.WEB_LOGIN: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { if f, _, e := m.R.FormFile("sub"); e == nil { defer f.Close()