Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

perf(web): optimize first-screen rendering performance (#35313)

yyh344546938552
diff --git a/web/app/(commonLayout)/layout.tsx b/web/app/(commonLayout)/layout.tsx
index 5ac39f1e390..49e9431940a 100644
--- a/web/app/(commonLayout)/layout.tsx
+++ b/web/app/(commonLayout)/layout.tsx
@@ -5,7 +5,6 @@ import InSiteMessageNotification from '@/app/components/app/in-site-message/noti
import AmplitudeProvider from '@/app/components/base/amplitude'
import GA, { GaType } from '@/app/components/base/ga'
import Zendesk from '@/app/components/base/zendesk'
-import GotoAnything from '@/app/components/goto-anything'
import Header from '@/app/components/header'
import HeaderWrapper from '@/app/components/header/header-wrapper'
import ReadmePanel from '@/app/components/plugins/readme-panel'
@@ -13,10 +12,15 @@ import { AppContextProvider } from '@/context/app-context-provider'
import { EventEmitterContextProvider } from '@/context/event-emitter-provider'
import { ModalContextProvider } from '@/context/modal-context-provider'
import { ProviderContextProvider } from '@/context/provider-context-provider'
+import dynamic from '@/next/dynamic'
import PartnerStack from '../components/billing/partner-stack'
import Splash from '../components/splash'
import RoleRouteGuard from './role-route-guard'
+const GotoAnything = dynamic(() => import('@/app/components/goto-anything'), {
+ ssr: false,
+})
+
const Layout = ({ children }: { children: ReactNode }) => {
return (
<>
diff --git a/web/app/components/devtools/react-scan/loader.tsx b/web/app/components/devtools/react-scan/loader.tsx
index 8e933c2b24d..bd310f292fe 100644
--- a/web/app/components/devtools/react-scan/loader.tsx
+++ b/web/app/components/devtools/react-scan/loader.tsx
@@ -9,7 +9,7 @@ export function ReactScanLoader() {
<Script
src="//unpkg.com/react-scan/dist/auto.global.js"
crossOrigin="anonymous"
- strategy="beforeInteractive"
+ strategy="afterInteractive"
/>
)
}
diff --git a/web/app/components/splash.tsx b/web/app/components/splash.tsx
index 4f5f4845829..3103f09ca3d 100644
--- a/web/app/components/splash.tsx
+++ b/web/app/components/splash.tsx
@@ -1,15 +1,13 @@
'use client'
import type { FC, PropsWithChildren } from 'react'
import * as React from 'react'
-import { useIsLogin } from '@/service/use-common'
+import { useUserProfile } from '@/service/use-common'
import Loading from './base/loading'
const Splash: FC<PropsWithChildren> = () => {
- // would auto redirect to signin page if not logged in
- const { isLoading, data: loginData } = useIsLogin()
- const isLoggedIn = loginData?.logged_in
+ const { isPending, data } = useUserProfile()
- if (isLoading || !isLoggedIn) {
+ if (isPending || !data?.profile) {
return (
<div className="fixed inset-0 z-9999999 flex h-full items-center justify-center bg-background-body">
<Loading />