获取项目详情
根据项目 ID 获取单个项目的详细信息。
接口信息
- 请求路径:
GET /api/projects/:id - 认证方式: 无需认证(公开接口)
- 内容类型:
application/json
路径参数
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| id | number | 是 | 项目 ID |
响应字段
| 字段名 | 类型 | 说明 |
|---|---|---|
| id | number | 项目 ID |
| title | string | 项目标题 |
| description | string | 项目描述 |
| content | string | 项目详细内容(Markdown) |
| coverImage | string | 封面图片 URL |
| demoUrl | string | 演示链接 |
| repoUrl | string | 代码仓库链接 |
| techStack | array | 技术栈标签 |
| screenshots | array | 项目截图列表 |
| likeCount | number | 点赞次数 |
| viewCount | number | 浏览次数 |
| status | string | 状态:published/draft |
| createdAt | string | 创建时间 |
| updatedAt | string | 更新时间 |
请求示例
bash
curl http://localhost:3000/api/projects/1响应示例
json
{
"success": true,
"data": {
"id": 1,
"title": "个人博客系统",
"description": "基于 Nuxt.js 3 的现代化博客系统",
"content": "# 项目介绍\n\n详细的项目介绍内容...",
"coverImage": "https://example.com/project1.jpg",
"demoUrl": "https://demo.example.com",
"repoUrl": "https://github.com/user/blog",
"techStack": ["Nuxt.js", "TypeScript", "Tailwind CSS"],
"screenshots": [
"https://example.com/screenshot1.jpg",
"https://example.com/screenshot2.jpg"
],
"likeCount": 45,
"viewCount": 230,
"status": "published",
"createdAt": "2024-01-15T10:00:00.000Z",
"updatedAt": "2024-01-20T15:30:00.000Z"
}
}错误响应
| HTTP 状态码 | 说明 |
|---|---|
| 404 | 项目不存在 |
| 500 | 服务器错误 |