fix(ui): Phase 7 C5 — 移除假按钮 + 真实托盘图标
用户报告设置页很多按钮无反应 + 关闭后托盘看不到图标。两处问题:\n\n1. ServerCard 占位按钮无回调:\n- server-card.slint:去掉了 toggled/edit-clicked/remove-clicked 三个回调以及 enabled 切换、Edit / Remove 按钮;变成纯展示卡(状态点 + name + url + 当前标记)\n- settings-page.slint:去掉硬编码的 Home / NAS 占位,改用 active-server-name / active-server-url / active-server-enabled 三个属性(MainWindow → AppConfig 实时填充);空时显示 '(未配置服务器)' 空态提示\n- app.slint:MainWindow 加三个属性 + 转发给 SettingsPage\n- lib.rs:startup 阶段把活跃服务器信息塞进 UI;测试连接成功/失败时更新 enabled 状态\n\n2. 托盘图标看不见:\n- tray.rs:原本 hIcon 写 null,Win10+ 上 Shell_NotifyIconW(NIM_ADD, NULL hIcon) 实际渲染为空白或很弱的小方块。改用 LoadIconW(NULL, IDI_APPLICATION) 加载 Windows 自带的应用程序图标(无需嵌入 .ico 资源,主题感知)。show_toast / Drop 的 hIcon 维持 null(让 NIM_MODIFY/NIM_DELETE 不动原有图标)。AGENTS.md §53 标记真 .ico 资源为 V2 项。
This commit is contained in:
+39
@@ -356,6 +356,37 @@ pub fn run() -> error::AppResult<()> {
|
||||
ui.set_status_text(status_text.into());
|
||||
ui.set_is_connected(is_connected);
|
||||
|
||||
// Phase 7 C5: forward active-server summary to SettingsPage.
|
||||
// V1 only has the single active server (AGENTS.md §21), so we
|
||||
// surface exactly that. Empty values trigger the "未配置服务器"
|
||||
// empty-state in SettingsPage. Display name falls back to the
|
||||
// URL host (e.g. "gotify.example.com" or "192.168.50.103:8418")
|
||||
// since `ServerConfig` only carries base_url + token — the human-
|
||||
// friendly `name` lives on `ServerEntry`, which V1 doesn't expose
|
||||
// through `ActiveConfig`. That's fine for V1.
|
||||
match cfg.server.as_ref() {
|
||||
Some(server) => {
|
||||
let display_name = url::Url::parse(&server.base_url)
|
||||
.ok()
|
||||
.and_then(|u| u.host_str().map(|s| {
|
||||
if let Some(port) = u.port() {
|
||||
format!("{s}:{port}")
|
||||
} else {
|
||||
s.to_string()
|
||||
}
|
||||
}))
|
||||
.unwrap_or_else(|| server.base_url.clone());
|
||||
ui.set_active_server_name(display_name.into());
|
||||
ui.set_active_server_url(server.base_url.as_str().into());
|
||||
ui.set_active_server_enabled(is_connected);
|
||||
}
|
||||
None => {
|
||||
ui.set_active_server_name("(未配置服务器)".into());
|
||||
ui.set_active_server_url("".into());
|
||||
ui.set_active_server_enabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
// ── Phase 4 C2 + 5 C2 + 7 C1/C2 + 7 C4: WebSocket worker + UI-thread
|
||||
// drain. The drain closure now writes to BOTH the canonical
|
||||
// shared_model AND the filtered_model (honoring the active
|
||||
@@ -584,6 +615,10 @@ pub fn run() -> error::AppResult<()> {
|
||||
if let Some(ui) = ui_handle.upgrade() {
|
||||
ui.set_status_text(text.into());
|
||||
ui.set_is_connected(true);
|
||||
// Phase 7 C5: refresh the active-server
|
||||
// summary so the Settings card lights up
|
||||
// green after a successful test.
|
||||
ui.set_active_server_enabled(true);
|
||||
}
|
||||
tracing::info!(msgs = msgs.len(), "Test Connection: ok");
|
||||
}
|
||||
@@ -593,6 +628,10 @@ pub fn run() -> error::AppResult<()> {
|
||||
format!("未连接 · 模拟数据 · {}", server.base_url).into(),
|
||||
);
|
||||
ui.set_is_connected(false);
|
||||
// Phase 7 C5: failed test → server card
|
||||
// dot returns to "configured but not
|
||||
// connected" (gray).
|
||||
ui.set_active_server_enabled(false);
|
||||
}
|
||||
tracing::warn!("Test Connection: failed");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user