From 16f7cde6bb4a84724d015562f73630ccf19eef6f Mon Sep 17 00:00:00 2001 From: shaoying Date: Sun, 22 Sep 2019 11:18:34 +0800 Subject: [PATCH] add Download.plugin.js --- src/contexts/cli/cli.go | 4 ++++ src/contexts/cli/version.go | 2 +- src/contexts/ctx/ctx.go | 6 +++--- src/contexts/nfs/nfs.go | 9 ++++++++- src/plugin/context/index.shy | 22 ++++++++++++---------- src/plugin/love/index.js | 3 +++ src/plugin/love/index.shy | 13 +++++++++++++ usr/librarys/chat.js | 33 +++++++++++++++++++++++---------- usr/librarys/example.js | 15 +++++++++++++-- 9 files changed, 80 insertions(+), 27 deletions(-) diff --git a/src/contexts/cli/cli.go b/src/contexts/cli/cli.go index 2b2642d6..a71cc08d 100644 --- a/src/contexts/cli/cli.go +++ b/src/contexts/cli/cli.go @@ -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()) diff --git a/src/contexts/cli/version.go b/src/contexts/cli/version.go index 55f86f8a..853eabf5 100644 --- a/src/contexts/cli/version.go +++ b/src/contexts/cli/version.go @@ -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, } diff --git a/src/contexts/ctx/ctx.go b/src/contexts/ctx/ctx.go index 80b96906..029693ae 100644 --- a/src/contexts/ctx/ctx.go +++ b/src/contexts/ctx/ctx.go @@ -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:]) diff --git a/src/contexts/nfs/nfs.go b/src/contexts/nfs/nfs.go index 1ebf655b..43b0f548 100644 --- a/src/contexts/nfs/nfs.go +++ b/src/contexts/nfs/nfs.go @@ -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 diff --git a/src/plugin/context/index.shy b/src/plugin/context/index.shy index bbaf7704..2ab5848b 100644 --- a/src/plugin/context/index.shy +++ b/src/plugin/context/index.shy @@ -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 diff --git a/src/plugin/love/index.js b/src/plugin/love/index.js index bb87657c..af150342 100644 --- a/src/plugin/love/index.js +++ b/src/plugin/love/index.js @@ -12,4 +12,7 @@ kit.classList.add(item.parentNode, "today") }) }, + play: function(event) { + kit.AppendChilds(output, [{type: "video", data: {src: option.url.value, autoplay: ""}}]) + }, }}} diff --git a/src/plugin/love/index.shy b/src/plugin/love/index.shy index 9c4e2c23..42c4b8bc 100644 --- a/src/plugin/love/index.shy +++ b/src/plugin/love/index.shy @@ -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 + diff --git a/usr/librarys/chat.js b/usr/librarys/chat.js index 93868e01..ff6f8403 100644 --- a/usr/librarys/chat.js +++ b/usr/librarys/chat.js @@ -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: "", height: 320, title: url, button: ["确定"], cb: function(which) { + page.ontoast({text: "", height: 320, width: 320, title: url, button: ["确定"], cb: function(which) { page.ontoast() }}) }) diff --git a/usr/librarys/example.js b/usr/librarys/example.js index 7f8bc767..90650127 100644 --- a/usr/librarys/example.js +++ b/usr/librarys/example.js @@ -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:''+name+type+'', 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)