feat: 资源监控对话框(CPU/内存/线程/每连接预算)
- 头部:logo + 运行时长 + 自动刷新开关(默认 1.5s)+ 立即刷新按钮 - 2×2 指标卡:CPU 占用、工作集内存(对比峰值进度条)、提交内存、 线程·句柄;每卡带图标与说明副文本 - 消息与连接:总数汇总 + 每连接卡片(状态、消息数、32MB 预算 占用进度条) - 入口:more-menu「资源监控」与全局快捷键 Ctrl+Shift+R;刷新循环 持弱引用,对话框关闭即停止 - MQTTX_OPEN_RESMON=1 启动直开(自动化 UI 验证后门)
This commit is contained in:
+24
-1
@@ -40,7 +40,7 @@ use crate::ui::{
|
||||
const MAX_LOGS: usize = 3000;
|
||||
|
||||
// 应用级快捷键动作(context=None:任意焦点状态下都匹配)。
|
||||
gpui_kit::actions!(mqttx, [NewConnection, OpenSettings, ExportConnections, ImportConnections]);
|
||||
gpui_kit::actions!(mqttx, [NewConnection, OpenSettings, ExportConnections, ImportConnections, OpenResourceMonitor]);
|
||||
|
||||
/// 侧边栏分组过滤;chips 只做列表过滤,分组重命名/删除通过编辑连接的分组字段完成。
|
||||
#[derive(Clone, PartialEq, Eq)]
|
||||
@@ -267,6 +267,7 @@ impl MqttXApp {
|
||||
KeyBinding::new("ctrl-,", OpenSettings, None),
|
||||
KeyBinding::new("ctrl-shift-e", ExportConnections, None),
|
||||
KeyBinding::new("ctrl-shift-i", ImportConnections, None),
|
||||
KeyBinding::new("ctrl-shift-r", OpenResourceMonitor, None),
|
||||
]);
|
||||
let weak = cx.entity().downgrade();
|
||||
// Context 上有同名 on_action(绘制期注册),这里必须走 App 的全局注册
|
||||
@@ -290,6 +291,16 @@ impl MqttXApp {
|
||||
});
|
||||
});
|
||||
let weak = cx.entity().downgrade();
|
||||
App::on_action::<OpenResourceMonitor>(cx, move |_, cx| {
|
||||
let w = weak.clone();
|
||||
run_on_active_window(cx, w, |entity, window, cx| {
|
||||
if window.has_active_dialog(cx) {
|
||||
return;
|
||||
}
|
||||
crate::ui::resource_dialog::open(entity, window, cx);
|
||||
});
|
||||
});
|
||||
let weak = cx.entity().downgrade();
|
||||
App::on_action::<ExportConnections>(cx, move |_, cx| {
|
||||
let w = weak.clone();
|
||||
run_on_active_window(cx, w, |entity, window, cx| {
|
||||
@@ -655,6 +666,11 @@ impl MqttXApp {
|
||||
}
|
||||
}
|
||||
|
||||
/// 打开的标签数(资源监控展示用)。
|
||||
pub fn open_tab_count(&self) -> usize {
|
||||
self.open_tabs.len()
|
||||
}
|
||||
|
||||
pub fn open_tab(&mut self, conn_id: &str, window: &mut Window, cx: &mut Context<Self>) {
|
||||
if !self.open_tabs.contains(&conn_id.to_string()) {
|
||||
self.open_tabs.push(conn_id.to_string());
|
||||
@@ -1136,6 +1152,13 @@ impl MqttXApp {
|
||||
}
|
||||
},
|
||||
))
|
||||
.item(PopupMenuItem::new("资源监控").on_click(
|
||||
move |_, window, cx| {
|
||||
if let Some(entity) = w6.upgrade() {
|
||||
crate::ui::resource_dialog::open(entity, window, cx);
|
||||
}
|
||||
},
|
||||
))
|
||||
.separator()
|
||||
.item(PopupMenuItem::new("导出连接").on_click(
|
||||
move |_, window, cx| {
|
||||
|
||||
Reference in New Issue
Block a user