Files
proxycast/docs/content/06.development/3.building.md
T
coso 267bbf75e3 feat: add documentation system with Docus framework
- Add complete documentation structure with 25+ markdown files
- Add introduction, user guide, provider configs, API reference
- Add troubleshooting and development guides
- Add disclaimer for legal use
- Add GitHub Actions workflow for auto-deploying docs to GitHub Pages
- Bump version to v0.11.0
2025-12-17 13:10:58 +08:00

255 lines
3.5 KiB
Markdown

---
title: 构建指南
description: 本地开发和构建发布
navigation:
icon: i-heroicons-wrench-screwdriver
---
# 构建指南
本指南介绍如何在本地开发和构建 ProxyCast。
## 本地开发
### 环境准备
1. **安装 Node.js**
```bash
# 使用 nvm 安装
nvm install 18
nvm use 18
```
2. **安装 pnpm**
```bash
npm install -g pnpm
```
3. **安装 Rust**
```bash
# macOS/Linux
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Windows
# 下载并运行 rustup-init.exe
```
4. **安装 Tauri 依赖**
**macOS:**
```bash
xcode-select --install
```
**Windows:**
- 安装 Visual Studio Build Tools
- 安装 WebView2
**Linux:**
```bash
sudo apt install libwebkit2gtk-4.1-dev build-essential curl wget file libssl-dev libayatana-appindicator3-dev librsvg2-dev
```
### 启动开发
```bash
# 安装依赖
pnpm install
# 启动开发模式
pnpm tauri dev
```
开发模式特性:
- 前端热重载
- Rust 代码变更自动重新编译
- 开发者工具可用
### 开发配置
#### 前端配置
`vite.config.ts`:
```typescript
export default defineConfig({
plugins: [react()],
server: {
port: 1420,
strictPort: true,
},
});
```
#### Tauri 配置
`src-tauri/tauri.conf.json`:
```json
{
"build": {
"devPath": "http://localhost:1420",
"distDir": "../dist"
}
}
```
## 构建发布
### 构建命令
```bash
# 构建当前平台
pnpm tauri build
# 构建 debug 版本
pnpm tauri build --debug
```
### 构建产物
| 平台 | 产物位置 |
|------|----------|
| macOS | `src-tauri/target/release/bundle/dmg/` |
| Windows | `src-tauri/target/release/bundle/msi/` |
| Linux | `src-tauri/target/release/bundle/deb/` |
### 跨平台构建
#### macOS 构建
```bash
# 构建 Apple Silicon
pnpm tauri build --target aarch64-apple-darwin
# 构建 Intel
pnpm tauri build --target x86_64-apple-darwin
# 构建 Universal
pnpm tauri build --target universal-apple-darwin
```
#### Windows 构建
```bash
# 构建 64 位
pnpm tauri build --target x86_64-pc-windows-msvc
```
#### Linux 构建
```bash
# 构建 deb 包
pnpm tauri build --target x86_64-unknown-linux-gnu
```
## 版本管理
### 更新版本号
1. 更新 `package.json`:
```json
{
"version": "1.0.1"
}
```
2. 更新 `src-tauri/Cargo.toml`:
```toml
[package]
version = "1.0.1"
```
3. 更新 `src-tauri/tauri.conf.json`:
```json
{
"version": "1.0.1"
}
```
### 创建发布
```bash
# 创建 tag
git tag v1.0.1
git push origin v1.0.1
```
## CI/CD
### GitHub Actions
项目使用 GitHub Actions 自动构建:
- Push 到 main 分支触发构建
- 创建 tag 触发发布
### 构建矩阵
| 平台 | 架构 | Runner |
|------|------|--------|
| macOS | arm64 | macos-latest |
| macOS | x64 | macos-13 |
| Windows | x64 | windows-latest |
| Linux | x64 | ubuntu-latest |
## 调试
### 前端调试
开发模式下按 `F12` 打开开发者工具。
### 后端调试
```bash
# 启用 Rust 日志
RUST_LOG=debug pnpm tauri dev
```
### 日志位置
| 平台 | 路径 |
|------|------|
| macOS | `~/Library/Logs/ProxyCast/` |
| Windows | `%APPDATA%\ProxyCast\logs\` |
| Linux | `~/.local/share/proxycast/logs/` |
## 常见问题
### 构建失败
1. 确保所有依赖已安装
2. 清理构建缓存:
```bash
# 清理前端
rm -rf node_modules dist
pnpm install
# 清理 Rust
cd src-tauri
cargo clean
```
### 签名问题
macOS 构建需要代码签名:
```bash
# 设置签名身份
export APPLE_SIGNING_IDENTITY="Developer ID Application: ..."
```
Windows 构建可选签名:
```bash
# 设置签名证书
export TAURI_SIGNING_PRIVATE_KEY="..."
```