架构: 添加API文档

This commit is contained in:
Architecture Designer 2026-03-10 08:32:35 +00:00
parent 2c616ab6d7
commit 9ee28f404f

View File

@ -0,0 +1,119 @@
# API 文档
## 认证接口
### POST /api/auth/register
注册新用户
**请求体:**
```json
{
"username": "string",
"password": "string",
"email": "string"
}
```
**响应:**
```json
{
"token": "string",
"userId": number
}
```
### POST /api/auth/login
用户登录
**请求体:**
```json
{
"username": "string",
"password": "string"
}
```
**响应:**
```json
{
"token": "string",
"user": {
"id": number,
"username": "string",
"email": "string",
"storageUsed": number,
"storageLimit": number
}
}
```
## 文件接口
### GET /api/files
获取文件列表
**查询参数:**
- `parentId`: 文件夹ID可选
**响应:**
```json
{
"files": [
{
"id": 1,
"name": "document.pdf",
"type": "pdf",
"size": 1024000,
"is_folder": false,
"updated_at": "2026-03-10T00:00:00Z"
}
]
}
```
### POST /api/files/upload
上传文件
**请求体:** multipart/form-data
**响应:**
```json
{
"success": true,
"fileId": 1,
"filename": "document.pdf"
}
```
### DELETE /api/files/:id
删除文件
**响应:**
```json
{
"success": true
}
```
## 分享接口
### POST /api/share
创建分享链接
**请求体:**
```json
{
"fileId": 1,
"password": "optional",
"expiresIn": 86400
}
```
**响应:**
```json
{
"success": true,
"shareToken": "abc123",
"shareUrl": "/share/abc123"
}
```