mirror of
https://github.com/router-for-me/Cli-Proxy-API-Management-Center.git
synced 2026-02-02 19:00:49 +08:00
fix: 调整登录页面的重定向逻辑和键盘事件处理顺序
This commit is contained in:
@@ -50,11 +50,6 @@ export function LoginPage() {
|
||||
init();
|
||||
}, [detectedBase, restoreSession, storedBase, storedKey, storedRememberPassword]);
|
||||
|
||||
if (isAuthenticated) {
|
||||
const redirect = (location.state as any)?.from?.pathname || '/';
|
||||
return <Navigate to={redirect} replace />;
|
||||
}
|
||||
|
||||
const handleSubmit = async () => {
|
||||
if (!managementKey.trim()) {
|
||||
setError(t('login.error_required'));
|
||||
@@ -81,12 +76,20 @@ export function LoginPage() {
|
||||
}
|
||||
};
|
||||
|
||||
const handleSubmitKeyDown = useCallback((event: React.KeyboardEvent) => {
|
||||
const handleSubmitKeyDown = useCallback(
|
||||
(event: React.KeyboardEvent) => {
|
||||
if (event.key === 'Enter' && !loading) {
|
||||
event.preventDefault();
|
||||
handleSubmit();
|
||||
}
|
||||
}, [loading, handleSubmit]);
|
||||
},
|
||||
[loading, handleSubmit]
|
||||
);
|
||||
|
||||
if (isAuthenticated) {
|
||||
const redirect = (location.state as any)?.from?.pathname || '/';
|
||||
return <Navigate to={redirect} replace />;
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="login-page">
|
||||
|
||||
Reference in New Issue
Block a user