Files
FunConnect/docs/BUILD-CLIENT.md
xiaobai 3f313283df fix: Update API base URL to include versioning
- Modify the base URL in the ApiClient constructor to append '/api/v1', ensuring compatibility with versioned API endpoints.
2026-02-26 22:27:25 +08:00

137 lines
3.8 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 各平台客户端构建并放入下载目录
下载页提供的文件名由服务端配置 `CLIENT_VERSION` 决定(默认 `0.1.0`),格式为:
- `FunMC-<版本>-windows-x64.exe`
- `FunMC-<版本>-macos-arm64.dmg` / `FunMC-<版本>-macos-x64.dmg`
- `FunMC-<版本>-linux-x64.AppImage`
- `FunMC-<版本>-android.apk`
构建产物需**复制到服务器的下载目录**并**按上述文件名命名**,下载页才会显示「下载」按钮。
服务器下载目录:`/opt/funmc/downloads`(或环境变量 `DOWNLOADS_DIR`)。
---
## 1. 版本号一致
构建前请确认与服务器一致:
- 查看服务器:`grep CLIENT_VERSION /etc/funmc/server.env`(例如 `0.1.0`
- 下文中的 `VERSION` 请替换为该版本号。
---
## 2. Linux可在服务器本机执行
**在服务器或任意 Linux 机器上:**
```bash
cd /opt/funmc/src/client # 或你的项目 client 目录
npm install --registry https://registry.npmjs.org/
npm run dist:linux
```
产物在 `client/release/` 下,例如:
- `FunConnect-1.1.0-Linux-x64.AppImage`
复制并重命名为下载页期望的文件名后放入下载目录:
```bash
VERSION=0.1.0 # 与 CLIENT_VERSION 一致
cp release/FunConnect-*-Linux-x64.AppImage /opt/funmc/downloads/FunMC-${VERSION}-linux-x64.AppImage
```
---
## 3. Windows
**在 Windows 本机:**
```cmd
cd client
npm install
npm run dist:win
```
产物在 `client\release\`,例如:
- `FunConnect-1.1.0-Win-x64.exe`(或带 nsis 的安装包)
上传到服务器后重命名并放入下载目录(在服务器上执行,或本机重命名后上传):
```bash
# 在服务器上(假设已上传为 FunConnect-1.1.0-Win-x64.exe
VERSION=0.1.0
mv /path/to/FunConnect-1.1.0-Win-x64.exe /opt/funmc/downloads/FunMC-${VERSION}-windows-x64.exe
```
或用 SCP 从本机直接放到服务器并命名PowerShell 示例):
```powershell
scp client\release\FunConnect-1.1.0-Win-x64.exe root@你的服务器IP:/opt/funmc/downloads/FunMC-0.1.0-windows-x64.exe
```
---
## 4. macOS
**在 Mac 本机:**
```bash
cd client
npm install
npm run dist:mac
```
产物在 `client/release/`,例如:
- Apple Silicon: `FunConnect-1.1.0-Mac-arm64.dmg`
- Intel: `FunConnect-1.1.0-Mac-x64.dmg`
上传到服务器并重命名(在服务器上):
```bash
VERSION=0.1.0
mv /path/to/FunConnect-1.1.0-Mac-arm64.dmg /opt/funmc/downloads/FunMC-${VERSION}-macos-arm64.dmg
mv /path/to/FunConnect-1.1.0-Mac-x64.dmg /opt/funmc/downloads/FunMC-${VERSION}-macos-x64.dmg
```
---
## 5. Android
若项目中有 Android 构建(如 `mobile/` 或 Android 子工程),构建出 `.apk` 后,上传到服务器并命名为:
```bash
VERSION=0.1.0
cp /path/to/your.apk /opt/funmc/downloads/FunMC-${VERSION}-android.apk
```
---
## 6. 一键复制脚本示例(在服务器上使用)
在服务器上,若已把各平台构建产物上传到某目录(或本机刚构建好 Linux 版),可统一复制并重命名:
```bash
# 请先确认版本号与 /etc/funmc/server.env 中 CLIENT_VERSION 一致
VERSION=0.1.0
DOWNLOADS=/opt/funmc/downloads
# Linux本机刚构建时
cp -v /opt/funmc/src/client/release/FunConnect-*-Linux-x64.AppImage "$DOWNLOADS/FunMC-${VERSION}-linux-x64.AppImage" 2>/dev/null || true
# 若 Windows/macOS 已上传到 /opt/funmc/uploads/ 等目录,可类似:
# cp -v /opt/funmc/uploads/FunConnect-*-Win-x64.exe "$DOWNLOADS/FunMC-${VERSION}-windows-x64.exe" 2>/dev/null || true
# cp -v /opt/funmc/uploads/FunConnect-*-Mac-arm64.dmg "$DOWNLOADS/FunMC-${VERSION}-macos-arm64.dmg" 2>/dev/null || true
# cp -v /opt/funmc/uploads/FunConnect-*-Mac-x64.dmg "$DOWNLOADS/FunMC-${VERSION}-macos-x64.dmg" 2>/dev/null || true
```
---
## 7. 验证
- 在服务器上:`ls -la /opt/funmc/downloads`
- 浏览器打开:`http://你的服务器:3000/download`,有文件的平台会显示「下载」按钮,没有的显示「暂无」。