Files
KennethCheng a091e6839a 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 项。
2026-09-19 20:40:33 +08:00

77 lines
2.6 KiB
Plaintext

// AGENTS.md §21 multi-server card.
//
// Phase 7 C5: V1 只支持单 active server,§21 描述的多 server UI(添加/
// 编辑/删除/启用/禁用)还没实现。原来的 ServerCard 有 enabled 切换
// + Edit / Remove 按钮,但 settings-page.slint 只是占位填写硬编码
// 的 "Home" / "NAS",回调也没接 —— 用户看到的 "点不动" 按钮是纯 UI
// 壳子,对应 "很多都没反应" 的反馈。
//
// 修法:把 ServerCard 简化成纯展示卡(name + url + 状态点),由
// settings-page.slint 从 AppConfig.active_server 实时填进去。无服务
// 器时整个 section 走空态。等 V2 真做多 server UI 再加回 toggle /
// Edit / Remove / Add。
export component ServerCard inherits Rectangle {
in property <string> server-name: "(未配置服务器)";
in property <string> server-url: "";
in property <bool> enabled: true;
in property <bool> is-current: false;
in property <color> bg-color: #28292d;
in property <color> card-border: #3a3b40;
in property <color> text-primary-color: #e6e6e6;
in property <color> text-secondary-color: #a0a0a0;
in property <color> accent-color: #4ea1ff;
in property <color> success-color: #4caf50;
width: 100%;
height: 64px;
border-radius: 8px;
background: bg-color;
border-color: card-border;
border-width: 1px;
HorizontalLayout {
padding-top: 12px;
padding-bottom: 12px;
padding-left: 16px;
padding-right: 16px;
spacing: 12px;
alignment: center;
// 状态点:已连接 → 绿,配置但未连 → 蓝,未配置 → 灰。
Rectangle {
width: 10px;
height: 10px;
border-radius: 5px;
background: enabled ? success-color : text-secondary-color;
y: parent.height / 2 - self.height / 2;
}
VerticalLayout {
horizontal-stretch: 1;
spacing: 2px;
HorizontalLayout {
spacing: 8px;
Text {
text: server-name;
color: text-primary-color;
font-size: 13px;
font-weight: 600;
}
if is-current: Text {
text: "• 当前";
color: accent-color;
font-size: 11px;
}
}
Text {
text: server-url != "" ? server-url : "(暂无 URL — 在 Settings → Connection 里填)";
color: text-secondary-color;
font-size: 11px;
overflow: elide;
}
}
}
}