From b206be4e70d3a9a2432ad993c31fd80920086a7e Mon Sep 17 00:00:00 2001 From: hailin Date: Tue, 20 May 2025 16:33:28 +0800 Subject: [PATCH] . --- .../app/[locale]/[workspaceid]/layout.tsx | 24 ++++--------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/chatdesk-ui/app/[locale]/[workspaceid]/layout.tsx b/chatdesk-ui/app/[locale]/[workspaceid]/layout.tsx index fe75907..aa85ab2 100644 --- a/chatdesk-ui/app/[locale]/[workspaceid]/layout.tsx +++ b/chatdesk-ui/app/[locale]/[workspaceid]/layout.tsx @@ -71,32 +71,16 @@ export default function WorkspaceLayout({ children }: WorkspaceLayoutProps) { const [loading, setLoading] = useState(true) - // useEffect(() => { - // ;(async () => { - // const session = (await supabase.auth.getSession()).data.session - - // if (!session) { - // // 跳转到带有 locale 的登录页面 - // return router.push(`/${locale}/login`) - // } else { - // await fetchWorkspaceData(workspaceId) - // } - // })() - // }, []) - useEffect(() => { - (async () => { + ;(async () => { const session = (await supabase.auth.getSession()).data.session if (!session) { - const pathname = usePathname() - const match = pathname.match(/^\/([a-z]{2})(\/|$)/) - const locale = match ? match[1] : "en" - + // 跳转到带有 locale 的登录页面 return router.push(`/${locale}/login`) + } else { + await fetchWorkspaceData(workspaceId) } - - await fetchWorkspaceData(workspaceId) })() }, [])