From 4cc9da13c53c4a011b3c6d8442b1baf485e4f32c Mon Sep 17 00:00:00 2001 From: shy Date: Wed, 14 Feb 2024 23:28:59 +0800 Subject: [PATCH] add some --- base/web/dream.go | 2 +- base/web/matrix.go | 4 ++-- base/web/spide.go | 2 +- core/code/upgrade.go | 3 ++- init.go | 11 ++--------- 5 files changed, 8 insertions(+), 14 deletions(-) diff --git a/base/web/dream.go b/base/web/dream.go index 18708a2e..3d7234e5 100644 --- a/base/web/dream.go +++ b/base/web/dream.go @@ -161,7 +161,7 @@ func _dream_binary(m *ice.Message, p string) { GoToast(m, DOWNLOAD, func(toast func(string, int, int)) (list []string) { begin := time.Now() SpideSave(m, bin, kit.MergeURL(p, cli.GOOS, runtime.GOOS, cli.GOARCH, runtime.GOARCH), func(count, total, value int) { - toast(m.Option(mdb.NAME)+" "+kit.FormatShow(cli.COST, kit.FmtDuration(time.Now().Sub(begin))), count, total) + toast(m.Option(mdb.NAME)+"\n"+kit.FormatShow(cli.COST, kit.FmtDuration(time.Now().Sub(begin))), count, total) }) return nil }) diff --git a/base/web/matrix.go b/base/web/matrix.go index 2613e5e9..2781c0b4 100644 --- a/base/web/matrix.go +++ b/base/web/matrix.go @@ -86,7 +86,7 @@ func init() { } GoToast(m, "", func(toast func(name string, count, total int)) []string { fields := kit.Split(mdb.Config(m, mdb.FIELD)) - m.Options("space.timeout", "3s", "dream.simple", ice.TRUE) + m.Options("space.timeout", cli.TIME_300ms, "dream.simple", ice.TRUE) kit.For(_matrix_list(m, "", fields...), func(domain string, index int, total int) { toast(domain, index, total) _matrix_list(m, domain, fields...) @@ -98,7 +98,7 @@ func init() { value = kit.MergeURL(strings.Split(value, "?")[0], ice.POD, kit.Keys(m.Appendv(DOMAIN)[index], m.Appendv(mdb.NAME)[index])) } return value - }).Sort("status,name,domain", []string{cli.START, cli.STOP, ""}, "str_r", "str_r") + }).Sort("type,status,name,domain", []string{SERVER, WORKER, ""}, []string{cli.START, cli.STOP, ""}, "str_r", "str_r") return nil }).Action(html.FILTER, mdb.CREATE).Display("") }}, diff --git a/base/web/spide.go b/base/web/spide.go index f35ec833..d25d9451 100644 --- a/base/web/spide.go +++ b/base/web/spide.go @@ -463,7 +463,7 @@ func SpideSave(m *ice.Message, file, link string, cb func(count, total, value in return m.Cmd(Prefix(SPIDE), ice.DEV_IP, SPIDE_SAVE, file, http.MethodGet, link, cb) } func SpideCache(m *ice.Message, link string) *ice.Message { - return m.Cmd(Prefix(SPIDE), ice.DEV, SPIDE_CACHE, http.MethodGet, link) + return m.Cmd(Prefix(SPIDE), ice.DEV_IP, SPIDE_CACHE, http.MethodGet, link) } func SpideOrigin(m *ice.Message, name string) string { return m.Cmdv(SPIDE, name, CLIENT_ORIGIN) } func SpideURL(m *ice.Message, name string) string { return m.Cmdv(SPIDE, name, CLIENT_URL) } diff --git a/core/code/upgrade.go b/core/code/upgrade.go index c255668d..69f9daf9 100644 --- a/core/code/upgrade.go +++ b/core/code/upgrade.go @@ -61,7 +61,8 @@ func init() { m.Cmdy(nfs.DIR, dir, "time,size,path,hash").Push(web.ORIGIN, kit.MergeURL2(web.SpideOrigin(m, ice.DEV_IP), uri)) }) if web.ToastSuccess(m); m.Option(ice.EXIT) == ice.TRUE { - web.Toast(m, cli.RESTART).Cmd("", cli.RESTART) + web.Toast(m, cli.RESTART) + m.GoSleep("30ms", func() { m.Cmd("", cli.RESTART) }) } }}, }}) diff --git a/init.go b/init.go index fb273a51..b6b34158 100644 --- a/init.go +++ b/init.go @@ -96,15 +96,8 @@ func init() { func Run(arg ...string) string { kit.If(len(arg) == 0 && len(os.Args) > 1, func() { arg = os.Args[1:] }) - if len(arg) == 0 { - if runtime.GOOS == WINDOWS { - arg = append(arg, SERVE, START) - } else { - arg = append(arg, FOREVER, START) - } - } else if arg[0] == FOREVER && arg[1] == START && runtime.GOOS == WINDOWS { - arg[0] = SERVE - } + kit.If(len(arg) == 0, func() { arg = append(arg, FOREVER, START) }) + kit.If(runtime.GOOS == WINDOWS && kit.HasPrefixList(arg, FOREVER, START), func() { arg[0] = SERVE }) Pulse.value(MSG_DETAIL, arg...) kit.For(kit.Sort(os.Environ()), func(env string) { if ls := strings.SplitN(env, EQ, 2); strings.ToLower(ls[0]) == ls[0] && ls[0] != "_" {