refactor: 合并 macOS 桌面打包流程
将 macOS .app 打包直接并入 desktop-build-mac,减少重复的桌面构建入口。\n\n同时移除未实现或已废弃的 desktop-package-* 命令和独立打包脚本,降低维护成本。
This commit is contained in:
55
Makefile
55
Makefile
@@ -5,7 +5,7 @@
|
||||
test-mysql-up test-mysql-down test-mysql test-mysql-quick \
|
||||
frontend-build frontend-dev frontend-test frontend-test-watch frontend-test-coverage frontend-test-e2e frontend-lint frontend-clean \
|
||||
desktop-build desktop-build-mac desktop-build-win desktop-build-linux \
|
||||
desktop-dev desktop-test desktop-package-mac desktop-package-win desktop-package-linux desktop-clean \
|
||||
desktop-dev desktop-test desktop-clean \
|
||||
desktop-prepare-frontend desktop-prepare-embedfs
|
||||
|
||||
# ============================================
|
||||
@@ -172,6 +172,50 @@ desktop-build-mac: desktop-prepare-frontend desktop-prepare-embedfs
|
||||
@echo "🍎 Building macOS..."
|
||||
cd backend && CGO_ENABLED=1 GOOS=darwin GOARCH=arm64 go build -o ../build/nex-mac-arm64 ./cmd/desktop
|
||||
cd backend && CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 go build -o ../build/nex-mac-amd64 ./cmd/desktop
|
||||
@echo "📦 Packaging macOS .app..."
|
||||
mkdir -p build/Nex.app/Contents/MacOS build/Nex.app/Contents/Resources
|
||||
cp build/nex-mac-arm64 build/Nex.app/Contents/MacOS/nex
|
||||
@if [ -f assets/AppIcon.icns ]; then \
|
||||
cp assets/AppIcon.icns build/Nex.app/Contents/Resources/; \
|
||||
else \
|
||||
echo "⚠️ 未找到 assets/AppIcon.icns"; \
|
||||
fi
|
||||
@{ \
|
||||
printf '%s\n' '<?xml version="1.0" encoding="UTF-8"?>' \
|
||||
'<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">' \
|
||||
'<plist version="1.0">' \
|
||||
'<dict>' \
|
||||
' <key>CFBundleDevelopmentRegion</key>' \
|
||||
' <string>zh_CN</string>' \
|
||||
' <key>CFBundleExecutable</key>' \
|
||||
' <string>nex</string>' \
|
||||
' <key>CFBundleIconFile</key>' \
|
||||
' <string>AppIcon</string>' \
|
||||
' <key>CFBundleIdentifier</key>' \
|
||||
' <string>io.nex.gateway</string>' \
|
||||
' <key>CFBundleInfoDictionaryVersion</key>' \
|
||||
' <string>6.0</string>' \
|
||||
' <key>CFBundleName</key>' \
|
||||
' <string>Nex Gateway</string>' \
|
||||
' <key>CFBundleDisplayName</key>' \
|
||||
' <string>Nex Gateway</string>' \
|
||||
' <key>CFBundlePackageType</key>' \
|
||||
' <string>APPL</string>' \
|
||||
' <key>CFBundleShortVersionString</key>' \
|
||||
' <string>1.0.0</string>' \
|
||||
' <key>CFBundleVersion</key>' \
|
||||
' <string>1.0.0</string>' \
|
||||
' <key>LSMinimumSystemVersion</key>' \
|
||||
' <string>10.13</string>' \
|
||||
' <key>LSUIElement</key>' \
|
||||
' <true/>' \
|
||||
' <key>NSHighResolutionCapable</key>' \
|
||||
' <true/>' \
|
||||
'</dict>' \
|
||||
'</plist>'; \
|
||||
} > build/Nex.app/Contents/Info.plist
|
||||
chmod +x build/Nex.app/Contents/MacOS/nex
|
||||
@echo "✅ macOS app packaged: build/Nex.app"
|
||||
|
||||
desktop-build-win: desktop-prepare-frontend desktop-prepare-embedfs
|
||||
@echo "🪟 Building Windows..."
|
||||
@@ -188,15 +232,6 @@ desktop-dev: desktop-prepare-frontend desktop-prepare-embedfs
|
||||
desktop-test:
|
||||
cd backend && go test ./cmd/desktop/... -v
|
||||
|
||||
desktop-package-mac:
|
||||
./scripts/build/package-macos.sh
|
||||
|
||||
desktop-package-win:
|
||||
@echo "⚠️ Windows packaging not implemented yet"
|
||||
|
||||
desktop-package-linux:
|
||||
@echo "⚠️ Linux packaging not implemented yet"
|
||||
|
||||
desktop-clean:
|
||||
rm -rf build/ embedfs/assets embedfs/frontend-dist
|
||||
|
||||
|
||||
@@ -39,10 +39,6 @@ nex/
|
||||
│ ├── AppIcon.icns # macOS 应用图标
|
||||
│ └── icon.ico # Windows 应用图标
|
||||
│
|
||||
├── scripts/ # 构建脚本
|
||||
│ └── build/
|
||||
│ └── package-macos.sh # macOS .app 打包脚本
|
||||
│
|
||||
└── README.md # 本文件
|
||||
```
|
||||
|
||||
@@ -105,9 +101,8 @@ JSON: {"level":"info","logger":"handler.proxy","msg":"处理请求","method":
|
||||
**构建桌面应用**:
|
||||
|
||||
```bash
|
||||
# macOS (arm64 + amd64)
|
||||
# macOS (arm64 + amd64,并打包为 .app)
|
||||
make desktop-build-mac
|
||||
make desktop-package-mac # 打包为 .app
|
||||
|
||||
# Windows
|
||||
make desktop-build-win
|
||||
|
||||
@@ -1,68 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
VERSION="1.0.0"
|
||||
APP_NAME="Nex"
|
||||
BUNDLE_ID="io.nex.gateway"
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||
PROJECT_ROOT="$(cd "${SCRIPT_DIR}/../.." && pwd)"
|
||||
BUILD_DIR="${PROJECT_ROOT}/build"
|
||||
ASSETS_DIR="${PROJECT_ROOT}/assets"
|
||||
|
||||
echo "打包 macOS .app..."
|
||||
|
||||
mkdir -p "${BUILD_DIR}/${APP_NAME}.app/Contents/MacOS"
|
||||
mkdir -p "${BUILD_DIR}/${APP_NAME}.app/Contents/Resources"
|
||||
|
||||
if [ -f "${BUILD_DIR}/nex-mac-arm64" ]; then
|
||||
cp "${BUILD_DIR}/nex-mac-arm64" "${BUILD_DIR}/${APP_NAME}.app/Contents/MacOS/nex"
|
||||
elif [ -f "${BUILD_DIR}/nex-mac-amd64" ]; then
|
||||
cp "${BUILD_DIR}/nex-mac-amd64" "${BUILD_DIR}/${APP_NAME}.app/Contents/MacOS/nex"
|
||||
else
|
||||
echo "错误: 未找到 macOS 二进制文件,请先运行 make desktop-build-mac"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -f "${ASSETS_DIR}/AppIcon.icns" ]; then
|
||||
cp "${ASSETS_DIR}/AppIcon.icns" "${BUILD_DIR}/${APP_NAME}.app/Contents/Resources/"
|
||||
else
|
||||
echo "警告: 未找到 AppIcon.icns"
|
||||
fi
|
||||
|
||||
cat > "${BUILD_DIR}/${APP_NAME}.app/Contents/Info.plist" << EOF
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>zh_CN</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>nex</string>
|
||||
<key>CFBundleIconFile</key>
|
||||
<string>AppIcon</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>${BUNDLE_ID}</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>${APP_NAME} Gateway</string>
|
||||
<key>CFBundleDisplayName</key>
|
||||
<string>${APP_NAME} Gateway</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>${VERSION}</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>${VERSION}</string>
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
<string>10.13</string>
|
||||
<key>LSUIElement</key>
|
||||
<true/>
|
||||
<key>NSHighResolutionCapable</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
EOF
|
||||
|
||||
chmod +x "${BUILD_DIR}/${APP_NAME}.app/Contents/MacOS/nex"
|
||||
|
||||
echo "打包完成: ${BUILD_DIR}/${APP_NAME}.app"
|
||||
Reference in New Issue
Block a user