Commit fca97531 authored by JzoNg's avatar JzoNg

fix app detail update

parent 0529c3d5
...@@ -27,8 +27,8 @@ const AppDetailLayout: FC<IAppDetailLayoutProps> = (props) => { ...@@ -27,8 +27,8 @@ const AppDetailLayout: FC<IAppDetailLayoutProps> = (props) => {
const router = useRouter() const router = useRouter()
const pathname = usePathname() const pathname = usePathname()
const { isCurrentWorkspaceManager } = useAppContext() const { isCurrentWorkspaceManager } = useAppContext()
const detailParams = { url: '/apps', id: appId }
const { appDetail, setAppDetail } = useStore() const { appDetail, setAppDetail } = useStore()
const detailParams = { url: '/apps', id: appId }
const { data: response } = useSWR(detailParams, fetchAppDetail) const { data: response } = useSWR(detailParams, fetchAppDetail)
const navigation = useMemo(() => { const navigation = useMemo(() => {
...@@ -67,24 +67,27 @@ const AppDetailLayout: FC<IAppDetailLayoutProps> = (props) => { ...@@ -67,24 +67,27 @@ const AppDetailLayout: FC<IAppDetailLayoutProps> = (props) => {
}, [appId, isCurrentWorkspaceManager, response?.mode, t]) }, [appId, isCurrentWorkspaceManager, response?.mode, t])
useEffect(() => { useEffect(() => {
if (response?.name) if (response && !appDetail)
document.title = `${(response.name || 'App')} - Dify`
if (response && response !== appDetail)
setAppDetail(response) setAppDetail(response)
}, [appDetail, response, setAppDetail]) }, [appDetail, response, setAppDetail])
if (!response) useEffect(() => {
if (appDetail?.name)
document.title = `${(appDetail.name || 'App')} - Dify`
}, [appDetail])
if (!appDetail)
return null return null
// redirections // redirections
if (response && (response?.mode === 'workflow' || response?.mode === 'advanced-chat') && (pathname).endsWith('configuration')) if ((appDetail.mode === 'workflow' || appDetail.mode === 'advanced-chat') && (pathname).endsWith('configuration'))
router.replace(`/app/${appId}/workflow`) router.replace(`/app/${appId}/workflow`)
if (response && (response?.mode !== 'workflow' && response?.mode !== 'advanced-chat') && (pathname).endsWith('workflow')) if ((appDetail.mode !== 'workflow' && appDetail.mode !== 'advanced-chat') && (pathname).endsWith('workflow'))
router.replace(`/app/${appId}/configuration`) router.replace(`/app/${appId}/configuration`)
return ( return (
<div className={cn(s.app, 'flex', 'overflow-hidden')}> <div className={cn(s.app, 'flex', 'overflow-hidden')}>
<AppSideBar title={response.name} icon={response.icon} icon_background={response.icon_background} desc={response.mode} navigation={navigation} /> <AppSideBar title={appDetail.name} icon={appDetail.icon} icon_background={appDetail.icon_background} desc={appDetail.mode} navigation={navigation} />
<div className="bg-white grow overflow-hidden"> <div className="bg-white grow overflow-hidden">
{children} {children}
</div> </div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment