152 lines
2.1 KiB
Markdown
152 lines
2.1 KiB
Markdown
# 构建和运行说明
|
||
|
||
## 前置要求
|
||
|
||
1. **Go 1.21+**
|
||
```bash
|
||
go version
|
||
```
|
||
|
||
2. **Node.js 16+**
|
||
```bash
|
||
node --version
|
||
npm --version
|
||
```
|
||
|
||
3. **FFmpeg**
|
||
```bash
|
||
ffmpeg -version
|
||
```
|
||
|
||
4. **Wails3 CLI**
|
||
```bash
|
||
# 安装 Wails3(如果还没有)
|
||
git clone https://github.com/wailsapp/wails.git
|
||
cd wails
|
||
git checkout v3-alpha
|
||
cd v3/cmd/wails3
|
||
go install
|
||
```
|
||
|
||
## 构建步骤
|
||
|
||
### 1. 安装前端依赖
|
||
|
||
```bash
|
||
cd frontend
|
||
npm install
|
||
```
|
||
|
||
### 2. 构建前端
|
||
|
||
```bash
|
||
npm run build
|
||
```
|
||
|
||
这会将前端代码构建到 `../assets` 目录。
|
||
|
||
### 3. 运行应用
|
||
|
||
```bash
|
||
cd ..
|
||
go run app.go
|
||
```
|
||
|
||
### 4. 构建可执行文件(可选)
|
||
|
||
```bash
|
||
go build -o videoconcat.exe app.go
|
||
```
|
||
|
||
## 开发模式
|
||
|
||
### 前端开发
|
||
|
||
```bash
|
||
cd frontend
|
||
npm run dev
|
||
```
|
||
|
||
### 后端开发
|
||
|
||
```bash
|
||
go run app.go
|
||
```
|
||
|
||
## 常见问题
|
||
|
||
### 1. FFmpeg 未找到
|
||
|
||
**错误**: `exec: "ffmpeg": executable file not found in %PATH%`
|
||
|
||
**解决**:
|
||
- Windows: 下载 FFmpeg 并添加到系统 PATH
|
||
- 或者修改代码指定 FFmpeg 完整路径
|
||
|
||
### 2. 前端构建失败
|
||
|
||
**错误**: `npm ERR!`
|
||
|
||
**解决**:
|
||
```bash
|
||
# 清除缓存
|
||
npm cache clean --force
|
||
# 删除 node_modules 重新安装
|
||
rm -rf node_modules
|
||
npm install
|
||
```
|
||
|
||
### 3. Go 模块下载失败
|
||
|
||
**错误**: `go: module ... not found`
|
||
|
||
**解决**:
|
||
```bash
|
||
# 设置 Go 代理(中国用户)
|
||
go env -w GOPROXY=https://goproxy.cn,direct
|
||
# 或者使用官方代理
|
||
go env -w GOPROXY=https://proxy.golang.org,direct
|
||
```
|
||
|
||
### 4. Wails3 绑定失败
|
||
|
||
**错误**: `window.go is undefined`
|
||
|
||
**解决**:
|
||
- 检查 Wails3 版本和 API
|
||
- 确保服务正确绑定
|
||
- 查看浏览器控制台错误信息
|
||
|
||
## 调试
|
||
|
||
### 查看日志
|
||
|
||
日志文件位于:`Log/logYYYYMMDD.log`
|
||
|
||
### 浏览器调试
|
||
|
||
1. 打开开发者工具(F12)
|
||
2. 查看 Console 标签页的错误信息
|
||
3. 查看 Network 标签页的请求
|
||
|
||
### Go 调试
|
||
|
||
```bash
|
||
# 使用 delve 调试器
|
||
go install github.com/go-delve/delve/cmd/dlv@latest
|
||
dlv debug app.go
|
||
```
|
||
|
||
## 打包发布
|
||
|
||
### Windows
|
||
|
||
```bash
|
||
go build -ldflags="-H windowsgui" -o videoconcat.exe app.go
|
||
```
|
||
|
||
### 其他平台
|
||
|
||
参考 Wails3 官方文档的打包说明。
|
||
|