From c3be7426ab58fd19f28aea10af4f1a52072698cc Mon Sep 17 00:00:00 2001 From: fofolee Date: Mon, 1 Apr 2019 00:30:18 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B9=E5=90=91=E9=94=AE=E8=BF=9B=E8=A1=8C?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E9=80=89=E6=8B=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/index.js | 93 ++++++++++++++++++++++++++++++++++++++++++++++++ assets/style.css | 3 +- index.html | 55 +--------------------------- 3 files changed, 95 insertions(+), 56 deletions(-) create mode 100644 assets/index.js diff --git a/assets/index.js b/assets/index.js new file mode 100644 index 0000000..ab332ae --- /dev/null +++ b/assets/index.js @@ -0,0 +1,93 @@ +kill = (taskname, taskpath) => { + window.taskkill(taskname, taskpath, err => { + if (err) { + $("#infopannel").css({ "background": "#EF5350" }); + $("#infopannel").html(err).fadeIn(300).delay(3000).fadeOut(300); + } else { + if(taskpath == undefined){ + $("[name='" + taskname + "']").fadeOut(300).remove() + let tasknum = $(".taskinfo").length + utools.setExpendHeight(tasknum > 10 ? 500 : 50 * tasknum); + window.tasklist((task) => { + window.tasks = task + }); + }else{ + $("#infopannel").css({ "background": "#83bf40" }); + $("#infopannel").html('重启进程成功!').fadeIn(300).delay(3000).fadeOut(300); + } + } + }); +} + +show = (tasks, text) => { + var taskinfo = ''; + for (var t of window.tasks) { + if (t.ProcessName.toUpperCase().search(text.toUpperCase()) != -1 || t.Description.toUpperCase().search(text.toUpperCase()) != -1) { + let title = t.Description ? t.Description : t.ProcessName; + taskinfo += '
'; + taskinfo += ''; + taskinfo += '
' + title + '
' + t.Path + '
'; + } + } + $("#tasklist").html(taskinfo); + $(".taskinfo:first").addClass("select"); + let tasknum = $(".taskinfo").length + utools.setExpendHeight(tasknum > 10 ? 500 : 50 * tasknum); +} + +utools.onPluginEnter(({ code, type, payload }) => { + utools.setExpendHeight(0); + window.tasklist((task) => { + window.tasks = task + show(window.tasks, ''); + utools.setSubInput(({ text }) => { + show(window.tasks, text); + }, '输入进程名,回车关闭,或点击关闭'); + }); +}); + +$("#tasklist").on('mousedown', '.taskinfo', function (e) { + if (1 == e.which) { + kill($(this).attr('name')); + } else if (3 == e.which) { + kill($(this).attr('name'), $(this).children(".path").html().replace(/\\/g, '/')) + } +}); + +$(document).keydown(e => { + switch (e.keyCode) { + case 13: + if (event.shiftKey) { + kill($(".select").attr('name'), $(".select").children(".path").html().replace(/\\/g, '/')) + } else { + kill($(".select").attr('name')); + } + break; + case 38: + let pre = $(".select").prev(); + if(pre.length != 0){ + event.preventDefault(); + if(pre.offset().top < $(window).scrollTop()){ + $("html").animate({ scrollTop: "-=50" }, 0); + } + pre.addClass("select"); + $(".select:last").removeClass("select"); + }else{ + $(".select").animate({"opacity":"0.3"}).delay(500).animate({"opacity":"1"}) + } + break; + case 40: + let next = $(".select").next(); + if(next.length !=0){ + event.preventDefault(); + if(next.offset().top >= $(window).scrollTop() + 500){ + $("html").animate({ scrollTop: "+=50" }, 0); + } + next.addClass("select"); + $(".select:first").removeClass("select"); + }else{ + $(".select").animate({"opacity":"0.3"}).delay(500).animate({"opacity":"1"}) + } + break; + } +}); \ No newline at end of file diff --git a/assets/style.css b/assets/style.css index b5a35cf..cc1cae4 100644 --- a/assets/style.css +++ b/assets/style.css @@ -12,9 +12,8 @@ height: 50px; } -.taskinfo:hover { +.select{ background: #ebebeb; - transition: 0.5s; } .description { diff --git a/index.html b/index.html index 27dbd19..f4be667 100644 --- a/index.html +++ b/index.html @@ -13,60 +13,7 @@
- + \ No newline at end of file