feat(desktop): add optional Electron desktop shell for Windows - #224
Open
mochen555 wants to merge 6 commits into
Open
feat(desktop): add optional Electron desktop shell for Windows#224mochen555 wants to merge 6 commits into
mochen555 wants to merge 6 commits into
Conversation
包一层独立窗口壳,复用现有 Python 后端与已挂载的前端, 替代默认的"启动后跳转系统浏览器"体验。main.js 负责拉起后端、 健康检查(/api/health)、按优先级定位后端地址,并加载 /chat/。 导入国内镜像配置加速 Electron 二进制下载。
开发态下 Electron 壳自动探测 backend/.venv 下的 python 解释器并拉起 desktop_launcher.py,不再依赖 STAFFDECK_URL 或手动先起后端;打包态回退 到 PATH 中的 staffdeck。spawn 参数顺序修正(脚本在前、--host 在后)。 已验证端到端链路:Electron 拉起后端 → 占 5173 → /api/health 命中 → (spawned=true) 加载 /chat/ 200 OK。
desktop_launcher.py 非 headless 时会在服务就绪后自动 _open_browser_when_ready 打开系统浏览器,导致 Electron 窗口之外又多开一个 tab。由 Electron 窗口负责 UI 展示,故拉起后端时注入 STAFFDECK_HEADLESS=1。 已验证日志输出 headless 启动中,/chat/ 由 Electron 窗口单独加载。
打包态下 Electron 壳从 process.resourcesPath/backend 拉起 PyInstaller 产出 的 staffdeck.exe(自带 Python 运行时),实现装完即用。已验证打包版 frozen=True 独立运行。 配套 electron-builder.yml 通过 extraResources 把 packaging/out/staffdeck 打进安装包。
代码已含上游 v0.5.0(main 比 v0.5.0 还新),壳元数据版本号此前随手填的 0.4.0,与代码版本脱节。改为 0.5.0 使安装包文件名/版本信息与后端一致。
桌面化第一步:关窗最小化到托盘(应用常驻后台,数字员工服务不中断)。 - 关闭按钮隐藏窗口而非退出,并弹系统气球提示后台运行 - 托盘图标 + 右键菜单:打开 / 服务端口 / 重启服务 / 退出 - 单击托盘图标切换窗口显示/隐藏;真正退出仅经托盘"退出"或关机 - electron-builder extraResources 带入托盘图标
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an optional, self-contained Electron desktop shell (
desktop/) forStaffDeck on Windows. It reuses the existing PyInstaller-packed backend
(
packaging/out/staffdeck) and loads the already-served web UI into a nativewindow instead of the system browser.
Additive & opt-in: existing backend/frontend/official pipeline untouched.
Features
backend/.venv, packaged:resources/backend/staffdeck.exe)/chat/click-to-toggle window
electron-builderbundles backend + tray iconPackaging: problems encountered & how they were solved
Added CN mirrors in
desktop/.npmrcand env vars (ELECTRON_MIRROR,ELECTRON_BUILDER_BINARIES_MIRROR) to speed up downloads.winCodeSignsymlink permission error on WindowsThe bundled
winCodeSignarchive contains macOS.dylibsymlinks; extractingthem fails with "client does not possess the required privilege" unless
Windows Developer Mode is enabled. Workaround: enable Developer Mode, or
run as admin. This is a known electron-builder quirk on non-admin Windows.
electron-builder.ymlextraResources.frompoints atpackaging/out/staffdeck,so run the official backend build first (
build_windows.ps1/ theultrarag.speccommand) — otherwise the installer has no backend to bundle.
desktop_launcher.pyauto-opens the browser unlessSTAFFDECK_HEADLESS=1;the shell sets this env var when spawning the backend.
Build & run