From dfb3a9fd8e8da99bfc819b02217fa8b33e68cae9 Mon Sep 17 00:00:00 2001 From: DeepFal <41166795+DeepFal@users.noreply.github.com> Date: Tue, 13 Oct 2026 21:24:48 +0800 Subject: [PATCH] =?UTF-8?q?build:=20make=20install-app=20=E6=9E=84?= =?UTF-8?q?=E5=BB=BA=E5=B9=B6=E6=9B=BF=E6=8D=A2=20/Applications=20?= =?UTF-8?q?=E4=B8=AD=E7=9A=84=20App?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 正在运行的 App 会先正常退出(同时停止后台引擎),装好后按原状态重新打开。 --- Makefile | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 55a9663..2ca4f3d 100644 --- a/Makefile +++ b/Makefile @@ -3,6 +3,7 @@ # make server 交叉编译 Linux 服务端到 dist/ # make agent 编译当前平台的 Agent 到 bin/ # make app 构建 macOS 应用 PortRelay.app(需要 Xcode 命令行工具) +# make install-app 构建并替换 /Applications/PortRelay.app(正在运行的会先退出,装好后重新打开) # make release 打包所有平台的服务端 / Agent 到 dist/ # make snapshots 离屏渲染 App 界面截图(tools/ui-snapshots/out) @@ -12,7 +13,7 @@ GOBUILD := CGO_ENABLED=0 go build -trimpath -ldflags "$(LDFLAGS)" PLATFORMS := linux/amd64 linux/arm64 darwin/arm64 darwin/amd64 windows/amd64 -.PHONY: all test fmt server agent app release snapshots clean +.PHONY: all test fmt server agent app install-app release snapshots clean all: test agent @@ -34,6 +35,18 @@ agent: app: VERSION=$(VERSION) ./build-app.sh +# 正常退出正在运行的 App(会一并停止后台引擎)后替换,装好后按原状态重新打开 +install-app: app + @running=; \ + if pgrep -f /Applications/PortRelay.app/ >/dev/null; then \ + running=1; osascript -e 'quit app "PortRelay"' >/dev/null; \ + for i in $$(seq 1 30); do pgrep -f /Applications/PortRelay.app/ >/dev/null || break; sleep 0.5; done; \ + if pgrep -f /Applications/PortRelay.app/ >/dev/null; then echo "PortRelay 未能退出,已放弃替换"; exit 1; fi; \ + fi; \ + rm -rf /Applications/PortRelay.app && ditto PortRelay.app /Applications/PortRelay.app && rm -rf PortRelay.app; \ + echo "✓ 已安装 /Applications/PortRelay.app ($(VERSION))"; \ + if [ -n "$$running" ]; then open /Applications/PortRelay.app; fi + release: @rm -rf dist && mkdir -p dist @for p in $(PLATFORMS); do \