1
0
forked from x/ContextOS

add Download.plugin.js

This commit is contained in:
shaoying 2019-09-22 11:18:34 +08:00
parent 447dba33c2
commit 16f7cde6bb
9 changed files with 80 additions and 27 deletions

View File

@ -727,6 +727,7 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心",
format, format_time = kit.Select("%s", m.Meta["format"], 0), kit.Select("20060102", m.Meta["format"], 1)
}
today := time.Now()
now := kit.Times(m.Cmd("cli.time", arg).Append("datetime"))
n := kit.Int(kit.Select("1", m.Option("count")))
if m.Has("nature") {
@ -752,6 +753,9 @@ var Index = &ctx.Context{Name: "cli", Help: "管理中心",
}
for month := cur.Month(); cur.Month() == month; cur = cur.AddDate(0, 0, 1) {
data := fmt.Sprintf("%d", cur.Day())
if cur.Year() == today.Year() && cur.YearDay() == today.YearDay() {
data = fmt.Sprintf(">%d<", cur.Day())
}
if cur.Day() == 1 {
if cur.Month() == 1 {
data = fmt.Sprintf("%d年", cur.Year())

View File

@ -4,5 +4,5 @@ var version = struct {
host string
self int
}{
"2019-09-21 18:43:47", "mac", 626,
"2019-09-22 09:30:17", "mac", 632,
}

View File

@ -449,17 +449,17 @@ var Index = &Context{Name: "ctx", Help: "模块中心", Server: &CTX{},
continue
}
if len(arg) == 1 || arg[1] == "all" {
m.Add("append", "key", k)
m.Add("append", "cmd", k)
m.Add("append", "name", v.Name)
} else if arg[1] == k {
m.Add("append", "key", k)
m.Add("append", "cmd", k)
m.Add("append", "name", v.Name)
m.Add("append", "help", v.Name)
}
}
return len(arg) == 1 || arg[1] != "all"
})
m.Sort("key").Table()
m.Sort("cmd").Table()
case "help":
m.Cmdy("ctx.help", "command", arg[1:])

View File

@ -96,7 +96,14 @@ func dir(m *ctx.Message, root string, name string, level int, deep bool, dir_typ
case "line":
if f.IsDir() {
if d, e := ioutil.ReadDir(p); m.Assert(e) {
m.Add("append", "line", len(d))
count := 0
for _, f := range d {
if strings.HasPrefix(f.Name(), ".") {
continue
}
count++
}
m.Add("append", "line", count)
}
} else {
nline := 0

View File

@ -17,7 +17,7 @@ kit publish "发布" private \
kit upgrade "升级" private "ssh._route" _ "cli.upgrade" \
text "" name pod imports plugin_pod \
select "" values script values plugin values restart values package values bench values portal values system action auto \
select "" values script values plugin values restart values package values system values portal values bench action auto \
text "" name see imports plugin_see \
button "升级"
@ -28,27 +28,29 @@ kit missyou "任务" private \
exports you "" you
kit pod "设备" private "ssh._route" _ "ssh.remote" __ \
text "" name pod view long \
button "行动" action auto \
button "返回" click Back \
text "" name pod \
button "查看" action auto \
exports pod pod pod
kit ctx "模块" private "ssh._route" _ context _ list __ \
text "" name pod imports plugin_pod action auto view long \
text "nfs" name ctx imports plugin_ctx action auto \
button "行动" \
text "" name pod imports plugin_pod action auto \
text "cli" name ctx imports plugin_ctx action auto \
button "查看" \
exports ctx names
kit cmd "命令" private "ssh._route" _ context _ command __ \
text "" name pod imports plugin_pod \
text "nfs" name ctx imports plugin_ctx \
text "pwd" name cmd \
button "执行"
text "cli" name ctx imports plugin_ctx \
text "date" name cmd imports plugin_cmd \
button "执行" \
button "返回" click Last \
exports cmd cmd
kit dir "目录" private "ssh._route" _ "nfs.dir" _ time size line path \
text "" name pod imports plugin_pod action auto \
text "usr/script" name dir imports plugin_dir action auto view long \
button "浏览" action auto \
button "返回" click Last \
feature display "editor" \
exports dir "" dir

View File

@ -12,4 +12,7 @@
kit.classList.add(item.parentNode, "today")
})
},
play: function(event) {
kit.AppendChilds(output, [{type: "video", data: {src: option.url.value, autoplay: ""}}])
},
}}}

View File

@ -35,3 +35,16 @@ fun delay "以后告诉你" private \
end
end
fun media "娱乐" private \
text "media" name table imports plugin_table \
text "电影" name title \
text "" name link \
button "记下了"
if $2 == "" || $3 == ""
copy ssh.data show _
else
copy ssh.data insert _ title _ link __
end
end

View File

@ -413,7 +413,7 @@ var page = Page({check: true,
"刷新": function(event, value) {
output.innerHTML = "", field.Pane.Show()
},
"清": function(event, value) {
"清": function(event, value) {
kit.Selector(output, "fieldset>div.output", function(item) {
item.innerHTML = ""
})
@ -435,6 +435,16 @@ var page = Page({check: true,
run(list)
},
"表格": function(event, value) {
page.plugin && page.plugin.Plugin.display("table")
},
"编辑": function(event, value) {
page.plugin && page.plugin.Plugin.display("editor")
},
"绘图": function(event, value) {
page.plugin && page.plugin.Plugin.display("canvas")
},
"添加": function(event, value) {
page.plugin && page.plugin.Plugin.Clone().Select()
},
@ -447,21 +457,24 @@ var page = Page({check: true,
"减参": function(event, value) {
page.plugin && page.plugin.Plugin.Remove()
},
"表格": function(event, value) {
page.plugin && page.plugin.Plugin.display("table")
"执行": function(event, value) {
page.plugin && page.plugin.Plugin.Check()
},
"编辑": function(event, value) {
page.plugin && page.plugin.Plugin.display("editor")
"下载": function(event, value) {
page.plugin && page.plugin.Plugin.Download()
},
"绘图": function(event, value) {
page.plugin && page.plugin.Plugin.display("canvas")
"清空": function(event, value) {
page.plugin && page.plugin.Plugin.clear()
},
"返回": function(event, value) {
page.plugin && page.plugin.Plugin.Last()
},
},
Button: [["layout", "聊天", "办公", "工作", "最高", "最宽", "最大"],
"", "刷新", "清", "并行", "串行",
"", "刷新", "清", "并行", "串行",
"", ["display", "表格", "编辑", "绘图"],
"", "添加", "删除", "加参", "减参",
"", "执行", "下载", "清空", "返回",
],
}
},
@ -499,7 +512,7 @@ var page = Page({check: true,
"layout": page.action.Pane.Layout(),
})], function(msg) {
var url = location.origin+location.pathname+"?relay="+msg.result.join("")
page.ontoast({text: "<img src=\""+ctx.Share({"group": "index", "name": "login", cmds: ["share", url]})+"\">", height: 320, title: url, button: ["确定"], cb: function(which) {
page.ontoast({text: "<img src=\""+ctx.Share({"group": "index", "name": "login", cmds: ["share", url]})+"\">", height: 320, width: 320, title: url, button: ["确定"], cb: function(which) {
page.ontoast()
}})
})

View File

@ -713,7 +713,7 @@ function Plugin(page, pane, field, runs) {
});
switch (item.value) {
case "date":
item.value = kit.format_date(new Date())
item.name == "date" && (item.value = kit.format_date(new Date()))
break
}
@ -870,6 +870,16 @@ function Plugin(page, pane, field, runs) {
deal = arg, plugin.ondaemon[deal||"table"](plugin.msg, cb)
plugin.show_after(plugin.msg)
},
Download: function() {
var text = kit.Selector(output, "tr", function(tr) {
return kit.Selector(tr, "td,th", function(td) {
return td.innerText
}).join(",")
}).join("\n"), type = ".csv"
!text && (text = plugin.msg.result.join(""), type = ".txt")
page.ontoast({text:'<a href="'+URL.createObjectURL(new Blob([text]))+'" target="_blank" download="'+name+type+'">'+name+type+'</a>', width: 200})
},
show_after: function(msg) {},
upload: function(event) {
ctx.Upload(option.upload.files[0], function(event, msg) {
@ -934,6 +944,7 @@ function Plugin(page, pane, field, runs) {
onaction: {
onfocus: function(event, action, type, name, item) {
page.input = event.target
plugin.Select(true)
},
onblur: function(event, action, type, name, item) {
page.input = undefined
@ -952,7 +963,7 @@ function Plugin(page, pane, field, runs) {
}
},
ondblclick: function(event, action, type, name, item) {
action.target.value = kit.History.get("txt", -1).data.trim()
type == "text" && (action.target.value = kit.History.get("txt", -1).data.trim())
},
onchange: function(event, action, type, name, item) {
type == "select" && plugin.Check(item.action == "auto"? undefined: action)