mirror of
https://github.com/fofolee/uTools-ProcessKiller.git
synced 2025-06-28 20:42:46 +08:00
方向键进行列表选择
This commit is contained in:
parent
cd5d98cd08
commit
c3be7426ab
93
assets/index.js
Normal file
93
assets/index.js
Normal file
@ -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 += '<div class="taskinfo" name="' + t.ProcessName + '">';
|
||||||
|
taskinfo += '<img src="file:///' + t.Icon + '">';
|
||||||
|
taskinfo += '<div class="description">' + title + '</div><div class="path">' + t.Path + '</div></div>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$("#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;
|
||||||
|
}
|
||||||
|
});
|
@ -12,9 +12,8 @@
|
|||||||
height: 50px;
|
height: 50px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.taskinfo:hover {
|
.select{
|
||||||
background: #ebebeb;
|
background: #ebebeb;
|
||||||
transition: 0.5s;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.description {
|
.description {
|
||||||
|
55
index.html
55
index.html
@ -13,60 +13,7 @@
|
|||||||
<body>
|
<body>
|
||||||
<div id="tasklist"></div>
|
<div id="tasklist"></div>
|
||||||
<div id="infopannel"></div>
|
<div id="infopannel"></div>
|
||||||
<script>
|
<script src="assets/index.js"></script>
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
utools.onPluginEnter(({ code, type, payload }) => {
|
|
||||||
utools.setExpendHeight(0);
|
|
||||||
window.tasklist((task) => {
|
|
||||||
window.tasks = task
|
|
||||||
utools.setSubInput(({ 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 += '<div class="taskinfo" name="' + t.ProcessName + '">';
|
|
||||||
taskinfo += '<img src="file:///' + t.Icon + '">';
|
|
||||||
taskinfo += '<div class="description">' + title + '</div><div class="path">' + t.Path + '</div></div>';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$("#tasklist").html(taskinfo);
|
|
||||||
let tasknum = $(".taskinfo").length
|
|
||||||
utools.setExpendHeight(tasknum > 10 ? 500 : 50 * tasknum);
|
|
||||||
}, '输入进程名,回车关闭,或点击关闭');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
$("#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 => {
|
|
||||||
if (e.keyCode === 13) {
|
|
||||||
kill($(".taskinfo").attr('name'));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
Loading…
x
Reference in New Issue
Block a user