feat: 重构项目心跳数据结构并实现相关功能

- 重构Redis心跳数据结构,使用统一的项目列表键
- 新增数据迁移工具和API端点
- 更新前端以使用真实项目数据
- 添加系统部署配置和文档
- 修复代码格式和样式问题
This commit is contained in:
2026-01-15 14:14:10 +08:00
parent 282f7268ed
commit a8faa7dcaa
24 changed files with 307 additions and 560 deletions

View File

@@ -1,54 +1,44 @@
# Command Capability Specification
## Overview
This specification defines the command capability for the BLS Project Console, which allows users to send console commands to Redis queues for other programs to read and execute.
## Requirements
### Requirement: Command Sending to Redis
The system SHALL send commands to a Redis queue.
#### Scenario: Sending a command to Redis queue
- **WHEN** the user enters a command in the console
- **AND** clicks the "Send" button
- **THEN** the command SHALL be sent to the Redis queue
- **AND** the user SHALL receive a success confirmation
### Requirement: Command Validation
The system SHALL validate commands before sending them to Redis.
#### Scenario: Validating an empty command
- **WHEN** the user tries to send an empty command
- **THEN** the system SHALL display an error message
- **AND** the command SHALL NOT be sent to Redis
#### Scenario: Validating a command with invalid characters
- **WHEN** the user tries to send a command with invalid characters
- **THEN** the system SHALL display an error message
- **AND** the command SHALL NOT be sent to Redis
### Requirement: Command History
The system SHALL maintain a history of sent commands.
#### Scenario: Viewing command history
- **WHEN** the user opens the command history
- **THEN** the system SHALL display a list of previously sent commands
- **AND** the user SHALL be able to select a command from the history to resend
### Requirement: Command Response Handling
The system SHALL handle responses from commands sent to Redis.
#### Scenario: Receiving a command response
- **WHEN** a command response is received from Redis
- **THEN** the system SHALL display the response in the console
- **AND** the response SHALL be associated with the original command
@@ -56,7 +46,6 @@ The system SHALL handle responses from commands sent to Redis.
## Data Model
### Command
```json
{
"id": "string",
@@ -67,7 +56,6 @@ The system SHALL handle responses from commands sent to Redis.
```
### Command Response
```json
{
"id": "string",
@@ -81,7 +69,6 @@ The system SHALL handle responses from commands sent to Redis.
## API Endpoints
### POST /api/commands
- **Description**: Send a command to a project's API endpoint
- **Request Body**:
```json
@@ -103,7 +90,6 @@ The system SHALL handle responses from commands sent to Redis.
```
### GET /api/projects
- **Description**: Get list of all projects with their heartbeat status
- **Response**:
```json
@@ -125,7 +111,6 @@ The system SHALL handle responses from commands sent to Redis.
```
### POST /api/projects/migrate
- **Description**: Migrate heartbeat data from old structure to new unified structure
- **Request Body**:
```json
@@ -147,7 +132,6 @@ The system SHALL handle responses from commands sent to Redis.
```
### GET /api/commands/history
- **Description**: Get command history (deprecated - use project logs instead)
- **Query Parameters**:
- `limit`: Maximum number of commands to return (default: 50)
@@ -155,6 +139,5 @@ The system SHALL handle responses from commands sent to Redis.
- **Response**: Array of command objects
### GET /api/commands/:id/response
- **Description**: Get response for a specific command (deprecated - use project logs instead)
- **Response**: Command response object