From 3f945f963ad68a1cac42cc711417da108d434ae1 Mon Sep 17 00:00:00 2001 From: shy Date: Sun, 26 May 2024 11:27:48 +0800 Subject: [PATCH] add some --- base/mdb/hash.go | 2 +- base/mdb/mdb.go | 2 +- base/web/dream.go | 7 +++++ base/web/product.go | 22 ++++++++++++++++ base/web/store.go | 6 +++++ core/chat/macos/desktop.go | 10 ++++++- core/code/inner.go | 6 +++++ core/code/xterm.go | 4 +++ core/wiki/portal.css | 11 ++++---- core/wiki/portal.go | 54 +------------------------------------- core/wiki/spark.go | 8 ++++++ 11 files changed, 71 insertions(+), 61 deletions(-) create mode 100644 base/web/product.go diff --git a/base/mdb/hash.go b/base/mdb/hash.go index 72f37ead..f51da10f 100644 --- a/base/mdb/hash.go +++ b/base/mdb/hash.go @@ -291,7 +291,7 @@ func HashSelect(m *ice.Message, arg ...string) *ice.Message { kit.If(kit.Select(Config(m, SHORT), Config(m, SORT)), func(sort string) { kit.If(sort != UNIQ, func() { m.Sort(sort) }) }) if m.PushAction(Config(m, ACTION), REMOVE); !m.FieldsIsDetail() { m.Options(ice.TABLE_CHECKBOX, Config(m, html.CHECKBOX)) - return m.Action(CREATE, PRUNES) + return m.Action(CREATE) } return sortByField(m, HashField(m), arg...) } diff --git a/base/mdb/mdb.go b/base/mdb/mdb.go index dc06f0fd..1c83ec70 100644 --- a/base/mdb/mdb.go +++ b/base/mdb/mdb.go @@ -294,7 +294,7 @@ func AutoConfig(arg ...Any) *ice.Action { } add := func(list []string) (inputs []Any) { kit.For(list, func(k string) { - kit.If(!kit.IsIn(k, TIME, HASH, COUNT, ID), func() { + kit.If(!kit.IsIn(k, TIME, HASH, COUNT, ID, ENABLE, DISABLE), func() { inputs = append(inputs, k+kit.Select("", FOREACH, strings.Contains(s, k))) }) }) diff --git a/base/web/dream.go b/base/web/dream.go index 82998e21..a486c29d 100644 --- a/base/web/dream.go +++ b/base/web/dream.go @@ -219,6 +219,13 @@ func init() { DREAM: {Name: "dream refresh", Help: "梦想家", Icon: "Launchpad.png", Role: aaa.VOID, Meta: kit.Dict( ice.CTX_TRANS, kit.Dict(html.INPUT, kit.Dict(WORKER, "空间", SERVER, "门户", ORIGIN, "主机")), ), Actions: ice.MergeActions(ice.Actions{ + ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { + AddPortalProduct(m, "空间", ` +比虚拟机和容器,更加轻量,每个空间都是一个完整的系统,拥有各种软件与独立的环境。 +空间内所有的软件、配置、数据以源码库形式保存,每个空间都可以随时启动、停止、上传、下载、分享。 +每个空间都自带软件开发工具,也可以随时编程添加新的功能。 +`, 200.0) + }}, html.BUTTON: {Hand: func(m *ice.Message, arg ...string) { mdb.Config(m, html.BUTTON, kit.Join(arg)) }}, diff --git a/base/web/product.go b/base/web/product.go new file mode 100644 index 00000000..a5e74743 --- /dev/null +++ b/base/web/product.go @@ -0,0 +1,22 @@ +package web + +import ( + ice "shylinux.com/x/icebergs" + "shylinux.com/x/icebergs/base/ctx" + "shylinux.com/x/icebergs/base/mdb" + kit "shylinux.com/x/toolkits" +) + +const PRODUCT = "product" + +func init() { + Index.MergeCommands(ice.Commands{ + PRODUCT: {Name: "product refresh", Help: "产品展示", Actions: mdb.HashAction(mdb.SHORT, "index", mdb.FIELD, "time,name,text,order,disable,index,args"), Hand: func(m *ice.Message, arg ...string) { + mdb.HashSelect(m, arg...).SortInt(mdb.ORDER) + }}, + }) +} + +func AddPortalProduct(m *ice.Message, name, text string, order float64, arg ...string) { + m.Cmd("web.product", mdb.CREATE, mdb.NAME, name, mdb.TEXT, text, mdb.ORDER, order, ctx.INDEX, m.PrefixKey(), ctx.ARGS, kit.Format(arg)) +} diff --git a/base/web/store.go b/base/web/store.go index 1f692b66..977bb8da 100644 --- a/base/web/store.go +++ b/base/web/store.go @@ -18,6 +18,12 @@ const STORE = "store" func init() { Index.MergeCommands(ice.Commands{ STORE: {Name: "store refresh", Help: "商店", Icon: "App Store.png", Role: aaa.VOID, Actions: ice.MergeActions(ice.Actions{ + ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { + AddPortalProduct(m, "商店", ` +每个用户都可以将自己的空间列表,以系统商店的方式分享给其它用户。 +同样的每个用户,也可以添加任意多个商店,直接将空间下载到本机使用。 +`, 300.0) + }}, mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) { m.Cmdy(SPIDE, mdb.INPUTS, arg) }}, mdb.CREATE: {Name: "create origin* name icons", Hand: func(m *ice.Message, arg ...string) { m.Cmd(SPIDE, mdb.CREATE, m.OptionSimple("origin,name,icons"), mdb.TYPE, nfs.REPOS) diff --git a/core/chat/macos/desktop.go b/core/chat/macos/desktop.go index 3b402544..127552c6 100644 --- a/core/chat/macos/desktop.go +++ b/core/chat/macos/desktop.go @@ -15,7 +15,9 @@ const DESKTOP = "desktop" func init() { Index.MergeCommands(ice.Commands{ - ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { m.Cmd(web.BINPACK, mdb.INSERT, nfs.USR_ICONS) }}, + ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { + m.Cmd(web.BINPACK, mdb.INSERT, nfs.USR_ICONS) + }}, ice.CTX_OPEN: {Hand: func(m *ice.Message, arg ...string) { if m.Cmd(DESKTOP).Length() == 0 { DeskAppend(m, "Books.png", web.WIKI_WORD) @@ -40,6 +42,12 @@ func init() { Notify(m, "usr/icons/Infomation.png", cli.RUNTIME, "系统启动成功", ctx.INDEX, cli.RUNTIME) }}, DESKTOP: {Help: "桌面", Role: aaa.VOID, Actions: ice.MergeActions(ice.Actions{ + ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { + web.AddPortalProduct(m, "桌面", ` +一款网页版的电脑桌面,打开网页即可随时随地的使用各种软件, +无论这些软件是运行在本机,还是远程,还是任何虚拟的空间,无论是内存还是磁盘。 +`, 100.0) + }}, // web.DREAM_ACTION: {Hand: func(m *ice.Message, arg ...string) { web.DreamProcessIframe(m, arg...) }}, // web.DREAM_ACTION: {Hand: func(m *ice.Message, arg ...string) { web.DreamProcess(m, "", arg, arg...) }}, }, web.DreamTablesAction(), PodCmdAction(), CmdHashAction(ctx.INDEX), mdb.ExportHashAction())}, diff --git a/core/code/inner.go b/core/code/inner.go index 394062b9..f771fde4 100644 --- a/core/code/inner.go +++ b/core/code/inner.go @@ -75,6 +75,12 @@ const INNER = "inner" func init() { Index.MergeCommands(ice.Commands{ INNER: {Name: "inner path=src/ file=main.go line=1 auto", Help: "源代码", Role: aaa.VOID, Actions: ice.Actions{ + ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { + web.AddPortalProduct(m, "编辑器", ` +一款网页版的编辑器,打开网页即可随时随地的编程, +无论这些代码是保存在本机,还是远程,还是任何虚拟的空间,无论是内存还是磁盘。 +`, 400.0) + }}, mdb.PLUGIN: {Hand: func(m *ice.Message, arg ...string) { if m.Cmdy(mdb.PLUGIN, arg); m.Result() == "" { m.Cmdy(mdb.PLUGIN, m.Option(lex.PARSE, strings.ToLower(kit.Split(path.Base(arg[1]), nfs.PT)[0])), arg[1:]) diff --git a/core/code/xterm.go b/core/code/xterm.go index 2efcdd93..8a6923bd 100644 --- a/core/code/xterm.go +++ b/core/code/xterm.go @@ -70,6 +70,10 @@ func init() { Index.MergeCommands(ice.Commands{ XTERM: {Name: "xterm refresh", Help: "终端", Icon: "Terminal.png", Actions: ice.MergeActions(ice.Actions{ ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { + web.AddPortalProduct(m, "命令行", ` +一款网页版的命令行,打开网页即可随时随地的敲命令, +无论这些命令是运行在本机,还是远程,还是任何虚拟的空间,无论是内存还是磁盘。 +`, 500.0) kit.For([]string{ "xterm/lib/xterm.js", "xterm/css/xterm.css", diff --git a/core/wiki/portal.css b/core/wiki/portal.css index ee8d6391..123788b2 100644 --- a/core/wiki/portal.css +++ b/core/wiki/portal.css @@ -37,17 +37,20 @@ fieldset.web.wiki.portal>div.output>div.layout>div.main fieldset.inner.output di --code-function:cyan; --code-constant:silver; --code-string:silver; --code-package:silver; --code-datatype:silver; --code-object:silver; } -body.dark fieldset.web.wiki.portal>div.output>div.layout>div.main div.story[data-type=spark][data-name=shell] { border-left:var(--box-notice3); } -// body.dark fieldset.web.wiki.portal>div.output>div.layout>div.main div.story[data-type=spark][data-name=shell] { border:var(--box-border); } fieldset.web.wiki.portal>div.output>div.layout>div.main div.story[data-type=spark][data-name=shell] { box-shadow:var(--th-box-shadow); border:0; border-left:var(--box-notice3); } fieldset.web.wiki.portal>div.output>div.layout>div.main div.story[data-type=spark][data-name=shell]:hover { box-shadow:var(--notice-box-shadow); } fieldset.web.wiki.portal>div.output>div.layout>div.main div.story[data-type=spark][data-name=shell] { background-color:var(--code-bg-color); color:var(--code-fg-color); padding:var(--button-padding); margin-top:var(--button-margin); } fieldset.web.wiki.portal>div.output>div.layout>div.main table.content div.story[data-type=spark][data-name=shell] { margin-top:unset; } fieldset.web.wiki.portal.home>div.output>div.layout>div.main p { white-space:pre-wrap; text-align:center; } fieldset.web.wiki.portal.home>div.output>div.layout>div.main p:hover { background-color:var(--hover-bg-color); color:var(--hover-fg-color); } -body.dark fieldset.web.wiki.portal>div.output>div.layout { background-color:var(--plugin-bg-color); --code-bg-color:var(--output-bg-color); } + body.dark fieldset.web.wiki.portal>div.output>div.header div.story[data-name=navmenu] div.item:hover { background-color:var(--plugin-bg-color); } body.dark fieldset.web.wiki.portal>div.output>div.header div.story[data-name=navmenu] div.item.select { background-color:var(--plugin-bg-color); } +body.dark fieldset.web.wiki.portal>div.output>div.layout { background-color:var(--plugin-bg-color); --code-bg-color:var(--output-bg-color); } +body.dark fieldset.web.wiki.portal>div.output>div.layout>div.main fieldset:not(.macos) { border:var(--plugin-border); } +body.dark fieldset.web.wiki.portal>div.output>div.layout>div.main fieldset.output>div.output { border-radius:var(--plugin-radius); } +body.dark fieldset.web.wiki.portal>div.output>div.layout>div.main div.story[data-type=spark][data-name=shell] { border-left:var(--box-notice3); } +// body.dark fieldset.web.wiki.portal>div.output>div.layout>div.main div.story[data-type=spark][data-name=shell] { border:var(--box-border); } body.white fieldset.web.wiki.portal>div.output>div.header { color:silver; } body.light fieldset.web.wiki.portal>div.output>div.header { color:white; } body.light fieldset.web.wiki.portal>div.output>div.header div.story[data-name=navmenu] { --hover-fg-color:black; } @@ -57,8 +60,6 @@ body.mobile fieldset.web.wiki.portal>div.output>div.layout>div.nav { height:400p body.mobile fieldset.web.wiki.portal>div.output>div.layout>div.main { height:unset; } body.mobile fieldset.web.wiki.portal>div.output>div.layout>div.main div.story.column { padding:10px 0 !important; } body.mobile fieldset.web.wiki.portal>div.output>div.layout>div.main fieldset { width:fit-content; } -body.dark fieldset.web.wiki.portal>div.output>div.layout>div.main fieldset:not(.macos) { border:var(--plugin-border); } -body.dark fieldset.web.wiki.portal>div.output>div.layout>div.main fieldset.output>div.output { border-radius:var(--plugin-radius); } body.mobile fieldset.web.wiki.portal>div.output>div.layout>div.main fieldset>div.action { display:none; } body.mobile fieldset.web.wiki.portal.cmd>div.output>div.header div.story[data-name=navmenu] div.item { line-height:calc(var(--portal-header-height) - 2 * var(--legend-padding)); } body.mobile fieldset.web.wiki.portal.home>div.output>div.layout>div.main p { white-space:normal; text-align:center; padding:var(--button-padding); } diff --git a/core/wiki/portal.go b/core/wiki/portal.go index f451798d..e63243c5 100644 --- a/core/wiki/portal.go +++ b/core/wiki/portal.go @@ -2,64 +2,14 @@ package wiki import ( "path" - "strings" ice "shylinux.com/x/icebergs" "shylinux.com/x/icebergs/base/aaa" "shylinux.com/x/icebergs/base/ctx" - "shylinux.com/x/icebergs/base/lex" "shylinux.com/x/icebergs/base/nfs" "shylinux.com/x/icebergs/base/web" - kit "shylinux.com/x/toolkits" ) -func _portal_commands(m *ice.Message, arg ...string) { - const ( - MAIN = "main" - BASE = "base" - CORE = "core" - MISC = "misc" - ) - help := map[string]string{} - list := map[string][]string{} - m.Travel(func(p *ice.Context, c *ice.Context, key string, cmd *ice.Command) { - if p := kit.ExtChange(cmd.FileLine(), nfs.SHY); nfs.Exists(m, p) { - help[strings.TrimPrefix(m.PrefixKey(), "web.")] = p - } - if strings.Contains(cmd.FileLine(), ice.Info.Make.Module) || strings.HasPrefix(cmd.FileLine(), ice.Info.Make.Path+nfs.SRC) { - list[MAIN] = append(list[MAIN], m.PrefixKey()) - } else if strings.Contains(cmd.FileLine(), nfs.PS+ice.ICEBERGS) { - for _, mod := range []string{BASE, CORE, MISC} { - if strings.Contains(cmd.FileLine(), nfs.PS+mod) { - list[mod] = append(list[mod], m.PrefixKey()) - } - } - } - }) - text := []string{"navmenu `"} - for _, mod := range []string{BASE, CORE, MISC} { - text = append(text, kit.Format("%s %s/", map[string]string{MAIN: "业务模块", BASE: "基础模块", CORE: "核心模块", MISC: "其它模块"}[mod], mod)) - last := "ice" - for _, cmd := range list[mod] { - kit.If(mod != BASE, func() { cmd = strings.TrimPrefix(cmd, "web.") }) - if !strings.HasPrefix(cmd, last) { - last = strings.Split(cmd, nfs.PT)[0] - if p := path.Join(nfs.USR_LEARNING_PORTAL, path.Join(arg...), mod, last); nfs.Exists(m, p) { - text = append(text, kit.Format(" %s %s/", last, last)) - } - } - cmd = strings.TrimPrefix(cmd, last+nfs.PT) - if p := path.Join(nfs.USR_LEARNING_PORTAL, path.Join(arg...), mod, last, strings.Replace(cmd, nfs.PT, nfs.PS, -1)+".shy"); nfs.Exists(m, p) { - text = append(text, kit.Format(" %s %s.shy", cmd, cmd)) - } else if p, ok := help[last+nfs.PT+cmd]; ok { - text = append(text, kit.Format(" %s %s", cmd, kit.TrimPrefix(m.FileURI(p), nfs.P, nfs.REQUIRE))) - } - } - } - text = append(text, "`") - m.Cmd(nfs.SAVE, path.Join(nfs.USR_LEARNING_PORTAL, path.Join(arg...), INDEX_SHY), strings.Join(text, lex.NL)) -} - const ( INDEX_SHY = "index.shy" HEADER = "header" @@ -77,17 +27,15 @@ func init() { ctx.Run(m, arg...) m.Cmd(nfs.SAVE, p, ice.Maps{nfs.CONTENT: m.FormatsMeta(nil), nfs.DIR_ROOT: ""}) } else { - m.Option(ice.MSG_USERROLE, aaa.TECH) + // m.Option(ice.MSG_USERROLE, aaa.TECH) m.Copy(m.Spawn([]byte(m.Cmdx(nfs.CAT, p)))) } }}, web.DREAM_ACTION: {Hand: func(m *ice.Message, arg ...string) { web.DreamProcessIframe(m, arg...) }}, }, web.ServeCmdAction(), web.DreamTablesAction()), Hand: func(m *ice.Message, arg ...string) { if m.Push(HEADER, m.Cmdx(WORD, _portal_path(m, INDEX_SHY))); len(arg) > 0 { - kit.If(path.Join(arg...) == "commands", func() { _portal_commands(m, arg...) }) m.Push(NAV, m.Cmdx(WORD, _portal_path(m, path.Join(arg...), INDEX_SHY))) } - web.Count(m, "", path.Join(arg...)) m.Display("") }}, }) diff --git a/core/wiki/spark.go b/core/wiki/spark.go index 07905d6d..c32840bb 100644 --- a/core/wiki/spark.go +++ b/core/wiki/spark.go @@ -138,6 +138,14 @@ open http://localhost:9020 m.Cmdy(STYLE, END) } func _spark_product(m *ice.Message, arg ...string) { + if len(arg) == 0 { + m.Cmd("web.product").Table(func(value ice.Maps) { + if value[mdb.DISABLE] != ice.FALSE { + _spark_product(m, value[ctx.INDEX], value[mdb.NAME], value[mdb.TEXT]) + } + }) + return + } m.Cmdy(SPARK, TITLE, arg[1]).Cmdy(SPARK, arg[2]) m.Cmdy(FIELD, arg[1], arg[0], arg[3:]) }