This commit is contained in:
hailin 2025-05-20 16:22:49 +08:00
parent 042a3d42ec
commit cf98a73e79
1 changed files with 21 additions and 4 deletions

View File

@ -68,19 +68,36 @@ 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) {
// 跳转到带有 locale 的登录页面
const pathname = usePathname()
const match = pathname.match(/^\/([a-z]{2})(\/|$)/)
const locale = match ? match[1] : "en"
return router.push(`/${locale}/login`)
} else {
await fetchWorkspaceData(workspaceId)
}
await fetchWorkspaceData(workspaceId)
})()
}, [])
useEffect(() => {
;(async () => await fetchWorkspaceData(workspaceId))()