diff --git a/base/ctx/command.go b/base/ctx/command.go index 315dc640..8710a676 100644 --- a/base/ctx/command.go +++ b/base/ctx/command.go @@ -45,6 +45,7 @@ func _command_search(m *ice.Message, kind, name, text string) { const ( INDEX = "index" + CMDS = "cmds" ARGS = "args" OPTS = "opts" STYLE = "style" diff --git a/base/nfs/dir.go b/base/nfs/dir.go index cfc7f0ec..fe5ce472 100644 --- a/base/nfs/dir.go +++ b/base/nfs/dir.go @@ -103,7 +103,7 @@ func _dir_list(m *ice.Message, root string, dir string, level int, deep bool, di m.PushDownload(mdb.LINK, p) } case mdb.SHOW: - switch p := kit.MergeURL("/share/local/"+p, ice.POD, m.Option(ice.MSG_USERPOD)); kit.Ext(s.Name()) { + switch p := kit.MergeURL(ice.SHARE_LOCAL+p, ice.POD, m.Option(ice.MSG_USERPOD)); kit.Ext(s.Name()) { case PNG, JPG: m.PushImages(field, p) case MP4: @@ -188,10 +188,15 @@ func init() { aaa.White(m, ice.SRC, ice.BIN, ice.USR) aaa.Black(m, ice.USR_LOCAL) }}, - ice.APP: {Help: "本机", Hand: func(m *ice.Message, arg ...string) { m.Cmd("cli.system", "opens", "Finder.app") }}, + ice.APP: {Help: "本机", Hand: func(m *ice.Message, arg ...string) { + m.Cmd("cli.system", "opens", "Finder.app") + }}, mdb.SHOW: {Help: "预览", Hand: func(m *ice.Message, arg ...string) { Show(m.ProcessInner(), path.Join(m.Option(DIR_ROOT), m.Option(PATH))) }}, mdb.UPLOAD: {}, + SIZE: {Hand: func(m *ice.Message, arg ...string) { + m.Echo(kit.Select("", kit.Split(m.Cmdx("cli.system", "du", "-sh")), 0)) + }}, TRASH: {Hand: func(m *ice.Message, arg ...string) { m.Cmd(TRASH, mdb.CREATE, m.Option(PATH)) }}, }, Hand: func(m *ice.Message, arg ...string) { root, dir := kit.Select(PWD, m.Option(DIR_ROOT)), kit.Select(PWD, arg, 0) @@ -211,7 +216,7 @@ func init() { func Relative(m *ice.Message, p string) string { if _p := kit.ExtChange(p, JS); Exists(m, _p) { return _p - } else if _p := kit.ExtChange(path.Join(ice.USR_VOLCANOS, "plugin/local", path.Join(kit.Slice(kit.Split(p, "/"), -2)...)), JS); Exists(m, _p) { + } else if _p := kit.ExtChange(path.Join(ice.USR_VOLCANOS, ice.PLUGIN_LOCAL, path.Join(kit.Slice(kit.Split(p, PS), -2)...)), JS); Exists(m, _p) { return _p } else { return p @@ -250,8 +255,10 @@ func DirDeepAll(m *ice.Message, root, dir string, cb func(ice.Maps), arg ...stri } } func Show(m *ice.Message, file string) bool { - p := "/share/local/" + file - kit.If(m.Option(ice.MSG_USERPOD), func(pod string) { p += "?pod=" + pod }) + p := ice.SHARE_LOCAL + file + kit.If(m.Option(ice.MSG_USERPOD), func(pod string) { + p += "?" + kit.JoinKV("=", "&", ice.POD, pod) + }) switch strings.ToLower(kit.Ext(file)) { case PNG, JPG: m.EchoImages(p) diff --git a/base/web/route.go b/base/web/route.go index 51aff1e4..213ef870 100644 --- a/base/web/route.go +++ b/base/web/route.go @@ -78,7 +78,7 @@ func init() { "spide": {Help: "导图", Hand: func(m *ice.Message, arg ...string) { ctx.DisplayStorySpide(m.Cmdy(""), nfs.DIR_ROOT, ice.Info.NodeName, mdb.FIELD, SPACE, lex.SPLIT, nfs.PT, ctx.ACTION, ice.MAIN) }}, - "cmds": {Name: "cmds space index* args", Help: "命令", Hand: func(m *ice.Message, arg ...string) { + ctx.CMDS: {Name: "cmds space index* args", Help: "命令", Hand: func(m *ice.Message, arg ...string) { _route_toast(m, m.Option(SPACE), append([]string{m.Option(ctx.INDEX)}, kit.Split(m.Option(ctx.ARGS))...)...) }}, cli.BUILD: {Name: "build space", Help: "构建", Hand: func(m *ice.Message, arg ...string) { @@ -86,7 +86,7 @@ func init() { m.Sleep("1s").Cmdy("", "travel") }}, "_build": {Hand: func(m *ice.Message, arg ...string) { - if nfs.Exists(m, ".git") { + if _, err := nfs.DiskFile.StatFile(ice.SRC_MAIN_GO); err == nil && nfs.Exists(m, ".git") { m.Cmdy(CODE_VIMER, "compile") } else if ice.Info.NodeType == SERVER { m.Cmdy(CODE_UPGRADE) @@ -106,7 +106,7 @@ func init() { case "md5": m.Push(key, ice.Info.Hash) case nfs.SIZE: - m.Push(key, kit.Format("%s/%s", ice.Info.Size, kit.Select("", kit.Split(m.Cmdx(cli.SYSTEM, "du", "-sh")), 0))) + m.Push(key, kit.Format("%s/%s", ice.Info.Size, m.Cmdx(nfs.DIR, nfs.SIZE))) case mdb.TYPE: m.Push(key, ice.Info.NodeType) case nfs.PATH: @@ -143,8 +143,9 @@ func init() { stat[OFFLINE]++ } }) - m.Sort("status,space", ice.STR_R, ice.STR).StatusTimeCount(stat, nfs.SIZE, kit.FmtSize(size)) - m.Option(ice.MSG_ACTION, "") + m.Sort("status,space", ice.STR_R, ice.STR) + m.StatusTimeCount(stat, nfs.SIZE, kit.FmtSize(size)) + m.Options(ice.MSG_ACTION, "") } }}, }) diff --git a/base/web/spide.go b/base/web/spide.go index 0e83ffd1..6c45f211 100644 --- a/base/web/spide.go +++ b/base/web/spide.go @@ -299,7 +299,7 @@ func init() { SPIDE: {Help: "蜘蛛侠", Actions: ice.MergeActions(ice.Actions{ ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { conf := mdb.Confm(m, cli.RUNTIME, cli.CONF) - m.Cmd("", mdb.CREATE, ice.OPS, kit.Select("http://127.0.0.1:9020", conf[cli.CTX_OPS])) + m.Cmd("", mdb.CREATE, ice.OPS, kit.Select("http://localhost:9020", conf[cli.CTX_OPS])) m.Cmd("", mdb.CREATE, ice.DEV, kit.Select(kit.Select("https://contexts.com.cn", ice.Info.Make.Domain), conf[cli.CTX_DEV])) m.Cmd("", mdb.CREATE, ice.COM, kit.Select("https://contexts.com.cn", conf[cli.CTX_COM])) m.Cmd("", mdb.CREATE, ice.HUB, kit.Select("https://repos.shylinux.com", conf[cli.CTX_HUB])) diff --git a/conf.go b/conf.go index 7fd759cc..3cfe9f61 100644 --- a/conf.go +++ b/conf.go @@ -114,6 +114,7 @@ const ( // DIR REQUIRE_MODULES = "/require/modules/" REQUIRE_USR = "/require/usr/" REQUIRE_SRC = "/require/src/" + SHARE_LOCAL = "/share/local/" ISH_PLUGED = ".ish/pluged/" USR_MODULES = "usr/node_modules/" diff --git a/core/code/compile.go b/core/code/compile.go index 3738b5ca..eff3858b 100644 --- a/core/code/compile.go +++ b/core/code/compile.go @@ -93,7 +93,7 @@ func init() { case SERVICE: m.Push(arg[0], kit.MergeURL2(m.Cmd(web.SPIDE, ice.DEV).Append(web.CLIENT_ORIGIN), "/publish/")) case VERSION: - m.Push(arg[0], "1.13.5", "1.15.5", "1.17.3") + m.Push(arg[0], "1.13.5", "1.15.5", "1.17.3", "1.20.3") default: m.Cmdy(nfs.DIR, ice.SRC, nfs.DIR_CLI_FIELDS, kit.Dict(nfs.DIR_REG, kit.ExtReg(GO))) } @@ -125,7 +125,10 @@ func init() { } else { m.Logs(nfs.SAVE, nfs.TARGET, file, nfs.SOURCE, main) m.Cmdy(nfs.DIR, file, "time,path,size,hash,link") - kit.If(!m.IsCliUA() && strings.Contains(file, ice.ICE), func() { m.Cmdy(PUBLISH, ice.CONTEXTS, ice.APP) }) + kit.If(!m.IsCliUA() && strings.Contains(file, ice.ICE), func() { + defer m.EchoScript("docker run -p 20000:9020 -w /root -it alpine") + m.Cmdy(PUBLISH, ice.CONTEXTS, ice.APP) + }) } }}, }) diff --git a/misc/webview/webview.go b/misc/webview/webview.go index 442d8d85..709c6d31 100644 --- a/misc/webview/webview.go +++ b/misc/webview/webview.go @@ -9,6 +9,7 @@ import ( "shylinux.com/x/icebergs/base/lex" "shylinux.com/x/icebergs/base/nfs" "shylinux.com/x/icebergs/base/tcp" + "shylinux.com/x/icebergs/base/web" kit "shylinux.com/x/toolkits" "shylinux.com/x/webview" ) @@ -90,5 +91,5 @@ func Run(cb func(*WebView) ice.Any) { } else { kit.Reflect(cb(view), func(name string, value ice.Any) { w.Bind(name, value) }) } - kit.If(!view.Menu(), func() { view.navigate("http://localhost:9020") }) + kit.If(!view.Menu(), func() { view.navigate(ice.Pulse.Cmdv(web.SPIDE, ice.OPS, web.CLIENT_ORIGIN)) }) }