fix: pc端修改
This commit is contained in:
@@ -10,12 +10,13 @@ import {
|
||||
NEXT_PUBLIC_DEFAULT_USER_EMAIL,
|
||||
NEXT_PUBLIC_DEFAULT_USER_PASSWORD,
|
||||
} from '@/config/constants';
|
||||
import useGlobalStore from '@/config/use-global';
|
||||
import { getRedirectUrl, setAuthorization } from '@/utils/common';
|
||||
import LoginForm from './login-form';
|
||||
import RegisterForm from './register-form';
|
||||
import ResetForm from './reset-form';
|
||||
|
||||
export default function EmailAuthForm() {
|
||||
export default function EmailAuthForm(props: { isRedirect: boolean; hide: () => void }) {
|
||||
const t = useTranslations('auth');
|
||||
const router = useRouter();
|
||||
const [type, setType] = useState<'login' | 'register' | 'reset'>('login');
|
||||
@@ -27,13 +28,19 @@ export default function EmailAuthForm() {
|
||||
email: NEXT_PUBLIC_DEFAULT_USER_EMAIL,
|
||||
password: NEXT_PUBLIC_DEFAULT_USER_PASSWORD,
|
||||
});
|
||||
|
||||
const { getUserInfo } = useGlobalStore();
|
||||
const handleFormSubmit = async (params: any) => {
|
||||
const onLogin = async (token?: string) => {
|
||||
if (!token) return;
|
||||
setAuthorization(token);
|
||||
router.replace(getRedirectUrl());
|
||||
router.refresh();
|
||||
|
||||
if (props.isRedirect) {
|
||||
router.replace(getRedirectUrl());
|
||||
router.refresh();
|
||||
} else {
|
||||
await getUserInfo();
|
||||
props.hide();
|
||||
}
|
||||
};
|
||||
startTransition(async () => {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user