From 5259773d9033f8f98bbe80288a24d819b9d96709 Mon Sep 17 00:00:00 2001 From: shylinux Date: Sat, 29 Apr 2023 23:16:49 +0800 Subject: [PATCH] add applications --- src/macosx/applications.go | 18 ++++++++++++++++++ src/macosx/desktop.css | 3 +++ src/macosx/desktop.js | 1 + src/macosx/finder.go | 34 ++++++++++++++++++++++++++-------- src/macosx/finder.js | 31 ++++++++++++++++++++++++++++--- src/macosx/macosx.go | 2 ++ 6 files changed, 78 insertions(+), 11 deletions(-) create mode 100644 src/macosx/applications.go diff --git a/src/macosx/applications.go b/src/macosx/applications.go new file mode 100644 index 00000000..515d2106 --- /dev/null +++ b/src/macosx/applications.go @@ -0,0 +1,18 @@ +package macosx + +import ( + ice "shylinux.com/x/icebergs" + "shylinux.com/x/icebergs/base/mdb" + "shylinux.com/x/icebergs/base/web" + kit "shylinux.com/x/toolkits" +) + +const APPLICATIONS = "applications" + +func init() { + Index.MergeCommands(ice.Commands{ + APPLICATIONS: {Name: "applications hash auto create", Help: "应用", Actions: CmdHashAction("index,args"), Hand: func(m *ice.Message, arg ...string) { + mdb.HashSelect(m, arg...).Options(ice.MSG_HEIGHT, kit.Select("240", "32", len(arg) == 0)).Table(func(value ice.Maps) { m.PushImages(web.IMAGE, "/require/"+value[mdb.ICON]) }) + }}, + }) +} diff --git a/src/macosx/desktop.css b/src/macosx/desktop.css index 1ecd49d1..e85efa5e 100644 --- a/src/macosx/desktop.css +++ b/src/macosx/desktop.css @@ -32,6 +32,9 @@ fieldset.macosx.dock>div.output>div.item { text-align:center; align-self:baselin 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; } +fieldset.macosx.finder>div.output div.content>div.item { float:left; text-align:center; } +fieldset.macosx.finder>div.output div.content>div.item img { width:84px; } +fieldset.macosx.finder>div.output div.content>div.item div.name { text-align:center; } div.carte.macosx.float { 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; } diff --git a/src/macosx/desktop.js b/src/macosx/desktop.js index a889ff69..5fb245a9 100644 --- a/src/macosx/desktop.js +++ b/src/macosx/desktop.js @@ -40,6 +40,7 @@ Volcanos(chat.ONIMPORT, { "#32c840": function(event) { sub.onaction.full(event, sub) }, }, function(color, cb) { can.page.insertBefore(can, [{view: [[html.ITEM, html.BUTTON]], style: {"background-color": color, right: 10+20*index++}, onclick: cb}], sub._output) }) sub.onimport.size(sub, item.height, item.width, true), can.onmotion.move(can, sub._target, {"z-index": 10, top: 25, left: 100}) + sub.onexport.record = function(sub, value, key, item) { can.onimport._window(can, item) } }, can.ui.desktop) }, layout: function(can) { can.page.styleHeight(can, can._output, can.ConfHeight()) }, diff --git a/src/macosx/finder.go b/src/macosx/finder.go index dfb6b264..47aa34f0 100644 --- a/src/macosx/finder.go +++ b/src/macosx/finder.go @@ -5,6 +5,7 @@ import ( ice "shylinux.com/x/icebergs" "shylinux.com/x/icebergs/base/ctx" + "shylinux.com/x/icebergs/base/mdb" "shylinux.com/x/icebergs/base/nfs" kit "shylinux.com/x/toolkits" ) @@ -13,9 +14,26 @@ const FINDER = "finder" func init() { Index.MergeCommands(ice.Commands{ - FINDER: {Name: "finder path auto create", Actions: CmdHashAction(), Hand: func(m *ice.Message, arg ...string) { - if len(arg) == 0 || strings.HasSuffix(arg[0], nfs.PS) { - switch kit.Select("", arg, 0) { + FINDER: {Name: "finder list", Actions: ice.MergeActions(ice.Actions{ + ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { + m.Cmd(APPLICATIONS, mdb.CREATE, mdb.NAME, "Finder", mdb.ICON, "usr/icons/Finder.png", ctx.INDEX, m.PrefixKey()) + m.Cmd(APPLICATIONS, mdb.CREATE, mdb.NAME, "Safari", mdb.ICON, "usr/icons/Safari.png", ctx.INDEX, "web.chat.iframe") + m.Cmd(APPLICATIONS, mdb.CREATE, mdb.NAME, "Preview", mdb.ICON, "usr/icons/Preview.png", ctx.INDEX, "web.wiki.feel") + m.Cmd(APPLICATIONS, mdb.CREATE, mdb.NAME, "Terminal", mdb.ICON, "usr/icons/Terminal.png", ctx.INDEX, "web.code.xterm") + m.Cmd(APPLICATIONS, mdb.CREATE, mdb.NAME, "vim", mdb.ICON, "usr/icons/vim.png", ctx.INDEX, "web.code.vimer") + if m.Cmd(DOCK).Length() == 0 { + m.Cmd(DOCK, mdb.CREATE, mdb.NAME, "Finder", mdb.ICON, "usr/icons/Finder.png", ctx.INDEX, m.PrefixKey()) + m.Cmd(DOCK, mdb.CREATE, mdb.NAME, "Terminal", mdb.ICON, "usr/icons/Terminal.png", ctx.INDEX, "web.code.xterm") + } + m.Cmd(FINDER, mdb.CREATE, mdb.NAME, "Applications", ctx.INDEX, Prefix(APPLICATIONS)) + m.Cmd(FINDER, mdb.CREATE, mdb.NAME, "contexts", ctx.INDEX, "nfs.dir") + }}, + }, CmdHashAction(mdb.NAME)), Hand: func(m *ice.Message, arg ...string) { + if len(arg) == 0 { + mdb.HashSelect(m, arg...) + m.Display("") + } else if len(arg) == 1 || strings.HasSuffix(arg[1], nfs.PS) { + switch kit.Select("", arg, 1) { case ice.USR_LOCAL_WORK: ctx.ProcessCmds(m, "web.dream") case ice.USR_LOCAL_REPOS: @@ -25,16 +43,16 @@ func init() { case ice.USR_LOCAL_DAEMON: ctx.ProcessCmds(m, "web.code.install") default: - m.Cmdy(nfs.DIR, arg).Display("") + m.Cmdy(nfs.DIR, arg[1:]).Display("") } } else { - switch kit.Ext(arg[0]) { + switch kit.Ext(arg[1]) { case "svg": - ctx.ProcessCmds(m, "web.wiki.draw", arg[0]) + ctx.ProcessCmds(m, "web.wiki.draw", arg[1]) case "shy": - ctx.ProcessCmds(m, "web.wiki.word", arg[0]) + ctx.ProcessCmds(m, "web.wiki.word", arg[1]) default: - ls := nfs.SplitPath(m, arg[0]) + ls := nfs.SplitPath(m, arg[1]) ctx.ProcessCmds(m, "web.code.vimer", ls[0], ls[1]) } } diff --git a/src/macosx/finder.js b/src/macosx/finder.js index 363dafec..f7e345b2 100644 --- a/src/macosx/finder.js +++ b/src/macosx/finder.js @@ -1,3 +1,28 @@ -Volcanos(chat.ONIMPORT, {_init: function(can, msg) { - msg.Dump(can) -}}) +Volcanos(chat.ONIMPORT, { _init: function(can, msg) { can.onmotion.clear(can), can.ui = can.onappend.layout(can) + msg.Table(function(value, index) { + var item = can.onimport.item(can, value, function(event) { + if (can.onmotion.cache(can, function() { return value.name }, can.ui.content)) { return } + can.runActionCommand(event, value.index, [], function(msg) { + switch (value.name) { + case "Applications": + can.onimport.icons(can, msg, can.ui.content) + break + default: + can.onappend.table(can, msg, null, can.ui.content) + } + can.onimport.layout(can) + }) + }); index == 0 && item.click() + }) + }, + icons: function(can, msg, target) { + msg.Table(function(value) { + can.page.Append(can, target, [{view: html.ITEM, list: [{view: html.ICON, list: [{img: "/require/"+value.icon}]}, {view: [mdb.NAME, "", value.name]}], onclick: function(event) { + can.sup.onexport.record(can.sup, value.name, mdb.NAME, value) + }}]) + }) + }, + layout: function(can) { + can.ui.layout(can.ConfHeight(), can.ConfWidth()) + }, +}) diff --git a/src/macosx/macosx.go b/src/macosx/macosx.go index 66eada24..388edd57 100644 --- a/src/macosx/macosx.go +++ b/src/macosx/macosx.go @@ -15,6 +15,8 @@ var Index = &ice.Context{Name: MACOSX} func init() { chat.Index.Register(Index, nil) } +func Prefix(arg ...string) string { return chat.Prefix(MACOSX, kit.Keys(arg)) } + func CmdHashAction(arg ...string) ice.Actions { file := kit.FileLines(2) return ice.MergeActions(ice.Actions{