1
0
mirror of https://shylinux.com/x/ContextOS synced 2025-04-25 16:58:06 +08:00
This commit is contained in:
shylinux 2019-06-25 09:12:30 +08:00
parent 66c702b91b
commit 3c139893ef
7 changed files with 114 additions and 61 deletions

View File

@ -47,8 +47,9 @@ hup() {
main() {
trap HUP hup
while true; do
date
${ctx_bin} "$@" && break
log "restarting..." && sleep 3
log "\nrestarting..." && sleep 1
done
}
action() {

View File

@ -744,12 +744,7 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心",
m.Append("time", m.Time())
m.Append("code", code)
m.Echo(", wait 1s\n")
m.Table()
fmt.Printf("\n")
for _, v := range m.Meta["result"] {
fmt.Printf("%v", v)
}
m.Echo(", wait 1s\n").Table()
m.GoFunc(m, func(m *ctx.Message) {
defer func() {

View File

@ -96,7 +96,7 @@ func (web *WEB) Login(msg *ctx.Message, w http.ResponseWriter, r *http.Request)
// return true
// }
// defer func() {
// msg.Log("info", "access: %s", msg.Option("access", msg.Cmdx("aaa.sess", "access")))
// msg.Log("info", "access: %s", msg.Option("access", msg.Cmdx("aaa.sess", "access")))
// }()
if msg.Confs("login", "cas") {
if !cas.IsAuthenticated(r) {
@ -1135,8 +1135,8 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心",
if p == "" {
p = m.Cmdx("nfs.path", m.Conf("publish", []string{"list", key}))
}
if s, e:= os.Stat(p); e != nil || s.IsDir() {
return
if s, e := os.Stat(p); e != nil || s.IsDir() {
return e
}
m.Log("info", "publish %s %s", kit.Hashs(p), p)

View File

@ -1,5 +1,5 @@
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) {
var page = this
kit.isWindows && (document.body.style.overflow = "hidden")
@ -197,8 +197,13 @@ Page({
var pane = this, foot = page.footer.Pane
var cmds = ["brow", river, i||which[river]||0]
cmds[2] || (output.innerHTML = ""), pane.Times(1000, cmds, function(line, index, msg) {
pane.Append("", line, ["text"], "index")
cmds[2] || (output.innerHTML = ""), pane.Times(page.conf.refresh, cmds, function(line, index, msg) {
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)
})
},
@ -236,7 +241,6 @@ Page({
},
initAction: function(page, field, option, output) {
var river = "", storm = 0, input = "", share = ""
var toggle = true
output.DisplayRaw = true
return {
@ -261,16 +265,13 @@ Page({
}
this.Update([river, storm], "plugin", ["node", "name"], "index", false, function(line, index, event, args, cbs) {
event.shiftKey? page.target.Send("field", JSON.stringify({
name: line.name, help: line.help, view: line.view, init: line.init,
node: line.node, group: line.group, index: line.index,
inputs: line.inputs, args: args,
})): field.Pane.Run([river, storm, index].concat(args), function(msg) {
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)
})
var plugin = event.Plugin
event.shiftKey? page.target.Pane.Send("field", plugin.Format()):
field.Pane.Run([river, storm, index].concat(args), function(msg) {
var text = plugin.Reveal(msg)
event.ctrlKey && page.target.Pane.Send(text[0], text[1])
typeof cbs == "function" && cbs(msg)
})
})
},
Layout: function(name) {
@ -282,11 +283,17 @@ Page({
"恢复": function(event, value) {
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})
},
"放大": function(event, value) {
page.onlayout(event, {action:300, source:60})
"办公": function(event, value) {
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) {
page.onlayout(event, {action: -1})
@ -295,31 +302,51 @@ Page({
page.onlayout(event, {river:0, storm:0})
},
"最大": 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})
},
"刷新": 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) {
page.plugin && page.plugin.Plugin.Clone().Select()
},
"删除": function(event, value) {
page.plugin && page.plugin.Clear()
page.input && page.plugin.Plugin.Remove()
},
"加参": function(event, value) {
page.plugin.Append({})
page.plugin && page.plugin.Plugin.Append({})
},
"去参": function(event, value) {
page.input && page.plugin.Remove(page.input)
},
"位置": function(event, value) {
page.getLocation(function(res) {
alert(res.latitude)
alert(res.longitude)
})
page.plugin && page.plugin.Plugin.Prepend()
},
},
Button: [["layout", "恢复", "缩小", "放大", "最高", "最宽", "最大", "全屏"], "br", "添加", "删除", "加参", "去参", "位置"],
Button: [["layout", "恢复", "聊天", "办公", "工作", "最高", "最宽", "最大"], "br",
"刷新", "清空", "并行", "串行", "br",
"添加", "删除", "加参", "去参", "br",
],
}
},
initStorm: function(page, field, option, output) {
@ -331,6 +358,7 @@ Page({
},
},
Show: function(which) {
this.which.get("") == which && page.action.Pane.Show()
this.Update([river], "text", ["key", "count"], "key", which||ctx.Search("storm")||true)
},
Next: function() {
@ -461,7 +489,7 @@ Page({
},
init: function(page) {
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.header.Pane.Order({"logout": "logout", "user": ""}, ["logout", "user"], function(event, item, value) {
switch (item) {
@ -480,7 +508,7 @@ Page({
default:
}
})
kit.isWeiXin && page.login.Pane.Run(["weixin"], function(msg) {
false && kit.isWeiXin && page.login.Pane.Run(["weixin"], function(msg) {
page.Include([
"https://res.wx.qq.com/open/js/jweixin-1.4.0.js",
"/static/librarys/weixin.js",

View File

@ -4,6 +4,7 @@ ctx = context = {
for (var k in dataset) {
option[k] = dataset[k].split(",")
}
kit.Log(option)
this.GET("", option, function(msg) {
msg[0] && (msg = msg[0])
// msg && (msg.__proto__ = (page || {}))

View File

@ -8,7 +8,7 @@ html, body {
fieldset {
background-color:#d8d8d8;
padding:0px;
min-width:160px;
min-width:10px;
overflow:auto;
margin:0px;
}

View File

@ -373,10 +373,25 @@ function Pane(page, field) {
var cache = []
var timer = ""
var list = [], last = -1
var conf = {}, conf_cb = {}
var name = option.dataset.componet_name
var pane = (page[field.dataset.init] || function() {
})(page, field, option, output) || {}; pane.__proto__ = {
__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) {
if (field.style.display != "block") {
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)
},
Runs: function(cmds, cb) {
ctx.Run(page, option.dataset, cmds, function(msg) {
pane.Run(cmds, function(msg) {
ctx.Table(msg, function(line, index) {
(cb||this.ondaemon)(line, index, msg)
})
@ -594,13 +609,21 @@ function Plugin(page, pane, field) {
})
return action
},
Prepend: function() {
var list = option.querySelectorAll(".args")
list.length > 0 && option.removeChild(list[list.length-1].parentNode)
},
Select: function() {
option.querySelectorAll("input")[1].focus()
},
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)
},
Reveal: function(msg) {
return msg.append && msg.append[0]? ["table", JSON.stringify(ctx.Tables(msg))]: ["code", msg.result.join("")]
},
Remove: function() {
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())
})
},
Runs: function(event) {
field.Run(event, kit.Selector(option, ".args", function(item, index) {
Runs: function(event, cb) {
event.Plugin = plugin, field.Run(event, kit.Selector(option, ".args", function(item, index) {
return item.value
}), plugin.ondaemon)
}), function(msg) {
typeof cb == "function" && cb(msg)
plugin.ondaemon[display.deal||"table"](msg)
})
},
Location: function(event) {
output.className = "output long"
@ -632,20 +658,22 @@ function Plugin(page, pane, field) {
Clear: function() {
output.innerHTML = ""
},
ondaemon: 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) {
if (line["latitude"]) {
page.openLocation(line.latitude, line.longitude, line.location)
ondaemon: {
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
}
page.Sync("plugin_"+exports[0]).set(plugin.onexport[exports[2]||""](value, name))
});
(display.show_result || !msg.append) && msg.result && kit.AppendChild(output, [{view: ["code", "div", msg.Results()]}])
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) {
if (line["latitude"]) {
page.openLocation(line.latitude, line.longitude, line.location)
}
page.Sync("plugin_"+exports[0]).set(plugin.onexport[exports[2]||""](value, name))
});
(display.show_result || !msg.append) && msg.result && kit.AppendChild(output, [{view: ["code", "div", msg.Results()]}])
},
},
onexport: {
"": function(value, name) {