From ebe1b1ddcc53cbd2c4e5168bd20948bf48451886 Mon Sep 17 00:00:00 2001 From: William Tso Date: Wed, 23 Apr 2025 20:18:08 +0800 Subject: [PATCH] fix build --- app/login/page.tsx | 38 +++++++++++++++++--------------------- next.config.ts | 15 ++++++--------- 2 files changed, 23 insertions(+), 30 deletions(-) diff --git a/app/login/page.tsx b/app/login/page.tsx index c3881e8..5826e6e 100644 --- a/app/login/page.tsx +++ b/app/login/page.tsx @@ -5,21 +5,8 @@ import { useSearchParams } from 'next/navigation'; import Link from 'next/link'; import { useAuth } from '@/lib/auth'; -// Separate component for message handling to isolate useSearchParams -function MessageHandler({ setMessage }: { setMessage: (message: { type: string, content: string }) => void }) { - const searchParams = useSearchParams(); - - useEffect(() => { - const messageParam = searchParams.get('message'); - if (messageParam) { - setMessage({ type: 'info', content: messageParam }); - } - }, [searchParams, setMessage]); - - return null; -} - -export default function LoginPage() { +// Separate component for content that uses useSearchParams +function LoginContent() { const searchParams = useSearchParams(); const { signIn, signInWithGoogle, user } = useAuth(); @@ -29,9 +16,14 @@ export default function LoginPage() { const [message, setMessage] = useState({ type: '', content: '' }); const [redirectUrl, setRedirectUrl] = useState(null); - // Get redirect URL + // Get message from URL and redirect URL useEffect(() => { if (searchParams) { + const messageParam = searchParams.get('message'); + if (messageParam) { + setMessage({ type: 'info', content: messageParam }); + } + const redirect = searchParams.get('redirect'); if (redirect) { setRedirectUrl(decodeURIComponent(redirect)); @@ -114,11 +106,6 @@ export default function LoginPage() { return (
- {/* Wrap the component using useSearchParams in Suspense */} - - - -

Login

@@ -230,4 +217,13 @@ export default function LoginPage() {
); +} + +// Main component wrapped in Suspense +export default function LoginPage() { + return ( + Loading...
}> + + + ); } \ No newline at end of file diff --git a/next.config.ts b/next.config.ts index 77f2f86..8feb307 100644 --- a/next.config.ts +++ b/next.config.ts @@ -2,17 +2,14 @@ import type { NextConfig } from "next"; const nextConfig: NextConfig = { /* config options here */ - // 设置需要转译的包 - // 配置实验性选项 + // 实验性选项 experimental: { - // 启用边缘函数中间件 - instrumentationHook: true, - // 配置中间件匹配 - middleware: { - // 确保匹配所有路径 - matchAll: '/((?!_next|static|api|public).*)', - }, + // 删除不支持的选项 + // instrumentationHook: true, + // middleware: { + // matchAll: '/((?!_next|static|api|public).*)', + // }, }, // 禁用严格模式,避免开发时重复渲染