diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..9ff1711 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,321 @@ +# CLAUDE.md + +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. + +--- + +## 项目概述 + +情绪博物馆 (Emotion Museum) 是一款基于 AI 技术的心理健康应用,通过智能对话、情绪分析、个性化成长方案等功能,帮助用户建立健康的情绪管理习惯。 + +**生产环境地址**: `101.200.208.45` +- 用户前端:http://101.200.208.45/emotion-museum/ +- 管理后台:http://101.200.208.45/emotion-museum-admin/ +- 后端 API:http://101.200.208.45:19089/api +- WebSocket:ws://101.200.208.45:19089/ws + +--- + +## 项目结构 + +``` +. +├── backend-single/ # Spring Boot 单体后端服务 +├── web/ # 用户前端 (Vue3 + TS + Vite) +├── web-admin/ # 管理后台 (Vue3 + TS + Element Plus) +├── UniApp/ # 跨平台移动应用 (微信小程序/H5) +├── mini-program/ # 小程序项目 +├── course-web/ # 课程 Web 项目 +├── life-script/ # 生活脚本工具 +└── tools/ # 工具脚本 +``` + +--- + +## 常用命令 + +### 后端 (backend-single) + +```bash +# 进入后端目录 +cd backend-single + +# 编译打包 +mvn clean package -DskipTests + +# 本地运行 +mvn spring-boot:run + +# 或直接运行 JAR +java -jar target/backend-single-1.0.0.jar + +# 运行测试 +mvn test + +# 运行单个测试类 +mvn test -Dtest=ClassNameTest +``` + +### 用户前端 (web) + +```bash +# 进入前端目录 +cd web + +# 安装依赖 +npm install + +# 启动开发服务器 (端口 5173) +npm run dev + +# 类型检查 +npm run type-check + +# 代码检查 +npm run lint + +# 构建生产版本 +npm run build + +# 运行测试 +npm run test + +# E2E 测试 +npm run test:e2e +``` + +### 管理后台 (web-admin) + +```bash +# 进入目录 +cd web-admin + +# 安装依赖 +npm install + +# 启动开发服务器 (端口 5174) +npm run dev + +# 类型检查 +npm run type-check + +# 代码检查 +npm run lint + +# 构建生产版本 +npm run build +``` + +### UniApp/小程序 + +```bash +# 进入目录 +cd UniApp + +# 开发微信小程序 +npm run dev:mp-weixin + +# 构建微信小程序 +npm run build:mp-weixin + +# 开发 H5 +npm run dev:h5 + +# 构建 H5 +npm run build:h5 +``` + +### 一键部署 + +```bash +# 部署所有服务(后端 + 前端 + 管理后台)到生产服务器 +bash deploy-all.sh + +# 仅部署后端 +bash deploy-all.sh backend + +# 仅部署前端 +bash deploy-all.sh frontend + +# 仅部署管理后台 +bash deploy-all.sh admin +``` + +--- + +## 技术栈 + +### 后端 +- **框架**: Spring Boot 2.7.18 +- **ORM**: MyBatis-Plus 3.5.3.1 +- **数据库**: MySQL 8.0.33 +- **缓存**: Redis 7.0+ +- **JWT**: io.jsonwebtoken 0.11.5 +- **构建**: Maven 3.6+ +- **JDK**: 17 + +### 前端 +- **框架**: Vue 3.4.x + TypeScript 5.x +- **构建**: Vite 5.x +- **UI**: Element Plus 2.4.x +- **样式**: Tailwind CSS 3.4.x +- **状态管理**: Pinia 2.1.x +- **路由**: Vue Router 4.2.x +- **HTTP**: Axios 1.6.x +- **实时通信**: @stomp/stompjs + SockJS +- **图表**: ECharts 5.4.x +- **包管理**: npm 9+ + +### 移动端 +- **框架**: UniApp (Vue 3) +- **平台**: 微信小程序、H5 + +--- + +## 架构规范 + +### 后端分层架构 +- **Controller 层**: 接口定义,参数校验,禁止业务逻辑 +- **Service 层**: 业务逻辑实现 +- **Mapper 层**: 数据访问层 +- **Entity 层**: 数据实体 +- **Request/Response 层**: 入参出参封装 +- **Config 层**: 配置类 + +### 接口设计规范 +- Controller 层路由禁止添加 `/api` 前缀 +- 使用 `@RequestParam` 传递路径参数,禁止使用 `@PathVariable` +- 接口方法参数不超过两个,超出时使用 Request/DTO 对象封装 +- 使用项目已有的 `Result` 作为统一接口返回 +- 禁止使用枚举类型作为接口入参 + +### 前端架构 +- 使用 Vue 3 Composition API (` -