生产管理系统 - 激活、删除的联调

This commit is contained in:
2025-11-12 14:34:34 +08:00
parent 8fefadaf55
commit dcd7ddeb71
16 changed files with 487 additions and 458 deletions

View File

@@ -27,8 +27,8 @@ import {
} from 'lucide-react';
import { toast } from 'sonner';
import { useAuth } from '@/components/auth/AuthContext';
import { authReducer, initialAuthState, AuthState, AuthAction } from './authReducer';
import { getCaptchaApiV1AuthCaptchaGet, loginApiV1AuthLoginPost } from '@/lib/api/sdk.gen';
import { authReducer, initialAuthState } from './authReducer';
import { loginApiV1AuthLoginPost } from '@/lib/api/sdk.gen';
import type { CaptchaResponse } from '@/lib/api/types.gen';
import {PERSONAL_CELTRAL_PAGE} from "@/config/constants"
interface LoginFormProps {
@@ -40,8 +40,7 @@ export function LoginForm({ onRegisterClick }: LoginFormProps) {
const [state, dispatch] = React.useReducer(authReducer, initialAuthState);
const [loginType, setLoginType] = useState<'password' | 'phone'>('password');
const [passwordCaptchaData, setPasswordCaptchaData] = useState<CaptchaResponse | null>(null);
const [phoneCaptchaData, setPhoneCaptchaData] = useState<CaptchaResponse | null>(null);
// 倒计时效果
useEffect(() => {
if (state.countdown > 0) {
@@ -154,9 +153,14 @@ export function LoginForm({ onRegisterClick }: LoginFormProps) {
dispatch({ type: 'SET_ERROR', payload: '登录失败,请检查用户名和密码' });
toast.error('登录失败,请检查用户名和密码');
}
} catch (err: any) {
console.error('登录失败:', err);
const errorMessage = err?.response?.data?.message || err?.message || '登录失败,请稍后重试';
} catch (error: unknown) {
console.error('????:', error);
const apiMessage =
typeof error === 'object' && error !== null && 'response' in error
? (error as { response?: { data?: { message?: string } } }).response?.data?.message
: undefined;
const fallbackMessage = error instanceof Error ? error.message : undefined;
const errorMessage = apiMessage || fallbackMessage || '??????????';
dispatch({ type: 'SET_ERROR', payload: errorMessage });
toast.error(errorMessage);
} finally {
@@ -204,9 +208,10 @@ export function LoginForm({ onRegisterClick }: LoginFormProps) {
dispatch({ type: 'SET_ERROR', payload: '验证码错误' });
toast.error('验证码错误');
}
} catch (err) {
dispatch({ type: 'SET_ERROR', payload: '登录失败,请稍后重试' });
toast.error('登录失败');
} catch (error) {
console.error('???????:', error);
dispatch({ type: 'SET_ERROR', payload: '??????????' });
toast.error('????');
} finally {
dispatch({ type: 'SET_LOADING', payload: false });
}