import { Avatar } from '@heroui/avatar'; import { Button } from '@heroui/button'; import { Dropdown, DropdownItem, DropdownMenu, DropdownTrigger } from '@heroui/dropdown'; import { Image } from '@heroui/image'; import { Input } from '@heroui/input'; import { useState } from 'react'; import { toast } from 'react-hot-toast'; import { IoChevronDown } from 'react-icons/io5'; import type { QQItem } from '@/components/quick_login'; import { isQQQuickNewItem } from '@/utils/qq'; import TencentCaptchaModal from '@/components/tencent_captcha'; import type { CaptchaCallbackData } from '@/components/tencent_captcha'; import NewDeviceVerify from '@/components/new_device_verify'; interface PasswordLoginProps { onSubmit: (uin: string, password: string) => void; onCaptchaSubmit?: (uin: string, password: string, captchaData: CaptchaCallbackData) => void; onNewDeviceVerified?: (token: string) => void; isLoading: boolean; qqList: (QQItem | LoginListItem)[]; captchaState?: { needCaptcha: boolean; proofWaterUrl: string; uin: string; password: string; } | null; newDeviceState?: { needNewDevice: boolean; jumpUrl: string; uin: string; } | null; onCaptchaCancel?: () => void; onNewDeviceCancel?: () => void; } const PasswordLogin: React.FC = ({ onSubmit, onCaptchaSubmit, onNewDeviceVerified, isLoading, qqList, captchaState, newDeviceState, onCaptchaCancel, onNewDeviceCancel }) => { const [uin, setUin] = useState(''); const [password, setPassword] = useState(''); const handleSubmit = () => { if (!uin) { toast.error('请输入QQ号'); return; } if (!password) { toast.error('请输入密码'); return; } onSubmit(uin, password); }; return (
{newDeviceState?.needNewDevice && newDeviceState.jumpUrl ? ( onNewDeviceVerified?.(token)} onCancel={onNewDeviceCancel} /> ) : captchaState?.needCaptcha && captchaState.proofWaterUrl ? (

登录需要安全验证,请完成验证码

{ onCaptchaSubmit?.(captchaState.uin, captchaState.password, data); }} onCancel={onCaptchaCancel} />
) : ( <>
QQ Avatar
setUin(key.toString())} > {(item) => (
{isQQQuickNewItem(item) ? `${item.nickName}(${item.uin})` : item.uin}
)}
} />
)}
); }; export default PasswordLogin;