This commit is contained in:
parent
042a3d42ec
commit
cf98a73e79
|
|
@ -68,19 +68,36 @@ export default function WorkspaceLayout({ children }: WorkspaceLayoutProps) {
|
||||||
|
|
||||||
const [loading, setLoading] = useState(true)
|
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(() => {
|
useEffect(() => {
|
||||||
;(async () => {
|
(async () => {
|
||||||
const session = (await supabase.auth.getSession()).data.session
|
const session = (await supabase.auth.getSession()).data.session
|
||||||
|
|
||||||
if (!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`)
|
return router.push(`/${locale}/login`)
|
||||||
} else {
|
|
||||||
await fetchWorkspaceData(workspaceId)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await fetchWorkspaceData(workspaceId)
|
||||||
})()
|
})()
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
;(async () => await fetchWorkspaceData(workspaceId))()
|
;(async () => await fetchWorkspaceData(workspaceId))()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue