V4.6.6-1 (#656)
This commit is contained in:
@@ -4,14 +4,17 @@ import { UserAuthTypeEnum } from '@fastgpt/global/support/user/constant';
|
||||
import { useToast } from '@/web/common/hooks/useToast';
|
||||
import { feConfigs } from '@/web/common/system/staticData';
|
||||
import { getErrText } from '@fastgpt/global/common/error/utils';
|
||||
import { useTranslation } from 'next-i18next';
|
||||
|
||||
let timer: any;
|
||||
|
||||
export const useSendCode = () => {
|
||||
const { t } = useTranslation();
|
||||
const { toast } = useToast();
|
||||
const [codeSending, setCodeSending] = useState(false);
|
||||
const [codeCountDown, setCodeCountDown] = useState(0);
|
||||
const sendCodeText = useMemo(() => {
|
||||
if (codeSending) return t('support.user.auth.Sending Code');
|
||||
if (codeCountDown >= 10) {
|
||||
return `${codeCountDown}s后重新获取`;
|
||||
}
|
||||
@@ -19,10 +22,11 @@ export const useSendCode = () => {
|
||||
return `0${codeCountDown}s后重新获取`;
|
||||
}
|
||||
return '获取验证码';
|
||||
}, [codeCountDown]);
|
||||
}, [codeCountDown, codeSending, t]);
|
||||
|
||||
const sendCode = useCallback(
|
||||
async ({ username, type }: { username: string; type: `${UserAuthTypeEnum}` }) => {
|
||||
if (codeCountDown > 0) return;
|
||||
setCodeSending(true);
|
||||
try {
|
||||
await sendAuthCode({
|
||||
@@ -52,7 +56,7 @@ export const useSendCode = () => {
|
||||
}
|
||||
setCodeSending(false);
|
||||
},
|
||||
[toast]
|
||||
[codeCountDown, toast]
|
||||
);
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user