This commit is contained in:
parent
e923336adc
commit
dae44767fd
|
|
@ -70,6 +70,8 @@ export default function WorkspaceLayout({ children }: WorkspaceLayoutProps) {
|
|||
} = useContext(ChatbotUIContext)
|
||||
|
||||
const [loading, setLoading] = useState(true)
|
||||
const [redirected, setRedirected] = useState(false) // 防止重复跳转
|
||||
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
|
|
@ -77,14 +79,16 @@ export default function WorkspaceLayout({ children }: WorkspaceLayoutProps) {
|
|||
//const supabaseClient = await supabase(); // Await the client creation
|
||||
const session = (await supabase.auth.getSession()).data.session
|
||||
|
||||
if (!session) {
|
||||
//if (!session) {
|
||||
if (!session && !redirected) {
|
||||
// 跳转到带有 locale 的登录页面
|
||||
setRedirected(true) // 设置标志,避免跳转重复
|
||||
return router.push(`/${locale}/login`)
|
||||
} else {
|
||||
await fetchWorkspaceData(workspaceId)
|
||||
}
|
||||
})()
|
||||
}, [])
|
||||
}, [workspaceId, redirected])
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
|
|
|
|||
Loading…
Reference in New Issue