forked from x/icebergs
add toast
This commit is contained in:
parent
b01ebf5c2f
commit
8c3f7d6124
@ -238,6 +238,7 @@ func init() {
|
|||||||
m.Target().Start(m, kit.MDB_NAME, m.Option(kit.MDB_NAME), tcp.HOST, m.Option(tcp.HOST), tcp.PORT, m.Option(tcp.PORT))
|
m.Target().Start(m, kit.MDB_NAME, m.Option(kit.MDB_NAME), tcp.HOST, m.Option(tcp.HOST), tcp.PORT, m.Option(tcp.PORT))
|
||||||
m.Sleep(ice.MOD_TICK)
|
m.Sleep(ice.MOD_TICK)
|
||||||
|
|
||||||
|
m.Option(kit.MDB_NAME, "")
|
||||||
for _, k := range kit.Split(m.Option(SPIDE_DEV)) {
|
for _, k := range kit.Split(m.Option(SPIDE_DEV)) {
|
||||||
m.Cmd(SPACE, tcp.DIAL, SPIDE_DEV, k, kit.MDB_NAME, ice.Info.NodeName)
|
m.Cmd(SPACE, tcp.DIAL, SPIDE_DEV, k, kit.MDB_NAME, ice.Info.NodeName)
|
||||||
}
|
}
|
||||||
|
@ -38,6 +38,11 @@ func init() {
|
|||||||
HEADER: {Name: HEADER, Help: "标题栏", Value: kit.Data(TITLE, "github.com/shylinux/contexts")},
|
HEADER: {Name: HEADER, Help: "标题栏", Value: kit.Data(TITLE, "github.com/shylinux/contexts")},
|
||||||
},
|
},
|
||||||
Commands: map[string]*ice.Command{
|
Commands: map[string]*ice.Command{
|
||||||
|
"toast": {Name: "toast target msg", Help: "命令行", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
|
m.Option(ice.MSG_USERUA, "chrome")
|
||||||
|
m.Cmd(web.SPACE, arg[0], "Header.user.toast", "", ice.Render(m, ice.RENDER_QRCODE, arg[1]), arg[2:])
|
||||||
|
}},
|
||||||
|
|
||||||
P_HEADER: {Name: "/header", Help: "标题栏", Action: map[string]*ice.Action{
|
P_HEADER: {Name: "/header", Help: "标题栏", Action: map[string]*ice.Action{
|
||||||
LOGIN: {Name: "login", Help: "用户登录", Hand: func(m *ice.Message, arg ...string) {
|
LOGIN: {Name: "login", Help: "用户登录", Hand: func(m *ice.Message, arg ...string) {
|
||||||
if aaa.UserLogin(m, arg[0], arg[1]) {
|
if aaa.UserLogin(m, arg[0], arg[1]) {
|
||||||
|
36
misc.go
36
misc.go
@ -74,6 +74,9 @@ func (m *Message) PushPodCmd(cmd string, arg ...string) {
|
|||||||
m.Cmd("web.space").Table(func(index int, value map[string]string, head []string) {
|
m.Cmd("web.space").Table(func(index int, value map[string]string, head []string) {
|
||||||
switch value[kit.MDB_TYPE] {
|
switch value[kit.MDB_TYPE] {
|
||||||
case "worker", "server":
|
case "worker", "server":
|
||||||
|
if value[kit.MDB_NAME] == Info.HostName {
|
||||||
|
break
|
||||||
|
}
|
||||||
m.Cmd("web.space", value[kit.MDB_NAME], m.Prefix(cmd), arg).Table(func(index int, val map[string]string, head []string) {
|
m.Cmd("web.space", value[kit.MDB_NAME], m.Prefix(cmd), arg).Table(func(index int, val map[string]string, head []string) {
|
||||||
val[kit.SSH_POD] = kit.Keys(value[kit.MDB_NAME], val[kit.SSH_POD])
|
val[kit.SSH_POD] = kit.Keys(value[kit.MDB_NAME], val[kit.SSH_POD])
|
||||||
m.Push("", val, head)
|
m.Push("", val, head)
|
||||||
@ -110,10 +113,12 @@ func (m *Message) PushSearchWeb(cmd string, name string) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func _render(m *Message, cmd string, args ...interface{}) string {
|
func Render(m *Message, cmd string, args ...interface{}) string {
|
||||||
|
m.Debug("waht %v", cmd)
|
||||||
if m.Option(MSG_USERUA) == "" || strings.Contains(m.Option(MSG_USERUA), "curl") {
|
if m.Option(MSG_USERUA) == "" || strings.Contains(m.Option(MSG_USERUA), "curl") {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
m.Debug("waht %v", cmd)
|
||||||
|
|
||||||
switch arg := kit.Simple(args...); cmd {
|
switch arg := kit.Simple(args...); cmd {
|
||||||
case RENDER_DOWNLOAD: // [name] file
|
case RENDER_DOWNLOAD: // [name] file
|
||||||
@ -177,31 +182,28 @@ func _render(m *Message, cmd string, args ...interface{}) string {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
func (m *Message) PushRender(key, view, name string, arg ...string) *Message {
|
func (m *Message) PushRender(key, view, name string, arg ...string) *Message {
|
||||||
return m.Push(key, _render(m, view, name, arg))
|
return m.Push(key, Render(m, view, name, arg))
|
||||||
}
|
}
|
||||||
func (m *Message) PushDownload(key string, arg ...interface{}) { // [name] file
|
func (m *Message) PushDownload(key string, arg ...interface{}) { // [name] file
|
||||||
m.Push(key, _render(m, RENDER_DOWNLOAD, arg...))
|
m.Push(key, Render(m, RENDER_DOWNLOAD, arg...))
|
||||||
}
|
}
|
||||||
func (m *Message) PushAnchor(arg ...interface{}) { // [name] link
|
func (m *Message) PushAnchor(arg ...interface{}) { // [name] link
|
||||||
m.Push(kit.MDB_LINK, _render(m, RENDER_ANCHOR, arg...))
|
m.Push(kit.MDB_LINK, Render(m, RENDER_ANCHOR, arg...))
|
||||||
}
|
}
|
||||||
func (m *Message) PushButton(arg ...string) {
|
func (m *Message) PushButton(arg ...string) {
|
||||||
if m.Option(MSG_USERUA) == "" || strings.Contains(m.Option(MSG_USERUA), "curl") {
|
m.Push(kit.MDB_ACTION, Render(m, RENDER_BUTTON, strings.Join(arg, ",")))
|
||||||
return
|
|
||||||
}
|
|
||||||
m.Push(kit.MDB_ACTION, _render(m, RENDER_BUTTON, strings.Join(arg, ",")))
|
|
||||||
}
|
}
|
||||||
func (m *Message) PushScript(arg ...string) *Message { // [type] text...
|
func (m *Message) PushScript(arg ...string) *Message { // [type] text...
|
||||||
return m.Push(kit.MDB_SCRIPT, _render(m, RENDER_SCRIPT, arg))
|
return m.Push(kit.MDB_SCRIPT, Render(m, RENDER_SCRIPT, arg))
|
||||||
}
|
}
|
||||||
func (m *Message) PushImages(key, src string, arg ...string) { // key src [size]
|
func (m *Message) PushImages(key, src string, arg ...string) { // key src [size]
|
||||||
m.Push(key, _render(m, RENDER_IMAGES, src, arg))
|
m.Push(key, Render(m, RENDER_IMAGES, src, arg))
|
||||||
}
|
}
|
||||||
func (m *Message) PushVideos(key, src string, arg ...string) { // key src [size]
|
func (m *Message) PushVideos(key, src string, arg ...string) { // key src [size]
|
||||||
m.Push(key, _render(m, RENDER_VIDEOS, src, arg))
|
m.Push(key, Render(m, RENDER_VIDEOS, src, arg))
|
||||||
}
|
}
|
||||||
func (m *Message) PushQRCode(key string, text string, arg ...string) { // key text [size]
|
func (m *Message) PushQRCode(key string, text string, arg ...string) { // key text [size]
|
||||||
m.Push(key, _render(m, RENDER_QRCODE, text, arg))
|
m.Push(key, Render(m, RENDER_QRCODE, text, arg))
|
||||||
}
|
}
|
||||||
func (m *Message) PushAction(list ...interface{}) {
|
func (m *Message) PushAction(list ...interface{}) {
|
||||||
m.Table(func(index int, value map[string]string, head []string) {
|
m.Table(func(index int, value map[string]string, head []string) {
|
||||||
@ -210,19 +212,19 @@ func (m *Message) PushAction(list ...interface{}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *Message) EchoAnchor(arg ...interface{}) *Message { // [name] link
|
func (m *Message) EchoAnchor(arg ...interface{}) *Message { // [name] link
|
||||||
return m.Echo(_render(m, RENDER_ANCHOR, arg...))
|
return m.Echo(Render(m, RENDER_ANCHOR, arg...))
|
||||||
}
|
}
|
||||||
func (m *Message) EchoButton(arg ...string) *Message {
|
func (m *Message) EchoButton(arg ...string) *Message {
|
||||||
return m.Echo(_render(m, RENDER_BUTTON, strings.Join(arg, ",")))
|
return m.Echo(Render(m, RENDER_BUTTON, strings.Join(arg, ",")))
|
||||||
}
|
}
|
||||||
func (m *Message) EchoScript(arg ...string) *Message {
|
func (m *Message) EchoScript(arg ...string) *Message {
|
||||||
return m.Echo(_render(m, RENDER_SCRIPT, arg))
|
return m.Echo(Render(m, RENDER_SCRIPT, arg))
|
||||||
}
|
}
|
||||||
func (m *Message) EchoImages(src string, arg ...string) *Message {
|
func (m *Message) EchoImages(src string, arg ...string) *Message {
|
||||||
return m.Echo(_render(m, RENDER_IMAGES, src, arg))
|
return m.Echo(Render(m, RENDER_IMAGES, src, arg))
|
||||||
}
|
}
|
||||||
func (m *Message) EchoQRCode(text string, arg ...string) *Message { // text [size]
|
func (m *Message) EchoQRCode(text string, arg ...string) *Message { // text [size]
|
||||||
return m.Echo(_render(m, RENDER_QRCODE, text, arg))
|
return m.Echo(Render(m, RENDER_QRCODE, text, arg))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Message) SortInt(key string) { m.Sort(key, "int") }
|
func (m *Message) SortInt(key string) { m.Sort(key, "int") }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user