1
0
forked from x/ContextOS

add mdb.ktv

This commit is contained in:
shylinux 2019-07-01 02:53:50 +08:00
parent 6329a497ea
commit aa77019406
14 changed files with 139 additions and 47 deletions

View File

@ -68,7 +68,7 @@ log "dir:$dir"
case $1 in case $1 in
install) shift && install "$@";; install) shift && install "$@";;
start|"") main "$@";; start|"") shift && main "$@";;
create) mkdir -p $2; cd $2 && shift && shift && main "$@";; create) mkdir -p $2; cd $2 && shift && shift && main "$@";;
restart) action 30;; restart) action 30;;
upgrade) action 31;; upgrade) action 31;;

View File

@ -1,5 +1,7 @@
~wiki ~wiki
config save var/tmp/wiki.json wiki_visit config save var/tmp/wiki.json wiki_visit
~mdb
config save var/tmp/data.json ktv
~ssh ~ssh
config save var/tmp/cert.json work flow trust config save var/tmp/cert.json work flow trust
~aaa ~aaa

View File

@ -4,6 +4,8 @@
config load tmp/auth.json auth config load tmp/auth.json auth
~ssh ~ssh
config load tmp/cert.json work flow trust config load tmp/cert.json work flow trust
~mdb
config load tmp/data.json ktv
~wiki ~wiki
config load tmp/wiki.json wiki_visit config load tmp/wiki.json wiki_visit
source etc/common.shy source etc/common.shy

View File

@ -759,7 +759,7 @@ var version = struct {
m.Add("append", "status", "stop") m.Add("append", "status", "stop")
} }
}) })
m.Table() m.Sort("status").Table()
return return
} }
@ -794,6 +794,7 @@ var version = struct {
return return
}}, }},
"quit": &ctx.Command{Name: "quit code", Help: "停止服务", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) { "quit": &ctx.Command{Name: "quit code", Help: "停止服务", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
m.Conf("runtime", "boot.count", m.Confi("runtime", "boot.count")+1)
code := kit.Select("0", arg, 0) code := kit.Select("0", arg, 0)
switch code { switch code {
case "0": case "0":

View File

@ -4,5 +4,5 @@ var version = struct {
host string host string
self int self int
}{ }{
"2019-06-30 17:36:39", "com.mac", 30, "2019-07-01 02:44:49", "com", 60,
} }

View File

@ -93,7 +93,8 @@ func (m *Message) Time(arg ...interface{}) string {
if len(arg) > 0 { if len(arg) > 0 {
if d, e := time.ParseDuration(arg[0].(string)); e == nil { if d, e := time.ParseDuration(arg[0].(string)); e == nil {
arg = arg[1:] arg = arg[1:]
t.Add(d) t = t.Add(d)
} else {
} }
} }
@ -486,6 +487,9 @@ func (m *Message) Copy(msg *Message, arg ...string) *Message {
return m return m
} }
func (m *Message) Push(str string, arg ...interface{}) *Message {
return m.Add("append", str, arg...)
}
func (m *Message) Echo(str string, arg ...interface{}) *Message { func (m *Message) Echo(str string, arg ...interface{}) *Message {
if len(arg) > 0 { if len(arg) > 0 {
return m.Add("result", fmt.Sprintf(str, arg...)) return m.Add("result", fmt.Sprintf(str, arg...))

View File

@ -95,8 +95,37 @@ var Index = &ctx.Context{Name: "mdb", Help: "数据中心",
"base": []interface{}{"key", "create_time", "type", "name", "model", "value"}, "base": []interface{}{"key", "create_time", "type", "name", "model", "value"},
"full": []interface{}{"key", "create_time", "access_time", "type", "name", "model", "value", "view", "data", "ship"}, "full": []interface{}{"key", "create_time", "access_time", "type", "name", "model", "value", "view", "data", "ship"},
}, Help: "数据视图"}, }, Help: "数据视图"},
"ktv": &ctx.Config{Name: "ktv", Value: map[string]interface{}{
"conf": map[string]interface{}{"expire": "24h"}, "data": map[string]interface{}{},
}, Help: "缓存数据"},
}, },
Commands: map[string]*ctx.Command{ Commands: map[string]*ctx.Command{
"ktv": &ctx.Command{Name: "ktv", Help: "", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
if len(arg) == 0 {
now := kit.Int(m.Time("stamp"))
m.Confm("ktv", "data", func(key string, value map[string]interface{}) {
m.Push("key", key)
m.Push("expire", kit.Int(value["expire"])-now)
m.Push("value", value["value"])
})
m.Table()
return
}
if len(arg) == 1 {
if m.Confi("ktv", []string{"data", arg[0], "expire"}) < kit.Int(m.Time("stamp")) {
m.Conf("ktv", []string{"data", arg[0]}, "")
}
m.Echo(m.Conf("ktv", []string{"data", arg[0], "value"}))
return
}
m.Confv("ktv", []string{"data", arg[0]}, map[string]interface{}{
"expire": m.Time(kit.Select(m.Conf("ktv", "conf.expire"), arg, 2), "stamp"),
"value": arg[1],
})
m.Echo(arg[1])
return
}},
"redis": &ctx.Command{Name: "redis conn address [protocol]", Help: "", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) { "redis": &ctx.Command{Name: "redis conn address [protocol]", Help: "", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
if mdb, ok := m.Target().Server.(*MDB); m.Assert(ok) { if mdb, ok := m.Target().Server.(*MDB); m.Assert(ok) {
switch arg[0] { switch arg[0] {

View File

@ -107,14 +107,14 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
}, },
}, },
"context": []interface{}{ "context": []interface{}{
map[string]interface{}{"componet_name": "runtime", "componet_help": "runtime", map[string]interface{}{"componet_name": "runtime", "componet_help": "系统",
"componet_tmpl": "componet", "componet_view": "Runtime", "componet_init": "", "componet_tmpl": "componet", "componet_view": "Runtime", "componet_init": "",
"componet_type": "private", "componet_ctx": "cli", "componet_cmd": "runtime", "componet_type": "private", "componet_ctx": "cli", "componet_cmd": "runtime",
"componet_args": []interface{}{"system"}, "inputs": []interface{}{ "componet_args": []interface{}{"system"}, "inputs": []interface{}{
map[string]interface{}{"type": "button", "value": "运行"}, map[string]interface{}{"type": "button", "value": "运行"},
}, },
}, },
map[string]interface{}{"componet_name": "project", "componet_help": "project", map[string]interface{}{"componet_name": "project", "componet_help": "项目",
"componet_tmpl": "componet", "componet_view": "componet", "componet_init": "", "componet_tmpl": "componet", "componet_view": "componet", "componet_init": "",
"componet_type": "private", "componet_ctx": "cli", "componet_cmd": "project", "componet_type": "private", "componet_ctx": "cli", "componet_cmd": "project",
"componet_args": []interface{}{}, "inputs": []interface{}{ "componet_args": []interface{}{}, "inputs": []interface{}{
@ -122,16 +122,16 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
map[string]interface{}{"type": "button", "value": "执行"}, map[string]interface{}{"type": "button", "value": "执行"},
}, },
}, },
map[string]interface{}{"componet_name": "compile", "componet_help": "compile", map[string]interface{}{"componet_name": "compile", "componet_help": "编译",
"componet_tmpl": "componet", "componet_view": "Compile", "componet_init": "", "componet_tmpl": "componet", "componet_view": "Compile", "componet_init": "",
"componet_type": "private", "componet_ctx": "cli", "componet_cmd": "compile", "componet_type": "private", "componet_ctx": "cli", "componet_cmd": "compile",
"componet_args": []interface{}{}, "inputs": []interface{}{ "componet_args": []interface{}{}, "inputs": []interface{}{
map[string]interface{}{"type": "select", "name": "action", "values": []interface{}{"linux", "darwin", "windows", "self", "all"}}, map[string]interface{}{"type": "select", "name": "action", "values": []interface{}{"windows", "darwin", "linux", "self", "all"}},
map[string]interface{}{"type": "button", "value": "编译"}, map[string]interface{}{"type": "button", "value": "编译"},
}, },
"display": map[string]interface{}{"hide_append": true, "show_result": true}, "display": map[string]interface{}{"hide_append": true, "show_result": true},
}, },
map[string]interface{}{"componet_name": "publish", "componet_help": "publish", map[string]interface{}{"componet_name": "publish", "componet_help": "发布",
"componet_tmpl": "componet", "componet_view": "Compile", "componet_init": "", "componet_tmpl": "componet", "componet_view": "Compile", "componet_init": "",
"componet_type": "private", "componet_ctx": "cli", "componet_cmd": "publish", "componet_type": "private", "componet_ctx": "cli", "componet_cmd": "publish",
"componet_args": []interface{}{}, "inputs": []interface{}{ "componet_args": []interface{}{}, "inputs": []interface{}{
@ -140,7 +140,7 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
}, },
"display": map[string]interface{}{"hide_append": true, "show_result": true}, "display": map[string]interface{}{"hide_append": true, "show_result": true},
}, },
map[string]interface{}{"componet_name": "upgrade", "componet_help": "upgrade", map[string]interface{}{"componet_name": "upgrade", "componet_help": "升级",
"componet_tmpl": "componet", "componet_view": "Compile", "componet_init": "", "componet_tmpl": "componet", "componet_view": "Compile", "componet_init": "",
"componet_type": "private", "componet_ctx": "ssh", "componet_cmd": "_route", "componet_type": "private", "componet_ctx": "ssh", "componet_cmd": "_route",
"componet_args": []interface{}{"$$", "context", "cli", "upgrade"}, "inputs": []interface{}{ "componet_args": []interface{}{"$$", "context", "cli", "upgrade"}, "inputs": []interface{}{
@ -151,7 +151,7 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
}, },
"display": map[string]interface{}{"hide_append": true, "show_result": true}, "display": map[string]interface{}{"hide_append": true, "show_result": true},
}, },
map[string]interface{}{"componet_name": "missyou", "componet_help": "missyou", map[string]interface{}{"componet_name": "missyou", "componet_help": "任务",
"componet_tmpl": "componet", "componet_view": "Compile", "componet_init": "", "componet_tmpl": "componet", "componet_view": "Compile", "componet_init": "",
"componet_type": "private", "componet_ctx": "cli", "componet_cmd": "missyou", "componet_type": "private", "componet_ctx": "cli", "componet_cmd": "missyou",
"componet_args": []interface{}{}, "inputs": []interface{}{ "componet_args": []interface{}{}, "inputs": []interface{}{
@ -160,6 +160,15 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
}, },
"exports": []interface{}{"you", "", "you"}, "exports": []interface{}{"you", "", "you"},
}, },
map[string]interface{}{"componet_name": "ktv", "componet_help": "存储",
"componet_tmpl": "componet", "componet_view": "Compile", "componet_init": "",
"componet_type": "private", "componet_ctx": "ssh", "componet_cmd": "_route",
"componet_args": []interface{}{"$$", "context", "mdb", "ktv"}, "inputs": []interface{}{
map[string]interface{}{"type": "text", "name": "you", "imports": "plugin_you", "action": "auto"},
map[string]interface{}{"type": "button", "value": "存储", "action": "auto"},
},
"exports": []interface{}{"you", "", "you"},
},
}, },
"favor": []interface{}{ "favor": []interface{}{
map[string]interface{}{"componet_name": "clip", "componet_help": "粘贴板", map[string]interface{}{"componet_name": "clip", "componet_help": "粘贴板",
@ -171,20 +180,21 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
map[string]interface{}{"type": "button", "value": "存储"}, map[string]interface{}{"type": "button", "value": "存储"},
}, },
}, },
map[string]interface{}{"componet_name": "qrcode", "componet_help": "生成二维码", map[string]interface{}{"componet_name": "qrcode", "componet_help": "二维码",
"componet_tmpl": "componet", "componet_view": "QRCode", "componet_init": "initQRCode.js", "componet_tmpl": "componet", "componet_view": "QRCode", "componet_init": "initQRCode.js",
"componet_type": "public", "componet_ctx": "web.chat", "componet_cmd": "login", "componet_type": "public", "componet_ctx": "web.chat", "componet_cmd": "login",
"componet_args": []interface{}{"qrcode"}, "inputs": []interface{}{ "componet_args": []interface{}{"qrcode"}, "inputs": []interface{}{
map[string]interface{}{"label": "content", "type": "text", "name": "content"}, map[string]interface{}{"type": "text", "name": "txt", "view": "long"},
map[string]interface{}{"type": "button", "value": "生成"}, map[string]interface{}{"type": "button", "value": "生成"},
}, },
}, },
map[string]interface{}{"componet_name": "salary", "componet_help": "计算工资", map[string]interface{}{"componet_name": "salary", "componet_help": "工资",
"componet_tmpl": "componet", "componet_view": "Salary", "componet_init": "", "componet_tmpl": "componet", "componet_view": "Salary", "componet_init": "",
"componet_type": "public", "componet_ctx": "web.chat", "componet_cmd": "salary", "componet_type": "public", "componet_ctx": "web.chat", "componet_cmd": "salary",
"componet_args": []interface{}{}, "inputs": []interface{}{ "componet_args": []interface{}{}, "inputs": []interface{}{
map[string]interface{}{"label": "total", "type": "text", "name": "text"}, map[string]interface{}{"label": "total", "type": "text", "name": "text"},
map[string]interface{}{"label": "base", "type": "text", "name": "total"}, map[string]interface{}{"label": "base", "type": "text", "name": "total", "value": "9000"},
map[string]interface{}{"type": "button", "value": "计算"},
}, },
}, },
map[string]interface{}{"componet_name": "location", "componet_help": "地理位置", map[string]interface{}{"componet_name": "location", "componet_help": "地理位置",
@ -208,16 +218,16 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
}, },
}, },
"index": []interface{}{ "index": []interface{}{
map[string]interface{}{"componet_name": "pod", "componet_help": "pod", map[string]interface{}{"componet_name": "pod", "componet_help": "设备",
"componet_tmpl": "componet", "componet_view": "Context", "componet_init": "", "componet_tmpl": "componet", "componet_view": "Context", "componet_init": "",
"componet_type": "private", "componet_ctx": "ssh", "componet_cmd": "_route", "componet_type": "private", "componet_ctx": "ssh", "componet_cmd": "_route",
"componet_args": []interface{}{"$$", "context", "ssh", "remote"}, "inputs": []interface{}{ "componet_args": []interface{}{"$$", "context", "ssh", "remote"}, "inputs": []interface{}{
map[string]interface{}{"type": "text", "name": "pod"}, map[string]interface{}{"type": "text", "name": "pod"},
map[string]interface{}{"type": "button", "value": "执行", "action": "auto"}, map[string]interface{}{"type": "button", "value": "执行", "action": "auto"},
}, },
"exports": []interface{}{"pod", "pod", "pod"}, "exports": []interface{}{"pod", "", "pod"},
}, },
map[string]interface{}{"componet_name": "ctx", "componet_help": "ctx", map[string]interface{}{"componet_name": "ctx", "componet_help": "模块",
"componet_tmpl": "componet", "componet_view": "Context", "componet_init": "", "componet_tmpl": "componet", "componet_view": "Context", "componet_init": "",
"componet_type": "private", "componet_ctx": "ssh", "componet_cmd": "_route", "componet_type": "private", "componet_ctx": "ssh", "componet_cmd": "_route",
"componet_args": []interface{}{"$$", "context", "$$", "context"}, "inputs": []interface{}{ "componet_args": []interface{}{"$$", "context", "$$", "context"}, "inputs": []interface{}{
@ -227,7 +237,7 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
}, },
"exports": []interface{}{"ctx", "names"}, "exports": []interface{}{"ctx", "names"},
}, },
map[string]interface{}{"componet_name": "cmd", "componet_help": "cmd", map[string]interface{}{"componet_name": "cmd", "componet_help": "命令",
"componet_tmpl": "componet", "componet_view": "Company", "componet_init": "", "componet_tmpl": "componet", "componet_view": "Company", "componet_init": "",
"componet_type": "private", "componet_ctx": "ssh", "componet_cmd": "_route", "componet_type": "private", "componet_ctx": "ssh", "componet_cmd": "_route",
"componet_args": []interface{}{"$$", "context", "$$", "command"}, "inputs": []interface{}{ "componet_args": []interface{}{"$$", "context", "$$", "command"}, "inputs": []interface{}{
@ -237,7 +247,7 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
map[string]interface{}{"type": "button", "value": "执行"}, map[string]interface{}{"type": "button", "value": "执行"},
}, },
}, },
map[string]interface{}{"componet_name": "dir", "componet_help": "dir", map[string]interface{}{"componet_name": "dir", "componet_help": "目录",
"componet_tmpl": "componet", "componet_view": "Context", "componet_init": "", "componet_tmpl": "componet", "componet_view": "Context", "componet_init": "",
"componet_type": "private", "componet_ctx": "ssh", "componet_cmd": "_route", "componet_type": "private", "componet_ctx": "ssh", "componet_cmd": "_route",
"componet_args": []interface{}{"$$", "context", "nfs", "dir"}, "inputs": []interface{}{ "componet_args": []interface{}{"$$", "context", "nfs", "dir"}, "inputs": []interface{}{
@ -250,7 +260,7 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
"exports": []interface{}{"dir", "filename", "dir"}, "exports": []interface{}{"dir", "filename", "dir"},
"dir_root": []interface{}{"/"}, "dir_root": []interface{}{"/"},
}, },
map[string]interface{}{"componet_name": "commit", "componet_help": "git", map[string]interface{}{"componet_name": "commit", "componet_help": "提交",
"componet_tmpl": "componet", "componet_view": "Context", "componet_init": "", "componet_tmpl": "componet", "componet_view": "Context", "componet_init": "",
"componet_type": "private", "componet_ctx": "nfs", "componet_cmd": "git", "componet_type": "private", "componet_ctx": "nfs", "componet_cmd": "git",
"componet_args": []interface{}{}, "inputs": []interface{}{ "componet_args": []interface{}{}, "inputs": []interface{}{
@ -262,7 +272,7 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
map[string]interface{}{"type": "button", "value": "执行"}, map[string]interface{}{"type": "button", "value": "执行"},
}, },
}, },
map[string]interface{}{"componet_name": "status", "componet_help": "git", map[string]interface{}{"componet_name": "status", "componet_help": "记录",
"componet_tmpl": "componet", "componet_view": "Context", "componet_init": "", "componet_tmpl": "componet", "componet_view": "Context", "componet_init": "",
"componet_type": "private", "componet_ctx": "nfs", "componet_cmd": "git", "componet_type": "private", "componet_ctx": "nfs", "componet_cmd": "git",
"componet_args": []interface{}{}, "inputs": []interface{}{ "componet_args": []interface{}{}, "inputs": []interface{}{
@ -273,7 +283,7 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
map[string]interface{}{"type": "button", "value": "执行"}, map[string]interface{}{"type": "button", "value": "执行"},
}, },
}, },
map[string]interface{}{"componet_name": "spide", "componet_help": "spide", map[string]interface{}{"componet_name": "spide", "componet_help": "爬虫",
"componet_tmpl": "componet", "componet_view": "Context", "componet_init": "", "componet_tmpl": "componet", "componet_view": "Context", "componet_init": "",
"componet_type": "private", "componet_ctx": "ssh", "componet_cmd": "_route", "componet_type": "private", "componet_ctx": "ssh", "componet_cmd": "_route",
"componet_args": []interface{}{"$$", "context", "web", "spide"}, "inputs": []interface{}{ "componet_args": []interface{}{"$$", "context", "web", "spide"}, "inputs": []interface{}{
@ -282,7 +292,7 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
}, },
"exports": []interface{}{"site", "key"}, "exports": []interface{}{"site", "key"},
}, },
map[string]interface{}{"componet_name": "post", "componet_help": "post", map[string]interface{}{"componet_name": "post", "componet_help": "请求",
"componet_tmpl": "componet", "componet_view": "Context", "componet_init": "", "componet_tmpl": "componet", "componet_view": "Context", "componet_init": "",
"componet_type": "private", "componet_ctx": "ssh", "componet_cmd": "_route", "componet_type": "private", "componet_ctx": "ssh", "componet_cmd": "_route",
"componet_args": []interface{}{"$$", "context", "web", "post", "$$", "content_type", "application/json", "parse", "json"}, "inputs": []interface{}{ "componet_args": []interface{}{"$$", "context", "web", "post", "$$", "content_type", "application/json", "parse", "json"}, "inputs": []interface{}{
@ -292,7 +302,7 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
map[string]interface{}{"type": "button", "value": "执行"}, map[string]interface{}{"type": "button", "value": "执行"},
}, },
}, },
map[string]interface{}{"componet_name": "get", "componet_help": "get", map[string]interface{}{"componet_name": "get", "componet_help": "请求",
"componet_tmpl": "componet", "componet_view": "Context", "componet_init": "", "componet_tmpl": "componet", "componet_view": "Context", "componet_init": "",
"componet_type": "private", "componet_ctx": "ssh", "componet_cmd": "_route", "componet_type": "private", "componet_ctx": "ssh", "componet_cmd": "_route",
"componet_args": []interface{}{"$$", "context", "web", "get"}, "inputs": []interface{}{ "componet_args": []interface{}{"$$", "context", "web", "get"}, "inputs": []interface{}{
@ -534,7 +544,6 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
} }
switch arg[0] { switch arg[0] {
case "auto": // 自动连接 case "auto": // 自动连接
m.Log("fuck", "what %v", m.Conf("runtime", "boot.ctx_ups"))
if m.Confs("runtime", "boot.ctx_ups") { if m.Confs("runtime", "boot.ctx_ups") {
m.Cmd("ssh.remote", "dial", m.Conf("runtime", "boot.ctx_ups")) m.Cmd("ssh.remote", "dial", m.Conf("runtime", "boot.ctx_ups"))
break break

View File

@ -651,6 +651,7 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心",
// 发送请求 // 发送请求
res, e := web.Client.Do(req) res, e := web.Client.Do(req)
m.Log("info", "%s %s", req, e)
if e != nil { if e != nil {
m.Log("warn", "%v", e) m.Log("warn", "%v", e)
return e return e

View File

@ -268,8 +268,8 @@ page = Page({
var plugin = event.Plugin var plugin = event.Plugin
event.shiftKey? page.target.Pane.Send("field", plugin.Format()): event.shiftKey? page.target.Pane.Send("field", plugin.Format()):
field.Pane.Run([river, storm, index].concat(args), function(msg) { field.Pane.Run([river, storm, index].concat(args), function(msg) {
var text = plugin.Reveal(msg) var text = plugin? plugin.Reveal(msg): ""
event.ctrlKey && page.target.Pane.Send(text[0], text[1]) text && event.ctrlKey && page.target.Pane.Send(text[0], text[1])
typeof cbs == "function" && cbs(msg) typeof cbs == "function" && cbs(msg)
}) })
}) })

View File

@ -94,6 +94,10 @@ fieldset.toast>div.output pre {
white-space:pre-wrap; white-space:pre-wrap;
text-align:center; text-align:center;
margin:0px; margin:0px;
font-size:16px;
}
fieldset.toast>div.output div.tick {
font-size:12px;
} }
fieldset.dialog { fieldset.dialog {
background-color:lightgray; background-color:lightgray;

View File

@ -108,7 +108,7 @@ function Page(page) {
ontoast: function(text, title, duration) { ontoast: function(text, title, duration) {
var args = typeof text == "object"? text: {text: text, title: title, duration: duration} var args = typeof text == "object"? text: {text: text, title: title, duration: duration}
var toast = kit.ModifyView("fieldset.toast", { var toast = kit.ModifyView("fieldset.toast", {
display: "block", dialog: [args.width||200, args.height||40], padding: 10, display: "block", dialog: [args.width||300, args.height||50], padding: 10,
}) })
if (!text) { if (!text) {
toast.style.display = "none" toast.style.display = "none"
@ -143,10 +143,18 @@ function Page(page) {
toast.style.display = "none" toast.style.display = "none"
}}) }})
}) })
list.push({view: ["tick"], name: "tick"})
kit.ModifyNode(toast.querySelector("legend"), args.title||"tips") kit.ModifyNode(toast.querySelector("legend"), args.title||"tips")
var ui = kit.AppendChild(kit.ModifyNode(toast.querySelector("div.output"), ""), list) var ui = kit.AppendChild(kit.ModifyNode(toast.querySelector("div.output"), ""), list)
args.duration !=- 1 && setTimeout(function(){toast.style.display = "none"}, args.duration||3000) var tick = 1
var begin = kit.time(0,"%H:%M:%S")
var timer = args.duration ==- 1? setTimeout(function() {
function ticker() {
toast.style.display != "none" && (ui.tick.innerText = begin+" ... "+(tick++)+"s") && setTimeout(ticker, 1000)
}
ticker()
}, 10): setTimeout(function(){toast.style.display = "none"}, args.duration||3000)
page.toast = toast page.toast = toast
return true return true
}, },
@ -633,7 +641,10 @@ function Plugin(page, pane, field) {
(action.value = value) && item.action == "auto" && plugin.Runs(window.event) (action.value = value) && item.action == "auto" && plugin.Runs(window.event)
}) })
}) })
item.type == "button" && item.action == "auto" && plugin.Runs(window.event) item.type == "button" && item.action == "auto" && plugin.Runs(window.event, function() {
var td = output.querySelector("td")
td && td.click()
})
return action return action
}, },
Remove: function() { Remove: function() {
@ -667,18 +678,21 @@ function Plugin(page, pane, field) {
}) })
}, },
Runs: function(event, cb) { Runs: function(event, cb) {
if (wait) { var args = kit.Selector(option, ".args", function(item, index) {
return
}
wait = true, event.Plugin = plugin, this.Clear(), field.Run(event, kit.Selector(option, ".args", function(item, index) {
return item.value return item.value
}), function(msg) { })
wait = false, typeof cb == "function" && cb(msg) var show = true
setTimeout(function() {
show && page.ontoast(kit.Format(args||["running..."]), meta.name, -1)
}, 1000)
wait = true, event.Plugin = plugin, field.Run(event, args, function(msg) {
show = false, page.ontoast("")
plugin.ondaemon[display.deal||"table"](msg) plugin.ondaemon[display.deal||"table"](msg)
wait = false, typeof cb == "function" && cb(msg)
}) })
}, },
Delay: function(time, event, text) { Delay: function(time, event, text) {
page.ontoast(text, "run", -1) page.ontoast(text, "", -1)
setTimeout(function() { setTimeout(function() {
plugin.Runs(event) plugin.Runs(event)
page.ontoast("") page.ontoast("")
@ -711,18 +725,18 @@ function Plugin(page, pane, field) {
}, },
you: function(value, name, line) { you: function(value, name, line) {
window.event.Plugin = plugin window.event.Plugin = plugin
name == "status" && (line.status == "start"? function() { line.you && name == "status" && (line.status == "start"? function() {
plugin.Delay(2000, window.event, line.you+" stop...") && field.Run(window.event, [line.you, "stop"]) plugin.Delay(3000, window.event, line.you+" stop...") && field.Run(window.event, [line.you, "stop"])
}(): field.Run(window.event, [line.you], function(msg) { }(): field.Run(window.event, [line.you], function(msg) {
plugin.Delay(1000, window.event, line.you+" start...") && plugin.Runs(window.event) plugin.Delay(3000, window.event, line.you+" start...")
})) }))
return name == "you"? value: undefined return name == "status" || line.status == "stop" ? undefined: line.you
}, },
pod: function(value, name) { pod: function(value, name, line) {
if (option[exports[0]].value) { if (option[exports[0]].value) {
return option[exports[0]].value+"."+value return option[exports[0]].value+"."+line.pod
} }
return value return line.pod
}, },
dir: function(value, name) { dir: function(value, name) {
if (value.endsWith("/")) { if (value.endsWith("/")) {

View File

@ -1,6 +1,6 @@
{init: function(page, pane, field, option, output) { {init: function(page, pane, field, option, output) {
this.Runs = function(event) { this.Runs = function(event) {
var value = option.content.value var value = option.txt.value
var url = page.login.Pane.Share({cmds: ["qrcode", value]}) var url = page.login.Pane.Share({cmds: ["qrcode", value]})
kit.AppendChilds(output, [{img: [url]}]) kit.AppendChilds(output, [{img: [url]}])
event.ctrlKey && page.target.Pane.Send("icon", url) event.ctrlKey && page.target.Pane.Send("icon", url)

View File

@ -493,7 +493,8 @@ kit = toolkit = {
return list return list
}, },
Format: function(objs) { Format: function(objs) {
return json.stringify(objs) return JSON.stringify(objs)
wa
}, },
List: function(obj, cb) { List: function(obj, cb) {
var list = [] var list = []
@ -515,6 +516,31 @@ kit = toolkit = {
location.reload() location.reload()
}, },
number: function(d, n) {
var result = []
while (d>0) {
result.push(d % 10)
d = parseInt(d / 10)
n--
}
while (n > 0) {
result.push("0")
n--
}
result.reverse()
return result.join("")
},
time: function(t, fmt) {
var now = t? new Date(t): new Date()
fmt = fmt || "%y-%m-%d %H:%M:%S"
fmt = fmt.replace("%y", now.getFullYear())
fmt = fmt.replace("%m", kit.number(now.getMonth()+1, 2))
fmt = fmt.replace("%d", kit.number(now.getDate(), 2))
fmt = fmt.replace("%H", kit.number(now.getHours(), 2))
fmt = fmt.replace("%M", kit.number(now.getMinutes(), 2))
fmt = fmt.replace("%S", kit.number(now.getSeconds(), 2))
return fmt
},
right: function(arg) { right: function(arg) {
if (arg == "true") { if (arg == "true") {
return true return true