feat(daemon-beta t7/t8): Dock 隱藏真機驗證通過(lsappinfo type=UIElement)——runtime Accessory policy(cgo)+appID+ad-hoc 重簽;mistakes 記四枚真機坑;暫用 icon(等 leo logo)

This commit is contained in:
2026-07-24 12:56:40 +08:00
parent 5017d0381e
commit 387ce3d1a4
5 changed files with 37 additions and 1 deletions
+4 -1
View File
@@ -14,7 +14,7 @@ echo "① 編 collector(同綑執行檔)"
( cd ../.. && go build -o "cmd/arcrun-tray/arcrun-collector" . )
echo "② fyne package"
go run fyne.io/fyne/v2/cmd/fyne@latest package -os darwin -icon icon.png -name "Arcrun RAG"
go run fyne.io/fyne/v2/cmd/fyne@latest package -os darwin -icon icon.png -name "Arcrun RAG" -appID dev.arcrun.rag.tray
APP="Arcrun RAG.app"
PLIST="$APP/Contents/Info.plist"
@@ -26,5 +26,8 @@ echo "③ LSUIElement=true(托盤唯一指示器,隱 Dock icon——leo 07-2
echo "④ 同綑 collector 進 app bundle(托盤 collectorBinPath 找同層)"
cp arcrun-collector "$APP/Contents/MacOS/arcrun-collector"
echo "⑤ ad-hoc 重簽(Apple Silicon:改過 plist/塞過檔必重簽,否則 launchd 拒開 error 162——07-24 真機實撞)"
codesign --force --deep -s - "$APP"
echo "✅ 完成:$APP"
echo "驗法:open '$APP' → 選單列出現 icon、Dock **不出現** icon → 選單列出資料夾清單"
+24
View File
@@ -0,0 +1,24 @@
//go:build darwin
// dock_darwin.go — 托盤唯一指示器(leo 07-24 裁決)的 macOS 實作。
//
// 真機實測(07-24 第三枚坑):Info.plist 的 LSUIElement=true 會被 fyne/glfw 啟動時
// 強制的 Regular activation policy 蓋掉(lsappinfo 實測 ApplicationType=Foreground),
// Dock icon 照樣出現。唯一可靠解=app 起來後 runtime 直接把 policy 切成 Accessory。
package main
/*
#cgo CFLAGS: -x objective-c
#cgo LDFLAGS: -framework AppKit
#import <AppKit/AppKit.h>
static void arcrunHideDock(void) {
dispatch_async(dispatch_get_main_queue(), ^{
[NSApp setActivationPolicy:NSApplicationActivationPolicyAccessory];
});
}
*/
import "C"
// hideDockIcon 把 app 切成 Accessory(選單列有、Dock 無)。須在 NSApp 初始化後呼叫
// (掛在 fyne Lifecycle SetOnStarted)。
func hideDockIcon() { C.arcrunHideDock() }
+6
View File
@@ -0,0 +1,6 @@
//go:build !darwin
package main
// hideDockIcon 在非 macOS 平台是 no-opWindows 系統匣本來就不佔工作列)。
func hideDockIcon() {}
Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

+3
View File
@@ -256,6 +256,9 @@ func main() {
desk.SetSystemTrayIcon(theme.StorageIcon()) // TODO 換品牌 iconleo logo 進行中);Mac 建議 template 單色
}
rebuildTray() // 開機即建初始選單(否則第一次狀態回呼前選單是空的)
// 托盤唯一指示器(leo 07-24 裁決):NSApp 起來後把 activation policy 切 Accessory
//plist LSUIElement 會被 fyne/glfw 蓋掉——07-24 真機實測第三枚坑,見 dock_darwin.go
a.Lifecycle().SetOnStarted(func() { hideDockIcon() })
refreshTray := rebuildTray
// 狀態變更 → 刷新 tray 文案(回呼在 supervisor goroutine,切回 UI thread