1
0
forked from x/ContextOS

add macosx

This commit is contained in:
IT 老营长 @云轩领航-创始人 2023-04-28 22:35:04 +08:00
parent 97362018d9
commit bd01155d8b
20 changed files with 302 additions and 1 deletions

View File

@ -26,7 +26,7 @@ ish_miss_prepare redis-story
# ish_miss_prepare wubi-dict
# ish_miss_prepare word-dict
# ish_miss_prepare echarts
# ish_miss_prepare icons
ish_miss_prepare icons
ish_miss_prepare websocket
ish_miss_prepare go-qrcode

View File

@ -0,0 +1,9 @@
chapter "dream 项目空间"
section "list 空间列表"
section "start 启动空间"
section "stop 停止空间"
section "trash 删除空间"

View File

@ -0,0 +1,4 @@
chapter "start 启动空间"
section "start 启动空间"

7
src/macosx/controls.go Normal file
View File

@ -0,0 +1,7 @@
package macosx
import ice "shylinux.com/x/icebergs"
const CONTROLS = "controls"
func init() { Index.MergeCommands(ice.Commands{CONTROLS: {Actions: CmdHashAction()}}) }

3
src/macosx/controls.js vendored Normal file
View File

@ -0,0 +1,3 @@
Volcanos(chat.ONIMPORT, {_init: function(can, msg) {
msg.Echo("hello world").Dump(can)
}})

43
src/macosx/desktop.css Normal file
View File

@ -0,0 +1,43 @@
fieldset.macosx.desktop { background-size:cover; background-position:center; color:#e8eaed; }
body.dark fieldset.macosx.desktop>div.output { background-color:unset; }
fieldset.macosx.desktop>div.output>fieldset.macosx>div.output { background-color:transparent; }
fieldset.macosx.desktop>div.output>fieldset.macosx.menu { background-color:#08234ad1; color:#e8eaed; line-height:25px; height:25px; width:100%; position:absolute; top:0; }
fieldset.macosx.desktop>div.output>fieldset.macosx.controls { background-color:#08234ad1; height:40%; width:240px; position:absolute; top:20px; right:0; }
fieldset.macosx.desktop>div.output>fieldset.macosx.notifications { background-color:#08234ad1; height:80%; width:240px; position:absolute; top:10%; right:0; }
fieldset.macosx.desktop>div.output>fieldset.macosx.dock { position:absolute; bottom:10px; left:300px; transition:margin-left 0.3s; }
fieldset.macosx.desktop>div.output>fieldset.macosx.dock:hover { margin-left:-40px; transition:margin-left 0.3s; }
fieldset.macosx.desktop>div.output>div.desktop:not(.select) { display:none; }
fieldset.macosx.desktop>div.output>div.desktop>fieldset { position:absolute; }
fieldset.macosx.desktop>div.output>div.desktop.scale>fieldset { scale:0.6; }
// fieldset.macosx.desktop>div.output>div.desktop fieldset { background-color:#333434; border:#ffffff3d solid 1px; border-top:#ffffff52 ridge 2px; border-radius:10px; }
fieldset.macosx.desktop>div.output>div.desktop fieldset { background-color:#333434; border-radius:10px; }
fieldset.macosx.desktop>div.output>div.desktop fieldset>legend { background-color:unset; margin:10px 0; }
fieldset.macosx.desktop>div.output>div.desktop fieldset>form.option>* { margin:10px 0; background-color:unset; }
fieldset.macosx.desktop>div.output>div.desktop fieldset>div.action>* { margin:10px 0; }
fieldset.macosx.desktop>div.output>div.desktop>fieldset>div.output { background-color:#1a1d1d; }
fieldset.macosx.desktop>div.output>div.desktop fieldset>div.status { background-color:transparent; border-top:#3e4040 solid 1px; }
fieldset.macosx.desktop>div.output>div.desktop fieldset>div.status>* { margin:10px 0; }
fieldset.macosx.desktop>div.output>div.desktop fieldset input { background-color:#333434; border:#404141 solid 1px; border-radius:5px; box-shadow:unset; }
fieldset.macosx.desktop>div.output>div.desktop fieldset input[type=button] { background-color:#5e5f5f; }
fieldset.macosx.desktop>div.output>div.desktop fieldset table.content th { background-color:unset; }
fieldset.macosx.desktop>div.output>div.desktop fieldset table.content.action td:last-child { background-color:unset; }
fieldset.macosx.desktop>div.output>div.desktop fieldset table.content tr:nth-child(odd) { background-color:#1a1d1e; }
fieldset.macosx.desktop>div.output>div.desktop fieldset table.content tr:nth-child(even) { background-color:#282B2F; }
fieldset.macosx.desktop>div.output>div.desktop fieldset>div.output.card>div.item { border:#3e4040 solid 1px; }
fieldset.macosx.desktop>div.output>div.desktop fieldset>div.output.card>div.item>div.title { border-bottom:#3e4040 solid 1px; }
fieldset.macosx.menu>div.output>div.item { padding:0 5px; float:right; cursor:pointer; }
fieldset.macosx.menu>div.output>div.icon { padding:0 5px; float:right; cursor:pointer; }
fieldset.macosx.dock>div.output { background-color:#02142196; border:#ffffff3d solid 1px; border-radius:20px; height:80px; min-width:200px; overflow:visible; display:flex; z-index:11; }
fieldset.macosx.dock>div.output>div.item { text-align:center; align-self:baseline; transition:margin-top 0.3s; }
fieldset.macosx.dock>div.output>div.item:hover { background-color:unset; margin-top:-80px; transition:margin-top 0.3s; }
fieldset.macosx.dock>div.output>div.item img { width:80px; transition:width 0.3s; }
fieldset.macosx.dock>div.output>div.item img:hover { width:160px; transition:width 0.3s; }
div.carte.macosx.float { background:#29323beb; color:#e8eaed; font-size:14px; padding:10px; border:#ffffff5e solid 1px; border-radius:8px; }
div.carte.macosx.float div.item { background:transparent; }
div.carte.macosx.float hr { border-bottom:gray solid 1px; }
fieldset.macosx.desktop input { color:#e8eaed; }
fieldset.macosx.desktop>div.output>div.item { text-align:center; width:120px; float:left; overflow:hidden; }
fieldset.macosx.desktop>div.output>div.item img { width:80px; }

7
src/macosx/desktop.go Normal file
View File

@ -0,0 +1,7 @@
package macosx
import ice "shylinux.com/x/icebergs"
const DESKTOP = "desktop"
func init() { Index.MergeCommands(ice.Commands{DESKTOP: {Actions: CmdHashAction()}}) }

61
src/macosx/desktop.js Normal file
View File

@ -0,0 +1,61 @@
Volcanos(chat.ONIMPORT, {
_init: function(can, msg, cb) { can.ui = {}, cb(msg), can.onmotion.clear(can)
can.page.styleHeight(can, can._output, can.ConfHeight())
can.onimport._menu(can), can.onimport._dock(can), can.onimport._desktop(can, msg), can.onlayout.background(can, can.user.info.background, can._fields)
},
_desktop: function(can, msg) { var target = can.page.Append(can, can._output, [{view: "desktop"}])._target
msg = msg||can._msg, msg.Table(function(item) { can.page.Append(can, target, [{view: html.ITEM, list: [{view: html.ICON, list: [{img: "/require/"+item.icon}]}, {view: [mdb.NAME, "", item.name]}]}]) })
can.onimport.tabs(can, [{name: "desktop", text: ""}], function() { can.onmotion.select(can, can._output, "div.desktop", target), can.ui.desktop = target }, function() { can.page.Remove(can, target) })
},
_window: function(can, item) { item.height = can.ConfHeight()-282, item.width = can.ConfWidth()-100
can.onappend.plugin(can, item, function(sub) { sub.onimport.size(sub, item.height, item.width, true), can.onmotion.move(can, sub._target, {"z-index": 10, top: 100, left: 100}) }, can.ui.desktop)
},
_notifications: function(can) { can.onappend.plugin(can, {index: "web.chat.macosx.notifications", style: html.OUTPUT}, function(sub) { can.ui.notifications = sub, can.onmotion.hidden(can, sub._target) }) },
_controls: function(can) { can.onappend.plugin(can, {index: "web.chat.macosx.controls", style: html.OUTPUT}, function(sub) { can.ui.controls = sub, can.onmotion.hidden(can, sub._target) }) },
_menu: function(can) { can.onappend.plugin(can, {index: "web.chat.macosx.menu", style: html.OUTPUT}, function(sub) { can.ui.menu = sub
can.onimport._notifications(can), can.onimport._controls(can)
sub.onexport.record = function(_, value, key, item) {
switch (value) {
case "notifications": can.onmotion.toggle(can, can.ui.notifications._target); break
case "controls": can.onmotion.toggle(can, can.ui.controls._target); break
case "system":
var carte = can.user.carte(event, can, {
"About This Mac": function(event) { can.user.toast(can, "about this mac") },
"System Preferences...": function(event) { can.user.toast(can, "about this mac") },
"App Store...": function(event) { can.user.toast(can, "about this mac") },
"Rencent iterms >": function(event) { can.user.toast(can, "about this mac") },
"Force Quit Chrome": function(event) { can.user.toast(can, "about this mac") },
"Sleep": function(event) { can.user.toast(can, "about this mac") },
"Restart...": function(event) { can.user.toast(can, "about this mac") },
"Shut Down...": function(event) { can.user.toast(can, "about this mac") },
"Lock Screen": function(event) { can.user.toast(can, "about this mac") },
"Log Out shy...": function(event) { can.user.toast(can, "about this mac") },
full: function(event) { can.onaction.full(event, can) },
scale: function(event) {
can.page.ClassList.neg(can, can.ui.desktop, "scale")
},
}); var list = can.page.Select(can, carte._target, html.DIV_ITEM)
can.core.List([1, 3, 4, 5, 8], function(i) { can.page.insertBefore(can, [{type: html.HR}], list[i]) })
can.page.style(can, carte._target, html.TOP, "25px")
break
}
}
}) },
_dock: function(can) { can.onappend.plugin(can, {index: "web.chat.macosx.dock", style: html.OUTPUT}, function(sub) { can.ui.dock = sub
sub.onexport.record = function(sub, value, key, item) { can.onimport._window(can, item) }
}) },
layout: function(can) {
can.page.styleHeight(can, can._output, can.ConfHeight())
return
if (can._fields.offsetHeight > 32) {
can.ConfHeight(can._fields.offsetHeight-html.ACTION_HEIGHT)
}
can.ConfWidth(can._output.offsetWidth)
can.ui && can.ui.dock && can.page.style(can, can.ui.dock._target, "bottom", "10px")
},
}, [""])
Volcanos(chat.ONACTION, {list: ["full"],
create: function(event, can, button) { can.onimport._desktop(can) },
// full: function(event, can, button) { can._fields.requestFullscreen() },
full: function(event, can) { document.body.requestFullscreen() },
})

25
src/macosx/dock.go Normal file
View File

@ -0,0 +1,25 @@
package macosx
import (
ice "shylinux.com/x/icebergs"
"shylinux.com/x/icebergs/base/mdb"
"shylinux.com/x/icebergs/base/nfs"
kit "shylinux.com/x/toolkits"
)
const DOCK = "dock"
func init() {
Index.MergeCommands(ice.Commands{
DOCK: {Actions: ice.MergeActions(ice.Actions{
mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) {
switch mdb.HashInputs(m, arg); arg[0] {
case mdb.NAME:
m.Cmd(nfs.DIR, "usr/icons/", func(value ice.Maps) { m.Push(arg[0], kit.TrimExt(value[nfs.PATH], nfs.PNG)) })
case mdb.ICON:
m.Cmd(nfs.DIR, "usr/icons/", func(value ice.Maps) { m.Push(arg[0], value[nfs.PATH]) })
}
}},
}, CmdHashAction())},
})
}

21
src/macosx/dock.js Normal file
View File

@ -0,0 +1,21 @@
Volcanos(chat.ONIMPORT, {_init: function(can, msg, cb) {
msg.Table(function(item) { can.page.Append(can, can._output, [{view: html.ITEM, list: [{view: html.ICON, list: [{img: "/require/"+item.icon}] }], onclick: function(event) {
can.sup.onexport.record(can, item.name, mdb.NAME, item)
} }]) })
can._output.oncontextmenu = function(event) { var carte = can.user.carte(event, can, {
create: function() { can.Update(event, [ctx.ACTION, mdb.CREATE]) },
}); can.page.style(can, carte._target, html.LEFT, event.x) }
return
var current = null, before, begin
can.page.SelectChild(can, can._output, "*", function(target) { target.draggable = true
target.ondragstart = function() { current = target, can.page.style(can, target, "visibility", "hidden") }
target.ondragenter = function(event) { before = target, begin = {x: event.x, y: event.y} }
target.ondragover = function(event) { var offset = event.x - begin.x
can.page.style(can, target, {position: "relative", left: -offset})
}
target.ondragleave = function(event) { }
target.ondragend = function(event) { before && can.page.insertBefore(can, current, before)
can.page.SelectChild(can, can._output, "*", function(target) { can.page.style(can, target, {position: "", left: "", visibility: "visible"}) })
}
})
}})

43
src/macosx/finder.go Normal file
View File

@ -0,0 +1,43 @@
package macosx
import (
"strings"
ice "shylinux.com/x/icebergs"
"shylinux.com/x/icebergs/base/ctx"
"shylinux.com/x/icebergs/base/nfs"
kit "shylinux.com/x/toolkits"
)
const FINDER = "finder"
func init() {
Index.MergeCommands(ice.Commands{
FINDER: {Name: "finder path auto create", Help: "浏览器", Actions: ice.MergeActions(CmdHashAction()), Hand: func(m *ice.Message, arg ...string) {
if len(arg) == 0 || strings.HasSuffix(arg[0], nfs.PS) {
switch kit.Select("", arg, 0) {
case ice.USR_LOCAL_WORK:
ctx.ProcessCmds(m, "web.dream")
case ice.USR_LOCAL_REPOS:
ctx.ProcessCmds(m, "web.code.git.service")
case ice.USR_LOCAL_IMAGE:
ctx.ProcessCmds(m, "web.wiki.feel")
case ice.USR_LOCAL_DAEMON:
ctx.ProcessCmds(m, "web.code.install")
default:
m.Cmdy(nfs.DIR, arg).Display("")
}
} else {
switch kit.Ext(arg[0]) {
case "svg":
ctx.ProcessCmds(m, "web.wiki.draw", arg[0])
case "shy":
ctx.ProcessCmds(m, "web.wiki.word", arg[0])
default:
ls := nfs.SplitPath(m, arg[0])
ctx.ProcessCmds(m, "web.code.vimer", ls[0], ls[1])
}
}
}},
})
}

3
src/macosx/finder.js Normal file
View File

@ -0,0 +1,3 @@
Volcanos(chat.ONIMPORT, {_init: function(can, msg) {
msg.Dump(can)
}})

22
src/macosx/macosx.go Normal file
View File

@ -0,0 +1,22 @@
package macosx
import (
ice "shylinux.com/x/icebergs"
"shylinux.com/x/icebergs/base/ctx"
"shylinux.com/x/icebergs/base/mdb"
"shylinux.com/x/icebergs/core/chat"
kit "shylinux.com/x/toolkits"
)
const MACOSX = "macosx"
var Index = &ice.Context{Name: MACOSX}
func init() { chat.Index.Register(Index, nil) }
func CmdHashAction(arg ...string) ice.Actions {
file := kit.FileLines(2)
return ice.MergeActions(ice.Actions{
mdb.SELECT: {Name: "list hash auto create", Hand: func(m *ice.Message, arg ...string) { mdb.HashSelect(m, arg...).Display(file) }},
}, ctx.CmdAction(), mdb.HashAction(mdb.SHORT, kit.Select("", arg, 0), mdb.FIELD, kit.Select("time,hash,type,name,icon,index,args", arg, 1), kit.Slice(arg, 2)))
}

13
src/macosx/macosx.shy Normal file
View File

@ -0,0 +1,13 @@
title "macosx"
chain `
desktop
menu
dock
finder
trash
safari
preview
terminal
settings
notifications
`

7
src/macosx/menu.go Normal file
View File

@ -0,0 +1,7 @@
package macosx
import ice "shylinux.com/x/icebergs"
const MENU = "menu"
func init() { Index.MergeCommands(ice.Commands{MENU: {Actions: CmdHashAction()}}) }

14
src/macosx/menu.js Normal file
View File

@ -0,0 +1,14 @@
Volcanos(chat.ONIMPORT, {_init: function(can, msg) { msg.Dump(can), can.page.Append(can, can._output, can.user.header(can))
false && can.page.Append(can, can._output, [{view: ["icon", "", "notifications"], onclick: function(event) {
can.sup.onexport.record(can, "notifications", mdb.NAME, {})
}}])
false && can.page.Append(can, can._output, [{view: ["icon", "", "controls"], onclick: function(event) {
can.sup.onexport.record(can, "controls", mdb.NAME, {})
}}])
can.page.Append(can, can._output, [{view: ["icon"], list: [{img: "/require/usr/icons/menu.png"}], onclick: function(event) {
can.sup.onexport.record(can, "controls", mdb.NAME, {})
}}])
can.page.Append(can, can._output, [{view: ["menu"], list: [{img: "/require/usr/icons/menu0.png"}], onclick: function(event) {
can.sup.onexport.record(can, "system", mdb.NAME, {})
}}])
}})

View File

@ -0,0 +1,7 @@
package macosx
import ice "shylinux.com/x/icebergs"
const NOTIFICATIONS = "notifications"
func init() { Index.MergeCommands(ice.Commands{NOTIFICATIONS: {Actions: CmdHashAction()}}) }

View File

@ -0,0 +1,3 @@
Volcanos(chat.ONIMPORT, {_init: function(can, msg) {
msg.Dump(can)
}})

7
src/macosx/settings.go Normal file
View File

@ -0,0 +1,7 @@
package macosx
import ice "shylinux.com/x/icebergs"
const SETTINGS = "settings"
func init() { Index.MergeCommands(ice.Commands{SETTINGS: {Actions: CmdHashAction()}}) }

View File

@ -30,6 +30,8 @@ import (
_ "shylinux.com/x/golang-story/src/grafana"
_ "shylinux.com/x/golang-story/src/kubernetes"
_ "shylinux.com/x/golang-story/src/prometheus"
_ "shylinux.com/x/contexts/src/macosx"
)
func main() { print(ice.Run()) }