'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 ( {title} {description} {badge} {showArrow && } ) } // 修改密码弹窗 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="请输入当前密码" /> setShowPasswords(prev => ({ ...prev, current: !prev.current }))} className="absolute right-3 top-1/2 -translate-y-1/2 text-text-tertiary hover:text-text-secondary" > {showPasswords.current ? : } {/* 新密码 */} 新密码 setFormData(prev => ({ ...prev, newPassword: e.target.value }))} placeholder="请输入新密码(8-20位)" /> setShowPasswords(prev => ({ ...prev, new: !prev.new }))} className="absolute right-3 top-1/2 -translate-y-1/2 text-text-tertiary hover:text-text-secondary" > {showPasswords.new ? : } 密码需包含字母和数字,长度8-20位 {/* 确认密码 */} 确认新密码 setFormData(prev => ({ ...prev, confirmPassword: e.target.value }))} placeholder="请再次输入新密码" /> setShowPasswords(prev => ({ ...prev, confirm: !prev.confirm }))} className="absolute right-3 top-1/2 -translate-y-1/2 text-text-tertiary hover:text-text-secondary" > {showPasswords.confirm ? : } {/* 按钮 */} 取消 {isSaving ? '提交中...' : '确认修改'} ) : ( 密码修改成功 下次登录请使用新密码 完成 )} ) } // 设备管理弹窗 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 && ( handleRemoveDevice(device.id)} className="text-accent-coral hover:text-accent-coral/80 text-sm font-medium" > 移除 )} ))} 关闭 ) } export default function AccountSettingsPage() { const router = useRouter() const [showPasswordModal, setShowPasswordModal] = useState(false) const [showDeviceModal, setShowDeviceModal] = useState(false) const [twoFactorEnabled, setTwoFactorEnabled] = useState(true) return ( {/* 顶部栏 */} router.back()} className="w-10 h-10 rounded-xl bg-bg-elevated flex items-center justify-center hover:bg-bg-elevated/80 transition-colors" > 账户设置 管理密码和账户安全选项 {/* 内容区 */} {/* 账户安全 */} 账户安全 setShowPasswordModal(true)} /> {twoFactorEnabled ? '已开启' : '未开启'} } onClick={() => setTwoFactorEnabled(!twoFactorEnabled)} /> setShowDeviceModal(true)} /> {/* 危险区域 */} 危险区域 注销账户 永久删除您的账户和所有相关数据,此操作不可撤销 注销账户 {/* 弹窗 */} setShowPasswordModal(false)} /> setShowDeviceModal(false)} /> ) }
密码需包含字母和数字,长度8-20位
密码修改成功
下次登录请使用新密码
管理已登录此账号的设备,可移除不再使用的设备以保障账户安全。
管理密码和账户安全选项