This commit is contained in:
hailin 2025-05-20 16:33:28 +08:00
parent 3c128425d9
commit b206be4e70
1 changed files with 4 additions and 20 deletions

View File

@ -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)
})()
}, [])