feat: 添加评论、反应、离线编辑及主题定制功能
All checks were successful
test/timeline-frontend/pipeline/head This commit looks good

- 实现评论系统,包括评论输入、列表展示和集成指南
- 添加反应功能组件(ReactionBar、ReactionButton、ReactionPicker)
- 实现离线编辑支持,包括同步状态管理和冲突解决
- 添加主题定制功能,支持多种配色方案和主题预览
- 新增多视图布局选项(时间线、分组、砌体视图)
- 实现个人资料编辑器,支持头像、简介和自定义字段编辑
- 添加统计页面,展示存储使用情况和上传趋势
- 新增相册管理功能,支持相册创建、编辑和照片管理
- 实现响应式设计和加载骨架屏组件
- 扩展国际化支持,新增孟加拉语、波斯语、印尼语、日语、葡萄牙语等语言
- 添加错误边界组件和离线指示器
- 更新配置文件、路由和依赖项
- 新增完整的文档、测试用例和集成指南
This commit is contained in:
2026-02-25 15:02:05 +08:00
parent 97a5ad3a00
commit 5a0aa2b3c1
210 changed files with 23556 additions and 300 deletions

View File

@@ -0,0 +1,215 @@
# Backend API Specification for Personal User Enhancements
## Overview
This document specifies the backend API requirements for the Personal User Enhancements feature set. The backend team should implement these endpoints in the `timeline-server` Java application.
**Base URL**: `/api/v1`
**Technology Stack**:
- Java-based REST API
- PostgreSQL/MySQL database
- Redis for caching
- WebSocket (STOMP) for real-time notifications
- jqwik library for property-based testing
## Database Schema Requirements
### Albums Table
```sql
CREATE TABLE albums (
id VARCHAR(36) PRIMARY KEY,
user_id VARCHAR(36) NOT NULL,
name VARCHAR(255) NOT NULL,
description TEXT,
cover_photo_id VARCHAR(36),
photo_count INT DEFAULT 0,
created_at TIMESTAMP NOT NULL,
updated_at TIMESTAMP NOT NULL,
version INT DEFAULT 0,
INDEX idx_user_id (user_id),
INDEX idx_created_at (created_at)
);
```
### Album Photos Table
```sql
CREATE TABLE album_photos (
id VARCHAR(36) PRIMARY KEY,
album_id VARCHAR(36) NOT NULL,
photo_id VARCHAR(36) NOT NULL,
display_order INT NOT NULL,
added_at TIMESTAMP NOT NULL,
FOREIGN KEY (album_id) REFERENCES albums(id) ON DELETE CASCADE,
INDEX idx_album_id (album_id),
INDEX idx_photo_id (photo_id),
UNIQUE KEY unique_album_photo (album_id, photo_id)
);
```
### Smart Collections Table
```sql
CREATE TABLE smart_collections (
id VARCHAR(36) PRIMARY KEY,
user_id VARCHAR(36) NOT NULL,
type ENUM('date', 'location', 'person') NOT NULL,
name VARCHAR(255) NOT NULL,
criteria JSON NOT NULL,
content_count INT DEFAULT 0,
thumbnail_url VARCHAR(512),
created_at TIMESTAMP NOT NULL,
updated_at TIMESTAMP NOT NULL,
INDEX idx_user_id (user_id),
INDEX idx_type (type)
);
```
### Comments Table
```sql
CREATE TABLE comments (
id VARCHAR(36) PRIMARY KEY,
entity_type ENUM('story', 'photo') NOT NULL,
entity_id VARCHAR(36) NOT NULL,
user_id VARCHAR(36) NOT NULL,
text TEXT NOT NULL,
created_at TIMESTAMP NOT NULL,
updated_at TIMESTAMP,
is_edited BOOLEAN DEFAULT FALSE,
INDEX idx_entity (entity_type, entity_id),
INDEX idx_user_id (user_id),
INDEX idx_created_at (created_at)
);
```
### Reactions Table
```sql
CREATE TABLE reactions (
id VARCHAR(36) PRIMARY KEY,
entity_type ENUM('story', 'photo') NOT NULL,
entity_id VARCHAR(36) NOT NULL,
user_id VARCHAR(36) NOT NULL,
type ENUM('like', 'love', 'laugh', 'wow', 'sad') NOT NULL,
created_at TIMESTAMP NOT NULL,
INDEX idx_entity (entity_type, entity_id),
INDEX idx_user_id (user_id),
UNIQUE KEY unique_user_entity_reaction (entity_type, entity_id, user_id)
);
```
### User Preferences Table
```sql
CREATE TABLE user_preferences (
user_id VARCHAR(36) PRIMARY KEY,
theme_mode ENUM('light', 'dark', 'auto') DEFAULT 'auto',
color_scheme VARCHAR(50) DEFAULT 'default',
gallery_layout ENUM('grid', 'list') DEFAULT 'grid',
timeline_layout ENUM('grid', 'list') DEFAULT 'grid',
album_layout ENUM('grid', 'list') DEFAULT 'grid',
card_size ENUM('small', 'medium', 'large') DEFAULT 'medium',
timeline_display_mode ENUM('chronological', 'grouped', 'masonry') DEFAULT 'chronological',
updated_at TIMESTAMP NOT NULL
);
```
### User Profile Table
```sql
CREATE TABLE user_profiles (
user_id VARCHAR(36) PRIMARY KEY,
cover_photo_url VARCHAR(512),
bio TEXT,
updated_at TIMESTAMP NOT NULL
);
CREATE TABLE profile_custom_fields (
id VARCHAR(36) PRIMARY KEY,
user_id VARCHAR(36) NOT NULL,
name VARCHAR(100) NOT NULL,
value TEXT NOT NULL,
visibility ENUM('public', 'private') DEFAULT 'public',
display_order INT NOT NULL,
FOREIGN KEY (user_id) REFERENCES user_profiles(user_id) ON DELETE CASCADE,
INDEX idx_user_id (user_id)
);
```
### User Statistics Table (Cache)
```sql
CREATE TABLE user_statistics (
user_id VARCHAR(36) PRIMARY KEY,
total_photos INT DEFAULT 0,
total_stories INT DEFAULT 0,
total_storage_bytes BIGINT DEFAULT 0,
calculated_at TIMESTAMP NOT NULL,
INDEX idx_calculated_at (calculated_at)
);
CREATE TABLE upload_trends (
id VARCHAR(36) PRIMARY KEY,
user_id VARCHAR(36) NOT NULL,
period VARCHAR(10) NOT NULL,
photo_count INT DEFAULT 0,
story_count INT DEFAULT 0,
storage_bytes BIGINT DEFAULT 0,
FOREIGN KEY (user_id) REFERENCES user_statistics(user_id) ON DELETE CASCADE,
INDEX idx_user_period (user_id, period)
);
```
### Sync Changes Table
```sql
CREATE TABLE sync_changes (
id VARCHAR(36) PRIMARY KEY,
user_id VARCHAR(36) NOT NULL,
entity_type ENUM('story', 'album', 'photo') NOT NULL,
entity_id VARCHAR(36) NOT NULL,
operation ENUM('create', 'update', 'delete') NOT NULL,
data JSON NOT NULL,
timestamp TIMESTAMP NOT NULL,
synced BOOLEAN DEFAULT FALSE,
synced_at TIMESTAMP,
error TEXT,
INDEX idx_user_synced (user_id, synced),
INDEX idx_timestamp (timestamp)
);
```
## API Endpoints
### Smart Collections API
#### GET /api/v1/collections/smart
List all smart collections for the authenticated user.
**Response**:
```json
[
{
"id": "uuid",
"userId": "uuid",
"type": "date",
"name": "2024",
"criteria": { "year": 2024 },
"contentCount": 150,
"thumbnailUrl": "https://...",
"createdAt": "2024-01-01T00:00:00Z",
"updatedAt": "2024-01-01T00:00:00Z"
}
]
```
#### GET /api/v1/collections/smart/:id/content
Get content within a specific smart collection.
**Query Parameters**:
- `page` (int, default: 1)
- `pageSize` (int, default: 20)
**Response**:
```json
{
"collectionId": "uuid",
"items": [
{
"id": "uuid",
"type": "photo",