feat: 完成情绪博物馆项目重构和功能增强 - 新增日记评论和帖子功能 - 重构前端架构,优化用户体验 - 完善WebSocket通信机制 - 更新项目文档和部署配置

This commit is contained in:
2025-07-27 10:05:59 +08:00
parent 6903ac1c0d
commit cc886cd4d5
126 changed files with 21179 additions and 15734 deletions
+206 -28
View File
@@ -1,83 +1,261 @@
/**
* 认证相关类型定义
*/
// 登录请求
export interface LoginRequest {
/** 账号(支持账号/邮箱/手机号) */
account: string
/** 密码 */
password: string
/** 验证码 */
captcha: string
captchaKey?: string
remember?: boolean
/** 验证码key */
captchaKey: string
/** 记住我 */
rememberMe?: boolean
}
// 注册请求
export interface RegisterRequest {
/** 账号 */
account: string
/** 密码 */
password: string
/** 确认密码 */
confirmPassword: string
/** 用户名 */
username: string
/** 昵称 */
nickname: string
/** 邮箱 */
email: string
/** 手机号 */
phone?: string
email?: string
/** 验证码 */
captcha: string
captchaKey?: string
/** 验证码key */
captchaKey: string
}
// 用户信息
export interface UserInfo {
/** 用户ID */
id: string
/** 账号 */
account: string
username?: string
nickname?: string
/** 用户名 */
username: string
/** 昵称 */
nickname: string
/** 头像 */
avatar?: string
phone?: string
/** 邮箱 */
email?: string
/** 手机号 */
phone?: string
/** 生日 */
birthDate?: string
/** 所在地 */
location?: string
/** 个人简介 */
bio?: string
/** 会员等级 */
memberLevel?: string
/** 使用天数 */
totalDays?: number
/** 成长数据 */
growthStats?: GrowthStats
/** 状态 */
status: number
/** 是否已验证 */
isVerified?: number
/** 创建时间 */
createTime: string
updateTime: string
/** 最后活跃时间 */
lastActiveTime?: string
}
// 登录响应
export interface LoginResponse {
// 成长数据
export interface GrowthStats {
/** 自我感知 */
selfAwareness: number
/** 情绪韧性 */
emotionalResilience: number
/** 行动力 */
actionPower: number
/** 共情力 */
empathy: number
/** 生活热度 */
lifeEnthusiasm: number
}
// 认证响应
export interface AuthResponse {
/** 访问令牌 */
accessToken: string
/** 刷新令牌 */
refreshToken: string
/** 用户信息 */
userInfo: UserInfo
/** 过期时间(秒) */
expiresIn: number
/** 登录时间 */
loginTime: string
}
// 用户信息响应
export interface UserInfoResponse {
/** 用户信息 */
userInfo: UserInfo
}
// 验证码响应
export interface CaptchaResponse {
/** 验证码key */
captchaKey: string
/** 验证码图片(base64 */
captchaImage: string
/** 过期时间(秒) */
expiresIn: number
}
// API响应基础结构
export interface ApiResponse<T = any> {
success: boolean
code: number
message: string
data: T
timestamp: number
}
// 刷新token请求
// 刷新Token请求
export interface RefreshTokenRequest {
/** 刷新令牌 */
refreshToken: string
}
// 修改密码请求
export interface ChangePasswordRequest {
/** 旧密码 */
oldPassword: string
/** 新密码 */
newPassword: string
/** 确认新密码 */
confirmPassword: string
}
// 忘记密码请求
export interface ForgotPasswordRequest {
account: string
captcha: string
captchaKey: string
}
// 重置密码请求
export interface ResetPasswordRequest {
token: string
/** 账号 */
account: string
/** 新密码 */
newPassword: string
/** 确认新密码 */
confirmPassword: string
/** 验证码 */
captcha: string
/** 验证码key */
captchaKey: string
}
// 发送验证码请求
export interface SendCodeRequest {
/** 手机号或邮箱 */
target: string
/** 验证码类型 */
type: 'sms' | 'email'
/** 场景 */
scene: 'register' | 'login' | 'reset_password' | 'change_phone' | 'change_email'
}
// 验证验证码请求
export interface VerifyCodeRequest {
/** 手机号或邮箱 */
target: string
/** 验证码 */
code: string
/** 场景 */
scene: string
}
// 第三方登录请求
export interface OAuthLoginRequest {
/** 平台类型 */
platform: 'wechat' | 'qq' | 'weibo' | 'github'
/** 授权码 */
code: string
/** 状态码 */
state?: string
}
// 绑定第三方账号请求
export interface BindOAuthRequest {
/** 平台类型 */
platform: 'wechat' | 'qq' | 'weibo' | 'github'
/** 授权码 */
code: string
/** 状态码 */
state?: string
}
// 解绑第三方账号请求
export interface UnbindOAuthRequest {
/** 平台类型 */
platform: 'wechat' | 'qq' | 'weibo' | 'github'
}
// 第三方账号信息
export interface OAuthInfo {
/** 平台类型 */
platform: 'wechat' | 'qq' | 'weibo' | 'github'
/** 平台用户ID */
openId: string
/** 平台昵称 */
nickname: string
/** 平台头像 */
avatar: string
/** 绑定时间 */
bindTime: string
}
// 用户权限信息
export interface UserPermission {
/** 角色列表 */
roles: string[]
/** 权限列表 */
permissions: string[]
/** 菜单列表 */
menus: string[]
}
// 登录历史
export interface LoginHistory {
/** ID */
id: string
/** 登录时间 */
loginTime: string
/** 登录IP */
loginIp: string
/** 登录地址 */
loginAddress: string
/** 设备信息 */
deviceInfo: string
/** 浏览器信息 */
browserInfo: string
/** 登录状态 */
status: number
}
// 在线用户信息
export interface OnlineUser {
/** 用户ID */
userId: string
/** 用户名 */
username: string
/** 昵称 */
nickname: string
/** 头像 */
avatar?: string
/** 登录时间 */
loginTime: string
/** 最后活动时间 */
lastActiveTime: string
/** 登录IP */
loginIp: string
/** 设备信息 */
deviceInfo: string
/** 浏览器信息 */
browserInfo: string
}
+17
View File
@@ -0,0 +1,17 @@
/// <reference types="vite/client" />
interface ImportMetaEnv {
readonly VITE_APP_ENV: string
readonly VITE_APP_TITLE: string
readonly VITE_APP_VERSION: string
readonly VITE_API_BASE_URL: string
readonly VITE_WS_BASE_URL: string
readonly VITE_UPLOAD_URL: string
readonly VITE_DEBUG: string
readonly VITE_MOCK: string
readonly VITE_APP_DESCRIPTION: string
}
interface ImportMeta {
readonly env: ImportMetaEnv
}
+9
View File
@@ -0,0 +1,9 @@
declare global {
interface Window {
lucide: {
createIcons: () => void;
};
}
}
export {}
+55 -134
View File
@@ -3,178 +3,99 @@ export interface User {
id: string
username: string
email?: string
phone?: string
avatar?: string
nickname?: string
createTime: string
updateTime: string
}
// 聊天消息类型
// 聊天消息类型 - 与后端MessageResponse匹配
export interface ChatMessage {
id: string
content: string
type: 'user' | 'ai'
type: 'user' | 'ai' | 'system'
timestamp: string
sessionId?: string
conversationId?: string // 改为conversationId以匹配后端
sessionId?: string // 保留sessionId作为别名
status?: 'sending' | 'sent' | 'delivered' | 'read' | 'failed'
sender?: 'user' | 'ai' | 'system'
isRead?: number
error?: string
sender?: string
role?: 'user' | 'assistant' | 'system' // 用于UI显示
}
// 聊天会话类型
// 聊天会话类型 - 与后端ConversationResponse匹配
export interface ChatSession {
id: string
title: string
userId?: string
userId: string
userType?: string
type?: string
status?: string
createTime: string
updateTime: string
messageCount: number
startTime?: string
endTime?: string
lastActiveTime?: string
}
// 日记条目类型
export interface DiaryEntry {
id: string
content: string
mood?: string
tags?: string[]
createTime: string
updateTime: string
aiReply?: string
}
// 个人信息类型
export interface PersonalInfo {
id: string
userId: string
nickname?: string
age?: number
gender?: string
location?: string
occupation?: string
interests: string[]
skills: string[]
quotes: PersonalQuote[]
updateTime: string
}
// 个人语录类型
export interface PersonalQuote {
id: string
content: string
createTime: string
source?: string
}
// 话题类型
export interface Topic {
id: string
title: string
description?: string
tags?: string[]
createTime: string
updateTime: string
status: 'active' | 'completed' | 'paused'
progress?: number
}
// 生活轨迹事件类型
export interface LifeEvent {
id: string
title: string
description?: string
date: string
type: 'milestone' | 'achievement' | 'memory' | 'goal'
importance: 1 | 2 | 3 | 4 | 5
tags?: string[]
attachments?: string[]
}
// 消息类型
export interface Message {
id: string
title: string
content: string
type: 'system' | 'notification' | 'reminder'
status: 'unread' | 'read'
createTime: string
actionUrl?: string
}
// API响应类型
// API响应基础类型
export interface ApiResponse<T = any> {
code: number
message: string
data: T
timestamp: string
success: boolean
}
// 分页参数类型
export interface PaginationParams {
// 分页请求参数
export interface PageParams {
page?: number
size?: number
keyword?: string
}
// 分页响应数据
export interface PageResult<T> {
list: T[]
total: number
page: number
size: number
total?: number
pages: number
}
// 分页响应类型
export interface PaginatedResponse<T> {
list: T[]
pagination: {
page: number
size: number
total: number
totalPages: number
}
// 登录请求参数
export interface LoginRequest {
account: string
password: string
}
// 导航链接类型
export interface NavLink {
name: string
href: string
icon?: string
children?: NavLink[]
// 登录响应数据
export interface LoginResponse {
accessToken: string
refreshToken: string
user: User
}
// 功能特性类型
export interface Feature {
icon: string
title: string
description: string
image: string
alt: string
// 注册请求参数
export interface RegisterRequest {
username: string
password: string
email?: string
nickname?: string
}
// 心情统计类型
export interface MoodStats {
date: string
mood: string
score: number
// 用户资料更新请求
export interface UserProfileUpdateRequest {
nickname?: string
email?: string
avatar?: string
}
// 表单验证规则类型
export interface ValidationRule {
required?: boolean
message?: string
pattern?: RegExp
min?: number
max?: number
validator?: (rule: any, value: any) => Promise<void>
}
// 主题配置类型
export interface ThemeConfig {
primaryColor: string
secondaryColor: string
backgroundColor: string
textColor: string
borderRadius: string
}
// 环境配置类型
export interface EnvConfig {
apiBaseUrl: string
uploadUrl: string
wsUrl: string
isDevelopment: boolean
isProduction: boolean
// 文件上传响应
export interface UploadResponse {
url: string
filename: string
size: number
type: string
}