diff --git a/app/app/(auth)/login/user-login-core.tsx b/app/app/(auth)/login/user-login-core.tsx index 5cb80f36b..bcb6df174 100644 --- a/app/app/(auth)/login/user-login-core.tsx +++ b/app/app/(auth)/login/user-login-core.tsx @@ -1,23 +1,31 @@ "use client"; import { signIn } from "next-auth/react"; -import React, { useState, useEffect, useRef, use } from "react"; +import React, { useState, useEffect, useRef, use, useMemo } from "react"; import { isName } from "@/lib/auth_list"; import { Form, Tabs, Input, + Button, InputRef, notification as notificationModule, NotificationArgsProps, } from "antd"; -import { UserOutlined, MailOutlined } from "@ant-design/icons"; +import { + UserOutlined, + MailOutlined, + LoadingOutlined, + AudioOutlined, +} from "@ant-design/icons"; import type { FormProps, TabsProps } from "antd"; import { SignInOptions } from "next-auth/react"; import { getSession } from "next-auth/react"; export default function UserLoginCore() { const [loading, setLoading] = useState(false); + const [capLoading, setCapLoading] = useState(false); + const [timeLeft, setTimeLeft] = useState(0); const [loginForm] = Form.useForm(); const [loginMethod, setLoginMethod] = useState<"common" | "cap">("common"); const [notification, notificationContextHolder] = @@ -37,11 +45,53 @@ export default function UserLoginCore() { } }; + useEffect(() => { + let timer = undefined; + if (timeLeft > 0) { + timer = setTimeout(() => { + setTimeLeft(timeLeft - 1); + }, 1000); + } + + return () => clearTimeout(timer); + }, [timeLeft]); + + const capIcon = useMemo(() => { + if (capLoading) { + return ( + + ); + } + return <>>; + }, [capLoading]); + const sendCap = () => { + loginForm.validateFields().then((values) => { + setCapLoading(true); + signIn("email", { + redirect: false, + email: values.email, + }).then((result) => { + console.log("33333333333", result); + setCapLoading(false); + setTimeLeft(60); + }); + }); + + // const email = loginForm.getFieldValue("email"); + // console.log('----------', email) + }; + // const [error, setError] = useState(false); type FieldType = { username?: string; password?: string; email?: string; + cap?: string; }; const onFinish: FormProps["onFinish"] = (values) => { setLoading(true); @@ -52,7 +102,20 @@ export default function UserLoginCore() { if (loginMethod === "cap") { loginProvider = "email"; - signInOptions = { ...signInOptions, email: values.email }; + signInOptions = { + ...signInOptions, + email: values.email, + cap: values.cap, + }; + fetch( + `/api/auth/callback/email?token=${values.cap}&email=${values.email}`, + ).then((result) => { + console.log("------------", result); + if (result.redirected) { + window.location.href = result.url; + } + }); + return; } else { loginProvider = "credentials"; signInOptions = { @@ -257,26 +320,63 @@ export default function UserLoginCore() { type: "email", message: "The input is not valid E-mail!", }, - // { - // validator: async (_, value) => { - // const username_value = loginForm.getFieldValue("username"); - // if (value && username_value) { - // return Promise.reject(new Error("Field must be unique!")); - // } - // }, - // }, + { + required: true, + }, ]} > } + addonAfter={ + 0} + className="align-bottom" + > + {capLoading ? ( + + + + ) : timeLeft > 0 ? ( + + {timeLeft}秒后重试 + + ) : ( + "发送验证码" + )} + + } + size="middle" placeholder="邮箱验证,测试阶段" className={ "text-sm font-medium text-stone-600 dark:text-stone-400" } /> + + + > )} diff --git a/app/app/login.scss b/app/app/login.scss index d2519df83..663cf7b2f 100644 --- a/app/app/login.scss +++ b/app/app/login.scss @@ -126,3 +126,7 @@ input { #set-password-form { text-align: right !important; } + +#login-form .ant-input-group-addon { + background-color: white; +} diff --git a/app/components/chat.module.scss b/app/components/chat.module.scss index 2707903be..fa932bc3f 100644 --- a/app/components/chat.module.scss +++ b/app/components/chat.module.scss @@ -550,8 +550,7 @@ .chat-input-panel { position: relative; width: 100%; - padding: 20px; - padding-top: 10px; + padding: 10px 20px 25px; box-sizing: border-box; flex-direction: column; border-top: var(--border-in-light); @@ -667,6 +666,10 @@ position: absolute; right: 100px; bottom: 32px; + + @media only screen and (max-width: 600px) { + right: 110px; + } } @media only screen and (max-width: 600px) { @@ -677,4 +680,20 @@ .chat-input-send { bottom: 30px; } + .bottom-tip { + padding-left: 60px; + padding-right: 60px; + } +} + +.bottom-tip { + text-align: center; + margin-top: -25px; + font-size: .75rem; + line-height: 1.5rem; + //margin-bottom: .5rem; + //padding-top: .5rem; + position: relative; + z-index: 1; + color: #7d7d7d !important; } diff --git a/app/components/chat.tsx b/app/components/chat.tsx index ae0ad1d39..64504cdd3 100644 --- a/app/components/chat.tsx +++ b/app/components/chat.tsx @@ -1786,6 +1786,19 @@ function _Chat() { /> + + AI 也可能会犯错。请核查重要信息。 + {showExport && ( setShowExport(false)} /> diff --git a/app/components/settings.tsx b/app/components/settings.tsx index b36c6e58c..6abf9fd95 100644 --- a/app/components/settings.tsx +++ b/app/components/settings.tsx @@ -677,7 +677,7 @@ export function Settings() { - + - - - - Sign in to ${escapedHost} - - - - - - - Sign - in - - - - - - - If you did not request this email you can safely ignore it. - - - -