Files
lmvpn_client/internal/paths/paths_darwin.go
T
kevin 96b1a8839c
Release / build-macos (push) Canceled after 0s
Release / build-windows (push) Canceled after 0s
Release / release (push) Canceled after 0s
feat: 单实例锁与窗口恢复机制
- GUI 单实例锁: 新增 internal/instance 包,首实例监听专用端点,
  第二实例发送 focus 信号后静默退出 (Unix: gui.sock, Win: 18924)
- 守护进程弱锁修复: NewServer() 在 os.Remove 前先 net.Dial 探测,
  有活进程时拒绝启动,避免静默抢占 socket 导致孤儿进程
- macOS .app 重开恢复: 通过 class_addMethod 给 GLFWApplicationDelegate
  注册 applicationShouldHandleReopen:hasVisibleWindows: 回调,
  绕过 GLFW 直接用 Cocoa makeKeyAndOrderFront: 显示窗口
- 三平台覆盖: macOS/Linux 用 unix socket, Windows 用 TCP 端口
2026-07-09 00:29:21 +08:00

41 lines
1.1 KiB
Go

//go:build darwin
package paths
import (
"os"
"path/filepath"
)
// IPCNetwork returns the transport network for GUI <-> daemon IPC.
func IPCNetwork() string { return "unix" }
// IPCAddress returns the listen/dial address for GUI <-> daemon IPC.
func IPCAddress() string { return "/tmp/lmvpn.sock" }
// GUILockNetwork returns the transport for the GUI single-instance lock.
func GUILockNetwork() string { return "unix" }
// GUILockAddress returns the address for the GUI single-instance lock.
func GUILockAddress() string { return Paths.Data + "/gui.sock" }
func init() {
home, _ := os.UserHomeDir()
recomputePaths(home)
}
// recomputePaths sets Paths based on the given home directory.
// On macOS the layout is:
//
// <home>/Library/Application Support/<BundleID>/ data
// <home>/Library/Caches/<BundleID>/ cache
// <home>/Library/Logs/<BundleID>/ logs
func recomputePaths(home string) {
lib := filepath.Join(home, "Library")
Paths = Dirs{
Data: filepath.Join(lib, "Application Support", BundleID),
Cache: filepath.Join(lib, "Caches", BundleID),
Log: filepath.Join(lib, "Logs", BundleID),
}
}