From 5bd4038d15028f9f95978e3eb0a2b91a90c2189d Mon Sep 17 00:00:00 2001 From: shy Date: Sat, 6 Apr 2024 22:32:14 +0800 Subject: [PATCH] add some --- base/ctx/command.go | 3 ++- base/nfs/dir.go | 8 ++++++-- base/web/dream.go | 7 ++++--- conf.go | 1 + core/code/inner.go | 21 ++++++++++----------- info.go | 14 ++++++++------ 6 files changed, 31 insertions(+), 23 deletions(-) diff --git a/base/ctx/command.go b/base/ctx/command.go index a5f5834a..361b695b 100644 --- a/base/ctx/command.go +++ b/base/ctx/command.go @@ -141,11 +141,12 @@ func FileCmd(dir string) string { return ice.Pulse.FileURI(kit.ExtChange(strings.Split(dir, nfs.DF)[0], nfs.GO)) } func AddFileCmd(dir, key string) { - ice.Info.File[FileCmd(dir)] = key if ls := strings.SplitN(path.Join(kit.Slice(kit.Split(FileCmd(dir), nfs.PS), 1, 4)...), mdb.AT, 2); len(ls) > 1 { _ls := strings.Split(FileCmd(dir), mdb.AT+ls[1]+nfs.PS) ice.Info.File[path.Join(nfs.REQUIRE_USR, path.Base(_ls[0]), _ls[1])] = key ice.Info.Gomod[ls[0]] = ls[1] + } else { + ice.Info.File[FileCmd(dir)] = key } } func GetFileCmd(dir string) string { diff --git a/base/nfs/dir.go b/base/nfs/dir.go index bee25962..7a8c8280 100644 --- a/base/nfs/dir.go +++ b/base/nfs/dir.go @@ -149,7 +149,9 @@ const ( ETC_CERT_PEM = "etc/cert/cert.pem" SRC_DOCUMENT = "src/document/" SRC_TEMPLATE = ice.SRC_TEMPLATE + USR_TOOLKITS = ice.USR_TOOLKITS USR_ICEBERGS = ice.USR_ICEBERGS + USR_RELEASE = ice.USR_RELEASE USR_PUBLISH = ice.USR_PUBLISH USR_LOCAL = ice.USR_LOCAL USR_LOCAL_WORK = ice.USR_LOCAL_WORK @@ -165,12 +167,14 @@ const ( USR_ICONS_VOLCANOS = "usr/icons/volcanos.png" USR_ICONS = "usr/icons/" + INTSHELL = "/intshell/" + VOLCANOS = "/volcanos/" + VOLCANOS_PLUGIN = "/volcanos/plugin/" REQUIRE_MODULES = "/require/modules/" REQUIRE_USR = "/require/usr/" REQUIRE_SRC = "/require/src/" REQUIRE = "/require/" - VOLCANOS = "/volcanos/" - INTSHELL = "/intshell/" + PLUGIN = "/plugin/" SHARE_LOCAL = "/share/local/" PATHNAME = "pathname" FILENAME = "filename" diff --git a/base/web/dream.go b/base/web/dream.go index 14f2b923..612d138a 100644 --- a/base/web/dream.go +++ b/base/web/dream.go @@ -334,9 +334,10 @@ func init() { "gowork": {Name: "gowork name", Help: "工作区", Hand: func(m *ice.Message, arg ...string) { m.Cmd(cli.SYSTEM, cli.GO, "work", "init") m.Cmd(cli.SYSTEM, cli.GO, "work", "use", ".") - DreamEach(m, m.Option(mdb.NAME), "", func(name string) { - m.Cmd(cli.SYSTEM, cli.GO, "work", "use", path.Join(ice.USR_LOCAL_WORK, name)) - }) + m.Cmd(cli.SYSTEM, cli.GO, "work", "use", nfs.USR_RELEASE) + m.Cmd(cli.SYSTEM, cli.GO, "work", "use", nfs.USR_ICEBERGS) + m.Cmd(cli.SYSTEM, cli.GO, "work", "use", nfs.USR_TOOLKITS) + DreamEach(m, m.Option(mdb.NAME), "", func(name string) { m.Cmd(cli.SYSTEM, cli.GO, "work", "use", path.Join(ice.USR_LOCAL_WORK, name)) }) }}, PUBLISH: {Name: "publish name", Hand: func(m *ice.Message, arg ...string) { m.Option(ice.MSG_TITLE, kit.Keys(m.Option(ice.MSG_USERPOD0), m.Option(ice.MSG_USERPOD), m.CommandKey(), m.ActionKey())) diff --git a/conf.go b/conf.go index 3d9e1321..88b775b9 100644 --- a/conf.go +++ b/conf.go @@ -117,6 +117,7 @@ const ( // DIR PLUGIN_LOCAL = "/plugin/local/" PLUGIN_STORY = "/plugin/story/" PLUGIN_TABLE_JS = "/plugin/table.js" + PKG_MOD = "/pkd/mod/" ISH_PLUGED = ".ish/pluged/" USR_INSTALL = "usr/install/" diff --git a/core/code/inner.go b/core/code/inner.go index 9d543b63..44bd4513 100644 --- a/core/code/inner.go +++ b/core/code/inner.go @@ -103,18 +103,17 @@ func init() { m.Cmdy(NAVIGATE, kit.Ext(m.Option(mdb.FILE)), m.Option(nfs.FILE), m.Option(nfs.PATH)) }}, }), Hand: func(m *ice.Message, arg ...string) { - if kit.HasPrefix(arg[0], "/volcanos/", "/require/", ice.HTTP) { - if kit.HasPrefix(arg[0], ice.HTTP) && strings.Contains(arg[0], "/plugin/") && !strings.Contains(arg[0], "/volcanos/plugin/") { - arg[0] = strings.Replace(arg[0], "/plugin/", "/volcanos/plugin/", 1) - } - if kit.HasPrefix(arg[0], nfs.REQUIRE_SRC) { - m.Option(nfs.FILE, strings.Split(strings.TrimPrefix(arg[0], nfs.REQUIRE_SRC), "?")[0]) - m.Option(nfs.PATH, nfs.SRC) - } - if kit.HasPrefix(arg[0], nfs.REQUIRE_USR) { + if kit.HasPrefix(arg[0], nfs.VOLCANOS, nfs.REQUIRE, ice.HTTP) { + if kit.HasPrefix(arg[0], ice.HTTP) && strings.Contains(arg[0], nfs.PLUGIN) && !strings.Contains(arg[0], nfs.VOLCANOS_PLUGIN) { + arg[0] = strings.Replace(arg[0], nfs.PLUGIN, nfs.VOLCANOS_PLUGIN, 1) + } else if kit.HasPrefix(arg[0], nfs.REQUIRE_SRC) { + m.Options(nfs.PATH, nfs.SRC, nfs.FILE, strings.Split(strings.TrimPrefix(arg[0], nfs.REQUIRE_SRC), "?")[0]) + } else if kit.HasPrefix(arg[0], nfs.REQUIRE_USR) { ls := kit.Split(arg[0], nfs.PS) - m.Option(nfs.FILE, strings.Split(strings.TrimPrefix(arg[0], nfs.REQUIRE_USR+ls[2]+nfs.PS), "?")[0]) - m.Option(nfs.PATH, nfs.USR+ls[2]+nfs.PS) + m.Options(nfs.PATH, nfs.USR+ls[2]+nfs.PS, nfs.FILE, strings.Split(strings.TrimPrefix(arg[0], nfs.REQUIRE_USR+ls[2]+nfs.PS), "?")[0]) + } else if kit.HasPrefix(arg[0], nfs.REQUIRE) { + ls := strings.Split(strings.Split(strings.TrimPrefix(arg[0], nfs.REQUIRE), "?")[0], nfs.SRC) + m.Options(nfs.PATH, kit.Join(kit.Slice(ls, 0, -1), nfs.PS)+nfs.SRC, nfs.FILE, kit.Select("", ls, -1)) } m.Echo(m.Cmdx(web.SPIDE, ice.OPS, web.SPIDE_RAW, http.MethodGet, arg[0])) m.Options("mode", "simple", lex.PARSE, kit.Ext(kit.ParseURL(arg[0]).Path)) diff --git a/info.go b/info.go index 337ecfb0..9ef9e781 100644 --- a/info.go +++ b/info.go @@ -297,16 +297,18 @@ func (m *Message) FileURI(dir string) string { return dir } p := kit.Path("") + PS - pp := strings.Split(kit.Path(""), "usr/local/work")[0] - pod := m.Option(MSG_USERPOD) - if strings.Contains(dir, "/pkg/mod/") { - dir = strings.Split(dir, "/pkg/mod/")[1] + pp := strings.Split(kit.Path(""), USR_LOCAL_WORK)[0] + ppp := strings.Split(Info.Make.Path, USR_LOCAL_WORK)[0] + if strings.Contains(dir, PKG_MOD) { + dir = strings.Split(dir, PKG_MOD)[1] } else if Info.Make.Path != "" && strings.HasPrefix(dir, Info.Make.Path) { dir = strings.TrimPrefix(dir, Info.Make.Path) } else if strings.HasPrefix(dir, p) { dir = strings.TrimPrefix(dir, p) - } else if strings.Contains(p, "usr/local/work") && strings.HasPrefix(dir, pp) { + } else if pp != "" && strings.HasPrefix(dir, pp) { dir = strings.TrimPrefix(dir, pp) + } else if ppp != "" && strings.HasPrefix(dir, ppp) { + dir = strings.TrimPrefix(dir, ppp) } else if strings.HasPrefix(dir, ISH_PLUGED) { dir = strings.TrimPrefix(dir, ISH_PLUGED) } @@ -315,7 +317,7 @@ func (m *Message) FileURI(dir string) string { } else if strings.HasPrefix(dir, USR_VOLCANOS) { dir = strings.TrimPrefix(dir, USR) } else { - dir = kit.MergeURL(path.Join(PS, REQUIRE, dir), POD, pod) + dir = kit.MergeURL(path.Join(PS, REQUIRE, dir), POD, m.Option(MSG_USERPOD)) } if m.Option(MSG_USERWEB0) != "" { dir = kit.MergeURL2(m.Option(MSG_USERWEB), dir)