From 8fd16ff52c85b42e88a123f4a5d8e6c8bfacea0b Mon Sep 17 00:00:00 2001 From: harveyshao Date: Thu, 16 Sep 2021 12:32:11 +0800 Subject: [PATCH] opt some --- base/web/dream.go | 10 ++++++---- base/web/serve.go | 3 +++ base/web/space.go | 12 +++++++----- base/web/spide.go | 5 +++++ misc.go | 8 ++++++++ misc/git/status.go | 3 ++- 6 files changed, 31 insertions(+), 10 deletions(-) diff --git a/base/web/dream.go b/base/web/dream.go index e604803f..5db418e3 100644 --- a/base/web/dream.go +++ b/base/web/dream.go @@ -140,11 +140,13 @@ func init() { cli.CMD, []interface{}{"ice.bin", SPACE, tcp.DIAL}, cli.ENV, kit.Dict(ice.CTX_LOG, ice.BIN_BOOTLOG), "miss", `#!/bin/bash -[ -f $PWD/.ish/plug.sh ] || [ -f $HOME/.ish/plug.sh ] || git clone ${ISH_CONF_HUB_PROXY:="https://"}shylinux.com/x/intshell $PWD/.ish -[ "$ISH_CONF_PRE" != "" ] || source $PWD/.ish/plug.sh || source $HOME/.ish/plug.sh -require miss.sh +if [ "$ISH_CONF_PRE" = "" ]; then + [ -f $PWD/.ish/plug.sh ] || [ -f $HOME/.ish/plug.sh ] || git clone ${ISH_CONF_HUB_PROXY:="https://"}shylinux.com/x/intshell $PWD/.ish + source $PWD/.ish/plug.sh || source $HOME/.ish/plug.sh +fi -# ish_miss_prepare_compile +require miss.sh +ish_miss_prepare_compile ish_miss_prepare_develop ish_miss_prepare_install diff --git a/base/web/serve.go b/base/web/serve.go index c052aa05..6f525ef1 100644 --- a/base/web/serve.go +++ b/base/web/serve.go @@ -305,6 +305,9 @@ func init() { _share_repos(m, path.Join(arg[0], arg[1], arg[2]), arg[3:]...) }}, "/help/": {Name: "/help/", Help: "帮助", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) { + if len(arg) == 0 { + arg = append(arg, "tutor.shy") + } if len(arg) > 0 && arg[0] != ctx.ACTION { arg[0] = "src/help/" + arg[0] } diff --git a/base/web/space.go b/base/web/space.go index 8a6c7807..abcbf35c 100644 --- a/base/web/space.go +++ b/base/web/space.go @@ -281,13 +281,15 @@ func init() { switch kind { case CHROME: // 交互节点 - switch m.Option("cmd") { - case "pwd": - m.Go(func(msg *ice.Message) { + m.Go(func(msg *ice.Message) { + switch m.Option("cmd") { + case "pwd": link := kit.MergeURL(_space_domain(msg), "grant", name) msg.Sleep("100ms").Cmd(SPACE, name, "pwd", name, link, msg.Cmdx(cli.QRCODE, link)) - }) - } + default: + msg.Sleep("100ms").Cmd(SPACE, name, "pwd", name) + } + }) case WORKER: // 工作节点 m.Event(DREAM_START, args...) defer m.Event(DREAM_STOP, args...) diff --git a/base/web/spide.go b/base/web/spide.go index e3166e9d..7092ff52 100644 --- a/base/web/spide.go +++ b/base/web/spide.go @@ -88,6 +88,10 @@ func _spide_show(m *ice.Message, arg ...string) { return } + for k, v := range res.Header { + m.Debug("%v: %v", k, v) + } + // 检查结果 defer res.Body.Close() m.Cost(kit.MDB_STATUS, res.Status, kit.MDB_SIZE, res.Header.Get(ContentLength), kit.MDB_TYPE, res.Header.Get(ContentType)) @@ -108,6 +112,7 @@ func _spide_show(m *ice.Message, arg ...string) { m.Warn(true, ice.ErrNotRight, " of ", uri) return default: + } } diff --git a/misc.go b/misc.go index 6ce174af..75cd621b 100644 --- a/misc.go +++ b/misc.go @@ -466,3 +466,11 @@ func (m *Message) SetResult() { m.Set(MSG_RESULT) return } + +func (m *Message) AppendTrans(cb func(value string, key string, index int) string) { + for _, k := range m.meta[MSG_APPEND] { + for i, v := range m.meta[k] { + m.meta[k][i] = cb(v, k, i) + } + } +} diff --git a/misc/git/status.go b/misc/git/status.go index 697f7fb2..99a44f1c 100644 --- a/misc/git/status.go +++ b/misc/git/status.go @@ -67,15 +67,16 @@ func _status_list(m *ice.Message) (files, adds, dels int, last time.Time) { m.Push(kit.MDB_NAME, value[kit.MDB_NAME]) m.Push(kit.MDB_TYPE, vs[0]) m.Push(kit.MDB_FILE, vs[1]) - m.Push("tags", tags) list := []string{} switch vs[0] { case "##": + m.Push("tags", tags) if strings.Contains(vs[1], "ahead") { list = append(list, PUSH) } default: + m.Push("tags", "") if strings.Contains(vs[0], "??") { list = append(list, ADD) } else {