跳到主要内容

官网系统快速启动

本指南帮助你在 5 分钟内启动整个官网系统。

前提条件

  • 后端服务 yudao-server 已在本地运行(端口 48080)
  • MySQL 8.0+ 数据库已初始化
  • Redis 7.x 服务运行中
  • Node.js 18+ 已安装

第一步:启动后端服务

官网后端已集成在 yudao-server 中,确保 yudao-module-website 已作为依赖引入。

# 查看 module-website 是否在 yudao-server 的 pom.xml 中
cd anli-service-api
grep -r "yudao-module-website" yudao-server/pom.xml

# 启动后端服务
cd yudao-server
mvn spring-boot:run -Dspring-boot.run.profiles=local

启动后 API 端点:

  • 管理后台:http://localhost:48080/admin-api/website/xxx
  • 前台公开:http://localhost:48080/app-api/website/xxx

第二步:启动管理后台(Vben Admin)

cd anli-admin-vben/apps/web-antd
pnpm dev

管理后台访问 http://localhost:5173,使用超级管理员账号登录后可在"官网管理"菜单下操作各功能模块。

第三步:启动前台官网(SSR)

cd jiudi-official-web

# 安装依赖
pnpm install

# 启动开发服务器
pnpm dev

前台官网访问 http://localhost:3000,支持热更新开发。

验证运行

# 1. 健康检查 - 后端
curl http://localhost:48080/actuator/health

# 2. 前台 API - 首页数据
curl http://localhost:48080/app-api/website/home/data

# 3. 前台 API - 解决方案列表
curl http://localhost:48080/app-api/website/solution/list

# 4. 管理后台 API(需 Token)
curl -H "Authorization: Bearer {token}" http://localhost:48080/admin-api/website/industry-category/tree

开发环境配置

前台环境变量

编辑 jiudi-official-web/.env.development

# API 基础地址(Nuxt 运行时配置)
NUXT_PUBLIC_API_BASE=http://localhost:48080

前台代理配置

Nuxt 的 nuxt.config.ts 已配置代理,开发时无需处理跨域:

nitro: {
devProxy: {
'/app-api': {
target: 'http://localhost:48080',
changeOrigin: true
}
}
}

管理后台 API 地址

管理后台通过 .env.development 或 Vite 代理配置指向后端 http://localhost:48080

目录结构速览

anli-service-api/yudao-module-website/ # 后端模块
├── controller/
│ ├── admin/ # 管理后台接口(/admin-api/website/)
│ └── app/ # 前台接口(/app-api/website/)
├── service/ # 业务逻辑
├── dal/
│ ├── dataobject/ # 数据实体
│ └── mysql/ # Mapper 接口
└── enums/ # 错误码

anli-admin-vben/apps/web-antd/src/
├── api/website/ # 后台管理 API 定义
└── views/website/ # 后台管理页面

jiudi-official-web/ # 前台 SSR 项目
├── pages/ # 页面(路由)
├── components/ # 通用组件
├── composables/ # 组合式函数
├── plugins/ # 插件(埋点等)
├── stores/ # 状态管理
├── layouts/ # 布局
└── middleware/ # 路由中间件