diff --git a/.gitignore b/.gitignore index 932c0fa..5fd5891 100644 --- a/.gitignore +++ b/.gitignore @@ -411,4 +411,5 @@ skills-lock.json # Embedfs generated embedfs/assets/ -embedfs/frontend-dist/ \ No newline at end of file +embedfs/frontend-dist/ +backend/cmd/desktop/rsrc_windows_*.syso diff --git a/Makefile b/Makefile index 3716705..99e2897 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ 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-clean \ - desktop-prepare-frontend desktop-prepare-embedfs + desktop-prepare-frontend desktop-prepare-embedfs desktop-prepare-windows-resource # ============================================ # 顶层便捷命令 @@ -158,15 +158,40 @@ desktop-build: desktop-build-mac desktop-build-win desktop-build-linux desktop-prepare-frontend: @echo "📦 Preparing frontend for desktop..." +ifeq ($(OS),Windows_NT) + powershell -NoProfile -Command "Copy-Item -LiteralPath 'frontend/.env.desktop' -Destination 'frontend/.env.production.local' -Force" + cd frontend && bun install && bun run build + powershell -NoProfile -Command "Remove-Item -LiteralPath 'frontend/.env.production.local' -Force -ErrorAction SilentlyContinue" +else cd frontend && cp .env.desktop .env.production.local cd frontend && bun install && bun run build rm -f frontend/.env.production.local +endif desktop-prepare-embedfs: @echo "📦 Preparing embedded filesystem..." +ifeq ($(OS),Windows_NT) + powershell -NoProfile -Command "Remove-Item -LiteralPath 'embedfs/assets' -Recurse -Force -ErrorAction SilentlyContinue; Remove-Item -LiteralPath 'embedfs/frontend-dist' -Recurse -Force -ErrorAction SilentlyContinue; Copy-Item -LiteralPath 'assets' -Destination 'embedfs/assets' -Recurse; Copy-Item -LiteralPath 'frontend/dist' -Destination 'embedfs/frontend-dist' -Recurse" +else rm -rf embedfs/assets embedfs/frontend-dist cp -r assets embedfs/assets cp -r frontend/dist embedfs/frontend-dist +endif + +desktop-prepare-windows-resource: + @echo "📦 Preparing Windows executable icon..." +ifeq ($(OS),Windows_NT) + cd backend/cmd/desktop && windres -O coff -F pe-x86-64 -i icon_windows.rc -o rsrc_windows_amd64.syso +else + @if command -v x86_64-w64-mingw32-windres >/dev/null 2>&1; then \ + cd backend/cmd/desktop && x86_64-w64-mingw32-windres -O coff -F pe-x86-64 -i icon_windows.rc -o rsrc_windows_amd64.syso; \ + elif command -v windres >/dev/null 2>&1; then \ + cd backend/cmd/desktop && windres -O coff -F pe-x86-64 -i icon_windows.rc -o rsrc_windows_amd64.syso; \ + else \ + echo "❌ 未找到 windres,无法生成 Windows exe 图标资源"; \ + exit 1; \ + fi +endif desktop-build-mac: desktop-prepare-frontend desktop-prepare-embedfs @echo "🍎 Building macOS..." @@ -176,10 +201,10 @@ desktop-build-mac: desktop-prepare-frontend desktop-prepare-embedfs @echo "📦 Packaging macOS .app..." mkdir -p build/Nex.app/Contents/MacOS build/Nex.app/Contents/Resources cp build/nex-mac-universal build/Nex.app/Contents/MacOS/nex - @if [ -f assets/AppIcon.icns ]; then \ - cp assets/AppIcon.icns build/Nex.app/Contents/Resources/; \ + @if [ -f assets/icon.icns ]; then \ + cp assets/icon.icns build/Nex.app/Contents/Resources/; \ else \ - echo "⚠️ 未找到 assets/AppIcon.icns"; \ + echo "⚠️ 未找到 assets/icon.icns"; \ fi @MIN_MACOS_VERSION=$$(vtool -show-build build/nex-mac-universal | awk '/minos / {print $$2; exit}'); \ if [ -z "$$MIN_MACOS_VERSION" ]; then \ @@ -196,7 +221,7 @@ desktop-build-mac: desktop-prepare-frontend desktop-prepare-embedfs ' CFBundleExecutable' \ ' nex' \ ' CFBundleIconFile' \ - ' AppIcon' \ + ' icon' \ ' CFBundleIdentifier' \ ' com.lanyuanxiaoyao.nex' \ ' CFBundleInfoDictionaryVersion' \ @@ -227,9 +252,15 @@ desktop-build-mac: desktop-prepare-frontend desktop-prepare-embedfs chmod +x build/Nex.app/Contents/MacOS/nex @echo "✅ macOS app packaged: build/Nex.app" -desktop-build-win: desktop-prepare-frontend desktop-prepare-embedfs +desktop-build-win: desktop-prepare-frontend desktop-prepare-embedfs desktop-prepare-windows-resource @echo "🪟 Building Windows..." +ifeq ($(OS),Windows_NT) + powershell -NoProfile -Command "New-Item -ItemType Directory -Path 'build' -Force | Out-Null" + cd backend && set "CGO_ENABLED=1"&& set "GOOS=windows"&& set "GOARCH=amd64"&& go build -ldflags "-H=windowsgui" -o ../build/nex-win-amd64.exe ./cmd/desktop +else + mkdir -p build cd backend && CGO_ENABLED=1 GOOS=windows GOARCH=amd64 go build -ldflags "-H=windowsgui" -o ../build/nex-win-amd64.exe ./cmd/desktop +endif desktop-build-linux: desktop-prepare-frontend desktop-prepare-embedfs @echo "🐧 Building Linux..." diff --git a/README.md b/README.md index f95ebb0..7e8b1f7 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ nex/ │ ├── assets/ # 应用资源 │ ├── icon.png # 托盘图标 -│ ├── AppIcon.icns # macOS 应用图标 +│ ├── icon.icns # macOS 应用图标 │ └── icon.ico # Windows 应用图标 │ └── README.md # 本文件 diff --git a/assets/AppIcon.icns b/assets/AppIcon.icns deleted file mode 100644 index 47645c0..0000000 Binary files a/assets/AppIcon.icns and /dev/null differ diff --git a/assets/README.md b/assets/README.md deleted file mode 100644 index 102c2c8..0000000 --- a/assets/README.md +++ /dev/null @@ -1,64 +0,0 @@ -# Assets - -应用资源文件目录。 - -## 文件说明 - -| 文件 | 用途 | 尺寸 | 格式 | -|------|------|------|------| -| `icon.svg` | 源图标 | 64x64 | SVG | -| `icon.png` | 托盘图标 | 64x64 | PNG | -| `AppIcon.icns` | macOS 应用图标 | 多尺寸 | ICNS | -| `icon.ico` | Windows 应用图标 | 256x256 | ICO | - -## 替换图标 - -### 1. 准备图标 - -推荐使用 SVG 格式的源图标,尺寸至少 256x256。 - -### 2. 生成各平台图标 - -**托盘图标 (PNG)**: -```bash -magick your-icon.svg -resize 64x64 icon.png -``` - -**macOS 应用图标 (ICNS)**: -```bash -mkdir icon.iconset -magick your-icon.svg -resize 16x16 icon.iconset/icon_16x16.png -magick your-icon.svg -resize 32x32 icon.iconset/icon_16x16@2x.png -magick your-icon.svg -resize 32x32 icon.iconset/icon_32x32.png -magick your-icon.svg -resize 64x64 icon.iconset/icon_32x32@2x.png -magick your-icon.svg -resize 128x128 icon.iconset/icon_128x128.png -magick your-icon.svg -resize 256x256 icon.iconset/icon_128x128@2x.png -iconutil -c icns icon.iconset -o AppIcon.icns -rm -rf icon.iconset -``` - -**Windows 应用图标 (ICO)**: -```bash -magick your-icon.svg -resize 256x256 icon.ico -``` - -### 3. 替换文件 - -将生成的文件放入此目录,然后重新构建桌面应用: -```bash -./scripts/build/build-darwin-arm64.sh -``` - -## macOS Template 图标 - -macOS 支持 Template 图标,自动适配深浅色模式: -- 使用黑色 + 透明设计 -- 文件名以 `Template` 结尾(如 `iconTemplate.png`) -- 黑色在深色模式下自动变为白色 - -## 设计建议 - -- 托盘图标应简洁,在小尺寸下清晰可辨 -- 避免过多细节和文字 -- 使用高对比度颜色 -- macOS 建议使用 Template 图标风格 diff --git a/assets/icon.icns b/assets/icon.icns new file mode 100644 index 0000000..908b73e Binary files /dev/null and b/assets/icon.icns differ diff --git a/assets/icon.ico b/assets/icon.ico index 7bc6e0f..d00c871 100644 Binary files a/assets/icon.ico and b/assets/icon.ico differ diff --git a/assets/icon.png b/assets/icon.png index bd18837..cc1e938 100644 Binary files a/assets/icon.png and b/assets/icon.png differ diff --git a/assets/icon.svg b/assets/icon.svg deleted file mode 100644 index a85dcff..0000000 --- a/assets/icon.svg +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/assets/icons/hicolor/128x128/apps/nex.png b/assets/icons/hicolor/128x128/apps/nex.png new file mode 100644 index 0000000..68ddcc2 Binary files /dev/null and b/assets/icons/hicolor/128x128/apps/nex.png differ diff --git a/assets/icons/hicolor/16x16/apps/nex.png b/assets/icons/hicolor/16x16/apps/nex.png new file mode 100644 index 0000000..a2ef0b5 Binary files /dev/null and b/assets/icons/hicolor/16x16/apps/nex.png differ diff --git a/assets/icons/hicolor/22x22/apps/nex.png b/assets/icons/hicolor/22x22/apps/nex.png new file mode 100644 index 0000000..2c689ec Binary files /dev/null and b/assets/icons/hicolor/22x22/apps/nex.png differ diff --git a/assets/icons/hicolor/24x24/apps/nex.png b/assets/icons/hicolor/24x24/apps/nex.png new file mode 100644 index 0000000..16804bc Binary files /dev/null and b/assets/icons/hicolor/24x24/apps/nex.png differ diff --git a/assets/icons/hicolor/256x256/apps/nex.png b/assets/icons/hicolor/256x256/apps/nex.png new file mode 100644 index 0000000..d03b498 Binary files /dev/null and b/assets/icons/hicolor/256x256/apps/nex.png differ diff --git a/assets/icons/hicolor/32x32/apps/nex.png b/assets/icons/hicolor/32x32/apps/nex.png new file mode 100644 index 0000000..10ec679 Binary files /dev/null and b/assets/icons/hicolor/32x32/apps/nex.png differ diff --git a/assets/icons/hicolor/48x48/apps/nex.png b/assets/icons/hicolor/48x48/apps/nex.png new file mode 100644 index 0000000..e9194a8 Binary files /dev/null and b/assets/icons/hicolor/48x48/apps/nex.png differ diff --git a/assets/icons/hicolor/512x512/apps/nex.png b/assets/icons/hicolor/512x512/apps/nex.png new file mode 100644 index 0000000..edbfe47 Binary files /dev/null and b/assets/icons/hicolor/512x512/apps/nex.png differ diff --git a/assets/icons/hicolor/64x64/apps/nex.png b/assets/icons/hicolor/64x64/apps/nex.png new file mode 100644 index 0000000..de3801f Binary files /dev/null and b/assets/icons/hicolor/64x64/apps/nex.png differ diff --git a/backend/cmd/desktop/icon_windows.rc b/backend/cmd/desktop/icon_windows.rc new file mode 100644 index 0000000..3630fbf --- /dev/null +++ b/backend/cmd/desktop/icon_windows.rc @@ -0,0 +1 @@ +1 ICON "../../../assets/icon.ico"