Skip to content

首页数据

获取首页展示的所有数据。

接口信息

  • 请求路径: GET /api/home
  • 认证方式: 无需认证(公开接口)
  • 内容类型: application/json

响应字段

字段名类型说明
heroobject首页横幅信息
hero.titlestring标题
hero.subtitlestring副标题
hero.avatarstring头像 URL
hero.backgroundImagestring背景图片 URL
statsobject统计数据
stats.articlesnumber文章总数
stats.projectsnumber项目总数
stats.viewsnumber总访问量
carouselsarray轮播图列表
latestArticlesarray最新文章
featuredProjectsarray推荐项目
skillsarray技能列表

请求示例

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 分钟,以提升性能。