使用 Go + React 重写的 GitHub 仓库监测器,提供更快的后端性能和更好的前端开发体验。
- 语言: Go 1.21+
- Web 框架: Gin (高性能 HTTP web 框架)
- ORM: GORM (SQLite)
- Git 操作: go-git
- 任务调度: robfig/cron
- API 风格: RESTful JSON API
- 框架: React 18 + TypeScript
- 构建工具: Vite
- UI 库: 无框架,原生 CSS + JavaScript (或 TailwindCSS)
- HTTP 客户端: fetch/axios
- 状态管理: React hooks (useState, useEffect)
- 仓库管理 - 添加/删除 GitHub 仓库地址
- 自动同步 - 定期克隆/更新仓库(所有分支)
- Issues 保存 - 本地保存所有 issues(含评论)
- Releases 保存 - 本地保存 release 信息和资产
- 仓库预览 - Web 界面浏览仓库内容
- 仓库列表展示(名称、描述、同步状态、最新更新)
- 添加仓库表单(输入 GitHub URL 或 owner/repo)
- 删除仓库(可选:同时删除本地文件)
- 手动触发同步
- 查看同步历史日志
- 全量克隆首次添加的仓库(包含所有分支)
- 增量更新已有仓库(git fetch --all)
- 获取并保存 issues(通过 GitHub API)
- 获取并保存 releases
- 同步间隔可配置(默认 1 小时)
type Repository struct {
ID uint `gorm:"primaryKey"`
Name string `gorm:"size:255;not null"`
Owner string `gorm:"size:255;not null"`
RepoPath string `gorm:"size:500;not null"` // owner/repo
LocalPath string `gorm:"size:1000"`
Description string `gorm:"type:text"`
LastSync *time.Time
SyncInterval int `gorm:"default:60"` // 分钟
IsActive bool `gorm:"default:true"`
CreatedAt time.Time
UpdatedAt time.Time
}type Issue struct {
ID uint `gorm:"primaryKey"`
RepoID uint `gorm:"index"`
GitHubID int64
Number int
Title string `gorm:"size:1000"`
Body string `gorm:"type:text"`
State string `gorm:"size:20"`
Author string `gorm:"size:255"`
Labels string `gorm:"type:text"` // JSON
CreatedAt time.Time
UpdatedAt time.Time
CommentsCount int
}type Release struct {
ID uint `gorm:"primaryKey"`
RepoID uint `gorm:"index"`
GitHubID int64
Tag string `gorm:"size:255"`
Name string `gorm:"size:1000"`
Body string `gorm:"type:text"`
Draft bool
Prerelease bool
CreatedAt time.Time
PublishedAt *time.Time
Assets string `gorm:"type:text"` // JSON
}github-watcher-go/
├── SPEC.md
├── README.md
├── backend/
│ ├── main.go
│ ├── go.mod
│ ├── go.sum
│ ├── config/
│ │ └── config.go
│ ├── models/
│ │ └── models.go
│ ├── database/
│ │ └── database.go
│ ├── handlers/
│ │ ├── repos.go
│ │ ├── issues.go
│ │ └── releases.go
│ ├── services/
│ │ ├── git_ops.go
│ │ ├── github_sync.go
│ │ └── scheduler.go
│ └── data/
│ ├── repos/ # 克隆的仓库
│ └── db.sqlite # SQLite 数据库
└── frontend/
├── package.json
├── vite.config.ts
├── index.html
├── src/
│ ├── main.tsx
│ ├── App.tsx
│ ├── App.css
│ ├── components/
│ │ ├── RepoList.tsx
│ │ ├── RepoDetail.tsx
│ │ ├── AddRepoModal.tsx
│ │ └── ...
│ └── types/
│ └── index.ts
└── tsconfig.json
GET /api/repos- 仓库列表POST /api/repos- 添加仓库GET /api/repos/:id- 仓库详情DELETE /api/repos/:id- 删除仓库POST /api/repos/:id/sync- 手动同步POST /api/repos/:id/toggle- 启用/暂停同步
GET /api/repos/:id/issues- Issues 列表
GET /api/repos/:id/releases- Releases 列表
GET /api/repos/:id/tree- 目录树GET /api/repos/:id/blob/*path- 文件内容
DATA_DIR- 数据目录SYNC_INTERVAL- 默认同步间隔(分钟)GITHUB_TOKEN- GitHub API Token(可选)PORT- HTTP 监听端口(默认 8898)
cd backend
go mod tidy
go run main.gocd frontend
npm install
npm run dev- 后端使用 Gin 提供 REST API
- 前端使用 Vite 开发服务器,代理 API 请求到后端
- 数据库使用 SQLite,无需额外安装
- Git 操作使用 go-git 库