docs: 将 README 改为中文

This commit is contained in:
672
2026-05-17 01:47:49 +08:00
parent 0e8c9f7bff
commit fa6d9359d8

134
README.md
View File

@@ -1,48 +1,48 @@
# PC Monitor
# PC Monitor - Windows 电脑监控系统
A monitoring system for Windows PCs that tracks CPU, GPU, memory, network, disk, and power status.
一个用于监控 Windows 电脑硬件状态的系统,支持监控 CPUGPU、内存、网络、磁盘和电源等信息。
## Architecture
## 系统架构
- **Client**: Windows executable (.exe) that collects hardware metrics
- **Server**: Go backend with SQLite database
- **Frontend**: Vue 3 + Element Plus web dashboard
- **Deployment**: Docker support for server
- **客户端**: Windows 可执行文件 (.exe),负责采集硬件指标数据
- **服务端**: Go 后端 + SQLite 数据库,负责数据存储和 API 服务
- **前端**: Vue 3 + Element Plus Web 仪表盘,负责数据展示
- **部署**: 服务端支持 Docker 一键部署
## Quick Start
## 快速开始
### Server (Docker)
### 服务端部署 (Docker)
1. Build and start the server:
1. 构建并启动服务端:
```bash
docker-compose up -d
```
2. Access the web dashboard at http://localhost:8080
2. 访问 Web 仪表盘:http://localhost:8080
### Client (Windows)
### 客户端安装 (Windows)
1. Download the client executable
2. Edit `config.yaml` to set your server URL
3. Run the client:
1. 下载客户端可执行文件
2. 编辑 `config.yaml` 配置文件,设置服务器地址
3. 运行客户端:
```powershell
.\pc-monitor-client.exe
```
Or install as a Windows service:
或者安装为 Windows 服务(开机自启):
```powershell
.\install\install.ps1 -ServerUrl "http://your-server:8080"
```
## Development
## 开发环境
### Prerequisites
### 环境要求
- Go 1.21+
- Node.js 18+
- Docker (optional)
- Docker(可选,用于部署服务端)
### Build Server
### 编译服务端
```bash
cd server
@@ -50,7 +50,7 @@ go mod tidy
go build -o server .
```
### Build Client
### 编译客户端
```bash
cd client
@@ -58,7 +58,7 @@ go mod tidy
go build -o pc-monitor-client.exe .
```
### Build Frontend
### 编译前端
```bash
cd web
@@ -66,57 +66,89 @@ npm install
npm run build
```
## API Endpoints
## API 接口
### Device Management
- `POST /api/v1/register` - Register a new device
- `GET /api/v1/devices` - List all devices
- `GET /api/v1/devices/:id` - Get device details
- `DELETE /api/v1/devices/:id` - Delete a device
- `POST /api/v1/devices/:id/heartbeat` - Send heartbeat
### 设备管理
- `POST /api/v1/register` - 注册新设备
- `GET /api/v1/devices` - 获取设备列表
- `GET /api/v1/devices/:id` - 获取设备详情
- `DELETE /api/v1/devices/:id` - 删除设备
- `POST /api/v1/devices/:id/heartbeat` - 设备心跳
### Metrics
- `POST /api/v1/report` - Report metrics
- `GET /api/v1/devices/:id/metrics/latest` - Get latest metrics
- `GET /api/v1/devices/:id/metrics/history` - Get metrics history
### 指标数据
- `POST /api/v1/report` - 上报指标数据
- `GET /api/v1/devices/:id/metrics/latest` - 获取最新指标
- `GET /api/v1/devices/:id/metrics/history` - 获取历史指标
### Alerts
- `GET /api/v1/alerts` - List active alerts
- `POST /api/v1/alerts/rules` - Create alert rule
- `GET /api/v1/devices/:id/alerts/rules` - Get device alert rules
- `DELETE /api/v1/alerts/rules/:id` - Delete alert rule
- `POST /api/v1/alerts/:id/resolve` - Resolve alert
### 告警管理
- `GET /api/v1/alerts` - 获取活跃告警列表
- `POST /api/v1/alerts/rules` - 创建告警规则
- `GET /api/v1/devices/:id/alerts/rules` - 获取设备告警规则
- `DELETE /api/v1/alerts/rules/:id` - 删除告警规则
- `POST /api/v1/alerts/:id/resolve` - 解决告警
## Configuration
## 配置说明
### Server Configuration (config.yaml)
### 服务端配置 (config.yaml)
```yaml
server:
addr: ":8080"
addr: ":8080" # 监听地址
database:
path: "./data/monitor.db"
retention_days: 30
path: "./data/monitor.db" # 数据库路径
retention_days: 30 # 数据保留天数
auth:
admin_password: "admin123"
admin_password: "admin123" # 管理密码
```
### Client Configuration (config.yaml)
### 客户端配置 (config.yaml)
```yaml
server:
url: "http://your-server:8080"
token: ""
url: "http://your-server:8080" # 服务器地址
token: "" # 设备令牌(首次注册后自动生成)
collect:
interval: 30s
interval: 30s # 数据采集间隔
report:
interval: 60s
interval: 60s # 数据上报间隔
```
## License
## 监控指标
| 模块 | 监控内容 |
|------|----------|
| CPU | 使用率、温度、每核使用率 |
| 内存 | 总量、已用、使用率 |
| GPU | 使用率、温度、显存(支持 NVIDIA |
| 磁盘 | 各分区容量、已用空间、使用率 |
| 网络 | 网卡状态、IP 地址、收发流量 |
| 电源 | 电池状态、电量百分比、充电状态 |
## 项目结构
```
pc-monitor/
├── client/ # Windows 客户端
│ ├── collector/ # 数据采集模块
│ ├── reporter/ # 数据上报模块
│ └── install/ # 安装脚本
├── server/ # 服务端
│ ├── api/ # API 路由和处理器
│ ├── model/ # 数据模型
│ ├── service/ # 业务逻辑
│ └── repository/ # 数据访问层
├── web/ # 前端源码
│ └── src/
│ ├── views/ # 页面组件
│ └── api/ # API 调用封装
├── docker-compose.yml # Docker 部署配置
└── Dockerfile.server # 服务端镜像构建
```
## 许可证
MIT License