Let's use AI to Earn!
TypeScript auto-publishdouyindouyin-apielectron-appelectron-reactkuaishoukwaipublishedshipinhaotoolxiaohongshu
fix(web): Forgot password function not working (#334)
布莱恩·奥夫托·杰森张40070a21bb63
diff --git a/project/web/src/api/apiReq.ts b/project/web/src/api/apiReq.tsindex 67e9ecc5..7ca12656 100644--- a/project/web/src/api/apiReq.ts+++ b/project/web/src/api/apiReq.ts@@ -84,7 +84,7 @@ export function resetPasswordApi(data: {password: string}) {const hash = md5(data.password)- return http.post<LoginResponse>('login/repassword/mail', {+ return http.put<LoginResponse>('login/repassword/mail', {...data,password: hash,})diff --git a/project/web/src/app/[lng]/forgot-password/page.tsx b/project/web/src/app/[lng]/forgot-password/page.tsxindex 503a4989..ca2452a4 100644--- a/project/web/src/app/[lng]/forgot-password/page.tsx+++ b/project/web/src/app/[lng]/forgot-password/page.tsx@@ -16,13 +16,13 @@ export default function ForgotPasswordPage() {const [isModalOpen, setIsModalOpen] = useState(false)const [resetForm] = Form.useForm()- // 处理Modal关闭+ // Handle modal closeconst handleModalClose = () => {setIsModalOpen(false)resetForm.resetFields()}- // 处理发送重置密码邮件+ // Handle send reset password emailconst handleSubmit = async (values: { mail: string }) => {try {setLoading(true)@@ -41,7 +41,7 @@ export default function ForgotPasswordPage() {}}- // 处理重置密码+ // Handle reset passwordconst handleResetPassword = async (values: { code: string, password: string }) => {try {setLoading(true)diff --git a/project/web/src/app/[lng]/login/page.tsx b/project/web/src/app/[lng]/login/page.tsxindex 3f0e71d5..c89f75e4 100644--- a/project/web/src/app/[lng]/login/page.tsx+++ b/project/web/src/app/[lng]/login/page.tsx@@ -5,7 +5,6 @@ import { Button, Form, Input, message, Modal } from 'antd'import Link from 'next/link'import { useRouter } from 'next/navigation'import { useEffect, useState } from 'react'-import { FcGoogle } from 'react-icons/fc'import {checkRegistStatusApi,getRegistUrlApi,@@ -42,14 +41,14 @@ export default function LoginPage() {if (response.code === 0) {if (response.data.type === 'regist') {- // 用户未注册,显示弹窗提示,并设置表单的默认密码值+ // User not registered, show modal prompt and set default password value for formsetRegistCode(response.data.code || '')- form.setFieldsValue({ password }) // 设置密码字段的默认值+ form.setFieldsValue({ password }) // Set default value for password fieldsetIsModalOpen(true)setIsChecking(true)}else if (response.data.token) {- // 登录成功+ // Login successfulsetToken(response.data.token)if (response.data.userInfo) {setUserInfo(response.data.userInfo)@@ -85,10 +84,10 @@ export default function LoginPage() {}if (response.code === 0 && response.data.token) {- // 注册成功+ // Registration successfulsetIsActivating(false)setIsModalOpen(false)- form.resetFields() // 重置表单+ form.resetFields() // Reset formsetToken(response.data.token)if (response.data.userInfo) {setUserInfo(response.data.userInfo)@@ -107,7 +106,7 @@ export default function LoginPage() {}}- // 组件卸载时清除定时器+ // Clear timer when component unmountsuseEffect(() => {return () => {if (activationTimer) {@@ -135,7 +134,7 @@ export default function LoginPage() {if (response.code === 0) {if (response.data.type === 'login') {- // 直接登录成功+ // Direct login successfulsetToken(response.data.token)if (response.data.userInfo) {setUserInfo(response.data.userInfo)@@ -219,7 +218,7 @@ export default function LoginPage() {setIsModalOpen(false)setIsChecking(false)setIsActivating(false)- form.resetFields() // 重置表单+ form.resetFields() // Reset formif (activationTimer) {clearInterval(activationTimer)}