fix build
This commit is contained in:
@@ -5,21 +5,8 @@ import { useSearchParams } from 'next/navigation';
|
|||||||
import Link from 'next/link';
|
import Link from 'next/link';
|
||||||
import { useAuth } from '@/lib/auth';
|
import { useAuth } from '@/lib/auth';
|
||||||
|
|
||||||
// Separate component for message handling to isolate useSearchParams
|
// Separate component for content that uses useSearchParams
|
||||||
function MessageHandler({ setMessage }: { setMessage: (message: { type: string, content: string }) => void }) {
|
function LoginContent() {
|
||||||
const searchParams = useSearchParams();
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
const messageParam = searchParams.get('message');
|
|
||||||
if (messageParam) {
|
|
||||||
setMessage({ type: 'info', content: messageParam });
|
|
||||||
}
|
|
||||||
}, [searchParams, setMessage]);
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function LoginPage() {
|
|
||||||
const searchParams = useSearchParams();
|
const searchParams = useSearchParams();
|
||||||
const { signIn, signInWithGoogle, user } = useAuth();
|
const { signIn, signInWithGoogle, user } = useAuth();
|
||||||
|
|
||||||
@@ -29,9 +16,14 @@ export default function LoginPage() {
|
|||||||
const [message, setMessage] = useState({ type: '', content: '' });
|
const [message, setMessage] = useState({ type: '', content: '' });
|
||||||
const [redirectUrl, setRedirectUrl] = useState<string | null>(null);
|
const [redirectUrl, setRedirectUrl] = useState<string | null>(null);
|
||||||
|
|
||||||
// Get redirect URL
|
// Get message from URL and redirect URL
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (searchParams) {
|
if (searchParams) {
|
||||||
|
const messageParam = searchParams.get('message');
|
||||||
|
if (messageParam) {
|
||||||
|
setMessage({ type: 'info', content: messageParam });
|
||||||
|
}
|
||||||
|
|
||||||
const redirect = searchParams.get('redirect');
|
const redirect = searchParams.get('redirect');
|
||||||
if (redirect) {
|
if (redirect) {
|
||||||
setRedirectUrl(decodeURIComponent(redirect));
|
setRedirectUrl(decodeURIComponent(redirect));
|
||||||
@@ -114,11 +106,6 @@ export default function LoginPage() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex items-center justify-center min-h-screen bg-gray-100">
|
<div className="flex items-center justify-center min-h-screen bg-gray-100">
|
||||||
{/* Wrap the component using useSearchParams in Suspense */}
|
|
||||||
<Suspense fallback={null}>
|
|
||||||
<MessageHandler setMessage={setMessage} />
|
|
||||||
</Suspense>
|
|
||||||
|
|
||||||
<div className="w-full max-w-md p-8 space-y-8 bg-white rounded-lg shadow-md">
|
<div className="w-full max-w-md p-8 space-y-8 bg-white rounded-lg shadow-md">
|
||||||
<div className="text-center">
|
<div className="text-center">
|
||||||
<h1 className="text-2xl font-bold text-gray-900">Login</h1>
|
<h1 className="text-2xl font-bold text-gray-900">Login</h1>
|
||||||
@@ -231,3 +218,12 @@ export default function LoginPage() {
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Main component wrapped in Suspense
|
||||||
|
export default function LoginPage() {
|
||||||
|
return (
|
||||||
|
<Suspense fallback={<div className="flex items-center justify-center min-h-screen bg-gray-100">Loading...</div>}>
|
||||||
|
<LoginContent />
|
||||||
|
</Suspense>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -2,17 +2,14 @@ import type { NextConfig } from "next";
|
|||||||
|
|
||||||
const nextConfig: NextConfig = {
|
const nextConfig: NextConfig = {
|
||||||
/* config options here */
|
/* config options here */
|
||||||
// 设置需要转译的包
|
|
||||||
|
|
||||||
// 配置实验性选项
|
// 实验性选项
|
||||||
experimental: {
|
experimental: {
|
||||||
// 启用边缘函数中间件
|
// 删除不支持的选项
|
||||||
instrumentationHook: true,
|
// instrumentationHook: true,
|
||||||
// 配置中间件匹配
|
// middleware: {
|
||||||
middleware: {
|
// matchAll: '/((?!_next|static|api|public).*)',
|
||||||
// 确保匹配所有路径
|
// },
|
||||||
matchAll: '/((?!_next|static|api|public).*)',
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// 禁用严格模式,避免开发时重复渲染
|
// 禁用严格模式,避免开发时重复渲染
|
||||||
|
|||||||
Reference in New Issue
Block a user