Skip to content

Close button hides the app instead of minimizing#21

Merged
TN019 merged 1 commit into
mainfrom
hide-on-close
Jul 25, 2026
Merged

Close button hides the app instead of minimizing#21
TN019 merged 1 commit into
mainfrom
hide-on-close

Conversation

@TN019

@TN019 TN019 commented Jul 25, 2026

Copy link
Copy Markdown
Owner

背景

#18 把关窗改成了最小化到 Dock,任务不再被误杀,但留下两个观感问题:Dock 里挂着一个最小化的窗口缩略图;且部分场景下用户预期的是"窗口消失、点 Dock 图标回来"的标准 mac 行为。另外品牌化 viewer 有一个图标问题:真实客户端的 Info.plist 带 CFBundleIconName,macOS 会优先从编译的 Assets.car 取 Flet 原版图标,导致换上的 icns 不生效。

改动与实现

  • 关窗 = 隐藏整个 app(core/viewer.py 新增 hide_viewer_app()):通过 NSRunningApplication 对 app 做 ⌘H 式隐藏——窗口消失、无缩略图、Dock 图标保留,点 Dock 由 macOS 自动 unhide,任务全程照跑。按品牌化/原版两个 bundle id 枚举所有实例逐一隐藏(开发重启后可能有残留副本,只挑第一个可能选错);不可用(非 macOS、找不到 viewer、AppKit 异常)一律返回 False,GUI 回退到原来的最小化
  • 图标修复:rebrand 时删除 CFBundleIconName,让 CFBundleIconFile 指向的 icns 生效;BRAND_REVISION = 2 进缓存目录名,强制已有副本重建并绕开 macOS 图标缓存
  • 依赖flet[desktop] 显式声明——裸 flet 时 flet-desktop 不进锁文件,严格 uv sync 会把 viewer 当孤儿卸掉;新增 macOS 限定的 pyobjc-framework-cocoa

验证

  • uv run pytest -q:144 passed / 6 skipped,新增图标键处理断言与 hide_viewer_app 安全降级测试(不存在的 bundle id → False,不抛异常)
  • 待人工确认:关窗后无缩略图、Dock 图标点击恢复、转录中关窗任务不中断、重建后 Dock 图标为 Scripto 而非 Flet

…humbnail lingers, the Dock icon brings it back, and jobs keep running.
@TN019
TN019 merged commit 70c6676 into main Jul 25, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant