From 1620e224bfd01ddd5b547e7a87e996573c1c025c Mon Sep 17 00:00:00 2001
From: Stephen Zhou <38493346+hyoban@users.noreply.github.com>
Date: Wed, 18 Mar 2026 18:09:23 +0800
Subject: [PATCH] refactor: no global loading
---
.../(commonLayout)/datasets/layout.spec.tsx | 5 +-
web/app/(commonLayout)/datasets/layout.tsx | 4 -
.../(commonLayout)/role-route-guard.spec.tsx | 5 +-
web/app/(commonLayout)/role-route-guard.tsx | 5 --
.../components/authenticated-layout.tsx | 16 +---
web/app/(shareLayout)/components/splash.tsx | 30 +------
web/app/account/oauth/authorize/layout.tsx | 12 +--
web/app/account/oauth/authorize/page.tsx | 12 +--
web/app/components/app-initializer.tsx | 8 +-
.../base/voice-input/__tests__/utils.spec.ts | 28 +++---
web/app/components/base/voice-input/index.tsx | 2 +-
web/app/components/base/voice-input/utils.ts | 61 +++++++++----
.../billing/partner-stack/use-ps-info.ts | 16 ++--
web/app/components/header/header-wrapper.tsx | 5 +-
.../components/header/maintenance-notice.tsx | 7 +-
.../steps/install.tsx | 6 +-
.../steps/install.tsx | 6 +-
.../components/plugins/plugin-item/index.tsx | 16 ++--
.../update-plugin/plugin-version-picker.tsx | 2 +-
web/app/components/splash.tsx | 11 +--
.../education-apply/education-apply-page.tsx | 2 +-
web/app/education-apply/hooks.ts | 4 +-
web/app/page.tsx | 2 -
web/app/signin/invite-settings/page.tsx | 8 +-
.../__tests__/global-public-context.spec.tsx | 74 +++++++++++++++
web/context/global-public-context.tsx | 5 +-
web/context/modal-context-provider.tsx | 4 +-
web/context/web-app-context.tsx | 18 +---
web/utils/semver.ts | 90 +++++++++++++++++--
29 files changed, 283 insertions(+), 181 deletions(-)
create mode 100644 web/context/__tests__/global-public-context.spec.tsx
diff --git a/web/app/(commonLayout)/datasets/layout.spec.tsx b/web/app/(commonLayout)/datasets/layout.spec.tsx
index 9c01cffba8..ac88109159 100644
--- a/web/app/(commonLayout)/datasets/layout.spec.tsx
+++ b/web/app/(commonLayout)/datasets/layout.spec.tsx
@@ -55,7 +55,7 @@ describe('DatasetsLayout', () => {
setAppContext()
})
- it('should render loading when workspace is still loading', () => {
+ it('should keep rendering children when workspace is still loading', () => {
setAppContext({
isLoadingCurrentWorkspace: true,
currentWorkspace: { id: '' },
@@ -67,8 +67,7 @@ describe('DatasetsLayout', () => {
))
- expect(screen.getByRole('status')).toBeInTheDocument()
- expect(screen.queryByTestId('datasets-content')).not.toBeInTheDocument()
+ expect(screen.getByTestId('datasets-content')).toBeInTheDocument()
expect(mockReplace).not.toHaveBeenCalled()
})
diff --git a/web/app/(commonLayout)/datasets/layout.tsx b/web/app/(commonLayout)/datasets/layout.tsx
index a465f8222b..ca70870b15 100644
--- a/web/app/(commonLayout)/datasets/layout.tsx
+++ b/web/app/(commonLayout)/datasets/layout.tsx
@@ -1,7 +1,6 @@
'use client'
import { useEffect } from 'react'
-import Loading from '@/app/components/base/loading'
import { useAppContext } from '@/context/app-context'
import { ExternalApiPanelProvider } from '@/context/external-api-panel-context'
import { ExternalKnowledgeApiProvider } from '@/context/external-knowledge-api-context'
@@ -19,9 +18,6 @@ export default function DatasetsLayout({ children }: { children: React.ReactNode
router.replace('/apps')
}, [shouldRedirect, router])
- if (isLoadingCurrentWorkspace || !currentWorkspace.id)
- return
{t(`${i18nPrefix}.readyToInstall`, { ns: 'plugin' })}
+
{t('difyVersionNotCompatible', { ns: 'plugin', minimalDifyVersion: payload.meta.minimum_dify_version })}
)} diff --git a/web/app/components/plugins/install-plugin/install-from-marketplace/steps/install.tsx b/web/app/components/plugins/install-plugin/install-from-marketplace/steps/install.tsx index 275d4ca47b..c2779aece8 100644 --- a/web/app/components/plugins/install-plugin/install-from-marketplace/steps/install.tsx +++ b/web/app/components/plugins/install-plugin/install-from-marketplace/steps/install.tsx @@ -5,11 +5,11 @@ import { RiLoader2Line } from '@remixicon/react' import * as React from 'react' import { useEffect, useMemo } from 'react' import { useTranslation } from 'react-i18next' -import { gte } from 'semver' import Button from '@/app/components/base/button' import useCheckInstalled from '@/app/components/plugins/install-plugin/hooks/use-check-installed' import { useAppContext } from '@/context/app-context' import { useInstallPackageFromMarketPlace, usePluginDeclarationFromMarketPlace, usePluginTaskList, useUpdatePackageFromMarketPlace } from '@/service/use-plugins' +import { gte } from '@/utils/semver' import Card from '../../../card' // import { RiInformation2Line } from '@remixicon/react' import { TaskStatus } from '../../../types' @@ -133,10 +133,10 @@ const Installed: FC{t(`${i18nPrefix}.readyToInstall`, { ns: 'plugin' })}
{!isDifyVersionCompatible && ( -+
{t('difyVersionNotCompatible', { ns: 'plugin', minimalDifyVersion: pluginDeclaration?.manifest.meta.minimum_dify_version })}
)} diff --git a/web/app/components/plugins/plugin-item/index.tsx b/web/app/components/plugins/plugin-item/index.tsx index 3f658c63a8..9a39bc936b 100644 --- a/web/app/components/plugins/plugin-item/index.tsx +++ b/web/app/components/plugins/plugin-item/index.tsx @@ -11,7 +11,6 @@ import { import * as React from 'react' import { useCallback, useMemo } from 'react' import { useTranslation } from 'react-i18next' -import { gte } from 'semver' import Tooltip from '@/app/components/base/tooltip' import useRefreshPluginList from '@/app/components/plugins/install-plugin/hooks/use-refresh-plugin-list' import { API_PREFIX } from '@/config' @@ -20,6 +19,7 @@ import { useGlobalPublicStore } from '@/context/global-public-context' import { useRenderI18nObject } from '@/hooks/use-i18n' import useTheme from '@/hooks/use-theme' import { cn } from '@/utils/classnames' +import { gte } from '@/utils/semver' import { getMarketplaceUrl } from '@/utils/var' import Badge from '../../base/badge' import { Github } from '../../base/icons/src/public/common' @@ -164,8 +164,8 @@ const PluginItem: FC