mirror of
https://github.com/langgenius/dify.git
synced 2026-09-03 06:53:26 +08:00
33 lines
1.0 KiB
TypeScript
33 lines
1.0 KiB
TypeScript
'use client'
|
|
|
|
import { useEffect } from 'react'
|
|
import { useAppContext } from '@/context/app-context'
|
|
import { ExternalApiPanelProvider } from '@/context/external-api-panel-context'
|
|
import { ExternalKnowledgeApiProvider } from '@/context/external-knowledge-api-context'
|
|
import { useRouter } from '@/next/navigation'
|
|
|
|
export default function DatasetsLayout({ children }: { children: React.ReactNode }) {
|
|
const { isCurrentWorkspaceEditor, isCurrentWorkspaceDatasetOperator, currentWorkspace, isLoadingCurrentWorkspace } = useAppContext()
|
|
const router = useRouter()
|
|
const shouldRedirect = !isLoadingCurrentWorkspace
|
|
&& currentWorkspace.id
|
|
&& !(isCurrentWorkspaceEditor || isCurrentWorkspaceDatasetOperator)
|
|
|
|
useEffect(() => {
|
|
if (shouldRedirect)
|
|
router.replace('/apps')
|
|
}, [shouldRedirect, router])
|
|
|
|
if (shouldRedirect) {
|
|
return null
|
|
}
|
|
|
|
return (
|
|
<ExternalKnowledgeApiProvider>
|
|
<ExternalApiPanelProvider>
|
|
{children}
|
|
</ExternalApiPanelProvider>
|
|
</ExternalKnowledgeApiProvider>
|
|
)
|
|
}
|