iptv-app/desktop/BUILD.md
2026-02-04 18:02:52 +08:00

226 lines
4.1 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.

# IPTV Desktop 构建指南
支持平台:**macOS** | **Windows** | **Linux**
---
## macOS 构建
### 1. 安装依赖
```bash
# 安装 Rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source ~/.cargo/env
```
### 2. 构建应用
```bash
# 一键构建
cd /Users/liyanyan/study/single-portal/iptv-app
./build-mac.sh
```
或手动构建:
```bash
cd web && npm run build && cp -r public/api dist-web/ && cd ..
cd desktop && npm install && npx tauri build
```
### 3. 输出位置
```
src-tauri/target/release/bundle/macos/IPTV Player.app
```
---
## Windows 构建
### 1. 安装依赖
1. 安装 Rust访问 https://rustup.rs/ 下载安装程序
2. 安装 Node.js访问 https://nodejs.org/ 下载 LTS 版本
### 2. 构建应用
**方式一PowerShell推荐**
```powershell
# 右键开始菜单 -> Windows PowerShell
cd C:\Users\YourName\study\single-portal\iptv-app
.\build-windows.ps1
```
**方式二CMD**
```cmd
cd C:\Users\YourName\study\single-portal\iptv-app
build-windows.bat
```
**方式三:手动**
```cmd
cd web
npm install
npm run build
xcopy /e /i /y public\api dist-web\api
cd ..\desktop
npm install
npx tauri build
```
### 3. 输出位置
```
src-tauri\target\release\bundle\msi\IPTV Player_1.0.0_x64.msi (安装版)
src-tauri\target\release\bundle\nsis\IPTV Player_1.0.0_x64.exe (便携版)
```
### 4. 安装方式
- **MSI 版**:双击安装,支持自动更新
- **EXE 版**:免安装,直接运行
---
## Linux 构建
### 1. 安装依赖
```bash
# Ubuntu/Debian
sudo apt update
sudo apt install libwebkit2gtk-4.0-dev libssl-dev libgtk-3-dev
# 安装 Rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source ~/.cargo/env
```
### 2. 构建应用
```bash
cd /Users/liyanyan/study/single-portal/iptv-app
./build-mac.sh # 脚本通用
```
### 3. 输出位置
```
src-tauri/target/release/bundle/deb/*.deb
src-tauri/target/release/bundle/appimage/*.AppImage
```
---
## 项目结构
```
desktop/
├── package.json # Node 配置
├── BUILD.md # 本文件
├── dist-web/ # Web 静态文件
│ ├── index.html
│ └── api/ # IPTV 数据
└── src-tauri/
├── Cargo.toml # Rust 依赖
├── tauri.conf.json # Tauri 配置
├── build.rs # 构建脚本
├── src/main.rs # 入口
└── icons/ # 应用图标
```
---
## 配置说明
### tauri.conf.json 关键配置
```json
{
"windows": [{
"width": 1200,
"height": 800,
"minWidth": 900,
"minHeight": 600,
"center": true,
"title": "IPTV Player"
}]
}
```
### 自定义图标
替换 `src-tauri/icons/` 下的文件:
- `icon.icns` - Mac 图标
- `icon.ico` - Windows 图标
- `32x32.png`, `128x128.png` - Linux 图标
---
## 常见问题
### 1. Rust 未安装
```bash
# macOS/Linux
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Windows
# 访问 https://rustup.rs/ 下载安装程序
```
### 2. 构建失败 "No such file or directory"
确保在项目根目录执行脚本:
```bash
cd /Users/liyanyan/study/single-portal/iptv-app
ls -la # 应该能看到 web/, desktop/, build-mac.sh
```
### 3. Windows 安装后无法运行
- 安装 WebView2 运行时Windows 10/11 通常已预装)
- 检查是否被杀毒软件拦截,添加信任
- 右键 -> 属性 -> 解除锁定(如有)
### 4. 签名问题
**Mac 开发版**
```bash
xattr -cr "IPTV Player.app" # 移除隔离属性
```
**Windows 发布版**
需要购买代码签名证书,或使用自签名(测试用)
---
## 平台特性对比
| 特性 | macOS | Windows | Linux |
|------|-------|---------|-------|
| 安装包 | .app / .dmg | .msi / .exe | .deb / .AppImage |
| 包体积 | ~5MB | ~5MB | ~5MB |
| 自动更新 | ✅ | ✅ | ✅ |
| 原生菜单 | ✅ | ✅ | ✅ |
| 系统托盘 | ✅ | ✅ | ✅ |
---
## 调试模式
开发时可以使用调试模式,更快启动:
```bash
cd desktop
npm run tauri dev
```
这会启动开发服务器,支持热重载。