mirror of
https://shylinux.com/x/ContextOS
synced 2025-04-26 09:14:06 +08:00
add nfs.draw
This commit is contained in:
parent
dc711c73c7
commit
13c9d07f71
@ -195,7 +195,6 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心",
|
|||||||
"path": "usr/work",
|
"path": "usr/work",
|
||||||
}, Help: "免密登录"},
|
}, Help: "免密登录"},
|
||||||
|
|
||||||
|
|
||||||
"timer": &ctx.Config{Name: "timer", Value: map[string]interface{}{}, Help: "定时器"},
|
"timer": &ctx.Config{Name: "timer", Value: map[string]interface{}{}, Help: "定时器"},
|
||||||
"timer_next": &ctx.Config{Name: "timer_next", Value: "", Help: "定时器"},
|
"timer_next": &ctx.Config{Name: "timer_next", Value: "", Help: "定时器"},
|
||||||
"time_unit": &ctx.Config{Name: "time_unit", Value: "1000", Help: "时间倍数"},
|
"time_unit": &ctx.Config{Name: "time_unit", Value: "1000", Help: "时间倍数"},
|
||||||
@ -669,6 +668,7 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心",
|
|||||||
m.Cmd("cli.version", "create")
|
m.Cmd("cli.version", "create")
|
||||||
if len(arg) > 0 && arg[0] == "self" {
|
if len(arg) > 0 && arg[0] == "self" {
|
||||||
if m.Cmdy("cli.system", "go", "install", m.Cmdx("nfs.path", m.Conf("compile", "bench"))); m.Result(0) == "" {
|
if m.Cmdy("cli.system", "go", "install", m.Cmdx("nfs.path", m.Conf("compile", "bench"))); m.Result(0) == "" {
|
||||||
|
m.Echo("version %v ", version.self)
|
||||||
m.Cmdy("cli.quit", 1)
|
m.Cmdy("cli.quit", 1)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
@ -4,5 +4,5 @@ var version = struct {
|
|||||||
host string
|
host string
|
||||||
self int
|
self int
|
||||||
}{
|
}{
|
||||||
"2019-07-04 21:17:32", "ZYB-20190522USI", 112,
|
"2019-07-05 08:16:40", "com.mac", 41,
|
||||||
}
|
}
|
||||||
|
@ -998,7 +998,7 @@ func (nfs *NFS) Start(m *ctx.Message, arg ...string) bool {
|
|||||||
msg, code, head, body := m, "0", "result", "append"
|
msg, code, head, body := m, "0", "result", "append"
|
||||||
bio := bufio.NewScanner(nfs.io)
|
bio := bufio.NewScanner(nfs.io)
|
||||||
bio.Buffer(make([]byte, m.Confi("buf_size")), m.Confi("buf_size"))
|
bio.Buffer(make([]byte, m.Confi("buf_size")), m.Confi("buf_size"))
|
||||||
for ; bio.Scan(); {
|
for bio.Scan() {
|
||||||
|
|
||||||
m.TryCatch(m, true, func(m *ctx.Message) {
|
m.TryCatch(m, true, func(m *ctx.Message) {
|
||||||
switch field, value := nfs.Recv(bio.Text()); field {
|
switch field, value := nfs.Recv(bio.Text()); field {
|
||||||
@ -1389,6 +1389,41 @@ var Index = &ctx.Context{Name: "nfs", Help: "存储中心",
|
|||||||
return
|
return
|
||||||
}},
|
}},
|
||||||
|
|
||||||
|
"draw": &ctx.Command{Name: "draw", Help: "", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
||||||
|
for len(arg) > 0 {
|
||||||
|
switch arg[0] {
|
||||||
|
case "trend":
|
||||||
|
m.Add("append", "type", arg[0])
|
||||||
|
m.Add("append", "meta", kit.Formats(arg[1:]))
|
||||||
|
arg = arg[:0]
|
||||||
|
|
||||||
|
case "begin":
|
||||||
|
m.Add("append", "type", arg[0])
|
||||||
|
m.Add("append", "meta", "{}")
|
||||||
|
arg = arg[1:]
|
||||||
|
|
||||||
|
case "circle":
|
||||||
|
m.Add("append", "type", arg[0])
|
||||||
|
m.Add("append", "meta", kit.Format(map[string]string{
|
||||||
|
"x": arg[1], "y": arg[2], "r": arg[3],
|
||||||
|
}))
|
||||||
|
arg = arg[4:]
|
||||||
|
|
||||||
|
case "stroke":
|
||||||
|
m.Add("append", "type", arg[0])
|
||||||
|
m.Add("append", "meta", kit.Format(map[string]string{
|
||||||
|
"width": arg[1],
|
||||||
|
"color": arg[2],
|
||||||
|
}))
|
||||||
|
arg = arg[3:]
|
||||||
|
|
||||||
|
default:
|
||||||
|
arg = arg[1:]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}},
|
||||||
|
|
||||||
"hash": &ctx.Command{Name: "hash filename", Help: "查找文件路径", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
"hash": &ctx.Command{Name: "hash filename", Help: "查找文件路径", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
||||||
dir, name := path.Split(arg[0])
|
dir, name := path.Split(arg[0])
|
||||||
m.Append("dir", dir)
|
m.Append("dir", dir)
|
||||||
|
@ -199,15 +199,6 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
|
|||||||
map[string]interface{}{"type": "button", "value": "计算"},
|
map[string]interface{}{"type": "button", "value": "计算"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
map[string]interface{}{"componet_name": "location", "componet_help": "地理位置",
|
|
||||||
"componet_tmpl": "componet", "componet_view": "Context", "componet_init": "",
|
|
||||||
"componet_type": "public", "componet_ctx": "aaa", "componet_cmd": "location",
|
|
||||||
"componet_args": []interface{}{}, "inputs": []interface{}{
|
|
||||||
map[string]interface{}{"type": "text", "name": "content", "view": "long"},
|
|
||||||
map[string]interface{}{"type": "button", "value": "位置", "click": "Location"},
|
|
||||||
map[string]interface{}{"type": "button", "value": "查看"},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
map[string]interface{}{"componet_name": "email", "componet_help": "电子邮件",
|
map[string]interface{}{"componet_name": "email", "componet_help": "电子邮件",
|
||||||
"componet_tmpl": "componet", "componet_view": "Context", "componet_init": "",
|
"componet_tmpl": "componet", "componet_view": "Context", "componet_init": "",
|
||||||
"componet_type": "public", "componet_ctx": "aaa", "componet_cmd": "email",
|
"componet_type": "public", "componet_ctx": "aaa", "componet_cmd": "email",
|
||||||
@ -217,7 +208,15 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
|
|||||||
map[string]interface{}{"type": "button", "value": "发送", "view": "clear"},
|
map[string]interface{}{"type": "button", "value": "发送", "view": "clear"},
|
||||||
map[string]interface{}{"type": "textarea", "name": "content", "view": "clear"},
|
map[string]interface{}{"type": "textarea", "name": "content", "view": "clear"},
|
||||||
},
|
},
|
||||||
"display": map[string]interface{}{"map": true},
|
},
|
||||||
|
map[string]interface{}{"componet_name": "location", "componet_help": "地理位置",
|
||||||
|
"componet_tmpl": "componet", "componet_view": "Context", "componet_init": "",
|
||||||
|
"componet_type": "public", "componet_ctx": "aaa", "componet_cmd": "location",
|
||||||
|
"componet_args": []interface{}{}, "inputs": []interface{}{
|
||||||
|
map[string]interface{}{"type": "text", "name": "content", "view": "long"},
|
||||||
|
map[string]interface{}{"type": "button", "value": "位置", "click": "Location"},
|
||||||
|
map[string]interface{}{"type": "button", "value": "查看"},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
map[string]interface{}{"componet_name": "baidu", "componet_help": "百度地图",
|
map[string]interface{}{"componet_name": "baidu", "componet_help": "百度地图",
|
||||||
"componet_tmpl": "componet", "componet_view": "Context", "componet_init": "",
|
"componet_tmpl": "componet", "componet_view": "Context", "componet_init": "",
|
||||||
@ -227,7 +226,16 @@ var Index = &ctx.Context{Name: "ssh", Help: "集群中心",
|
|||||||
map[string]interface{}{"type": "button", "value": "位置", "click": "Location"},
|
map[string]interface{}{"type": "button", "value": "位置", "click": "Location"},
|
||||||
map[string]interface{}{"type": "button", "value": "查看"},
|
map[string]interface{}{"type": "button", "value": "查看"},
|
||||||
},
|
},
|
||||||
"display": map[string]interface{}{"map": true},
|
"display": map[string]interface{}{"deal": "map"},
|
||||||
|
},
|
||||||
|
map[string]interface{}{"componet_name": "draw", "componet_help": "绘图",
|
||||||
|
"componet_tmpl": "componet", "componet_view": "Context", "componet_init": "",
|
||||||
|
"componet_type": "public", "componet_ctx": "nfs", "componet_cmd": "draw",
|
||||||
|
"componet_args": []interface{}{}, "inputs": []interface{}{
|
||||||
|
map[string]interface{}{"type": "text", "name": "type"},
|
||||||
|
map[string]interface{}{"type": "button", "value": "查看"},
|
||||||
|
},
|
||||||
|
"display": map[string]interface{}{"deal": "point"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"index": []interface{}{
|
"index": []interface{}{
|
||||||
|
@ -715,6 +715,7 @@ function Plugin(page, pane, field) {
|
|||||||
}, 1000)
|
}, 1000)
|
||||||
event.Plugin = plugin, field.Run(event, args, function(msg) {
|
event.Plugin = plugin, field.Run(event, args, function(msg) {
|
||||||
show = false, page.ontoast("")
|
show = false, page.ontoast("")
|
||||||
|
output.innerHTML = ""
|
||||||
plugin.ondaemon[display.deal||"table"](msg)
|
plugin.ondaemon[display.deal||"table"](msg)
|
||||||
typeof cb == "function" && cb(msg)
|
typeof cb == "function" && cb(msg)
|
||||||
})
|
})
|
||||||
@ -733,20 +734,36 @@ function Plugin(page, pane, field) {
|
|||||||
ondaemon: {
|
ondaemon: {
|
||||||
void: function(msg) {},
|
void: function(msg) {},
|
||||||
table: function(msg) {
|
table: function(msg) {
|
||||||
output.innerHTML = ""
|
|
||||||
if (display.map) {
|
|
||||||
kit.AppendChild(output, [{img: ["https://gss0.bdstatic.com/8bo_dTSlRMgBo1vgoIiO_jowehsv/tile/?qt=vtile&x=25310&y=9426&z=17&styles=pl&scaler=2&udt=20190622"]}])
|
|
||||||
return
|
|
||||||
}
|
|
||||||
output.innerHTML = ""
|
|
||||||
!display.hide_append && msg.append && kit.OrderTable(kit.AppendTable(kit.AppendChild(output, "table"), ctx.Table(msg), msg.append), exports[1], function(event, value, name, line) {
|
!display.hide_append && msg.append && kit.OrderTable(kit.AppendTable(kit.AppendChild(output, "table"), ctx.Table(msg), msg.append), exports[1], function(event, value, name, line) {
|
||||||
// if (line["latitude"]) {
|
|
||||||
// page.openLocation(line.latitude, line.longitude, line.location)
|
|
||||||
// }
|
|
||||||
page.Sync("plugin_"+exports[0]).set(plugin.onexport[exports[2]||""](value, name, line))
|
page.Sync("plugin_"+exports[0]).set(plugin.onexport[exports[2]||""](value, name, line))
|
||||||
});
|
});
|
||||||
(display.show_result || !msg.append) && msg.result && kit.OrderCode(kit.AppendChild(output, [{view: ["code", "div", msg.Results()]}]).first)
|
(display.show_result || !msg.append) && msg.result && kit.OrderCode(kit.AppendChild(output, [{view: ["code", "div", msg.Results()]}]).first)
|
||||||
},
|
},
|
||||||
|
point: function(msg) {
|
||||||
|
var id = "canvas"+page.ID()
|
||||||
|
var canvas = kit.AppendChild(output, [{view: ["draw", "canvas"], data: {id: id, width: output.clientWidth-15}}]).last.getContext("2d")
|
||||||
|
ctx.Table(msg, function(line) {
|
||||||
|
var meta = JSON.parse(line.meta||"{}")
|
||||||
|
switch (line.type) {
|
||||||
|
case "begin":
|
||||||
|
canvas.beginPath()
|
||||||
|
break
|
||||||
|
|
||||||
|
case "circle":
|
||||||
|
canvas.arc(parseInt(meta.x), parseInt(meta.y), parseInt(meta.r), 0, Math.PI*2, true)
|
||||||
|
break
|
||||||
|
|
||||||
|
case "stroke":
|
||||||
|
canvas.strokeStyle = meta.color
|
||||||
|
canvas.lineWidth = parseInt(meta.width)
|
||||||
|
canvas.stroke()
|
||||||
|
break
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
map: function(msg) {
|
||||||
|
kit.AppendChild(output, [{img: ["https://gss0.bdstatic.com/8bo_dTSlRMgBo1vgoIiO_jowehsv/tile/?qt=vtile&x=25310&y=9426&z=17&styles=pl&scaler=2&udt=20190622"]}])
|
||||||
|
},
|
||||||
},
|
},
|
||||||
onexport: {
|
onexport: {
|
||||||
"": function(value, name) {
|
"": function(value, name) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user