forked from x/icebergs
add some
This commit is contained in:
parent
bb673d80d7
commit
a2ca5fbecb
@ -323,14 +323,15 @@ func init() {
|
||||
kit.If(m.Option(mdb.NAME) == "", func() { m.Sleep3s().Cmdy(ROUTE, cli.BUILD).ProcessInner() })
|
||||
}},
|
||||
PUBLISH: {Name: "publish name", Help: "发布", Icon: "bi bi-send-check", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Option(ice.MSG_TITLE, kit.Keys(m.Option(ice.MSG_USERPOD0), m.Option(ice.MSG_USERPOD), m.CommandKey(), m.ActionKey()))
|
||||
defer ToastProcess(m)()
|
||||
list := []string{cli.LINUX, cli.DARWIN, cli.WINDOWS}
|
||||
msg := m.Spawn(ice.Maps{ice.MSG_DAEMON: ""})
|
||||
m.Cmd(AUTOGEN, BINPACK)
|
||||
kit.For(list, func(goos string) {
|
||||
PushNoticeRich(m, mdb.NAME, ice.Info.NodeName, msg.Cmd(COMPILE, goos, cli.AMD64).AppendSimple())
|
||||
})
|
||||
func() {
|
||||
defer ToastProcess(m, PUBLISH, ice.Info.NodeName)(PUBLISH, ice.Info.NodeName)
|
||||
m.Cmd(AUTOGEN, BINPACK)
|
||||
kit.For(list, func(goos string) {
|
||||
PushNoticeRich(m, mdb.NAME, ice.Info.NodeName, msg.Cmd(COMPILE, goos, cli.AMD64).AppendSimple())
|
||||
})
|
||||
}()
|
||||
DreamEach(m, m.Option(mdb.NAME), "", func(name string) {
|
||||
m.Cmd(SPACE, name, AUTOGEN, BINPACK)
|
||||
kit.For(list, func(goos string) {
|
||||
|
@ -122,7 +122,7 @@ var Icons = map[string]string{ice.PROCESS: "🕑", ice.FAILURE: "❌", ice.SUCCE
|
||||
|
||||
func toastContent(m *ice.Message, state string, arg ...ice.Any) string {
|
||||
if len(arg) == 0 {
|
||||
return kit.JoinWord(kit.Simple(Icons[state], kit.Select("", m.ActionKey(), m.ActionKey() != ice.LIST), state)...)
|
||||
return kit.JoinWord(kit.Simple(Icons[state], kit.Select(ice.LIST, m.ActionKey()), state)...)
|
||||
} else {
|
||||
return kit.JoinWord(kit.Simple(Icons[state], arg)...)
|
||||
}
|
||||
@ -136,14 +136,14 @@ func ToastFailure(m *ice.Message, arg ...ice.Any) {
|
||||
func ToastProcess(m *ice.Message, arg ...ice.Any) func(...ice.Any) {
|
||||
h := kit.HashsUniq()
|
||||
Toast(m, toastContent(m, ice.PROCESS, arg...), "", "-1", "", h)
|
||||
return func(arg ...ice.Any) { Toast(m, toastContent(m, ice.SUCCESS, arg...), "", cli.TIME_1s, "", h) }
|
||||
return func(arg ...ice.Any) { Toast(m, toastContent(m, ice.SUCCESS, arg...), "", cli.TIME_3s, "", h) }
|
||||
}
|
||||
func GoToast(m *ice.Message, title string, cb func(toast func(name string, count, total int)) []string) *ice.Message {
|
||||
h := kit.HashsUniq()
|
||||
icon, _total := Icons[ice.PROCESS], 0
|
||||
toast := func(name string, count, total int) {
|
||||
kit.If(total == 0, func() { total = 1 })
|
||||
Toast(m, kit.Format("%s %s %s", icon, kit.JoinWord(m.ActionKey(), name), strings.ReplaceAll(kit.FmtSize(count, total), "B", "")),
|
||||
Toast(m, kit.Format("%s %s %s", icon, kit.JoinWord(kit.Select(ice.LIST, m.ActionKey()), name), strings.ReplaceAll(kit.FmtSize(count, total), "B", "")),
|
||||
kit.Select(title, m.Option(ice.MSG_TITLE)), m.OptionDefault(ice.TOAST_DURATION, "-1"), count*100/total, h)
|
||||
_total = total
|
||||
}
|
||||
@ -153,7 +153,7 @@ func GoToast(m *ice.Message, title string, cb func(toast func(name string, count
|
||||
toast(kit.JoinWord(list...), len(list), _total)
|
||||
} else {
|
||||
icon = Icons[ice.SUCCESS]
|
||||
m.Option(ice.TOAST_DURATION, cli.TIME_1s)
|
||||
m.Option(ice.TOAST_DURATION, cli.TIME_3s)
|
||||
toast(ice.SUCCESS, _total, _total)
|
||||
}
|
||||
m.Sleep(m.Option(ice.TOAST_DURATION))
|
||||
|
@ -195,7 +195,7 @@ func _space_echo(m *ice.Message, source, target []string, c *websocket.Conn) {
|
||||
func _space_send(m *ice.Message, name string, arg ...string) (h string) {
|
||||
withecho := true
|
||||
kit.If(len(arg) > 0 && arg[0] == "toast", func() { withecho = false; m.Option(ice.MSG_DEBUG, ice.FALSE) })
|
||||
wait, done := m.Wait(kit.Select("", m.OptionDefault("space.timeout", "180s"), withecho), func(msg *ice.Message, arg ...string) {
|
||||
wait, done := m.Wait(kit.Select("", m.OptionDefault("space.timeout", "300s"), withecho), func(msg *ice.Message, arg ...string) {
|
||||
m.Cost(kit.Format("%v->[%v] %v %v", m.Optionv(ice.MSG_SOURCE), name, m.Detailv(), msg.FormatSize())).Copy(msg)
|
||||
})
|
||||
if withecho {
|
||||
|
Loading…
x
Reference in New Issue
Block a user