feat: 前端对接 Profile/Messages/Settings 页面 API

- 3 消息页 + 2 资料编辑页 + 3 设置页 + 2 资料展示页
- api.ts 新增 Profile/Messages/ChangePassword 等类型和方法
- SSEContext 事件映射修复 + 断线重连修复
- 剩余页面加 USE_MOCK 双模式,52/55 页面已完成

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Your Name
2026-02-10 10:27:59 +08:00
co-authored by Claude Opus 4.6
parent a76c302d7a
commit f02b3f4098
14 changed files with 473 additions and 41 deletions
+149 -3
View File
@@ -136,9 +136,11 @@ export interface RefreshTokenResponse {
}
export interface UploadPolicyResponse {
access_key_id: string
q_sign_algorithm: string
q_ak: string
q_key_time: string
q_signature: string
policy: string
signature: string
host: string
dir: string
expire: number
@@ -153,6 +155,92 @@ export interface FileUploadedResponse {
file_type: string
}
// ==================== 用户资料类型 ====================
export interface BrandProfileInfo {
id: string
name: string
logo?: string
description?: string
contact_name?: string
contact_phone?: string
contact_email?: string
}
export interface AgencyProfileInfo {
id: string
name: string
logo?: string
description?: string
contact_name?: string
contact_phone?: string
contact_email?: string
}
export interface CreatorProfileInfo {
id: string
name: string
avatar?: string
bio?: string
douyin_account?: string
xiaohongshu_account?: string
bilibili_account?: string
}
export interface ProfileResponse {
id: string
email?: string
phone?: string
name: string
avatar?: string
role: string
is_verified: boolean
created_at?: string
brand?: BrandProfileInfo
agency?: AgencyProfileInfo
creator?: CreatorProfileInfo
}
export interface ProfileUpdateRequest {
name?: string
avatar?: string
phone?: string
description?: string
contact_name?: string
contact_phone?: string
contact_email?: string
bio?: string
douyin_account?: string
xiaohongshu_account?: string
bilibili_account?: string
}
export interface ChangePasswordRequest {
old_password: string
new_password: string
}
// ==================== 消息类型 ====================
export interface MessageItem {
id: string
type: string
title: string
content: string
is_read: boolean
related_task_id?: string
related_project_id?: string
sender_name?: string
created_at?: string
}
export interface MessageListResponse {
items: MessageItem[]
total: number
page: number
page_size: number
}
// ==================== Token 管理 ====================
function getAccessToken(): string | null {
@@ -338,7 +426,7 @@ class ApiClient {
// ==================== 文件上传 ====================
/**
* 获取 OSS 上传凭证
* 获取 COS 上传凭证
*/
async getUploadPolicy(fileType: string = 'general'): Promise<UploadPolicyResponse> {
const response = await this.client.post<UploadPolicyResponse>('/upload/policy', {
@@ -803,6 +891,64 @@ class ApiClient {
return response.data
}
// ==================== 用户资料 ====================
/**
* 获取当前用户资料
*/
async getProfile(): Promise<ProfileResponse> {
const response = await this.client.get<ProfileResponse>('/profile')
return response.data
}
/**
* 更新用户资料
*/
async updateProfile(data: ProfileUpdateRequest): Promise<ProfileResponse> {
const response = await this.client.put<ProfileResponse>('/profile', data)
return response.data
}
/**
* 修改密码
*/
async changePassword(data: ChangePasswordRequest): Promise<{ message: string }> {
const response = await this.client.put<{ message: string }>('/profile/password', data)
return response.data
}
// ==================== 消息/通知 ====================
/**
* 获取消息列表
*/
async getMessages(params?: { page?: number; page_size?: number; is_read?: boolean; type?: string }): Promise<MessageListResponse> {
const response = await this.client.get<MessageListResponse>('/messages', { params })
return response.data
}
/**
* 获取未读消息数
*/
async getUnreadCount(): Promise<{ count: number }> {
const response = await this.client.get<{ count: number }>('/messages/unread-count')
return response.data
}
/**
* 标记单条消息已读
*/
async markMessageAsRead(messageId: string): Promise<void> {
await this.client.put(`/messages/${messageId}/read`)
}
/**
* 标记所有消息已读
*/
async markAllMessagesAsRead(): Promise<void> {
await this.client.put('/messages/read-all')
}
// ==================== 健康检查 ====================
/**