From f021ff2a746b6d8c8f6f71f62dd40510c7e485bd Mon Sep 17 00:00:00 2001 From: xiaoxia Date: Thu, 30 Jul 2026 07:42:46 +0800 Subject: [PATCH] =?UTF-8?q?refactor(BindContactModal):=20=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E6=97=A7=E7=9A=84=E5=8D=95=E6=96=87=E4=BB=B6=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=EF=BC=88=E5=B7=B2=E7=9B=AE=E5=BD=95=E5=8C=96=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/auth/BindContactModal.tsx | 180 ------------------ 1 file changed, 180 deletions(-) delete mode 100644 apps/web/src/components/auth/BindContactModal.tsx diff --git a/apps/web/src/components/auth/BindContactModal.tsx b/apps/web/src/components/auth/BindContactModal.tsx deleted file mode 100644 index c600657de..000000000 --- a/apps/web/src/components/auth/BindContactModal.tsx +++ /dev/null @@ -1,180 +0,0 @@ -import React, { useState, useEffect, useRef } from "react" -import { Modal, Tabs, Form, Input, Button, message } from "antd" -import { sendVerificationCode, bindContact, type BindContactResponse } from "@/api/auth" - -interface BindContactModalProps { - open: boolean - onSuccess?: (user: BindContactResponse["user"]) => void - onCancel?: () => void -} - -const BindContactModal: React.FC = ({ open, onSuccess, onCancel }) => { - const [activeTab, setActiveTab] = useState<"email" | "phone">("email") - const [form] = Form.useForm() - const [loading, setLoading] = useState(false) - const [codeLoading, setCodeLoading] = useState(false) - const [countdown, setCountdown] = useState(0) - const timerRef = useRef | null>(null) - - useEffect(() => { - if (countdown > 0) { - timerRef.current = setInterval(() => { - setCountdown((prev) => prev - 1) - }, 1000) - } else if (timerRef.current) { - clearInterval(timerRef.current) - timerRef.current = null - } - return () => { - if (timerRef.current) clearInterval(timerRef.current) - } - }, [countdown]) - - useEffect(() => { - if (open) { - form.resetFields() - setCountdown(0) - } - }, [open, form]) - - const handleSendCode = async () => { - try { - const value = form.getFieldValue(activeTab === "email" ? "email" : "phone") - if (!value) { - message.warning(activeTab === "email" ? "请输入邮箱" : "请输入手机号") - return - } - setCodeLoading(true) - await sendVerificationCode({ - target: activeTab, - value, - purpose: "bind", - }) - message.success("验证码已发送") - setCountdown(60) - } catch (error) { - // error handled by interceptor - } finally { - setCodeLoading(false) - } - } - - const handleSubmit = async () => { - try { - const values = await form.validateFields() - setLoading(true) - - const payload = - activeTab === "email" - ? { email: values.email, email_code: values.code } - : { phone: values.phone, phone_code: values.code } - - const result = await bindContact(payload) - - message.success("绑定成功") - onSuccess?.(result.user) - } catch (error) { - // error handled by interceptor - } finally { - setLoading(false) - } - } - - return ( - -

为了保障账号安全,请绑定您的邮箱或手机号

- - setActiveTab(key as "email" | "phone")} - items={[ - { - key: "email", - label: "邮箱绑定", - children: ( -
- - - - -
- - -
-
-
- ), - }, - { - key: "phone", - label: "手机绑定", - children: ( -
- - - - -
- - -
-
-
- ), - }, - ]} - /> - -
- -
-
- ) -} - -export default BindContactModal