This commit is contained in:
hailin 2025-05-21 02:09:58 +08:00
parent e923336adc
commit dae44767fd
1 changed files with 6 additions and 2 deletions

View File

@ -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(() => {