feat: 支持应用打包

This commit is contained in:
richarjiang
2026-07-15 20:16:20 +08:00
parent 9e0b44dfd3
commit 25bca0e859
6 changed files with 4118 additions and 3 deletions

3
.gitignore vendored
View File

@@ -1,6 +1,9 @@
node_modules/
dist/
out/
release/
build/icon.iconset/
build/icon.icns
.DS_Store
*.log
.env

View File

@@ -38,6 +38,14 @@
- 下单、取消等写操作必须由对应球场适配器独立实现;公共层只编排确认、状态和恢复,不拼装球场专属请求。
- 模拟数据只允许存在于 `demo` 适配器或明确命名的 fixture 中,接入真实 API 后不得静默回退到模拟成功。
## macOS 分发规则
- macOS 安装包统一由 `electron-builder` 生成,产物写入 `release/`,不得把 `out/` 目录误认为可分发安装包。
- 应用标识固定为 `com.tennisbook.desktop`,对外名称、`.app`、DMG 和 ZIP 统一使用 `Tennis Book`
- 默认发布 `universal` 架构,同时支持 Apple Silicon 和 Intel Mac应用图标源文件和打包用 PNG 放在 `build/` 统一管理。
- 未配置 Apple Developer ID 和公证凭据时允许生成本机测试用未公证包,但交付时必须明确提示 Gatekeeper 限制;正式对外发布必须完成 Developer ID 签名和 Apple 公证。
- `release/`、打包缓存和生成产物不得提交版本库。
## 安全规则
- Electron 必须保持 `contextIsolation: true``nodeIntegration: false``sandbox: true`

BIN
build/icon-1024.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

18
build/icon.svg Normal file
View File

@@ -0,0 +1,18 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024">
<defs>
<linearGradient id="background" x1="128" y1="96" x2="896" y2="928" gradientUnits="userSpaceOnUse">
<stop offset="0" stop-color="#236e52"/>
<stop offset="1" stop-color="#123d2d"/>
</linearGradient>
<filter id="shadow" x="-20%" y="-20%" width="140%" height="140%">
<feDropShadow dx="0" dy="34" stdDeviation="32" flood-color="#09261b" flood-opacity="0.34"/>
</filter>
</defs>
<rect x="72" y="72" width="880" height="880" rx="220" fill="url(#background)"/>
<path d="M225 270h574c28 0 51 23 51 51v382c0 28-23 51-51 51H225c-28 0-51-23-51-51V321c0-28 23-51 51-51Z" fill="none" stroke="#f5f7e8" stroke-width="28" opacity="0.94"/>
<path d="M512 282v460M188 512h648" fill="none" stroke="#f5f7e8" stroke-width="22" opacity="0.7"/>
<g filter="url(#shadow)">
<circle cx="512" cy="512" r="196" fill="#d8ff63"/>
<path d="M384 364c73 46 113 98 128 148 15 50 55 102 128 148M640 364c-73 46-113 98-128 148-15 50-55 102-128 148" fill="none" stroke="#f8ffe4" stroke-width="27" stroke-linecap="round"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.1 KiB

4067
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -8,6 +8,7 @@
"scripts": {
"dev": "electron-vite dev",
"build": "npm run typecheck && electron-vite build",
"dist:mac": "npm run build && electron-builder --mac dmg zip --universal",
"preview": "electron-vite preview",
"typecheck": "tsc --noEmit",
"test": "vitest run"
@@ -26,9 +27,33 @@
"@types/react-dom": "18.3.5",
"@vitejs/plugin-react": "4.7.0",
"electron": "35.7.5",
"electron-builder": "26.0.12",
"electron-builder": "^26.0.12",
"electron-vite": "3.1.0",
"typescript": "5.9.3",
"vite": "6.4.3",
"vitest": "3.2.7"
},
"build": {
"appId": "com.tennisbook.desktop",
"productName": "Tennis Book",
"asar": true,
"directories": {
"output": "release",
"buildResources": "build"
},
"files": [
"out/**/*",
"package.json"
],
"mac": {
"category": "public.app-category.sports",
"icon": "build/icon-1024.png",
"artifactName": "${productName}-${version}-${arch}.${ext}",
"target": [
"dmg",
"zip"
]
}
}
}