From 8c8238ceb991f6adcc49995b39eb0d140dcccd80 Mon Sep 17 00:00:00 2001 From: shy Date: Fri, 23 Feb 2024 22:43:20 +0800 Subject: [PATCH] opt some --- base/cli/qrcode.go | 2 +- base/web/dream.go | 5 +++-- base/web/option.go | 2 +- base/web/serve.go | 2 +- base/web/space.go | 8 ++++---- base/web/toast.go | 2 +- conf.go | 1 + core/chat/macos/desktop.css | 2 ++ core/wiki/portal.js | 3 ++- info.go | 21 +++++++++++++-------- 10 files changed, 29 insertions(+), 19 deletions(-) diff --git a/base/cli/qrcode.go b/base/cli/qrcode.go index 5e0d8028..74203a6f 100644 --- a/base/cli/qrcode.go +++ b/base/cli/qrcode.go @@ -37,7 +37,7 @@ func _qrcode_web(m *ice.Message, text string) string { sc.ForegroundColor = ParseColor(m.Option(FG)) sc.BackgroundColor = ParseColor(m.Option(BG)) if data, err := sc.PNG(kit.Int(m.Option(SIZE))); m.Assert(err) { - m.Echo(``, base64.StdEncoding.EncodeToString(data), text) + m.Echo(``, base64.StdEncoding.EncodeToString(data), text) } return text } diff --git a/base/web/dream.go b/base/web/dream.go index 2d747060..66a23d19 100644 --- a/base/web/dream.go +++ b/base/web/dream.go @@ -117,7 +117,8 @@ func _dream_start(m *ice.Message, name string) { return } if !m.IsCliUA() { - defer m.ProcessOpen(m.MergePod(name)) + // defer m.ProcessOpen(m.MergePod(name)) + defer m.ProcessOpenAndRefresh(m.MergePod(name)) defer ToastProcess(m, mdb.CREATE, name)() } defer mdb.Lock(m, m.PrefixKey(), cli.START, name)() @@ -334,7 +335,7 @@ func init() { DreamEach(m, m.Option(mdb.NAME), "", func(name string) { m.Cmd(SPACE, name, AUTOGEN, BINPACK) kit.For(list, func(goos string) { - PushNoticeRich(m, mdb.NAME, name, msg.Cmd(SPACE, name, COMPILE, goos, cli.AMD64, kit.Dict(ice.MSG_USERPOD, name)).AppendSimple()) + PushNoticeRich(m.Options(ice.MSG_COUNT, "0", ice.LOG_DISABLE, ice.TRUE), mdb.NAME, name, msg.Cmd(SPACE, name, COMPILE, goos, cli.AMD64, kit.Dict(ice.MSG_USERPOD, name)).AppendSimple()) }) }).ProcessHold() }}, diff --git a/base/web/option.go b/base/web/option.go index e6bf4d41..c14b1c5c 100644 --- a/base/web/option.go +++ b/base/web/option.go @@ -73,7 +73,7 @@ func PushNotice(m *ice.Message, arg ...ice.Any) { return } opts := ice.Map{ice.MSG_OPTION: []string{}, ice.MSG_OPTS: []string{}} - kit.For([]string{ctx.DISPLAY, ctx.STYLE, cli.DELAY, ice.MSG_TITLE, ice.MSG_STATUS, ice.LOG_DEBUG, ice.LOG_TRACEID}, func(key string) { + kit.For([]string{ctx.DISPLAY, ctx.STYLE, cli.DELAY, ice.MSG_TITLE, ice.MSG_STATUS, ice.LOG_DEBUG, ice.LOG_TRACEID, ice.LOG_DISABLE}, func(key string) { opts[ice.MSG_OPTION], opts[key] = kit.Simple(opts[ice.MSG_OPTION], key), m.Option(key) }) m.Cmd(SPACE, m.Option(ice.MSG_DAEMON), arg, opts) diff --git a/base/web/serve.go b/base/web/serve.go index d06812cb..828d6df8 100644 --- a/base/web/serve.go +++ b/base/web/serve.go @@ -32,7 +32,7 @@ func _serve_start(m *ice.Message) { cli.NodeInfo(m, kit.Select(kit.Split(ice.Info.Hostname, nfs.PT)[0], m.Option(tcp.NODENAME)), SERVER) m.Go(func() { m.Cmd(SPIDE, ice.OPS, _serve_address(m)+"/exit", ice.Maps{CLIENT_TIMEOUT: cli.TIME_30ms, ice.LOG_DISABLE: ice.TRUE}) - }).Sleep300ms() + }).Sleep(cli.TIME_1s) m.Start("", m.OptionSimple(tcp.HOST, tcp.PORT)...) m.Cmd(nfs.SAVE, ice.VAR_LOG_ICE_PORT, m.Option(tcp.PORT)) if m.Cmd(tcp.HOST).Length() == 0 { diff --git a/base/web/space.go b/base/web/space.go index 8c23f5f3..c458b746 100644 --- a/base/web/space.go +++ b/base/web/space.go @@ -205,10 +205,10 @@ func _space_send(m *ice.Message, name string, arg ...string) (h string) { if target := kit.Split(name, nfs.PT, nfs.PT); !mdb.HashSelectDetail(m, target[0], func(value ice.Map) { if c, ok := value[mdb.TARGET].(*websocket.Conn); !m.WarnNotValid(!ok, mdb.TARGET) { kit.If(kit.Format(value[mdb.TYPE]) == MASTER, func() { - m.Options(ice.MSG_USERWEB, value[mdb.TEXT], - ice.MSG_USERPOD, "", - ice.MSG_USERPOD0, name, - ice.MSG_USERHOST, "") + m.Options( + ice.MSG_USERWEB0, m.Option(ice.MSG_USERWEB), ice.MSG_USERPOD0, name, + ice.MSG_USERWEB, value[mdb.TEXT], ice.MSG_USERPOD, "", ice.MSG_USERHOST, "", + ) }) kit.For([]string{ice.MSG_USERROLE, ice.LOG_TRACEID}, func(k string) { m.Optionv(k, m.Optionv(k)) }) kit.For(m.Optionv(ice.MSG_OPTS), func(k string) { m.Optionv(k, m.Optionv(k)) }) diff --git a/base/web/toast.go b/base/web/toast.go index b563e18f..18084684 100644 --- a/base/web/toast.go +++ b/base/web/toast.go @@ -62,7 +62,7 @@ func ToastSuccess(m *ice.Message, arg ...ice.Any) { Toast(m, toastContent(m, ice.SUCCESS, arg...), "", cli.TIME_3s) } func ToastFailure(m *ice.Message, arg ...ice.Any) { - Toast(m, toastContent(m, ice.FAILURE, arg...), "", m.OptionDefault(ice.TOAST_DURATION, cli.TIME_3s)).Sleep(m.OptionDefault(ice.TOAST_DURATION, cli.TIME_3s)) + Toast(m, toastContent(m, ice.FAILURE, arg...), "", m.OptionDefault(ice.TOAST_DURATION, "-1")).Sleep(m.OptionDefault(ice.TOAST_DURATION, cli.TIME_3s)) } func ToastProcess(m *ice.Message, arg ...ice.Any) func(...ice.Any) { text := toastContent(m, ice.PROCESS, arg...) diff --git a/conf.go b/conf.go index 3b607167..1f4c51d0 100644 --- a/conf.go +++ b/conf.go @@ -211,6 +211,7 @@ const ( // MSG MSG_USERWEB = "user.web" MSG_USERPOD = "user.pod" MSG_USERPOD0 = "user.pod0" + MSG_USERWEB0 = "user.web0" MSG_USERHOST = "user.host" MSG_USERADDR = "user.addr" MSG_USERDATA = "user.data" diff --git a/core/chat/macos/desktop.css b/core/chat/macos/desktop.css index 1e7bf149..6be6e3b4 100644 --- a/core/chat/macos/desktop.css +++ b/core/chat/macos/desktop.css @@ -42,6 +42,7 @@ fieldset.macos.desktop>div.output>div.desktop>fieldset>form.option>div.icon { ma fieldset.macos.desktop>div.output>div.desktop>fieldset>form.option>div.list.icons { margin:var(--button-margin) 0; } fieldset.macos.desktop>div.output>div.desktop>fieldset>form.option>div.back.icons { margin:var(--button-margin) 0; } fieldset.macos.desktop>div.output>div.desktop>fieldset>div.action>div.item:last-child { margin-right:100px; } +body:not(.mobile) fieldset.macos.desktop>div.output>div.desktop>fieldset>div.action:not(.hide) { display:contents; } fieldset.macos.desktop>div.output>div.desktop>fieldset>div.action>* { margin:var(--button-margin) var(--input-margin); } fieldset.macos.desktop>div.output>div.desktop>fieldset>div.action>div.tabs { display:none; } fieldset.macos.desktop>div.output>div.desktop>fieldset>div.output { min-height:240px; } @@ -75,6 +76,7 @@ fieldset.macos.dock>div.output>div.item img { object-fit:contain; min-height:var fieldset.macos.dock>div.output>div.item>div.name { display:none; } fieldset.macos.finder>div.output div.content>div.item { text-align:center; float:left; } fieldset.macos.finder>div.output div.content>div.item img { object-fit:contain; width:var(--desktop-icon-size); } +fieldset.macos.finder>div.output div.content>div.item img { object-fit:contain; width:var(--desktop-icon-size); height:var(--desktop-icon-size); } fieldset.macos.finder>div.output div.content>div.item div.name { font-size:var(--code-font-size); text-align:center; } body.dark fieldset.macos.desktop>div.output>fieldset.macos { background-color:#08234ad1; } body.dark fieldset.macos.desktop>div.output>div.desktop fieldset table.content tbody tr:nth-child(odd):not(:hover) { background-color:#282B2F; } diff --git a/core/wiki/portal.js b/core/wiki/portal.js index 7835a68d..0b04d567 100644 --- a/core/wiki/portal.js +++ b/core/wiki/portal.js @@ -1,5 +1,6 @@ Volcanos(chat.ONIMPORT, { - _init: function(can, msg) { can.isCmdMode() && (can.user.toast = function() {}) + _init: function(can, msg) { + // can.isCmdMode() && (can.user.toast = function() {}) var p = "/cmd/"+web.PORTAL; can.db.prefix = location.pathname.indexOf(p) > -1? location.pathname.split(p)[0]+p: nfs.WIKI_PORTAL var p = "/c/"+web.PORTAL; can.db.prefix = location.pathname.indexOf(p) > -1? location.pathname.split(p)[0]+p: nfs.WIKI_PORTAL can.db.current = can.isCmdMode()? can.base.trimPrefix(location.pathname, can.db.prefix+nfs.PS, can.db.prefix): can.Option(nfs.PATH) diff --git a/info.go b/info.go index 32197ee1..1b12eec4 100644 --- a/info.go +++ b/info.go @@ -283,9 +283,10 @@ func Module(prefix string, arg ...Any) { } } func (m *Message) FileURI(dir string) string { - if dir == "" { - return "" - } else if strings.Contains(dir, "/pkg/mod/") { + if dir == "" || kit.HasPrefix(dir, HTTP) { + return dir + } + if strings.Contains(dir, "/pkg/mod/") { dir = strings.Split(dir, "/pkg/mod/")[1] } else if Info.Make.Path != "" && strings.HasPrefix(dir, Info.Make.Path) { dir = strings.TrimPrefix(dir, Info.Make.Path) @@ -293,12 +294,16 @@ func (m *Message) FileURI(dir string) string { dir = strings.TrimPrefix(dir, kit.Path("")+PS) } else if strings.HasPrefix(dir, ISH_PLUGED) { dir = strings.TrimPrefix(dir, ISH_PLUGED) - } else if kit.HasPrefix(dir, PS, HTTP) { - return dir } - if strings.HasPrefix(dir, USR_VOLCANOS) { - return strings.TrimPrefix(dir, USR) + if strings.HasPrefix(dir, PS) { + + } else if strings.HasPrefix(dir, USR_VOLCANOS) { + dir = strings.TrimPrefix(dir, USR) } else { - return kit.MergeURL(path.Join(PS, REQUIRE, dir), POD, m.Option(MSG_USERPOD)) + dir = kit.MergeURL(path.Join(PS, REQUIRE, dir), POD, m.Option(MSG_USERPOD)) } + if m.Option(MSG_USERWEB0) != "" { + dir = kit.MergeURL2(m.Option(MSG_USERWEB), dir) + } + return dir }