From 28820ac34dd29c06a1e82ea9f62cb6afa6097db1 Mon Sep 17 00:00:00 2001 From: shylinux Date: Sun, 30 Apr 2023 13:03:18 +0800 Subject: [PATCH] opt some --- etc/init.shy | 7 +++++++ src/macos/applications.go | 24 +++++++++++++++--------- src/macos/desktop.css | 7 ++++--- src/macos/finder.js | 4 ++-- 4 files changed, 28 insertions(+), 14 deletions(-) diff --git a/etc/init.shy b/etc/init.shy index b340d8b4..f67d8774 100644 --- a/etc/init.shy +++ b/etc/init.shy @@ -8,6 +8,13 @@ webpack insert xterm-addon-web-links webpack insert xterm/css/xterm.css +~web.chat.macos + applications install "" cli.qrcode + applications install "" nfs.trash + applications install "" web.dream + applications install "" web.space + applications install "" web.code.vimer + ~aaa role white void web.code.git.trend role white void web.code.git.spide diff --git a/src/macos/applications.go b/src/macos/applications.go index 93574b9a..aa558908 100644 --- a/src/macos/applications.go +++ b/src/macos/applications.go @@ -4,6 +4,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" "shylinux.com/x/icebergs/base/web" kit "shylinux.com/x/toolkits" ) @@ -14,21 +15,26 @@ func init() { Index.MergeCommands(ice.Commands{ APPLICATIONS: {Name: "applications hash auto create", Help: "应用", 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, "nfs.dir") - 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, "Calendar", mdb.ICON, "usr/icons/Calendar.png", ctx.INDEX, "web.team.plan", ctx.ARGS, "month") - m.Cmd(APPLICATIONS, mdb.CREATE, mdb.NAME, "Grapher", mdb.ICON, "usr/icons/Grapher.png", ctx.INDEX, "web.wiki.draw") - m.Cmd(APPLICATIONS, mdb.CREATE, mdb.NAME, "Books", mdb.ICON, "usr/icons/Books.png", ctx.INDEX, "web.wiki.word") - m.Cmd(APPLICATIONS, mdb.CREATE, mdb.NAME, "vim", mdb.ICON, "usr/icons/vim.png", ctx.INDEX, "web.code.vimer") - + Install(m, "Finder", "nfs.dir") + Install(m, "Safari", "web.chat.iframe") + Install(m, "Photos", "web.wiki.feel") + Install(m, "Terminal", "web.code.xterm") + Install(m, "Calendar", "web.team.plan", ctx.ARGS, "month") + Install(m, "Grapher", "web.wiki.draw") + Install(m, "Books", "web.wiki.word") m.Cmd(FINDER, mdb.CREATE, mdb.NAME, "Applications", ctx.INDEX, Prefix(APPLICATIONS)) m.Cmd(FINDER, mdb.CREATE, mdb.NAME, "Pictures", ctx.INDEX, "web.wiki.feel") m.Cmd(FINDER, mdb.CREATE, mdb.NAME, "Trash", ctx.INDEX, "nfs.trash") }}, + "install": {Hand: func(m *ice.Message, arg ...string) { Install(m, arg[0], arg[1], arg[2:]...) }}, }, 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]) }) + m.Sort(mdb.NAME) }}, }) } +func Install(m *ice.Message, name, index string, arg ...string) { + name, icon := kit.Select(kit.Select("", kit.Split(index, ice.PT), -1), name), "" + kit.If(nfs.Exists(m, "usr/icons/"+name+".png"), func() { icon = "usr/icons/" + name + ".png" }) + m.Cmd(Prefix(APPLICATIONS), mdb.CREATE, mdb.NAME, name, mdb.ICON, icon, ctx.INDEX, index, arg) +} diff --git a/src/macos/desktop.css b/src/macos/desktop.css index ce36fbb0..02d9b3b2 100644 --- a/src/macos/desktop.css +++ b/src/macos/desktop.css @@ -13,9 +13,10 @@ fieldset.macos.desktop>div.output>div.desktop>fieldset { position:absolute; } fieldset.macos.desktop>div.output>div.desktop>fieldset>div.item.button { border-radius:20px; height:20px; width:20px; scale:0.7; position:absolute; top:15px; right:10px; } fieldset.macos.desktop>div.output>div.desktop.scale>fieldset { scale:0.6; } fieldset.macos.desktop>div.output>div.desktop fieldset { border-radius:10px; } -fieldset.macos.desktop>div.output>div.desktop fieldset>legend { background-color:unset; margin:10px 0; } -fieldset.macos.desktop>div.output>div.desktop fieldset>form.option>* { margin:10px 0; background-color:unset; } -fieldset.macos.desktop>div.output>div.desktop fieldset>div.action>* { margin:10px 0; } +fieldset.macos.desktop>div.output>div.desktop fieldset>legend { background-color:unset; padding-right:10px; margin:10px 0; } +fieldset.macos.desktop>div.output>div.desktop>fieldset>form.option>* { margin:10px 0; background-color:unset; } +fieldset.macos.desktop>div.output>div.desktop>fieldset>form.option>div.icon { margin-top:12px; margin-bottom:8px; } +fieldset.macos.desktop>div.output>div.desktop>fieldset>div.action>* { margin:10px 0; } fieldset.macos.desktop>div.output>div.desktop fieldset>div.status { background-color:transparent; } fieldset.macos.desktop>div.output>div.desktop fieldset fieldset>legend { margin:0; } fieldset.macos.desktop>div.output>div.desktop fieldset fieldset>form.option>* { margin:0; background-color:unset; } diff --git a/src/macos/finder.js b/src/macos/finder.js index f7e345b2..6259571b 100644 --- a/src/macos/finder.js +++ b/src/macos/finder.js @@ -16,8 +16,8 @@ Volcanos(chat.ONIMPORT, { _init: function(can, msg) { can.onmotion.clear(can), c }) }, 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) { + msg.Table(function(value) { value.icon = value.icon? "/require/"+value.icon: can.page.drawText(can, value.name, 80) + can.page.Append(can, target, [{view: html.ITEM, list: [{view: html.ICON, list: [{img: value.icon}]}, {view: [mdb.NAME, "", value.name]}], onclick: function(event) { can.sup.onexport.record(can.sup, value.name, mdb.NAME, value) }}]) })