首页数据
获取首页展示的所有数据。
接口信息
- 请求路径:
GET /api/home - 认证方式: 无需认证(公开接口)
- 内容类型:
application/json
响应字段
| 字段名 | 类型 | 说明 |
|---|---|---|
| hero | object | 首页横幅信息 |
| hero.title | string | 标题 |
| hero.subtitle | string | 副标题 |
| hero.avatar | string | 头像 URL |
| hero.backgroundImage | string | 背景图片 URL |
| stats | object | 统计数据 |
| stats.articles | number | 文章总数 |
| stats.projects | number | 项目总数 |
| stats.views | number | 总访问量 |
| carousels | array | 轮播图列表 |
| latestArticles | array | 最新文章 |
| featuredProjects | array | 推荐项目 |
| skills | array | 技能列表 |
请求示例
bash
curl http://localhost:3000/api/home响应示例
json
{
"success": true,
"data": {
"hero": {
"title": "欢迎来到我的博客",
"subtitle": "分享技术与生活",
"avatar": "https://example.com/avatar.jpg",
"backgroundImage": "https://example.com/hero-bg.jpg"
},
"stats": {
"articles": 150,
"projects": 25,
"views": 12500
},
"carousels": [
{
"id": 1,
"title": "轮播图1",
"imageUrl": "https://example.com/banner1.jpg",
"linkUrl": "/articles/1"
}
],
"latestArticles": [
{
"id": 1,
"title": "最新文章",
"excerpt": "文章摘要",
"coverImage": "https://example.com/article.jpg",
"createdAt": "2024-01-15T10:00:00.000Z"
}
],
"featuredProjects": [
{
"id": 1,
"title": "项目1",
"description": "项目描述",
"coverImage": "https://example.com/project.jpg",
"techStack": ["Vue.js", "TypeScript"]
}
],
"skills": [
{
"name": "Vue.js",
"category": "frontend",
"level": 90
}
]
}
}错误响应
| HTTP 状态码 | 说明 |
|---|---|
| 500 | 服务器错误 |
缓存
该接口默认缓存 5 分钟,以提升性能。