This commit is contained in:
Mr Chen 2024-06-05 11:58:07 +08:00
parent 0082bcd159
commit 207cef200f
2 changed files with 66 additions and 44 deletions

View File

@ -116,67 +116,66 @@ $('.layui-layer').not($('.setting_ul_li')).click(function () {
});
var isProcessing = false; // 设置标志
$('.setting_ul_li').off('click').click(function (e) {
var that = $(this)
$('.setting_ul_li').off('click').click(function (e) {
var that = $(this);
e.stopPropagation()
// 检查标志
if (isProcessing) {
return;
return;
}
if (!$(this).hasClass('disabled')) {
isProcessing = true; // 点击事件被触发,设置标志
var name = $(this).attr("name")
clearInterval(process_list_s);
bt_tools.send({
url: 'plugin?action=a&name=task_manager&s=set_meter_head',
data: {meter_head_name: name}
}, function (data) {
isProcessing = false; // 操作完成,清除标志
if (!data) {
layer.msg('设置失败');
}
that.toggleClass('active')
get_process_list(null, null, false);
isProcessing = true; // 点击事件被触发,设置标志
var name = $(this).attr("name");
clearInterval(process_list_s);
process_list_s = setInterval(function () {
if ($(".t-mana").length == 0) {
clearInterval(process_list_s);
process_list_s = 0;
console.log('进程列表轮询任务已停止');
}
get_process_list(null, null, true);
}, 3000);
})
}
})
$('.setting_btn').on('click',function (e) {
e.stopPropagation()
tmPostCallback('set_meter_head',{meter_head_name: name}, function(data){
console.log(data);
isProcessing = false; // 操作完成,清除标志
if (!data) {
layer.msg('设置失败');
}
that.toggleClass('active');
get_process_list(null, null, false);
clearInterval(process_list_s);
process_list_s = setInterval(function () {
if ($(".t-mana").length == 0) {
clearInterval(process_list_s);
process_list_s = 0;
console.log('进程列表轮询任务已停止');
}
get_process_list(null, null, true);
}, 3000);
});
}
});
$('.setting_btn').on('click',function (e) {
e.stopPropagation();
var offset = $('.man-menu-sub').offset();
var x = e.pageX - offset.left;
var y = e.pageY - offset.top;
var width = $('.man-menu-sub').outerWidth();
if ($('.man-menu-sub').width() - x < width) {
$(".plug_menu").css({
position: 'absolute',
right: "14.5px",
top:"40px",
}).toggle();
$('.setting_ul').addClass('undisplay')
$(".plug_menu").css({
position: 'absolute',
right: "14.5px",
top:"40px",
}).toggle();
$('.setting_ul').addClass('undisplay')
}
$(".setting_ul").toggle();
})
});
if (process_list_s === 0) {
if (process_list_s === 0) {
process_list_s = setInterval(function () {
if ($(".t-mana").length == 0) {
clearInterval(process_list_s);
process_list_s = 0;
console.log('进程列表轮询任务已停止')
}
get_process_list(null, null, true);
if ($(".t-mana").length == 0) {
clearInterval(process_list_s);
process_list_s = 0;
console.log('进程列表轮询任务已停止')
}
get_process_list(null, null, true);
}, 3000);
}
}
function get_list_bytab(isblur) {
if (isblur && $('.search-bar .search_input').val() === search_val) {

View File

@ -483,6 +483,24 @@ class mainClass(object):
data['15'] = round(float(c[2]), 3) # float(c[2])
return data
def set_meter_head(self, get):
if not 'meter_head_name' in get:
return False
meter_head_name = get['meter_head_name']
meter_head_file = getServerDir()+'/meter_head.json'
try:
self.get_meter_head()
if meter_head_name not in self.meter_head.keys():
return False
if meter_head_name in ['ps', 'memory_used', 'cpu_percent', 'name']:
return False
self.meter_head[meter_head_name] = not self.meter_head[meter_head_name]
mw.writeFile(meter_head_file, json.dumps(self.meter_head))
return True
except:
return False
def get_meter_head(self, get=None):
meter_head_file = getServerDir()+'/meter_head.json'
if os.path.exists(meter_head_file):
@ -675,6 +693,8 @@ class mainClass(object):
pass
return mw.returnData(True, '已结束此进程树!')
def get_process_list(self, args = {}):
# https://hellowac.github.io/psutil-doc-zh/processes/process_class/oneshot.html
if self.is_mac:
@ -1591,6 +1611,9 @@ def kill_process_all(args = {}):
return mw.returnData(False, '缺少参数!')
return mc_instance.kill_process_all(int(args['pid']))
def set_meter_head(args = {}):
return mc_instance.set_meter_head(args)
def remove_service(args = {}):
return mc_instance.remove_service(args)