1
0
forked from x/icebergs
This commit is contained in:
IT 老营长 @云轩领航-创始人 2024-01-16 13:14:59 +08:00
parent 25016141bb
commit 8a36cbfe51
7 changed files with 50 additions and 27 deletions

View File

@ -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.HELP, kit.Format(cmd.Help))
m.Push(mdb.LIST, kit.Format(cmd.List)) m.Push(mdb.LIST, kit.Format(cmd.List))
m.Push(mdb.META, kit.Format(cmd.Meta)) 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", ShortCmd(kit.Keys(s.Prefix(), key)))
m.Push("_command", key)
} else {
m.Push("_command", kit.Keys(s.Prefix(), key))
}
if !nfs.Exists(m, kit.Split(cmd.FileLine(), ":")[0], func(p string) { 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", kit.MergeURL(FileURI(p), ice.POD, m.Option(ice.MSG_USERPOD)))
}) { }) {
m.Push("_fileline", "") 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)) m.Push("_help", GetCmdHelp(m, name))
}) })
return m return m
@ -161,7 +158,7 @@ func AddFileCmd(dir, key string) {
ice.Info.File[FileCmd(dir)] = key 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 { 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) _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] ice.Info.Gomod[ls[0]] = ls[1]
} }
} }
@ -183,16 +180,16 @@ func GetFileCmd(dir string) string {
return "" return ""
} }
func GetCmdHelp(m *ice.Message, cmds string) (file string) { func GetCmdHelp(m *ice.Message, cmds string) (file string) {
file = strings.TrimPrefix(FileURI(kit.ExtChange(GetCmdFile(m, cmds), nfs.SHY)), "/require/") 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, "usr/icebergs/")), func(p string) { file = p }) { 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 = "" }) kit.If(!nfs.Exists(m, file), func() { file = "" })
} }
return return
} }
func GetCmdFile(m *ice.Message, cmds string) (file string) { func GetCmdFile(m *ice.Message, cmds string) (file string) {
m.Search(kit.Select(m.PrefixKey(), cmds), func(key string, cmd *ice.Command) { 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) { if file = strings.TrimPrefix(FileURI(kit.Split(cmd.FileLine(), nfs.DF)[0]), nfs.REQUIRE); !nfs.Exists(m, file) {
file = path.Join("/require/", file) file = path.Join(nfs.REQUIRE, file)
} }
}) })
return 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 IsOrderCmd(key string) bool { return key[0] == '/' || key[0] == '_' }
func ShortCmd(key string) string { 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 { if _p, ok := ice.Info.Index[_key].(*ice.Context); ok && _p.Prefix(_key) == key {
return _key return _key
} }

View File

@ -195,7 +195,7 @@ const DIR = "dir"
func init() { func init() {
Index.MergeCommands(ice.Commands{ 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) { ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
aaa.White(m, ice.SRC, ice.BIN, ice.USR) aaa.White(m, ice.SRC, ice.BIN, ice.USR)
aaa.Black(m, ice.USR_LOCAL) aaa.Black(m, ice.USR_LOCAL)

View File

@ -159,6 +159,8 @@ func RenderVersion(m *ice.Message) string {
const ( const (
CHAT = "chat" CHAT = "chat"
DESKTOP = "desktop" DESKTOP = "desktop"
COMPILE = "compile"
XTERM = "xterm"
CODE_GIT_SERVICE = "web.code.git.service" CODE_GIT_SERVICE = "web.code.git.service"
CODE_GIT_SEARCH = "web.code.git.search" CODE_GIT_SEARCH = "web.code.git.search"

View File

@ -103,8 +103,9 @@ func init() {
} }
switch msg.Append(mdb.TYPE) { switch msg.Append(mdb.TYPE) {
case LOGIN: case LOGIN:
RenderCookie(m, aaa.SessCreate(m, msg.Append(aaa.USERNAME))) // RenderCookie(m, aaa.SessCreate(m, msg.Append(aaa.USERNAME)))
m.RenderRedirect(msg.Append(mdb.TEXT)) // 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: case STORM:
RenderCookie(m, aaa.SessCreate(m, msg.Append(aaa.USERNAME))) 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))) m.RenderRedirect(m.MergeLink(kit.Select(nfs.PS, msg.Append(mdb.TEXT)), msg.AppendSimple(RIVER, STORM)))

View File

@ -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.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.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.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 { 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 { padding:0; }
fieldset.macos.menu>div.output>div.item.avatar>img { height:var(--desktop-menu-height); } fieldset.macos.menu>div.output>div.item.avatar>img { height:var(--desktop-menu-height); }

View File

@ -17,7 +17,7 @@ Volcanos(chat.ONIMPORT, {
switch (value) { switch (value) {
case "notifications": can.ui.notifications._output.innerHTML && can.onmotion.toggle(can, can.ui.notifications._target); break case "notifications": can.ui.notifications._output.innerHTML && can.onmotion.toggle(can, can.ui.notifications._target); break
case "searchs": can.onaction._search(can); 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 mdb.CREATE: can.onaction.create(event, can); break
case html.DESKTOP: case html.DESKTOP:
var carte = can.user.carte(event, can, {}, can.core.Item(can.onfigure), function(event, button, meta, carte) { 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.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 } 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) 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) can.onappend.plugin(can, item, function(sub) { can.ondetail.select(can, sub._target)
var index = 0; can.core.Item({ var index = 0; can.core.Item({
close: {color: "#f95f57", inner: "x", onclick: function(event) { sub.onaction._close(event, sub) }}, close: {color: "#f95f57", inner: "x", onclick: function(event) { sub.onaction._close(event, sub) }},
@ -104,7 +104,6 @@ Volcanos(chat.ONIMPORT, {
}, can.ui.desktop) }, can.ui.desktop)
}, },
session: function(can, list) { if (!list || list.length == 0) { return } 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._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) }) 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) { var _select; can.core.Next(list, function(item, next) {
@ -115,7 +114,6 @@ Volcanos(chat.ONIMPORT, {
}, function() { _select && _select.click() }) }, function() { _select && _select.click() })
}, },
layout: function(can) { can.page.style(can, can._output, html.HEIGHT, can.ConfHeight(), html.WIDTH, can.ConfWidth()) 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)) 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.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.user.toastSuccess(can, "session created"), can.misc.SearchHash(can, list[0])
can.misc.SearchHash(can, list[0])
}) })
}) })
}}].concat("", msg.Table(function(value) { }}].concat("", msg.Table(function(value) {
return {view: [html.ITEM, "", value.name+(value.name == hash[0]? " *": "")], return {view: [html.ITEM, "", value.name+(value.name == hash[0]? " *": "")],
onclick: function() { onclick: function() { can.onimport.session(can, can.base.Obj(value.args, [])), can.misc.SearchHash(can, value.name) },
can.onimport.session(can, can.base.Obj(value.args, []))
can.misc.SearchHash(can, value.name)
},
oncontextmenu: function(event) { can.user.carteRight(event, can, { oncontextmenu: function(event) { can.user.carteRight(event, can, {
open: function() { can.user.open(can.misc.MergePodCmd(can, {cmd: "desktop", session: value.name})) }, 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") }) }, remove: function() { can.runActionCommand(event, "session", [mdb.REMOVE, value.name], function() { can.user.toastSuccess(can, "session removed") }) },

View File

@ -2,6 +2,8 @@ package macos
import ( import (
ice "shylinux.com/x/icebergs" 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/ctx"
"shylinux.com/x/icebergs/base/mdb" "shylinux.com/x/icebergs/base/mdb"
"shylinux.com/x/icebergs/base/nfs" "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 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 { func PodCmdAction(arg ...string) ice.Actions {
file := kit.FileLine(2, 100) file := kit.FileLine(2, 100)
return ice.Actions{ return ice.Actions{
mdb.SELECT: {Name: "list hash auto create", Hand: func(m *ice.Message, arg ...string) { mdb.SELECT: {Name: "list hash auto create", Hand: func(m *ice.Message, arg ...string) {
defer m.Display(ctx.FileURI(file)) 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...) web.PushPodCmd(msg, m.PrefixKey(), arg...)
has := map[string]bool{} has := map[string]bool{}
msg.Table(func(index int, value ice.Maps, head []string) { 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.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))) }, 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)))
} }