From 21f899b0720fd994197671f27709121f4135618a Mon Sep 17 00:00:00 2001 From: shaoying Date: Tue, 24 Dec 2019 01:33:14 +0800 Subject: [PATCH] add dream --- base/web/web.go | 438 ++++++++++++++++++++++++++++++---------------- conf.go | 14 +- core/chat/chat.go | 2 +- core/code/code.go | 6 +- core/mall/mall.go | 6 +- core/team/team.go | 2 +- core/wiki/wiki.go | 13 +- 7 files changed, 311 insertions(+), 170 deletions(-) diff --git a/base/web/web.go b/base/web/web.go index 10352680..48120780 100644 --- a/base/web/web.go +++ b/base/web/web.go @@ -9,6 +9,7 @@ import ( "encoding/json" "fmt" "io" + "io/ioutil" "math/rand" "net" "net/http" @@ -315,7 +316,7 @@ func (web *Frame) Close(m *ice.Message, arg ...string) bool { var Index = &ice.Context{Name: "web", Help: "网页模块", Caches: map[string]*ice.Cache{}, Configs: map[string]*ice.Config{ - ice.WEB_SPIDE: {Name: "spide", Help: "客户端", Value: kit.Data("self.port", ice.WEB_PORT)}, + ice.WEB_SPIDE: {Name: "spide", Help: "客户端", Value: kit.Data("self.port", ice.WEB_PORT, kit.MDB_SHORT, "name")}, ice.WEB_SERVE: {Name: "serve", Help: "服务器", Value: kit.Data( "static", map[string]interface{}{"/": "usr/volcanos/", "/static/volcanos/": "usr/volcanos/", @@ -330,27 +331,98 @@ var Index = &ice.Context{Name: "web", Help: "网页模块", "buffer.r", 4096, "buffer.w", 4096, kit.MDB_SHORT, "name", )}, + ice.WEB_DREAM: {Name: "dream", Help: "梦想家", Value: kit.Data( + "path", "usr/local/work", + "cmd", []interface{}{"cli.system", "sh", "ice.sh", "start", "web.space", "connect"}, + )}, + ice.WEB_FAVOR: {Name: "favor", Help: "收藏夹", Value: kit.Data(kit.MDB_SHORT, kit.MDB_NAME)}, + ice.WEB_CACHE: {Name: "cache", Help: "缓存池", Value: kit.Data( + kit.MDB_SHORT, "text", "path", "var/file", + "store", "var/data", "limit", "30", "least", "10", + )}, ice.WEB_STORY: {Name: "story", Help: "故事会", Value: kit.Dict( kit.MDB_META, kit.Dict(kit.MDB_SHORT, "data", "download", `%s`), "head", kit.Data(kit.MDB_SHORT, "story"), )}, - ice.WEB_CACHE: {Name: "cache", Help: "缓存", Value: kit.Data( - kit.MDB_SHORT, "text", "path", "var/file", - "store", "var/data", "limit", "30", "least", "10", - )}, - ice.WEB_ROUTE: {Name: "route", Help: "路由", Value: kit.Data()}, - ice.WEB_PROXY: {Name: "proxy", Help: "代理", Value: kit.Data()}, - ice.WEB_FAVOR: {Name: "favor", Help: "收藏", Value: kit.Data(kit.MDB_SHORT, kit.MDB_NAME)}, - ice.WEB_SHARE: {Name: "share", Help: "共享", Value: kit.Data( + ice.WEB_SHARE: {Name: "share", Help: "共享链", Value: kit.Data( "href", `%s`, "template", share_template, )}, + ice.WEB_ROUTE: {Name: "route", Help: "路由表", Value: kit.Data()}, + ice.WEB_PROXY: {Name: "proxy", Help: "代理商", Value: kit.Data()}, }, Commands: map[string]*ice.Command{ ice.ICE_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {}}, ice.ICE_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { m.Done() }}, ice.WEB_SPIDE: {Name: "spide", Help: "客户端", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + if len(arg) == 0 { + // 爬虫列表 + m.Richs(ice.WEB_SPIDE, nil, "", func(key string, value map[string]interface{}) { + m.Push("name", value["name"]) + m.Push(key, value["client"], []string{"method", "protocol", "hostname", "path", "file"}) + }) + return + } + switch arg[0] { + case "add": + // 添加爬虫 + if uri, e := url.Parse(arg[2]); e == nil && arg[2] != "" { + dir, file := path.Split(uri.EscapedPath()) + m.Rich(ice.WEB_SPIDE, nil, kit.Dict( + "name", arg[1], + "cookie", kit.Dict(), + "header", kit.Dict(), + "client", kit.Dict( + "logheaders", false, + "timeout", "100s", + "method", "GET", + "protocol", uri.Scheme, + "hostname", uri.Host, + "path", dir, + "file", file, + "query", uri.RawQuery, + "url", arg[2], + ), + )) + } + default: + m.Richs(ice.WEB_SPIDE, nil, arg[0], func(key string, value map[string]interface{}) { + client := value["client"].(map[string]interface{}) + method := kit.Select("GET", client["method"]) + uri := kit.MergeURL(kit.Format(client["url"]), arg[1:]) + + body, ok := m.Optionv("body").(io.Reader) + if !ok && method == "POST" { + if ls := strings.Split(uri, "?"); len(ls) > 0 { + uri, body = ls[0], bytes.NewReader([]byte(ls[1])) + } + } + + req, e := http.NewRequest(method, uri, body) + m.Log("info", "%s %s", req.Method, req.URL) + m.Assert(e) + + web := m.Target().Server().(*Frame) + if web.Client == nil { + web.Client = &http.Client{Timeout: kit.Duration(kit.Format(client["timeout"]))} + } + + // 发送请求 + res, e := web.Client.Do(req) + if m.Warn(e != nil, "%s", e) { + return + } + + if m.Warn(res.StatusCode != http.StatusOK, "%s", res.Status) { + return + } + + if buf, e := ioutil.ReadAll(res.Body); m.Assert(e) { + m.Echo(string(buf)) + } + }) + } }}, ice.WEB_SERVE: {Name: "serve", Help: "服务器", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { m.Conf(ice.CLI_RUNTIME, "node.name", m.Conf(ice.CLI_RUNTIME, "boot.hostname")) @@ -385,7 +457,7 @@ var Index = &ice.Context{Name: "web", Help: "网页模块", user := m.Conf(ice.CLI_RUNTIME, "boot.username") host := kit.Select(m.Conf(ice.WEB_SPIDE, "meta.self.port"), arg, 1) - if u, e := url.Parse(kit.MergeURL("ws://"+host+kit.Select("/space", arg, 2), "node", node, "name", name, "user", user)); m.Assert(e) { + if u, e := url.Parse(kit.MergeURL("ws://"+host+kit.Select("/space/", arg, 2), "node", node, "name", name, "user", user)); m.Assert(e) { for i := 0; i < m.Confi(ice.WEB_SPACE, "meta.redial.c"); i++ { if s, e := net.Dial("tcp", host); !m.Warn(e != nil, "%s", e) { if s, _, e := websocket.NewClient(s, u, nil, m.Confi(ice.WEB_SPACE, "meta.buffer.r"), m.Confi(ice.WEB_SPACE, "meta.buffer.w")); !m.Warn(e != nil, "%s", e) { @@ -433,7 +505,188 @@ var Index = &ice.Context{Name: "web", Help: "网页模块", }) == nil, "not found %s", arg[0]) } }}, - ice.WEB_STORY: {Name: "story", Help: "故事会", Meta: kit.Dict("exports", []string{"top", "story"}), List: kit.List( + ice.WEB_DREAM: {Name: "dream", Help: "梦想家", Meta: kit.Dict( + "exports", []interface{}{"you", "name"}, + "detail", []interface{}{"启动", "停止"}, + ), List: kit.List( + kit.MDB_INPUT, "text", "value", "", "name", "name", + kit.MDB_INPUT, "text", "value", "", "name", "type", + kit.MDB_INPUT, "button", "value", "创建", "action", "auto", + ), Hand: func(m *ice.Message, c *ice.Context, key string, arg ...string) { + if len(arg) > 1 { + switch arg[1] { + case "启动": + case "停止": + m.Cmd(ice.WEB_SPACE, arg[0], "exit", "1") + m.Cmd(ice.GDB_EVENT, "action", "miss.stop", arg[0]) + return + } + } + + if len(arg) > 0 { + // 规范命名 + if !strings.Contains(arg[0], "-") { + arg[0] = m.Time("20060102-") + arg[0] + } + + // 创建目录 + p := path.Join(m.Conf(ice.WEB_DREAM, "meta.path"), arg[0]) + if _, e := os.Stat(p); e != nil { + os.MkdirAll(p, 0777) + } + + if m.Richs(ice.WEB_SPACE, nil, arg[0], nil) == nil { + // 启动任务 + m.Option("cmd_dir", p) + m.Option("cmd_type", "daemon") + m.Cmd(ice.GDB_EVENT, "action", "miss.start", arg[0]) + m.Cmd(m.Confv(ice.WEB_DREAM, "meta.cmd")) + } + } + + // 任务列表 + m.Cmdy("nfs.dir", m.Conf(ice.WEB_DREAM, "meta.path"), "", "time name") + m.Table(func(index int, value map[string]string, head []string) { + m.Push("status", kit.Select("start", "stop", m.Richs(ice.WEB_SPACE, nil, value["name"], nil) == nil)) + }) + }}, + ice.WEB_FAVOR: {Name: "favor", Help: "收藏夹", Meta: kit.Dict( + "remote", "you", + "exports", []string{"hot", "favor"}, + ), List: kit.List( + kit.MDB_INPUT, "text", "name", "hot", "action", "auto", + kit.MDB_INPUT, "text", "name", "id", "action", "auto", + kit.MDB_INPUT, "button", "value", "查看", "action", "auto", + kit.MDB_INPUT, "button", "value", "返回", "cb", "Last", + ), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + if len(arg) == 0 { + // 收藏门类 + m.Richs(ice.WEB_FAVOR, nil, "", func(key string, value map[string]interface{}) { + m.Push("time", kit.Value(value, "meta.time")) + m.Push("favor", kit.Value(value, "meta.name")) + m.Push("count", kit.Value(value, "meta.count")) + }) + return + } + + if len(arg) > 1 { + switch arg[1] { + case "modify": + // 编辑收藏 + m.Richs(ice.WEB_FAVOR, nil, m.Option("hot"), func(key string, value map[string]interface{}) { + m.Grows(ice.WEB_FAVOR, kit.Keys(kit.MDB_HASH, key), "id", m.Option("id"), func(index int, value map[string]interface{}) { + m.Info("modify favor: %s index: %d value: %v->%v", key, index, value[arg[2]], arg[3]) + kit.Value(value, arg[2], arg[3]) + }) + }) + return + } + } + + // 创建收藏 + favor := "" + if m.Richs(ice.WEB_FAVOR, nil, arg[0], func(key string, value map[string]interface{}) { + favor = key + }) == nil { + favor = m.Rich(ice.WEB_FAVOR, nil, kit.Data(kit.MDB_NAME, arg[0])) + m.Info("create favor: %s name: %s", favor, arg[0]) + } + + if len(arg) == 1 { + // 收藏列表 + m.Grows(ice.WEB_FAVOR, kit.Keys(kit.MDB_HASH, favor), "", "", func(index int, value map[string]interface{}) { + m.Push(kit.Format(index), value, []string{kit.MDB_TIME, kit.MDB_ID, kit.MDB_TYPE, kit.MDB_NAME}) + switch kit.Format(value[kit.MDB_TYPE]) { + case kit.MIME_STORY: + m.Push(kit.MDB_TEXT, kit.Format(m.Conf(ice.WEB_STORY, kit.Keys(kit.MDB_META, "download")), + value[kit.MDB_TEXT], value[kit.MDB_TEXT])) + default: + m.Push(kit.MDB_TEXT, value[kit.MDB_TEXT]) + } + }) + return + } + + if len(arg) == 2 { + // 收藏详情 + m.Grows(ice.WEB_FAVOR, kit.Keys(kit.MDB_HASH, favor), "id", arg[1], func(index int, value map[string]interface{}) { + for k, v := range value { + m.Push("key", k).Push("value", v) + } + m.Sort("key") + }) + return + } + if arg[1] == "file" { + arg[1] = kit.MIME_FILE + } + + // 添加收藏 + index := m.Grow(ice.WEB_FAVOR, kit.Keys(kit.MDB_HASH, favor), kit.Dict( + kit.MDB_TYPE, arg[1], kit.MDB_NAME, arg[2], kit.MDB_TEXT, arg[3], + )) + m.Info("create favor: %s index: %d name: %s", favor, index, arg[2]) + m.Echo("%d", index) + }}, + ice.WEB_CACHE: {Name: "cache", Help: "缓存池", Meta: kit.Dict("remote", "you"), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + if len(arg) == 0 { + // 缓存列表 + m.Richs(ice.WEB_CACHE, nil, "", func(key string, value map[string]interface{}) { + m.Push(key, value, []string{kit.MDB_TIME, kit.MDB_NAME, kit.MDB_SIZE, kit.MDB_TYPE, kit.MDB_TEXT}) + }) + return + } + + switch arg[0] { + case "upload": + // 打开文件 + r := m.Optionv("request").(*http.Request) + if f, h, e := r.FormFile(kit.Select("upload", arg, 1)); m.Assert(e) { + defer f.Close() + + // 创建文件 + file := kit.Hashs(f) + if o, p, e := kit.Create(path.Join(m.Conf(ice.WEB_CACHE, ice.Meta("path")), file[:2], file)); m.Assert(e) { + defer o.Close() + + // 保存文件 + f.Seek(0, os.SEEK_SET) + if n, e := io.Copy(o, f); m.Assert(e) { + m.Info("upload: %s file: %s", kit.FmtSize(n), p) + arg = kit.Simple(arg[0], h.Header.Get("Content-Type"), h.Filename, p, p, n) + } + } + } + fallthrough + case "add": + // 添加数据 + size := kit.Select(kit.Format(len(arg[3])), arg, 5) + h := m.Rich(ice.WEB_CACHE, nil, kit.Dict( + kit.MDB_TYPE, arg[1], kit.MDB_NAME, arg[2], kit.MDB_TEXT, arg[3], + kit.MDB_FILE, kit.Select("", arg, 4), + kit.MDB_SIZE, size, arg[1], arg[3], + )) + m.Info("cache: %s type: %s name: %s", h, arg[1], arg[2]) + + // 返回结果 + m.Push("time", m.Time()) + m.Push("type", arg[1]) + m.Push("name", arg[2]) + m.Push("text", arg[3]) + m.Push("size", size) + m.Push("data", h) + + // 保存数据 + if arg[0] == "add" { + m.Cmd("nfs.save", path.Join(m.Conf(ice.WEB_CACHE, ice.Meta("path")), h[:2], h), arg[3]) + } + default: + } + }}, + ice.WEB_STORY: {Name: "story", Help: "故事会", Meta: kit.Dict( + "remote", "you", + "exports", []string{"top", "story"}, + ), List: kit.List( kit.MDB_INPUT, "text", "name", "top", "action", "auto", kit.MDB_INPUT, "button", "value", "查看", "action", "auto", kit.MDB_INPUT, "button", "value", "返回", "cb", "Last", @@ -520,9 +773,6 @@ var Index = &ice.Context{Name: "web", Help: "网页模块", }) m.Echo(list) - case "share": - m.Cmdy(ice.WEB_SHARE, arg[1:]) - case "history": // 历史记录 list := m.Cmd(ice.WEB_STORY, "index", arg[1]).Append("list") @@ -582,141 +832,7 @@ var Index = &ice.Context{Name: "web", Help: "网页模块", }) } }}, - ice.WEB_CACHE: {Name: "cache", Help: "缓存", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { - if len(arg) == 0 { - // 缓存列表 - m.Richs(ice.WEB_CACHE, nil, "", func(key string, value map[string]interface{}) { - m.Push(key, value, []string{kit.MDB_TIME, kit.MDB_NAME, kit.MDB_SIZE, kit.MDB_TYPE, kit.MDB_TEXT}) - }) - return - } - - switch arg[0] { - case "upload": - // 打开文件 - r := m.Optionv("request").(*http.Request) - if f, h, e := r.FormFile(kit.Select("upload", arg, 1)); m.Assert(e) { - defer f.Close() - - // 创建文件 - file := kit.Hashs(f) - if o, p, e := kit.Create(path.Join(m.Conf(ice.WEB_CACHE, ice.Meta("path")), file[:2], file)); m.Assert(e) { - defer o.Close() - - // 保存文件 - f.Seek(0, os.SEEK_SET) - if n, e := io.Copy(o, f); m.Assert(e) { - m.Info("upload: %s file: %s", kit.FmtSize(n), p) - arg = kit.Simple(arg[0], h.Header.Get("Content-Type"), h.Filename, p, p, n) - } - } - } - fallthrough - case "add": - // 添加数据 - size := kit.Select(kit.Format(len(arg[3])), arg, 5) - h := m.Rich(ice.WEB_CACHE, nil, kit.Dict( - kit.MDB_TYPE, arg[1], kit.MDB_NAME, arg[2], kit.MDB_TEXT, arg[3], - kit.MDB_FILE, kit.Select("", arg, 4), - kit.MDB_SIZE, size, arg[1], arg[3], - )) - m.Info("cache: %s type: %s name: %s", h, arg[1], arg[2]) - - // 返回结果 - m.Push("time", m.Time()) - m.Push("type", arg[1]) - m.Push("name", arg[2]) - m.Push("text", arg[3]) - m.Push("size", size) - m.Push("data", h) - - // 保存数据 - if arg[0] == "add" { - m.Cmd("nfs.save", path.Join(m.Conf(ice.WEB_CACHE, ice.Meta("path")), h[:2], h), arg[3]) - } - default: - } - }}, - ice.WEB_ROUTE: {Name: "route", Help: "路由", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { - }}, - ice.WEB_PROXY: {Name: "proxy", Help: "代理", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { - }}, - ice.WEB_FAVOR: {Name: "favor", Help: "收藏", Meta: kit.Dict("exports", []string{"hot", "favor"}), List: kit.List( - kit.MDB_INPUT, "text", "name", "hot", "action", "auto", - kit.MDB_INPUT, "text", "name", "id", "action", "auto", - kit.MDB_INPUT, "button", "value", "查看", "action", "auto", - kit.MDB_INPUT, "button", "value", "返回", "cb", "Last", - ), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { - if len(arg) == 0 { - // 收藏门类 - m.Richs(ice.WEB_FAVOR, nil, "", func(key string, value map[string]interface{}) { - m.Push("time", kit.Value(value, "meta.time")) - m.Push("favor", kit.Value(value, "meta.name")) - m.Push("count", kit.Value(value, "meta.count")) - }) - return - } - - if len(arg) > 1 { - switch arg[1] { - case "modify": - // 编辑收藏 - m.Richs(ice.WEB_FAVOR, nil, m.Option("hot"), func(key string, value map[string]interface{}) { - m.Grows(ice.WEB_FAVOR, kit.Keys(kit.MDB_HASH, key), "id", m.Option("id"), func(index int, value map[string]interface{}) { - m.Info("modify favor: %s index: %d value: %v->%v", key, index, value[arg[2]], arg[3]) - kit.Value(value, arg[2], arg[3]) - }) - }) - return - } - } - - // 创建收藏 - favor := "" - if m.Richs(ice.WEB_FAVOR, nil, arg[0], func(key string, value map[string]interface{}) { - favor = key - }) == nil { - favor = m.Rich(ice.WEB_FAVOR, nil, kit.Data(kit.MDB_NAME, arg[0])) - m.Info("create favor: %s name: %s", favor, arg[0]) - } - - if len(arg) == 1 { - // 收藏列表 - m.Grows(ice.WEB_FAVOR, kit.Keys(kit.MDB_HASH, favor), "", "", func(index int, value map[string]interface{}) { - m.Push(kit.Format(index), value, []string{kit.MDB_TIME, kit.MDB_ID, kit.MDB_TYPE, kit.MDB_NAME}) - switch kit.Format(value[kit.MDB_TYPE]) { - case kit.MIME_STORY: - m.Push(kit.MDB_TEXT, kit.Format(m.Conf(ice.WEB_STORY, kit.Keys(kit.MDB_META, "download")), - value[kit.MDB_TEXT], value[kit.MDB_TEXT])) - default: - m.Push(kit.MDB_TEXT, value[kit.MDB_TEXT]) - } - }) - return - } - - if len(arg) == 2 { - // 收藏详情 - m.Grows(ice.WEB_FAVOR, kit.Keys(kit.MDB_HASH, favor), "id", arg[1], func(index int, value map[string]interface{}) { - for k, v := range value { - m.Push("key", k).Push("value", v) - } - m.Sort("key") - }) - return - } - if arg[1] == "file" { - arg[1] = kit.MIME_FILE - } - - // 添加收藏 - index := m.Grow(ice.WEB_FAVOR, kit.Keys(kit.MDB_HASH, favor), kit.Dict( - kit.MDB_TYPE, arg[1], kit.MDB_NAME, arg[2], kit.MDB_TEXT, arg[3], - )) - m.Info("create favor: %s index: %d name: %s", favor, index, arg[2]) - m.Echo("%d", index) - }}, - ice.WEB_SHARE: {Name: "share", Help: "共享", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + ice.WEB_SHARE: {Name: "share", Help: "共享链", Meta: kit.Dict("remote", "you"), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { if len(arg) == 0 { // 共享列表 m.Richs(ice.WEB_SHARE, nil, "", func(key string, value map[string]interface{}) { @@ -733,8 +849,12 @@ var Index = &ice.Context{Name: "web", Help: "网页模块", m.Info("share: %s", h) m.Echo(h) }}, + ice.WEB_ROUTE: {Name: "route", Help: "路由表", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }}, + ice.WEB_PROXY: {Name: "proxy", Help: "代理商", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + }}, - "/share/": {Name: "/share", Help: "共享", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + "/proxy/": {Name: "/proxy/", Help: "代理商", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { key := kit.Select("", strings.Split(cmd, "/"), 2) m.Confm(ice.WEB_SHARE, kit.Keys("hash", key), func(value map[string]interface{}) { m.Info("share %s %v", key, kit.Format(value)) @@ -750,7 +870,23 @@ var Index = &ice.Context{Name: "web", Help: "网页模块", }) }}, - "/space": {Name: "/space", Help: "空间站", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + "/share/": {Name: "/share/", Help: "共享链", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + key := kit.Select("", strings.Split(cmd, "/"), 2) + m.Confm(ice.WEB_SHARE, kit.Keys("hash", key), func(value map[string]interface{}) { + m.Info("share %s %v", key, kit.Format(value)) + switch value["type"] { + case kit.MIME_STORY: + m.Cmdy(ice.WEB_STORY, "index", value["text"]).Push("_output", "file") + return + default: + m.Push("_output", "result").Push(key, value) + m.Render(m.Conf(ice.WEB_SHARE, kit.Keys(kit.MDB_META, "template", value["type"]))) + m.Append("type", "text/html") + } + + }) + }}, + "/space/": {Name: "/space/", Help: "空间站", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { r := m.Optionv("request").(*http.Request) w := m.Optionv("response").(http.ResponseWriter) diff --git a/conf.go b/conf.go index 9d575e0d..f16c3b99 100644 --- a/conf.go +++ b/conf.go @@ -49,12 +49,13 @@ const ( WEB_SPIDE = "spide" WEB_SERVE = "serve" WEB_SPACE = "space" - WEB_STORY = "story" + WEB_DREAM = "dream" + WEB_FAVOR = "favor" WEB_CACHE = "cache" + WEB_STORY = "story" + WEB_SHARE = "share" WEB_ROUTE = "route" WEB_PROXY = "proxy" - WEB_FAVOR = "favor" - WEB_SHARE = "share" ) const ( LOG_CMD = "cmd" @@ -93,12 +94,13 @@ var Alias = map[string]string{ WEB_SPIDE: "web.spide", WEB_SERVE: "web.serve", WEB_SPACE: "web.space", - WEB_STORY: "web.story", + WEB_DREAM: "web.dream", + WEB_FAVOR: "web.favor", WEB_CACHE: "web.cache", + WEB_STORY: "web.story", + WEB_SHARE: "web.share", WEB_ROUTE: "web.route", WEB_PROXY: "web.proxy", - WEB_FAVOR: "web.favor", - WEB_SHARE: "web.share", GDB_SIGNAL: "gdb.signal", GDB_TIMER: "gdb.timer", diff --git a/core/chat/chat.go b/core/chat/chat.go index fd73f459..bdc9357a 100644 --- a/core/chat/chat.go +++ b/core/chat/chat.go @@ -20,7 +20,7 @@ var Index = &ice.Context{Name: "chat", Help: "聊天模块", }}, ice.ICE_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { m.Cmd(ice.CTX_CONFIG, "save", "chat.json", ice.CHAT_GROUP) - m.Cmd(ice.CTX_CONFIG, "save", "web.json", ice.WEB_STORY, ice.WEB_CACHE, ice.WEB_FAVOR, ice.WEB_SHARE) + m.Cmd(ice.CTX_CONFIG, "save", "web.json", ice.WEB_SPIDE, ice.WEB_FAVOR, ice.WEB_CACHE, ice.WEB_STORY, ice.WEB_SHARE) m.Cmd(ice.CTX_CONFIG, "save", "aaa.json", ice.AAA_ROLE, ice.AAA_USER, ice.AAA_SESS) }}, diff --git a/core/code/code.go b/core/code/code.go index 39c07bc5..faf65138 100644 --- a/core/code/code.go +++ b/core/code/code.go @@ -77,7 +77,7 @@ var Index = &ice.Context{Name: "code", Help: "编程模块", m.Cmdy(ice.WEB_STORY, "download", m.Optionv("arg")) } }}, - "tmux": {Name: "tmux [session [window [pane cmd]]]", Help: "窗口", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + "_tmux": {Name: "tmux [session [window [pane cmd]]]", Help: "窗口", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { prefix := kit.Simple(m.Confv("prefix", "tmux")) if len(arg) > 1 { switch arg[1] { @@ -111,7 +111,7 @@ var Index = &ice.Context{Name: "code", Help: "编程模块", } return }}, - "docker": {Name: "docker image|volume|network|container", Help: "容器", Hand: func(m *ice.Message, c *ice.Context, key string, arg ...string) { + "_docker": {Name: "docker image|volume|network|container", Help: "容器", Hand: func(m *ice.Message, c *ice.Context, key string, arg ...string) { prefix := kit.Simple(m.Confv("prefix", "docker")) switch arg[0] { case "image": @@ -226,7 +226,7 @@ var Index = &ice.Context{Name: "code", Help: "编程模块", } return }}, - "git": {Name: "git init|diff|status|commit|branch|remote|pull|push|sum", Help: "版本", Hand: func(m *ice.Message, c *ice.Context, key string, arg ...string) { + "_git": {Name: "git init|diff|status|commit|branch|remote|pull|push|sum", Help: "版本", Hand: func(m *ice.Message, c *ice.Context, key string, arg ...string) { prefix, arg := append(kit.Simple(m.Confv("prefix", "git")), "cmd_dir", kit.Select(".", arg[0])), arg[1:] switch arg[0] { diff --git a/core/mall/mall.go b/core/mall/mall.go index 4f6bc64f..f1f0b655 100644 --- a/core/mall/mall.go +++ b/core/mall/mall.go @@ -16,7 +16,7 @@ var Index = &ice.Context{Name: "mall", Help: "团队模块", Caches: map[string]*ice.Cache{}, Configs: map[string]*ice.Config{}, Commands: map[string]*ice.Command{ - "miss": {Name: "miss", Help: "任务", Meta: map[string]interface{}{ + "_miss": {Name: "miss", Help: "任务", Meta: map[string]interface{}{ "exports": []interface{}{"you", "name"}, "detail": []interface{}{"启动", "停止"}, }, List: []interface{}{ @@ -55,7 +55,7 @@ var Index = &ice.Context{Name: "mall", Help: "团队模块", m.Push("status", kit.Select("stop", "start", m.Confs("web.space", "hash."+value["name"]))) }) }}, - "task": {Name: "task", Help: "任务", + "_task": {Name: "task", Help: "任务", Meta: map[string]interface{}{ "remote": "true", }, @@ -80,7 +80,7 @@ var Index = &ice.Context{Name: "mall", Help: "团队模块", case "cancel": } }}, - "process": {Name: "process", Help: "任务进度", Meta: map[string]interface{}{ + "_process": {Name: "process", Help: "任务进度", Meta: map[string]interface{}{ "remote": "true", "detail": []string{"编辑", "准备", "开始", "取消", "完成"}, }, List: []interface{}{ diff --git a/core/team/team.go b/core/team/team.go index 7829bc68..9d51a9a0 100644 --- a/core/team/team.go +++ b/core/team/team.go @@ -62,7 +62,7 @@ var Index = &ice.Context{Name: "team", Help: "团队模块", // 任务列表 m.Cmdy("nfs.dir", m.Conf("miss", "meta.path"), "", "time name") m.Table(func(index int, value map[string]string, head []string) { - m.Push("status", kit.Select("stop", "start", m.Confs(ice.WEB_SPACE, kit.Keys("hash", value["name"])))) + m.Push("status", kit.Select("start", "stop", m.Richs(ice.WEB_SPACE, nil, value["name"], nil) == nil)) }) }}, }, diff --git a/core/wiki/wiki.go b/core/wiki/wiki.go index b8a14492..10fcda7f 100644 --- a/core/wiki/wiki.go +++ b/core/wiki/wiki.go @@ -163,17 +163,20 @@ var Index = &ice.Context{Name: "wiki", Help: "文档模块", }}, "note": {Name: "note file", Help: "笔记", Meta: map[string]interface{}{ "remote": "you", "display": "inner", - "detail": []string{"add", "commit", "history", "share"}, + "detail": []string{"add", "commit", "history", "share", "favor"}, }, List: kit.List( kit.MDB_INPUT, "text", "value", "miss.md", "name", "path", kit.MDB_INPUT, "button", "value", "执行", "action", "auto", kit.MDB_INPUT, "button", "value", "返回", "cb", "Last", ), Hand: func(m *ice.Message, c *ice.Context, key string, arg ...string) { - if len(arg) > 0 { - switch arg[0] { - case "story": + if len(arg) > 1 { + switch arg[1] { + case "favor": + m.Cmdy(ice.WEB_FAVOR, kit.Select("story", m.Option("hot")), arg[2:]) + case "share": + m.Cmdy(ice.WEB_SHARE, arg[2:]) + default: m.Cmdy(arg) - return } } m.Cmdy(kit.Select("_tree", "_text", len(arg) > 0 && strings.HasSuffix(arg[0], ".md")), arg)