From 8a36cbfe51a2be3d8561796d57edd44831699e5e Mon Sep 17 00:00:00 2001 From: shy Date: Tue, 16 Jan 2024 13:14:59 +0800 Subject: [PATCH] add some --- base/ctx/command.go | 21 +++++++++------------ base/nfs/dir.go | 2 +- base/web/render.go | 2 ++ base/web/share.go | 5 +++-- core/chat/macos/desktop.css | 3 +++ core/chat/macos/desktop.js | 14 ++++---------- core/chat/macos/macos.go | 30 ++++++++++++++++++++++++++++-- 7 files changed, 50 insertions(+), 27 deletions(-) diff --git a/base/ctx/command.go b/base/ctx/command.go index 5cca4a55..4005b1fe 100644 --- a/base/ctx/command.go +++ b/base/ctx/command.go @@ -23,17 +23,14 @@ func _command_list(m *ice.Message, name string) *ice.Message { m.Push(mdb.HELP, kit.Format(cmd.Help)) m.Push(mdb.LIST, kit.Format(cmd.List)) m.Push(mdb.META, kit.Format(cmd.Meta)) - 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)) - } + m.Push("_command", ShortCmd(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("_role", kit.Select("", ice.OK, kit.IsIn(ShortCmd(kit.Keys(s.Prefix(), key)), "portal", aaa.OFFER) && aaa.Right(m.Spawn(), name))) m.Push("_help", GetCmdHelp(m, name)) }) return m @@ -161,7 +158,7 @@ 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("/require/usr/", path.Base(_ls[0]), _ls[1])] = key + ice.Info.File[path.Join(nfs.REQUIRE_USR, path.Base(_ls[0]), _ls[1])] = key ice.Info.Gomod[ls[0]] = ls[1] } } @@ -183,16 +180,16 @@ func GetFileCmd(dir string) string { return "" } func GetCmdHelp(m *ice.Message, cmds string) (file string) { - file = strings.TrimPrefix(FileURI(kit.ExtChange(GetCmdFile(m, cmds), nfs.SHY)), "/require/") - if !nfs.Exists(m, path.Join(nfs.USR_LEARNING_PORTAL, "commands", strings.TrimPrefix(file, "usr/icebergs/")), func(p string) { file = p }) { + file = strings.TrimPrefix(FileURI(kit.ExtChange(GetCmdFile(m, cmds), nfs.SHY)), nfs.REQUIRE) + if !nfs.Exists(m, path.Join(nfs.USR_LEARNING_PORTAL, "commands", strings.TrimPrefix(file, nfs.USR_ICEBERGS)), func(p string) { file = p }) { kit.If(!nfs.Exists(m, file), func() { file = "" }) } return } func GetCmdFile(m *ice.Message, cmds string) (file string) { m.Search(kit.Select(m.PrefixKey(), cmds), func(key string, cmd *ice.Command) { - if file = strings.TrimPrefix(FileURI(kit.Split(cmd.FileLine(), nfs.DF)[0]), "/require/"); !nfs.Exists(m, file) { - file = path.Join("/require/", file) + if file = strings.TrimPrefix(FileURI(kit.Split(cmd.FileLine(), nfs.DF)[0]), nfs.REQUIRE); !nfs.Exists(m, file) { + file = path.Join(nfs.REQUIRE, file) } }) return @@ -216,7 +213,7 @@ func TravelCmd(m *ice.Message, cb func(key, file, line string)) *ice.Message { } func IsOrderCmd(key string) bool { return key[0] == '/' || key[0] == '_' } func ShortCmd(key string) string { - _key := kit.Select("", kit.Split(key, "."), -1) + _key := kit.Select("", kit.Split(key, nfs.PT), -1) if _p, ok := ice.Info.Index[_key].(*ice.Context); ok && _p.Prefix(_key) == key { return _key } diff --git a/base/nfs/dir.go b/base/nfs/dir.go index 69a080d9..d2b202ef 100644 --- a/base/nfs/dir.go +++ b/base/nfs/dir.go @@ -195,7 +195,7 @@ const DIR = "dir" func init() { Index.MergeCommands(ice.Commands{ - DIR: {Name: "dir path auto upload app", Icon: "dir.png", Help: "目录", Actions: ice.Actions{ + DIR: {Name: "dir path auto upload app", Icon: "dir.png", Help: "文件夹", Actions: ice.Actions{ ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { aaa.White(m, ice.SRC, ice.BIN, ice.USR) aaa.Black(m, ice.USR_LOCAL) diff --git a/base/web/render.go b/base/web/render.go index 2ffc2579..dd18d7a6 100644 --- a/base/web/render.go +++ b/base/web/render.go @@ -159,6 +159,8 @@ func RenderVersion(m *ice.Message) string { const ( CHAT = "chat" DESKTOP = "desktop" + COMPILE = "compile" + XTERM = "xterm" CODE_GIT_SERVICE = "web.code.git.service" CODE_GIT_SEARCH = "web.code.git.search" diff --git a/base/web/share.go b/base/web/share.go index 7619c332..9dbc8d54 100644 --- a/base/web/share.go +++ b/base/web/share.go @@ -103,8 +103,9 @@ func init() { } switch msg.Append(mdb.TYPE) { case LOGIN: - RenderCookie(m, aaa.SessCreate(m, msg.Append(aaa.USERNAME))) - m.RenderRedirect(msg.Append(mdb.TEXT)) + // RenderCookie(m, aaa.SessCreate(m, msg.Append(aaa.USERNAME))) + // m.RenderRedirect(msg.Append(mdb.TEXT)) + m.RenderRedirect(kit.MergeURL(msg.Append(mdb.TEXT), ice.MSG_SESSID, aaa.SessCreate(m, msg.Append(aaa.USERNAME)))) case STORM: RenderCookie(m, aaa.SessCreate(m, msg.Append(aaa.USERNAME))) m.RenderRedirect(m.MergeLink(kit.Select(nfs.PS, msg.Append(mdb.TEXT)), msg.AppendSimple(RIVER, STORM))) diff --git a/core/chat/macos/desktop.css b/core/chat/macos/desktop.css index c0c9bb0a..2e79d143 100644 --- a/core/chat/macos/desktop.css +++ b/core/chat/macos/desktop.css @@ -61,6 +61,9 @@ fieldset.macos.desktop>div.output>div.desktop>fieldset.web.chat.location>div.act fieldset.macos.desktop>div.output>div.desktop>fieldset.web.chat.location>div.action>div.item.feature select { width:60px; } fieldset.macos.desktop>div.output>div.desktop>fieldset.web.chat.iframe>form.option>div.item.hash>input { width:var(--river-width); } fieldset.macos.desktop>div.output>div.desktop>fieldset.web.chat.macos.finder>div.status { display:none; } +fieldset.macos.desktop>div.output>div.desktop>fieldset.web.chat.macos.finder>div.output div.item.disable { display:none; } +fieldset.macos.desktop>div.output>fieldset.web.chat.macos.dock>div.output div.item.disable { display:none; } +fieldset.macos.desktop>div.output>div.desktop>div.item.disable { display:none; } fieldset.macos.menu>div.output>div.item { padding:0 var(--button-padding); height:var(--desktop-menu-height); float:right; } fieldset.macos.menu>div.output>div.item.avatar { padding:0; } fieldset.macos.menu>div.output>div.item.avatar>img { height:var(--desktop-menu-height); } diff --git a/core/chat/macos/desktop.js b/core/chat/macos/desktop.js index 13b0a40c..11b80b59 100644 --- a/core/chat/macos/desktop.js +++ b/core/chat/macos/desktop.js @@ -17,7 +17,7 @@ Volcanos(chat.ONIMPORT, { switch (value) { case "notifications": can.ui.notifications._output.innerHTML && can.onmotion.toggle(can, can.ui.notifications._target); break case "searchs": can.onaction._search(can); break - case "qrcode": can.sup.onaction["生成链接"]({}, can.sup); break + case cli.QRCODE: can.sup.onaction["生成链接"]({}, can.sup); break case mdb.CREATE: can.onaction.create(event, can); break case html.DESKTOP: var carte = can.user.carte(event, can, {}, can.core.Item(can.onfigure), function(event, button, meta, carte) { @@ -72,7 +72,7 @@ Volcanos(chat.ONIMPORT, { if (can.ConfHeight() > 800) { item.height = can.base.Min(can.ConfHeight()-200, 320, 800), item.top = 50 } 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 } + 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) }}, @@ -104,7 +104,6 @@ Volcanos(chat.ONIMPORT, { }, can.ui.desktop) }, session: function(can, list) { if (!list || list.length == 0) { return } - // if (!list || list.length == 0 || !can.isCmdMode() || window != window.parent) { return } can.page.Select(can, can._output, html.DIV_DESKTOP, function(target) { can.page.Remove(can, target) }) can.page.Select(can, can.ui.menu._output, html.DIV_TABS, function(target) { can.page.Remove(can, target) }) var _select; can.core.Next(list, function(item, next) { @@ -115,7 +114,6 @@ Volcanos(chat.ONIMPORT, { }, function() { _select && _select.click() }) }, layout: function(can) { can.page.style(can, can._output, html.HEIGHT, can.ConfHeight(), html.WIDTH, can.ConfWidth()) - // can.ui.notifications && can.page.style(can, can.ui.notifications._target, html.LEFT, can.ConfWidth()-250) can.ui.dock && can.page.style(can, can.ui.dock._target, html.LEFT, can.base.Min((can.ConfWidth()-(can.ui.dock._target.offsetWidth||502))/2, 0)) }, }, [""]) @@ -159,16 +157,12 @@ Volcanos(chat.ONFIGURE, { })} }) can.runActionCommand(event, "session", [ctx.ACTION, mdb.CREATE, mdb.NAME, list[0], ctx.ARGS, JSON.stringify(args)], function(msg) { - can.user.toastSuccess(can, "session created") - can.misc.SearchHash(can, list[0]) + can.user.toastSuccess(can, "session created"), can.misc.SearchHash(can, list[0]) }) }) }}].concat("", msg.Table(function(value) { return {view: [html.ITEM, "", value.name+(value.name == hash[0]? " *": "")], - onclick: function() { - can.onimport.session(can, can.base.Obj(value.args, [])) - can.misc.SearchHash(can, value.name) - }, + onclick: function() { can.onimport.session(can, can.base.Obj(value.args, [])), can.misc.SearchHash(can, value.name) }, oncontextmenu: function(event) { can.user.carteRight(event, can, { open: function() { can.user.open(can.misc.MergePodCmd(can, {cmd: "desktop", session: value.name})) }, remove: function() { can.runActionCommand(event, "session", [mdb.REMOVE, value.name], function() { can.user.toastSuccess(can, "session removed") }) }, diff --git a/core/chat/macos/macos.go b/core/chat/macos/macos.go index e3d7f501..98e381a7 100644 --- a/core/chat/macos/macos.go +++ b/core/chat/macos/macos.go @@ -2,6 +2,8 @@ package macos import ( ice "shylinux.com/x/icebergs" + "shylinux.com/x/icebergs/base/aaa" + "shylinux.com/x/icebergs/base/cli" "shylinux.com/x/icebergs/base/ctx" "shylinux.com/x/icebergs/base/mdb" "shylinux.com/x/icebergs/base/nfs" @@ -20,12 +22,36 @@ func init() { chat.Index.Register(Index, nil, DESKTOP, APPLICATIONS) } func Prefix(arg ...string) string { return chat.Prefix(MACOS, kit.Keys(arg)) } +func disableApp(m *ice.Message) *ice.Message { + m.Table(func(value ice.Maps) { + switch ctx.ShortCmd(value[ctx.INDEX]) { + case web.DREAM, web.CODE_GIT_SEARCH: + if ice.Info.NodeType == web.WORKER { + m.Push(mdb.STATUS, mdb.DISABLE) + return + } + case web.COMPILE: + if cli.SystemFind(m, "go") == "" { + m.Push(mdb.STATUS, mdb.DISABLE) + return + } + fallthrough + case web.XTERM: + if !kit.IsIn(m.Option(ice.MSG_USERROLE), aaa.TECH, aaa.ROOT) { + m.Push(mdb.STATUS, mdb.DISABLE) + return + } + } + m.Push(mdb.STATUS, mdb.ENABLE) + }) + return m +} func PodCmdAction(arg ...string) ice.Actions { file := kit.FileLine(2, 100) return ice.Actions{ mdb.SELECT: {Name: "list hash auto create", Hand: func(m *ice.Message, arg ...string) { defer m.Display(ctx.FileURI(file)) - msg := mdb.HashSelect(m.Spawn(), arg...).Sort(mdb.NAME) + msg := disableApp(mdb.HashSelect(m.Spawn(), arg...).Sort(mdb.NAME)) web.PushPodCmd(msg, m.PrefixKey(), arg...) has := map[string]bool{} msg.Table(func(index int, value ice.Maps, head []string) { @@ -46,7 +72,7 @@ func CmdHashAction(arg ...string) ice.Actions { } }}, mdb.SELECT: {Hand: func(m *ice.Message, arg ...string) { - mdb.HashSelect(m, arg...).Sort(mdb.NAME).Display(ctx.FileURI(file)) + disableApp(mdb.HashSelect(m, arg...).Sort(mdb.NAME).Display(ctx.FileURI(file))) }}, }, mdb.HashAction(mdb.SHORT, kit.Select("", arg, 0), mdb.FIELD, kit.Select("time,hash,icon,name,text,space,index,args", arg, 1), kit.Slice(arg, 2))) }