From 27d8cbad4896ae78278a59a89829eceb3bd7d0a1 Mon Sep 17 00:00:00 2001 From: shy Date: Sat, 3 Feb 2024 17:56:18 +0800 Subject: [PATCH] opt theme --- base/cli/system.go | 5 +++++ base/tcp/host.go | 8 ++++---- base/web/broad.go | 3 +++ base/web/option.go | 4 ++-- base/web/serve.go | 7 +++++-- base/web/spide.go | 7 ++++++- base/web/store.go | 2 +- core/code/vimer.go | 2 +- 8 files changed, 27 insertions(+), 11 deletions(-) diff --git a/base/cli/system.go b/base/cli/system.go index f0742e38..028f3080 100644 --- a/base/cli/system.go +++ b/base/cli/system.go @@ -128,6 +128,11 @@ func _system_find(m *ice.Message, bin string, dir ...string) string { } const ( + TIME_300ms = "300ms" + TIME_30ms = "30ms" + TIME_30s = "30s" + TIME_3s = "3s" + CMD_DIR = "cmd_dir" CMD_ENV = "cmd_env" diff --git a/base/tcp/host.go b/base/tcp/host.go index 25dcc9e9..108d3f92 100644 --- a/base/tcp/host.go +++ b/base/tcp/host.go @@ -44,9 +44,9 @@ func _host_list(m *ice.Message, name string) *ice.Message { } } } - if len(m.Appendv(aaa.IP)) == 0 { - m.Push(mdb.INDEX, -1).Push(mdb.NAME, LOCALHOST).Push(aaa.IP, "127.0.0.1").Push(MASK, "255.0.0.0").Push(MAC_ADDRESS, "") - } + // if len(m.Appendv(aaa.IP)) == 0 { + // m.Push(mdb.INDEX, -1).Push(mdb.NAME, LOCALHOST).Push(aaa.IP, "127.0.0.1").Push(MASK, "255.0.0.0").Push(MAC_ADDRESS, "") + // } return m.SortInt(mdb.INDEX).StatusTimeCount(DOMAIN, _host_domain(m)) } @@ -73,7 +73,7 @@ func init() { m.Cmd("", func(value ice.Maps) { m.Cmd("", aaa.WHITE, LOCALHOST, value[aaa.IP]) }) }}, mdb.SEARCH: {Hand: func(m *ice.Message, arg ...string) { - if mdb.IsSearchPreview(m, arg) { + if mdb.IsSearchPreview(m, arg) && m.Cmd(HOST).Length() > 0 { ip := m.Cmdv(HOST, GATEWAY, aaa.IP) m.PushSearch(mdb.TYPE, GATEWAY, mdb.NAME, ip, mdb.TEXT, "http://"+ip) } diff --git a/base/web/broad.go b/base/web/broad.go index eed32e15..cf134950 100644 --- a/base/web/broad.go +++ b/base/web/broad.go @@ -22,6 +22,9 @@ func _broad_send(m *ice.Message, to_host, to_port string, host, port string, arg }) } func _broad_serve(m *ice.Message) { + if m.Cmd(tcp.HOST).Length() == 0 { + return + } m.GoSleep300ms(func() { m.Cmd(tcp.HOST, func(value ice.Maps) { _broad_send(m, "", "", value[aaa.IP], m.Option(tcp.PORT), kit.Simple(gdb.EVENT, tcp.LISTEN, mdb.NAME, ice.Info.NodeName, mdb.TYPE, ice.Info.NodeType, mdb.TIME, m.Time(), cli.SimpleMake())...) diff --git a/base/web/option.go b/base/web/option.go index 6fef2f0f..56644691 100644 --- a/base/web/option.go +++ b/base/web/option.go @@ -135,7 +135,7 @@ func ToastFailure(m *ice.Message, arg ...ice.Any) { Toast(m, toastContent(m, ice.FAILURE, arg...), "", m.OptionDefault(ice.TOAST_DURATION, "3s")).Sleep(m.OptionDefault(ice.TOAST_DURATION, "3s")) } func ToastProcess(m *ice.Message, arg ...ice.Any) func(...ice.Any) { - Toast(m, toastContent(m, ice.PROCESS, arg...), "", "30s") + Toast(m, toastContent(m, ice.PROCESS, arg...), "", cli.TIME_30s) return func(arg ...ice.Any) { Toast(m, toastContent(m, ice.SUCCESS, arg...), "", "1s") } } func GoToast(m *ice.Message, title string, cb func(toast func(name string, count, total int)) []string) *ice.Message { @@ -144,7 +144,7 @@ func GoToast(m *ice.Message, title string, cb func(toast func(name string, count toast := func(name string, count, total int) { kit.If(total == 0, func() { total = 1 }) Toast(m, kit.Format("%s %s %s", icon, kit.JoinWord(kit.Select(kit.Select("", m.ActionKey(), m.ActionKey() != ice.LIST), title, m.Option(ice.MSG_TITLE)), name), strings.ReplaceAll(kit.FmtSize(count, total), "B", "")), - "", m.OptionDefault(ice.TOAST_DURATION, "30s"), count*100/total) + "", m.OptionDefault(ice.TOAST_DURATION, cli.TIME_30s), count*100/total) _total = total } if list := cb(toast); len(list) > 0 { diff --git a/base/web/serve.go b/base/web/serve.go index cd57812b..65666c5a 100644 --- a/base/web/serve.go +++ b/base/web/serve.go @@ -29,10 +29,13 @@ func _serve_start(m *ice.Message) { kit.If(m.Option(tcp.PORT) == tcp.RANDOM, func() { m.Option(tcp.PORT, m.Cmdx(tcp.PORT, aaa.RIGHT)) }) cli.NodeInfo(m, kit.Select(kit.Split(ice.Info.Hostname, ".")[0], m.Option(tcp.NODENAME)), SERVER) m.Go(func() { - m.Cmd(SPIDE, ice.OPS, _serve_address(m)+"/exit", ice.Maps{CLIENT_TIMEOUT: "30ms", ice.LOG_DISABLE: ice.TRUE}) + m.Cmd(SPIDE, ice.OPS, _serve_address(m)+"/exit", ice.Maps{CLIENT_TIMEOUT: cli.TIME_30ms, ice.LOG_DISABLE: ice.TRUE}) }).Sleep300ms() - m.Cmd(nfs.SAVE, ice.VAR_LOG_ICE_PORT, m.Option(tcp.PORT)) 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 { + return + } kit.For(kit.Split(m.Option(ice.DEV)), func(dev string) { if m.Cmds(SPIDE, dev).Append(TOKEN) == "" { m.Sleep30ms(SPACE, tcp.DIAL, ice.DEV, dev, mdb.NAME, ice.Info.NodeName, m.OptionSimple(TOKEN)) diff --git a/base/web/spide.go b/base/web/spide.go index 8612fcbb..80ac3b60 100644 --- a/base/web/spide.go +++ b/base/web/spide.go @@ -326,8 +326,13 @@ func init() { m.Cmd("", mdb.CREATE, ice.OPS, kit.Select("http://localhost:9020", conf[cli.CTX_OPS]), nfs.REPOS, nfs.USR_ICONS_VOLCANOS) m.Cmd("", mdb.CREATE, ice.DEMO, kit.Select("http://localhost:20000", conf[cli.CTX_DEMO]), "", nfs.USR_ICONS_VOLCANOS) m.Cmd("", mdb.CREATE, ice.MAIL, kit.Select("https://mail.shylinux.com", conf[cli.CTX_MAIL]), "", "usr/icons/Mail.png") + if m.Cmd(tcp.HOST).Length() == 0 { + return + } mdb.HashSelects(m.Spawn()).Table(func(value ice.Maps) { - kit.If(value[TOKEN], func() { m.Cmd(SPACE, tcp.DIAL, ice.DEV, value[CLIENT_NAME], TOKEN, value[TOKEN], mdb.TYPE, SERVER) }) + kit.If(value[TOKEN], func() { + m.Cmd(SPACE, tcp.DIAL, ice.DEV, value[CLIENT_NAME], TOKEN, value[TOKEN], mdb.TYPE, SERVER) + }) }) }}, mdb.SEARCH: {Hand: func(m *ice.Message, arg ...string) { diff --git a/base/web/store.go b/base/web/store.go index 9bae2896..780d2484 100644 --- a/base/web/store.go +++ b/base/web/store.go @@ -43,7 +43,7 @@ func init() { PORTAL: {Role: aaa.VOID, Hand: func(m *ice.Message, arg ...string) { ProcessIframe(m, m.Option(mdb.NAME), m.Option(ORIGIN)+S(m.Option(mdb.NAME))+C(PORTAL), arg...) }}, - }, ctx.ConfAction(CLIENT_TIMEOUT, "300ms")), Hand: func(m *ice.Message, arg ...string) { + }, ctx.ConfAction(CLIENT_TIMEOUT, cli.TIME_300ms)), Hand: func(m *ice.Message, arg ...string) { m.Display("") if len(arg) == 0 { m.Cmd(SPIDE, arg, kit.Dict(ice.MSG_FIELDS, "time,icons,client.type,client.name,client.origin")).Table(func(value ice.Maps) { diff --git a/core/code/vimer.go b/core/code/vimer.go index 0f05c1eb..677457c0 100644 --- a/core/code/vimer.go +++ b/core/code/vimer.go @@ -182,7 +182,7 @@ func init() { } if msg := m.Cmd(cmds); cli.IsSuccess(msg) { if m.GoSleep30ms(func() { m.Cmd(UPGRADE, cli.RESTART) }); isWebview() { - m.Cmd(cli.DAEMON, ice.BIN_ICE_BIN, cli.FOREVER, cli.DELAY, "300ms", cli.SYSTEM, cli.OPEN, app) + m.Cmd(cli.DAEMON, ice.BIN_ICE_BIN, cli.FOREVER, cli.DELAY, cli.TIME_300ms, cli.SYSTEM, cli.OPEN, app) } } else { _vimer_make(m, nfs.PWD, msg)