From d0c964f5bdde6687cf7d59a3886183ca3c6b9d9c Mon Sep 17 00:00:00 2001 From: Frontend Developer Date: Tue, 10 Mar 2026 09:59:24 +0000 Subject: [PATCH] =?UTF-8?q?=E5=89=8D=E7=AB=AF:=20=E6=B7=BB=E5=8A=A0API?= =?UTF-8?q?=E8=B0=83=E7=94=A8=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/API.md | 62 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 frontend/API.md diff --git a/frontend/API.md b/frontend/API.md new file mode 100644 index 0000000..63c3381 --- /dev/null +++ b/frontend/API.md @@ -0,0 +1,62 @@ +# CloudDisk API 文档 + +## 基础配置 + +```javascript +const API_BASE = 'http://localhost:3000/api'; +const token = localStorage.getItem('token'); +``` + +## 认证 + +### 登录 +```javascript +POST /api/auth/login +{ username, password } +// 返回: { token, user } +``` + +### 注册 +```javascript +POST /api/auth/register +{ username, password, email } +// 返回: { token, userId } +``` + +## 文件 + +### 获取文件列表 +```javascript +GET /api/files?parentId=xxx +// 返回: { files: [...] } +``` + +### 上传文件 +```javascript +POST /api/files/upload +FormData: { file: File } +// 返回: { success, fileId } +``` + +### 删除文件 +```javascript +DELETE /api/files/:id +// 返回: { success } +``` + +## 分享 + +### 创建分享 +```javascript +POST /api/share +{ fileId, password?, expiresIn? } +// 返回: { success, shareToken, shareUrl } +``` + +## 用户 + +### 获取信息 +```javascript +GET /api/user/profile +// 返回: { user } +```