2024-01-23 19:31:56 +08:00
|
|
|
'use client'
|
|
|
|
import type { FC } from 'react'
|
2024-07-09 17:47:54 +08:00
|
|
|
import { useRouter } from 'next/navigation'
|
2024-01-23 19:31:56 +08:00
|
|
|
import { useTranslation } from 'react-i18next'
|
|
|
|
import React, { useEffect } from 'react'
|
2024-05-27 21:57:08 +08:00
|
|
|
import ToolProviderList from '@/app/components/tools/provider-list'
|
2024-07-09 17:47:54 +08:00
|
|
|
import { useAppContext } from '@/context/app-context'
|
2024-01-23 19:31:56 +08:00
|
|
|
|
|
|
|
const Layout: FC = () => {
|
|
|
|
const { t } = useTranslation()
|
2024-07-09 17:47:54 +08:00
|
|
|
const router = useRouter()
|
|
|
|
const { isCurrentWorkspaceDatasetOperator } = useAppContext()
|
2024-01-23 19:31:56 +08:00
|
|
|
|
|
|
|
useEffect(() => {
|
2024-07-19 18:37:42 +08:00
|
|
|
if (typeof window !== 'undefined')
|
|
|
|
document.title = `${t('tools.title')} - Dify`
|
2024-07-09 17:47:54 +08:00
|
|
|
if (isCurrentWorkspaceDatasetOperator)
|
|
|
|
return router.replace('/datasets')
|
2024-07-19 18:37:42 +08:00
|
|
|
}, [isCurrentWorkspaceDatasetOperator, router, t])
|
2024-01-23 19:31:56 +08:00
|
|
|
|
2024-07-09 17:47:54 +08:00
|
|
|
useEffect(() => {
|
|
|
|
if (isCurrentWorkspaceDatasetOperator)
|
|
|
|
return router.replace('/datasets')
|
2024-07-19 18:37:42 +08:00
|
|
|
}, [isCurrentWorkspaceDatasetOperator, router])
|
2024-07-09 17:47:54 +08:00
|
|
|
|
2024-05-27 21:57:08 +08:00
|
|
|
return <ToolProviderList />
|
2024-01-23 19:31:56 +08:00
|
|
|
}
|
|
|
|
export default React.memo(Layout)
|