Remove .env.local file and update middleware, page, and auth callback files to enhance logging and user experience. Translate comments and console logs to English for better clarity. Refactor Create Short URL form and Debug page for improved user feedback and error handling.
This commit is contained in:
@@ -29,7 +29,7 @@ export default function LoginPage() {
|
||||
const [message, setMessage] = useState({ type: '', content: '' });
|
||||
const [redirectUrl, setRedirectUrl] = useState<string | null>(null);
|
||||
|
||||
// 获取重定向URL
|
||||
// Get redirect URL
|
||||
useEffect(() => {
|
||||
if (searchParams) {
|
||||
const redirect = searchParams.get('redirect');
|
||||
@@ -39,19 +39,19 @@ export default function LoginPage() {
|
||||
}
|
||||
}, [searchParams]);
|
||||
|
||||
// 如果用户已登录,重定向到原始页面或首页
|
||||
// If user is logged in, redirect to original page or home page
|
||||
useEffect(() => {
|
||||
if (user) {
|
||||
console.log('用户已登录,准备重定向', { redirectUrl });
|
||||
console.log('User is logged in, preparing to redirect', { redirectUrl });
|
||||
|
||||
// 添加短暂延时确保状态更新完成
|
||||
// Add a short delay to ensure state updates are complete
|
||||
setTimeout(() => {
|
||||
if (redirectUrl) {
|
||||
// 使用硬重定向替代router.push
|
||||
console.log('重定向到原始URL:', redirectUrl);
|
||||
// Use hard redirect instead of router.push
|
||||
console.log('Redirecting to original URL:', redirectUrl);
|
||||
window.location.href = redirectUrl;
|
||||
} else {
|
||||
console.log('重定向到首页');
|
||||
console.log('Redirecting to home page');
|
||||
window.location.href = '/';
|
||||
}
|
||||
}, 100);
|
||||
@@ -79,7 +79,7 @@ export default function LoginPage() {
|
||||
throw new Error(error instanceof Error ? error.message : 'Unknown error');
|
||||
}
|
||||
|
||||
// 登录成功后,会通过 useEffect 重定向
|
||||
// After successful login, redirect via useEffect
|
||||
} catch (error) {
|
||||
console.error('Login error:', error);
|
||||
setMessage({
|
||||
|
||||
Reference in New Issue
Block a user