Files
arcrun-collector/cmd/arcrun-app/build-mac.sh
T
Leo 549834f343 t194:托盤收成 Google Drive 式(點 icon 開視窗/右鍵只有結束)+同綑 collector
leo 2026-08-05:「依照 google drive,托盤裡只剩下按右鍵會結束,
其他設定都在這個頁面,點擊托盤的 icon 就立刻展開界面」

## 托盤
Wails v2 沒有內建托盤 ⇒ 用 energye/systray(Wails 相容分支,支援左鍵事件)。
- 左鍵:直接展開主視窗,**不彈選單**
- 右鍵:只有一項「結束 Arcrun」
- 設定全部留在視窗裡,托盤不再是第二套 UI
  (fyne 版把設定塞下拉選單,leo 早說過「不可能統統塞在下拉選單」)
- 關窗=隱藏不結束(daemon 常駐;按 × 就停止同步不符預期)
- Dock 不出現 icon:Wails v2.13 的 mac.ActivationPolicy 還沒開放(原始碼是註解掉的)
  ⇒ 改走 Info.plist 的 LSUIElement,與 fyne 版同一個做法

## 🔴 順手抓到自己的大漏:這個 App 根本沒有啟動 collector
daemon 的**本體**是 `collector direct`(監看/萃卡/上傳),Wails 版我一路沒接
⇒ 照這樣出貨會是「裝了也不會同步」的空殼。
修:新增 supervise.go,**複用既有 supervisor 套件**(重起退避/狀態機/
    t191 的 phase:start/done ⇒「同步中…」),不複製一份(複製=會漂移)。
    go.mod 用 replace 指回 collector 主模組。
    加/刪資料夾、改 AI 設定後都會 restartWatch(),設定立刻生效。

## 打包
新增 build-mac.sh:編 collector → wails build → **同綑進 .app** → ad-hoc 重簽。
沒同綑就等於沒有 daemon。

實測(v0.18.0):collector 同綑 15M /LSUIElement=true /版本注入 /已簽 
兩支機械閘全過。
⚠️ 未驗:托盤左右鍵的實際行為要真機點(我開不了視窗)。
2026-08-05 00:31:52 +08:00

32 lines
1.3 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
# build-mac.sh — 打包 Arcrun.appWails 版,t194
#
# 與 fyne 版最重要的差別:**要把 collector 同綑進 .app**。
# daemon 的本體是 `collector direct`(監看/萃卡/上傳),App 只是它的門面;
# 沒同綑 ⇒ 裝了也不會同步。
set -euo pipefail
cd "$(dirname "$0")"
VERSION="${VERSION:-$(git describe --tags --always --dirty 2>/dev/null || echo dev)}"
export PATH="$PATH:$(go env GOPATH)/bin"
echo "🏷 版本:${VERSION}"
echo "① 編 collector(同綑執行檔,純 stdlib、CGO_ENABLED=0"
( cd ../.. && CGO_ENABLED=0 go build -ldflags "-s -w" -o "cmd/arcrun-app/arcrun-collector" . )
echo "② wails build"
wails build -clean -ldflags "-X main.version=${VERSION}"
APP="build/bin/Arcrun.app"
[ -d "build/bin/arcrun-app.app" ] && { rm -rf "$APP"; mv "build/bin/arcrun-app.app" "$APP"; }
echo "③ 同綑 collector 進 .appApp 用 os.Executable() 找同層)"
cp arcrun-collector "$APP/Contents/MacOS/arcrun-collector"
echo "④ ad-hoc 重簽(改過 bundle 內容必重簽,否則 launchd 拒開)"
codesign --force --deep --sign - "$APP" 2>/dev/null || true
rm -f arcrun-collector
echo "✅ 完成:$APP"
echo " 驗法:open '$APP' → 選單列出現 icon、Dock **不出現** icon"
echo " 點 icon → 立刻展開視窗;右鍵 → 只有「結束 Arcrun」"