feat(linux): 支持 Linux / Wayland 桌面运行

- 新增 src/main/platform.ts:Ozone 后端选择(Wayland 优先 XWayland)、
  能力降级封装、XDG 数据目录、缺参 relaunch
- 主进程窗口定位/置顶/跨工作区/拖拽/视线跟随改为平台能力封装
- 托盘失败容错、Linux 窗口图标、pet:// 缺失文件返回 404
- 新增 scripts/linux/{install,run,uninstall}.sh 与启动器、desktop 菜单项、自启动
- 新增 assets/linux 应用图标;README 增加 Linux/Wayland 文档
- 清理仓库根目录误提交的 Chromium 日志文件
This commit is contained in:
2026-12-02 05:13:49 +09:00
parent 4f1d8d5bf9
commit 9313704918
56 changed files with 685 additions and 80 deletions
+34
View File
@@ -0,0 +1,34 @@
#!/usr/bin/env bash
# 开发模式在 Linux 上运行(不安装,直接用仓库里的 out/ + electron)
# scripts/linux/run.sh [electron 参数...]
set -euo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
cd "$ROOT"
ELECTRON="node_modules/electron/dist/electron"
if [ ! -x "$ELECTRON" ]; then
echo "[run] 先安装依赖…"
npm install --no-audit --no-fund
if [ ! -x "$ELECTRON" ]; then
ELECTRON_MIRROR="${ELECTRON_MIRROR:-https://npmmirror.com/mirrors/electron/}" \
node node_modules/electron/install.js
fi
fi
[ -f out/main/index.js ] || npm run build
ozone="${SODIUM_PET_OZONE:-auto}"
if [ "$ozone" = "auto" ]; then
if [ -n "${WAYLAND_DISPLAY:-}" ] || [ "${XDG_SESSION_TYPE:-}" = "wayland" ]; then
if [ -n "${DISPLAY:-}" ]; then ozone="x11"; else ozone="wayland"; fi
else
ozone="x11"
fi
fi
if [ "$ozone" = "x11" ] && [ -z "${DISPLAY:-}" ]; then
echo "[run] 没有 DISPLAY,改用原生 Wayland(窗口位置/置顶会受限)" >&2
ozone="wayland"
fi
echo "[run] backend=$ozone"
exec "$ELECTRON" --ozone-platform="$ozone" . "$@"