'use client' import { cn } from '@langgenius/dify-ui/cn' import { useQuery, useSuspenseQuery } from '@tanstack/react-query' import Loading from '@/app/components/base/loading' import Header from '@/app/signin/_header' import { AppContextProvider } from '@/context/app-context-provider' import useDocumentTitle from '@/hooks/use-document-title' import { systemFeaturesQueryOptions } from '@/service/system-features' import { isLegacyBase401, userProfileQueryOptions } from '@/service/use-common' export default function SignInLayout({ children }: any) { const { data: systemFeatures } = useSuspenseQuery(systemFeaturesQueryOptions()) useDocumentTitle('') // Probe login state. 401 stays as `error` (not thrown) so this layout can render // the signin/oauth UI for unauthenticated users; other errors bubble to error.tsx. // (When unauthenticated, service/base.ts's auto-redirect to /signin still fires.) const { isPending, data: userResp, error } = useQuery({ ...userProfileQueryOptions(), throwOnError: err => !isLegacyBase401(err), }) const isLoggedIn = !!userResp && !error if (isPending) { return (
) } return ( <>
{isLoggedIn ? ( {children} ) : children}
{systemFeatures.branding.enabled === false && (
© {' '} {new Date().getFullYear()} {' '} LangGenius, Inc. All rights reserved.
)}
) }