This commit is contained in:
Archer
2023-12-27 11:07:39 +08:00
committed by GitHub
parent 86286efb54
commit 759a2330e6
182 changed files with 3099 additions and 81685 deletions

View File

@@ -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 {