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:
2025-04-23 18:17:41 +08:00
parent ebb1e77ecc
commit bee8369a6b
9 changed files with 196 additions and 192 deletions

View File

@@ -6,32 +6,32 @@ import { useAuth } from '@/lib/auth';
export default function Home() {
const { user, isLoading } = useAuth();
// 添加调试日志
console.log('根页面状态:', { isLoading, userAuthenticated: !!user });
// Add debug logs
console.log('Root page state:', { isLoading, userAuthenticated: !!user });
useEffect(() => {
if (!isLoading) {
console.log('准备从根页面重定向', { isLoggedIn: !!user });
console.log('Preparing to redirect from root page', { isLoggedIn: !!user });
// 使用硬重定向确保页面完全刷新
// Use hard redirect to ensure full page refresh
if (user) {
console.log('用户已登录,重定向到分析页面');
console.log('User is logged in, redirecting to analytics page');
window.location.href = '/analytics';
} else {
console.log('用户未登录,重定向到登录页面');
console.log('User is not logged in, redirecting to login page');
window.location.href = '/login';
}
}
}, [isLoading, user]);
// 显示加载指示器,并包含状态信息
// Display loading indicator with status information
return (
<div className="flex items-center justify-center min-h-screen">
<div className="text-center">
<div className="animate-spin rounded-full h-16 w-16 border-t-2 border-b-2 border-blue-500 mx-auto"></div>
<p className="mt-4 text-lg text-gray-700">...</p>
<p className="mt-4 text-lg text-gray-700">Loading...</p>
<p className="mt-2 text-sm text-gray-500">
: {isLoading ? '检查登录中' : (user ? '已登录' : '未登录')}
Status: {isLoading ? 'Checking login status' : (user ? 'Logged in' : 'Not logged in')}
</p>
</div>
</div>