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:
co-authored by
Claude Opus 4.6
parent
a76c302d7a
commit
f02b3f4098
@@ -18,6 +18,9 @@ import { Button } from '@/components/ui/Button'
|
||||
import { Input } from '@/components/ui/Input'
|
||||
import { Modal } from '@/components/ui/Modal'
|
||||
import { cn } from '@/lib/utils'
|
||||
import { USE_MOCK } from '@/contexts/AuthContext'
|
||||
import { api } from '@/lib/api'
|
||||
import { useToast } from '@/components/ui/Toast'
|
||||
|
||||
// 模拟登录设备数据
|
||||
const mockDevices = [
|
||||
@@ -108,12 +111,31 @@ function ChangePasswordModal({
|
||||
confirmPassword: '',
|
||||
})
|
||||
const [isSaving, setIsSaving] = useState(false)
|
||||
const toast = useToast()
|
||||
|
||||
const handleSubmit = async () => {
|
||||
if (formData.newPassword !== formData.confirmPassword) {
|
||||
toast.error('两次输入的密码不一致')
|
||||
return
|
||||
}
|
||||
setIsSaving(true)
|
||||
await new Promise(resolve => setTimeout(resolve, 1500))
|
||||
setIsSaving(false)
|
||||
setStep(2)
|
||||
if (USE_MOCK) {
|
||||
await new Promise(resolve => setTimeout(resolve, 1500))
|
||||
setIsSaving(false)
|
||||
setStep(2)
|
||||
return
|
||||
}
|
||||
try {
|
||||
await api.changePassword({
|
||||
old_password: formData.currentPassword,
|
||||
new_password: formData.newPassword,
|
||||
})
|
||||
setIsSaving(false)
|
||||
setStep(2)
|
||||
} catch (err: any) {
|
||||
setIsSaving(false)
|
||||
toast.error(err.message || '密码修改失败')
|
||||
}
|
||||
}
|
||||
|
||||
const handleClose = () => {
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
import React, { useState } from 'react'
|
||||
import { useRouter } from 'next/navigation'
|
||||
import { USE_MOCK } from '@/contexts/AuthContext'
|
||||
import { api } from '@/lib/api'
|
||||
import {
|
||||
ArrowLeft,
|
||||
Mail,
|
||||
|
||||
Reference in New Issue
Block a user