mirror of
https://shylinux.com/x/ContextOS
synced 2025-06-27 02:17:31 +08:00
add run
This commit is contained in:
parent
66c702b91b
commit
3c139893ef
@ -47,8 +47,9 @@ hup() {
|
|||||||
main() {
|
main() {
|
||||||
trap HUP hup
|
trap HUP hup
|
||||||
while true; do
|
while true; do
|
||||||
|
date
|
||||||
${ctx_bin} "$@" && break
|
${ctx_bin} "$@" && break
|
||||||
log "restarting..." && sleep 3
|
log "\nrestarting..." && sleep 1
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
action() {
|
action() {
|
||||||
|
@ -744,12 +744,7 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心",
|
|||||||
|
|
||||||
m.Append("time", m.Time())
|
m.Append("time", m.Time())
|
||||||
m.Append("code", code)
|
m.Append("code", code)
|
||||||
m.Echo(", wait 1s\n")
|
m.Echo(", wait 1s\n").Table()
|
||||||
m.Table()
|
|
||||||
fmt.Printf("\n")
|
|
||||||
for _, v := range m.Meta["result"] {
|
|
||||||
fmt.Printf("%v", v)
|
|
||||||
}
|
|
||||||
|
|
||||||
m.GoFunc(m, func(m *ctx.Message) {
|
m.GoFunc(m, func(m *ctx.Message) {
|
||||||
defer func() {
|
defer func() {
|
||||||
|
@ -1136,7 +1136,7 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心",
|
|||||||
p = m.Cmdx("nfs.path", m.Conf("publish", []string{"list", key}))
|
p = m.Cmdx("nfs.path", m.Conf("publish", []string{"list", key}))
|
||||||
}
|
}
|
||||||
if s, e := os.Stat(p); e != nil || s.IsDir() {
|
if s, e := os.Stat(p); e != nil || s.IsDir() {
|
||||||
return
|
return e
|
||||||
}
|
}
|
||||||
|
|
||||||
m.Log("info", "publish %s %s", kit.Hashs(p), p)
|
m.Log("info", "publish %s %s", kit.Hashs(p), p)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
Page({
|
Page({
|
||||||
conf: {border: 4, layout: {header:30, river:180, action:180, source:60, storm:180, footer:30}},
|
conf: {refresh: 1000, border: 4, layout: {header:30, river:120, action:180, source:60, storm:100, footer:30}},
|
||||||
onlayout: function(event, sizes) {
|
onlayout: function(event, sizes) {
|
||||||
var page = this
|
var page = this
|
||||||
kit.isWindows && (document.body.style.overflow = "hidden")
|
kit.isWindows && (document.body.style.overflow = "hidden")
|
||||||
@ -197,8 +197,13 @@ Page({
|
|||||||
|
|
||||||
var pane = this, foot = page.footer.Pane
|
var pane = this, foot = page.footer.Pane
|
||||||
var cmds = ["brow", river, i||which[river]||0]
|
var cmds = ["brow", river, i||which[river]||0]
|
||||||
cmds[2] || (output.innerHTML = ""), pane.Times(1000, cmds, function(line, index, msg) {
|
cmds[2] || (output.innerHTML = ""), pane.Times(page.conf.refresh, cmds, function(line, index, msg) {
|
||||||
pane.Append("", line, ["text"], "index")
|
pane.Append("", line, ["text"], "index", function(line, index, event, args, cbs) {
|
||||||
|
var text = JSON.parse(line.text)
|
||||||
|
page.action.Pane.Run([text.river, text.storm, text.action].concat(args), function(msg) {
|
||||||
|
typeof cbs == "function" && cbs(msg)
|
||||||
|
})
|
||||||
|
})
|
||||||
foot.State("text", which[river] = cmds[2] = parseInt(line.index)+1)
|
foot.State("text", which[river] = cmds[2] = parseInt(line.index)+1)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
@ -236,7 +241,6 @@ Page({
|
|||||||
},
|
},
|
||||||
initAction: function(page, field, option, output) {
|
initAction: function(page, field, option, output) {
|
||||||
var river = "", storm = 0, input = "", share = ""
|
var river = "", storm = 0, input = "", share = ""
|
||||||
var toggle = true
|
|
||||||
|
|
||||||
output.DisplayRaw = true
|
output.DisplayRaw = true
|
||||||
return {
|
return {
|
||||||
@ -261,14 +265,11 @@ Page({
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.Update([river, storm], "plugin", ["node", "name"], "index", false, function(line, index, event, args, cbs) {
|
this.Update([river, storm], "plugin", ["node", "name"], "index", false, function(line, index, event, args, cbs) {
|
||||||
event.shiftKey? page.target.Send("field", JSON.stringify({
|
var plugin = event.Plugin
|
||||||
name: line.name, help: line.help, view: line.view, init: line.init,
|
event.shiftKey? page.target.Pane.Send("field", plugin.Format()):
|
||||||
node: line.node, group: line.group, index: line.index,
|
field.Pane.Run([river, storm, index].concat(args), function(msg) {
|
||||||
inputs: line.inputs, args: args,
|
var text = plugin.Reveal(msg)
|
||||||
})): field.Pane.Run([river, storm, index].concat(args), function(msg) {
|
event.ctrlKey && page.target.Pane.Send(text[0], text[1])
|
||||||
event.ctrlKey && (msg.append && msg.append[0]?
|
|
||||||
page.target.Send("table", JSON.stringify(ctx.Tables(msg))):
|
|
||||||
page.target.Send("code", msg.result.join("")))
|
|
||||||
typeof cbs == "function" && cbs(msg)
|
typeof cbs == "function" && cbs(msg)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -282,11 +283,17 @@ Page({
|
|||||||
"恢复": function(event, value) {
|
"恢复": function(event, value) {
|
||||||
page.onlayout(event, page.conf.layout)
|
page.onlayout(event, page.conf.layout)
|
||||||
},
|
},
|
||||||
"缩小": function(event, value) {
|
"聊天": function(event, value) {
|
||||||
|
page.onlayout(event, page.conf.layout)
|
||||||
page.onlayout(event, {action:60, source:60})
|
page.onlayout(event, {action:60, source:60})
|
||||||
},
|
},
|
||||||
"放大": function(event, value) {
|
"办公": function(event, value) {
|
||||||
page.onlayout(event, {action:300, source:60})
|
page.onlayout(event, page.conf.layout)
|
||||||
|
page.onlayout(event, {river: 0, action:300, source:60})
|
||||||
|
},
|
||||||
|
"工作": function(event, value) {
|
||||||
|
page.onlayout(event, page.conf.layout)
|
||||||
|
page.onlayout(event, {river:0, action:-1, source:60})
|
||||||
},
|
},
|
||||||
"最高": function(event, value) {
|
"最高": function(event, value) {
|
||||||
page.onlayout(event, {action: -1})
|
page.onlayout(event, {action: -1})
|
||||||
@ -295,31 +302,51 @@ Page({
|
|||||||
page.onlayout(event, {river:0, storm:0})
|
page.onlayout(event, {river:0, storm:0})
|
||||||
},
|
},
|
||||||
"最大": function(event, value) {
|
"最大": function(event, value) {
|
||||||
(toggle = !toggle)? page.onlayout(event, page.conf.layout): page.onlayout(event, {river:0, action:-1, source:60})
|
|
||||||
},
|
|
||||||
"全屏": function(event, value) {
|
|
||||||
page.onlayout(event, {header:0, footer:0, river:0, action: -1, storm:0})
|
page.onlayout(event, {header:0, footer:0, river:0, action: -1, storm:0})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
"刷新": function(event, value) {
|
||||||
|
output.innerHTML = "", field.Pane.Show()
|
||||||
|
},
|
||||||
|
"清空": function(event, value) {
|
||||||
|
kit.Selector(output, "fieldset>div.output", function(item) {
|
||||||
|
item.innerHTML = ""
|
||||||
|
})
|
||||||
|
},
|
||||||
|
"并行": function(event, value) {
|
||||||
|
kit.Selector(output, "fieldset", function(item) {
|
||||||
|
item.Plugin.Runs(event)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
"串行": function(event, value) {
|
||||||
|
var list = kit.Selector(output, "fieldset")
|
||||||
|
function run(list) {
|
||||||
|
list.length > 0? list[0].Plugin.Runs(event, function() {
|
||||||
|
field.Pane.Conf("running", true), setTimeout(function() {
|
||||||
|
run(list.slice(1))
|
||||||
|
}, 1000)
|
||||||
|
}): pane.Conf("running", false)
|
||||||
|
}
|
||||||
|
run(list)
|
||||||
|
},
|
||||||
|
|
||||||
"添加": function(event, value) {
|
"添加": function(event, value) {
|
||||||
page.plugin && page.plugin.Plugin.Clone().Select()
|
page.plugin && page.plugin.Plugin.Clone().Select()
|
||||||
},
|
},
|
||||||
"删除": function(event, value) {
|
"删除": function(event, value) {
|
||||||
page.plugin && page.plugin.Clear()
|
page.input && page.plugin.Plugin.Remove()
|
||||||
},
|
},
|
||||||
"加参": function(event, value) {
|
"加参": function(event, value) {
|
||||||
page.plugin.Append({})
|
page.plugin && page.plugin.Plugin.Append({})
|
||||||
},
|
},
|
||||||
"去参": function(event, value) {
|
"去参": function(event, value) {
|
||||||
page.input && page.plugin.Remove(page.input)
|
page.plugin && page.plugin.Plugin.Prepend()
|
||||||
},
|
|
||||||
"位置": function(event, value) {
|
|
||||||
page.getLocation(function(res) {
|
|
||||||
alert(res.latitude)
|
|
||||||
alert(res.longitude)
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Button: [["layout", "恢复", "缩小", "放大", "最高", "最宽", "最大", "全屏"], "br", "添加", "删除", "加参", "去参", "位置"],
|
Button: [["layout", "恢复", "聊天", "办公", "工作", "最高", "最宽", "最大"], "br",
|
||||||
|
"刷新", "清空", "并行", "串行", "br",
|
||||||
|
"添加", "删除", "加参", "去参", "br",
|
||||||
|
],
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
initStorm: function(page, field, option, output) {
|
initStorm: function(page, field, option, output) {
|
||||||
@ -331,6 +358,7 @@ Page({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Show: function(which) {
|
Show: function(which) {
|
||||||
|
this.which.get("") == which && page.action.Pane.Show()
|
||||||
this.Update([river], "text", ["key", "count"], "key", which||ctx.Search("storm")||true)
|
this.Update([river], "text", ["key", "count"], "key", which||ctx.Search("storm")||true)
|
||||||
},
|
},
|
||||||
Next: function() {
|
Next: function() {
|
||||||
@ -461,7 +489,7 @@ Page({
|
|||||||
},
|
},
|
||||||
init: function(page) {
|
init: function(page) {
|
||||||
page.onlayout(null, page.conf.layout)
|
page.onlayout(null, page.conf.layout)
|
||||||
page.action.Pane.Layout(ctx.Search("layout")? ctx.Search("layout"): kit.isMobile? "最宽": "最大")
|
page.action.Pane.Layout(ctx.Search("layout")? ctx.Search("layout"): kit.isMobile? "办公": "工作")
|
||||||
page.footer.Pane.Order({"site": "", "ip": "", "text": "", ":":""}, kit.isMobile? ["site", "ip", "text"]: ["ip", "text", ":"], function(event, item, value) {})
|
page.footer.Pane.Order({"site": "", "ip": "", "text": "", ":":""}, kit.isMobile? ["site", "ip", "text"]: ["ip", "text", ":"], function(event, item, value) {})
|
||||||
page.header.Pane.Order({"logout": "logout", "user": ""}, ["logout", "user"], function(event, item, value) {
|
page.header.Pane.Order({"logout": "logout", "user": ""}, ["logout", "user"], function(event, item, value) {
|
||||||
switch (item) {
|
switch (item) {
|
||||||
@ -480,7 +508,7 @@ Page({
|
|||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
kit.isWeiXin && page.login.Pane.Run(["weixin"], function(msg) {
|
false && kit.isWeiXin && page.login.Pane.Run(["weixin"], function(msg) {
|
||||||
page.Include([
|
page.Include([
|
||||||
"https://res.wx.qq.com/open/js/jweixin-1.4.0.js",
|
"https://res.wx.qq.com/open/js/jweixin-1.4.0.js",
|
||||||
"/static/librarys/weixin.js",
|
"/static/librarys/weixin.js",
|
||||||
|
@ -4,6 +4,7 @@ ctx = context = {
|
|||||||
for (var k in dataset) {
|
for (var k in dataset) {
|
||||||
option[k] = dataset[k].split(",")
|
option[k] = dataset[k].split(",")
|
||||||
}
|
}
|
||||||
|
kit.Log(option)
|
||||||
this.GET("", option, function(msg) {
|
this.GET("", option, function(msg) {
|
||||||
msg[0] && (msg = msg[0])
|
msg[0] && (msg = msg[0])
|
||||||
// msg && (msg.__proto__ = (page || {}))
|
// msg && (msg.__proto__ = (page || {}))
|
||||||
|
@ -8,7 +8,7 @@ html, body {
|
|||||||
fieldset {
|
fieldset {
|
||||||
background-color:#d8d8d8;
|
background-color:#d8d8d8;
|
||||||
padding:0px;
|
padding:0px;
|
||||||
min-width:160px;
|
min-width:10px;
|
||||||
overflow:auto;
|
overflow:auto;
|
||||||
margin:0px;
|
margin:0px;
|
||||||
}
|
}
|
||||||
|
@ -373,10 +373,25 @@ function Pane(page, field) {
|
|||||||
var cache = []
|
var cache = []
|
||||||
var timer = ""
|
var timer = ""
|
||||||
var list = [], last = -1
|
var list = [], last = -1
|
||||||
|
var conf = {}, conf_cb = {}
|
||||||
var name = option.dataset.componet_name
|
var name = option.dataset.componet_name
|
||||||
var pane = (page[field.dataset.init] || function() {
|
var pane = (page[field.dataset.init] || function() {
|
||||||
})(page, field, option, output) || {}; pane.__proto__ = {
|
})(page, field, option, output) || {}; pane.__proto__ = {
|
||||||
__proto__: page,
|
__proto__: page,
|
||||||
|
Conf: function(key, value, cb) {
|
||||||
|
if (key == undefined) {
|
||||||
|
return conf
|
||||||
|
}
|
||||||
|
if (cb != undefined) {
|
||||||
|
conf_cb[key] = cb
|
||||||
|
}
|
||||||
|
if (value != undefined) {
|
||||||
|
var old = conf[key]
|
||||||
|
conf[key] = value
|
||||||
|
conf_cb[key] && conf_cb[key](value, old)
|
||||||
|
}
|
||||||
|
return conf[key]
|
||||||
|
},
|
||||||
ShowDialog: function(width, height) {
|
ShowDialog: function(width, height) {
|
||||||
if (field.style.display != "block") {
|
if (field.style.display != "block") {
|
||||||
page.dialog && page.dialog != field && page.dialog.style.display == "block" && page.dialog.Show()
|
page.dialog && page.dialog != field && page.dialog.style.display == "block" && page.dialog.Show()
|
||||||
@ -403,7 +418,7 @@ function Pane(page, field) {
|
|||||||
ctx.Run(page, option.dataset, cmds, cb||this.ondaemon)
|
ctx.Run(page, option.dataset, cmds, cb||this.ondaemon)
|
||||||
},
|
},
|
||||||
Runs: function(cmds, cb) {
|
Runs: function(cmds, cb) {
|
||||||
ctx.Run(page, option.dataset, cmds, function(msg) {
|
pane.Run(cmds, function(msg) {
|
||||||
ctx.Table(msg, function(line, index) {
|
ctx.Table(msg, function(line, index) {
|
||||||
(cb||this.ondaemon)(line, index, msg)
|
(cb||this.ondaemon)(line, index, msg)
|
||||||
})
|
})
|
||||||
@ -594,13 +609,21 @@ function Plugin(page, pane, field) {
|
|||||||
})
|
})
|
||||||
return action
|
return action
|
||||||
},
|
},
|
||||||
|
Prepend: function() {
|
||||||
|
var list = option.querySelectorAll(".args")
|
||||||
|
list.length > 0 && option.removeChild(list[list.length-1].parentNode)
|
||||||
|
},
|
||||||
Select: function() {
|
Select: function() {
|
||||||
option.querySelectorAll("input")[1].focus()
|
option.querySelectorAll("input")[1].focus()
|
||||||
},
|
},
|
||||||
Format: function() {
|
Format: function() {
|
||||||
arguments.length > 0 && (field.Meta.args = kit.List(arguments))
|
field.Meta.args = arguments.length > 0? kit.List(arguments):
|
||||||
|
kit.Selector(option, ".args", function(item) {return item.value})
|
||||||
return JSON.stringify(field.Meta)
|
return JSON.stringify(field.Meta)
|
||||||
},
|
},
|
||||||
|
Reveal: function(msg) {
|
||||||
|
return msg.append && msg.append[0]? ["table", JSON.stringify(ctx.Tables(msg))]: ["code", msg.result.join("")]
|
||||||
|
},
|
||||||
Remove: function() {
|
Remove: function() {
|
||||||
field.parentNode.removeChild(field)
|
field.parentNode.removeChild(field)
|
||||||
},
|
},
|
||||||
@ -615,10 +638,13 @@ function Plugin(page, pane, field) {
|
|||||||
item == target && (index == list.length-1? plugin.Runs(event): page.plugin == field && list[index+1].focus())
|
item == target && (index == list.length-1? plugin.Runs(event): page.plugin == field && list[index+1].focus())
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
Runs: function(event) {
|
Runs: function(event, cb) {
|
||||||
field.Run(event, kit.Selector(option, ".args", function(item, index) {
|
event.Plugin = plugin, field.Run(event, kit.Selector(option, ".args", function(item, index) {
|
||||||
return item.value
|
return item.value
|
||||||
}), plugin.ondaemon)
|
}), function(msg) {
|
||||||
|
typeof cb == "function" && cb(msg)
|
||||||
|
plugin.ondaemon[display.deal||"table"](msg)
|
||||||
|
})
|
||||||
},
|
},
|
||||||
Location: function(event) {
|
Location: function(event) {
|
||||||
output.className = "output long"
|
output.className = "output long"
|
||||||
@ -632,7 +658,8 @@ function Plugin(page, pane, field) {
|
|||||||
Clear: function() {
|
Clear: function() {
|
||||||
output.innerHTML = ""
|
output.innerHTML = ""
|
||||||
},
|
},
|
||||||
ondaemon: function(msg) {
|
ondaemon: {
|
||||||
|
table: function(msg) {
|
||||||
output.innerHTML = ""
|
output.innerHTML = ""
|
||||||
if (display.map) {
|
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"]}])
|
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"]}])
|
||||||
@ -647,6 +674,7 @@ function Plugin(page, pane, field) {
|
|||||||
});
|
});
|
||||||
(display.show_result || !msg.append) && msg.result && kit.AppendChild(output, [{view: ["code", "div", msg.Results()]}])
|
(display.show_result || !msg.append) && msg.result && kit.AppendChild(output, [{view: ["code", "div", msg.Results()]}])
|
||||||
},
|
},
|
||||||
|
},
|
||||||
onexport: {
|
onexport: {
|
||||||
"": function(value, name) {
|
"": function(value, name) {
|
||||||
return value
|
return value
|
||||||
|
Loading…
x
Reference in New Issue
Block a user