'use client' import React, { useState } from 'react' import { useRouter } from 'next/navigation' import { ArrowLeft, Key, ShieldCheck, Smartphone, ChevronRight, Check, X, Eye, EyeOff, } from 'lucide-react' import { ResponsiveLayout } from '@/components/layout/ResponsiveLayout' import { Button } from '@/components/ui/Button' import { Input } from '@/components/ui/Input' import { Modal } from '@/components/ui/Modal' import { cn } from '@/lib/utils' // 模拟登录设备数据 const mockDevices = [ { id: '1', name: 'iPhone 15 Pro', type: 'mobile', location: '北京', lastActive: '当前设备', isCurrent: true, }, { id: '2', name: 'MacBook Pro', type: 'desktop', location: '北京', lastActive: '2小时前', isCurrent: false, }, { id: '3', name: 'iPad Air', type: 'tablet', location: '上海', lastActive: '3天前', isCurrent: false, }, ] // 设置项组件 function SettingItem({ icon: Icon, iconColor, title, description, badge, onClick, showArrow = true, }: { icon: React.ElementType iconColor: string title: string description: string badge?: React.ReactNode onClick?: () => void showArrow?: boolean }) { return ( ) } // 修改密码弹窗 function ChangePasswordModal({ isOpen, onClose, }: { isOpen: boolean onClose: () => void }) { const [step, setStep] = useState(1) const [showPasswords, setShowPasswords] = useState({ current: false, new: false, confirm: false, }) const [formData, setFormData] = useState({ currentPassword: '', newPassword: '', confirmPassword: '', }) const [isSaving, setIsSaving] = useState(false) const handleSubmit = async () => { setIsSaving(true) await new Promise(resolve => setTimeout(resolve, 1500)) setIsSaving(false) setStep(2) } const handleClose = () => { setStep(1) setFormData({ currentPassword: '', newPassword: '', confirmPassword: '' }) onClose() } return ( {step === 1 ? (
{/* 当前密码 */}
setFormData(prev => ({ ...prev, currentPassword: e.target.value }))} placeholder="请输入当前密码" />
{/* 新密码 */}
setFormData(prev => ({ ...prev, newPassword: e.target.value }))} placeholder="请输入新密码(8-20位)" />

密码需包含字母和数字,长度8-20位

{/* 确认密码 */}
setFormData(prev => ({ ...prev, confirmPassword: e.target.value }))} placeholder="请再次输入新密码" />
{/* 按钮 */}
) : (

密码修改成功

下次登录请使用新密码

)}
) } // 设备管理弹窗 function DeviceManageModal({ isOpen, onClose, }: { isOpen: boolean onClose: () => void }) { const [devices, setDevices] = useState(mockDevices) const handleRemoveDevice = (deviceId: string) => { setDevices(prev => prev.filter(d => d.id !== deviceId)) } return (

管理已登录此账号的设备,可移除不再使用的设备以保障账户安全。

{devices.map((device) => (
{device.name} {device.isCurrent && ( 当前 )}
{device.location} · {device.lastActive}
{!device.isCurrent && ( )}
))}
) } export default function AccountSettingsPage() { const router = useRouter() const [showPasswordModal, setShowPasswordModal] = useState(false) const [showDeviceModal, setShowDeviceModal] = useState(false) const [twoFactorEnabled, setTwoFactorEnabled] = useState(true) return (
{/* 顶部栏 */}

账户设置

管理密码和账户安全选项

{/* 内容区 */}
{/* 账户安全 */}

账户安全

setShowPasswordModal(true)} /> {twoFactorEnabled ? '已开启' : '未开启'} } onClick={() => setTwoFactorEnabled(!twoFactorEnabled)} /> setShowDeviceModal(true)} />
{/* 危险区域 */}

危险区域

注销账户 永久删除您的账户和所有相关数据,此操作不可撤销
{/* 弹窗 */} setShowPasswordModal(false)} /> setShowDeviceModal(false)} />
) }