feat: unify service port and add GitHub packages workflow
Build Packages / Test (push) Has been cancelled
Build Packages / Build macOS package (push) Has been cancelled
Build Packages / Build Linux package (push) Has been cancelled
Build Packages / Build Windows package (push) Has been cancelled
Build Packages / Publish GitHub Release (push) Has been cancelled

This commit is contained in:
2026-08-05 15:13:29 +08:00
parent 56db1cc642
commit 6f07849a53
7 changed files with 318 additions and 367 deletions
+27 -12
View File
@@ -82,12 +82,12 @@ cd ../..
**开发模式:**
需要打开两个终端窗口
生产运行只需要启动一个服务。需要前端热更新时,可额外启动 Vite 开发服务器
**终端1 - 启动Go后端**
**终端1 - 启动统一服务**
```bash
# 在项目根目录运行
go run main.go
make run
```
**终端2 - 启动前端开发服务器:**
@@ -97,11 +97,11 @@ npm run dev
```
**说明:**
- `go run main.go` 会编译并运行Go程序
- 后端默认运行在 `http://localhost:1551`
- 前端默认运行在 `http://localhost:1552`
- `make run` 会先构建前端,再启动同时提供前端、API和上传文件的统一服务
- 统一服务默认运行在 `http://localhost:1552`
- Vite 开发服务器运行在 `http://localhost:5173`,并将 API 请求代理到统一服务
- 首次运行会自动创建 `data/` 目录和数据库
- 可以通过环境变量 `PORT` 修改后端端口(默认1551
- 可以通过环境变量 `PORT` 修改统一服务端口(默认1552
**Windows用户注意:** 如果遇到中文乱码,在PowerShell中运行:
```powershell
@@ -113,6 +113,7 @@ chcp 65001
- 前端:http://localhost:1552
- 管理界面:http://localhost:1552/admin
- 登录页面:http://localhost:1552/login
- APIhttp://localhost:1552/api
**默认管理员账号:**
- 用户名:`admin`
@@ -146,8 +147,8 @@ npm run build
```
构建完成后:
- Go二进制文件:`./home-vue-go` (Linux) 或 `./home-vue-go.exe` (Windows)
- 前端构建文件:`./dist`
- `make build` 的发布包位于 `./dist/`
- 前端资源已经嵌入每个平台的二进制文件,部署时只需要对应的可执行文件
**说明:**
- `go build` 编译Go程序为二进制文件
@@ -159,7 +160,6 @@ npm run build
1. **上传文件到服务器:**
- 上传 `home-vue-go` 二进制文件
- 上传 `dist` 目录(前端构建文件)
2. **运行二进制文件:**
```bash
@@ -173,7 +173,7 @@ npm run build
4. **环境变量(可选):**
```bash
export PORT=1551 # 服务端口,默认1551
export PORT=1552 # 统一服务端口,默认1552
export JWT_SECRET=your-secret-key # JWT密钥,建议修改
```
@@ -239,7 +239,7 @@ go mod download
cd internal/ent && go generate ./... && cd ../..
# 运行后端(开发模式)
go run main.go
make run
# 构建后端(当前平台)
CGO_ENABLED=0 go build -o home-vue-go .
@@ -269,6 +269,21 @@ npm run build
npm run preview
```
### GitHub Actions 构建与安装包
仓库内置 `.github/workflows/build.yml`,在推送到 `main` 或创建 Pull Request 时运行测试和跨平台构建。每次工作流运行都会产生三个可下载的安装包:
- Windows amd64ZIP
- Linux amd64TAR.GZ
- macOS amd64TAR.GZ
在 GitHub Actions 的运行详情页下载 `package-windows`、`package-linux` 或 `package-darwin`。发布版本时推送一个 `v` 开头的标签,工作流会自动创建 GitHub Release 并附加这三个安装包:
```bash
git tag v1.0.0
git push github v1.0.0
```
### 许可证
MIT License