1
0
forked from x/icebergs
This commit is contained in:
IT 老营长 @云轩领航-创始人 2024-07-15 22:26:35 +08:00
parent 0f87c5ac5e
commit 7214a38d52
2 changed files with 18 additions and 3 deletions

View File

@ -1,6 +1,8 @@
package web
import (
"net/url"
ice "shylinux.com/x/icebergs"
"shylinux.com/x/icebergs/base/aaa"
"shylinux.com/x/icebergs/base/cli"
@ -104,6 +106,10 @@ func init() {
m.PushButton(PORTAL, INSTALL)
}
})
m.RewriteAppend(func(value, key string, index int) string {
value, _ = url.QueryUnescape(value)
return value
})
m.StatusTimeCount(ORIGIN, origin, stat)
}
}},

15
meta.go
View File

@ -1,6 +1,7 @@
package ice
import (
"net/url"
"strconv"
"strings"
@ -254,8 +255,15 @@ func (m *Message) TableEcho() *Message {
}
space := kit.Select(SP, m.Option(TABLE_SPACE))
align := kit.Select("left", m.Option(TABLE_ALIGN))
encode := m.R != nil && m.IsCliUA()
if encode {
m.RewriteAppend(func(value, key string, index int) string {
return url.QueryEscape(value)
})
}
_width := func(v string) int { return kit.Width(v, len(space)) }
_align := func(value string, width int) string {
switch n := width - kit.Width(value, len(space)); align {
switch n := width - _width(value); align {
case "left":
return value + strings.Repeat(space, n)
case "right":
@ -269,9 +277,10 @@ func (m *Message) TableEcho() *Message {
length, width := 0, map[string]int{}
for _, k := range m.value(MSG_APPEND) {
kit.If(len(m.value(k)) > length, func() { length = len(m.value(k)) })
width[k] = kit.Width(k, len(space))
width[k] = _width(k)
kit.For(m.value(k), func(v string) {
kit.If(kit.Width(v, len(space)) > width[k], func() { width[k] = kit.Width(v, len(space)) })
l := _width(v)
kit.If(l > width[k], func() { width[k] = l })
})
}
show(kit.Simple(m.value(MSG_APPEND), func(k string) string { return _align(k, width[k]) }))