Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

🔥 chore(theme): remove AntdStaticMethods now that nothing renders through antd static APIs (#19458)

Innei48c61be524ca
diff --git a/apps/share/src/shell/ShareTheme.tsx b/apps/share/src/shell/ShareTheme.tsx
index 953286ce180..d8b300b1897 100644
--- a/apps/share/src/shell/ShareTheme.tsx
+++ b/apps/share/src/shell/ShareTheme.tsx
@@ -9,7 +9,6 @@ import { domMax, LazyMotion } from 'motion/react';
import * as m from 'motion/react-m';
import { memo, type PropsWithChildren } from 'react';
-import AntdStaticMethods from '@/components/AntdStaticMethods';
import { useIsDark } from '@/hooks/useIsDark';
import Image from '@/libs/next/Image';
import Link from '@/libs/next/Link';
@@ -28,7 +27,6 @@ const ShareTheme = memo<PropsWithChildren>(({ children }) => {
theme={{ cssVar: { key: 'lobe-vars' } }}
>
<App style={{ height: '100%' }}>
- <AntdStaticMethods />
<ConfigProvider config={{ aAs: Link, imgAs: Image, imgUnoptimized: true }} motion={m}>
<LazyMotion features={domMax}>{children}</LazyMotion>
</ConfigProvider>
diff --git a/apps/workbench/src/shell/WorkbenchTheme.tsx b/apps/workbench/src/shell/WorkbenchTheme.tsx
index d4068e86e4b..3c16941879f 100644
--- a/apps/workbench/src/shell/WorkbenchTheme.tsx
+++ b/apps/workbench/src/shell/WorkbenchTheme.tsx
@@ -9,7 +9,6 @@ import { domMax, LazyMotion } from 'motion/react';
import * as m from 'motion/react-m';
import { memo, type PropsWithChildren } from 'react';
-import AntdStaticMethods from '@/components/AntdStaticMethods';
import { useIsDark } from '@/hooks/useIsDark';
import Image from '@/libs/next/Image';
import Link from '@/libs/next/Link';
@@ -28,7 +27,6 @@ const WorkbenchTheme = memo<PropsWithChildren>(({ children }) => {
theme={{ cssVar: { key: 'lobe-vars' } }}
>
<App style={{ height: '100%' }}>
- <AntdStaticMethods />
<ConfigProvider config={{ aAs: Link, imgAs: Image, imgUnoptimized: true }} motion={m}>
<LazyMotion features={domMax}>{children}</LazyMotion>
</ConfigProvider>
diff --git a/src/components/AntdStaticMethods/index.test.tsx b/src/components/AntdStaticMethods/index.test.tsx
deleted file mode 100644
index a32a3dc22c6..00000000000
--- a/src/components/AntdStaticMethods/index.test.tsx
+++ /dev/null
@@ -1,40 +0,0 @@
-// EntryComponent.test.tsx
-import { render } from '@testing-library/react';
-import { App } from 'antd';
-import { describe, expect, it, vi } from 'vitest';
-
-import EntryComponent, { modal, notification } from './index';
-
-// 模拟 App.useApp 方法返回的对象
-const mockUseApp = {
- modal: { confirm: vi.fn() },
- notification: { open: vi.fn() },
-};
-
-vi.mock('antd', async (importOriginal) => ({
- ...(await importOriginal<object>()),
- App: {
- useApp: vi.fn(() => mockUseApp),
- },
-}));
-
-describe('EntryComponent', () => {
- it('should correctly initialize modal and notification', () => {
- render(<EntryComponent />);
-
- // 验证 App.useApp 是否被调用
- expect(App.useApp).toHaveBeenCalled();
-
- expect(modal).toBeDefined();
- expect(notification).toBeDefined();
-
- // 验证是否赋值的对象与模拟的对象匹配
- expect(modal).toEqual(mockUseApp.modal);
- expect(notification).toEqual(mockUseApp.notification);
- });
-
- it('should render without crashing', () => {
- const { container } = render(<EntryComponent />);
- expect(container).toBeDefined();
- });
-});
diff --git a/src/components/AntdStaticMethods/index.tsx b/src/components/AntdStaticMethods/index.tsx
deleted file mode 100644
index 39032d05176..00000000000
--- a/src/components/AntdStaticMethods/index.tsx
+++ /dev/null
@@ -1,18 +0,0 @@
-// Entry component
-import { App } from 'antd';
-import { type ModalStaticFunctions } from 'antd/es/modal/confirm';
-import { memo } from 'react';
-
-// eslint-disable-next-line import-x/no-mutable-exports
-let notification: ReturnType<typeof App.useApp>['notification'];
-// eslint-disable-next-line import-x/no-mutable-exports
-let modal: Omit<ModalStaticFunctions, 'warn'>;
-
-export default memo(() => {
- const staticFunction = App.useApp();
- modal = staticFunction.modal;
- notification = staticFunction.notification;
- return null;
-});
-
-export { modal, notification };
diff --git a/src/features/AuthShell/AuthThemeLite.tsx b/src/features/AuthShell/AuthThemeLite.tsx
index f15ea71500e..d453c89d27f 100644
--- a/src/features/AuthShell/AuthThemeLite.tsx
+++ b/src/features/AuthShell/AuthThemeLite.tsx
@@ -10,7 +10,6 @@ import * as m from 'motion/react-m';
import { type PropsWithChildren } from 'react';
import { memo } from 'react';
-import AntdStaticMethods from '@/components/AntdStaticMethods';
import { useIsDark } from '@/hooks/useIsDark';
import Image from '@/libs/next/Image';
import Link from '@/libs/next/Link';
@@ -35,7 +34,6 @@ const AuthThemeLite = memo<AuthThemeLiteProps>(({ children, globalCDN }) => {
}}
>
<App style={{ height: '100%' }}>
- <AntdStaticMethods />
<ConfigProvider
motion={m}
config={{
diff --git a/src/features/ChatInput/ControlBar/__tests__/GitStatus.test.tsx b/src/features/ChatInput/ControlBar/__tests__/GitStatus.test.tsx
index 977380988a1..345ed8670a2 100644
--- a/src/features/ChatInput/ControlBar/__tests__/GitStatus.test.tsx
+++ b/src/features/ChatInput/ControlBar/__tests__/GitStatus.test.tsx
@@ -80,10 +80,6 @@ vi.mock('@/services/git', () => ({
},
}));
-vi.mock('@/components/AntdStaticMethods', () => ({
- message: { error: vi.fn(), info: vi.fn(), success: vi.fn() },
-}));
-
vi.mock('@/components/RingLoading', () => ({
default: () => <span data-testid="ring-loading" />,
}));
diff --git a/src/features/ChatInput/ControlBar/__tests__/WorktreeSwitcher.test.tsx b/src/features/ChatInput/ControlBar/__tests__/WorktreeSwitcher.test.tsx
index f4fafa65dae..da35b2eb4b8 100644
--- a/src/features/ChatInput/ControlBar/__tests__/WorktreeSwitcher.test.tsx
+++ b/src/features/ChatInput/ControlBar/__tests__/WorktreeSwitcher.test.tsx
@@ -18,13 +18,6 @@ vi.mock('../useCommitWorkingDirectory', () => ({
useCommitWorkingDirectory: () => ({ commit: commitMock }),
}));
-vi.mock('@/components/AntdStaticMethods', () => ({
- message: {
- error: messageErrorMock,
- success: messageSuccessMock,
- },
-}));
-
vi.mock('@/services/git', () => ({
gitService: {
removeGitWorktree: removeGitWorktreeMock,
diff --git a/src/features/Conversation/WorkingSidebar/Review/__tests__/FileItem.test.tsx b/src/features/Conversation/WorkingSidebar/Review/__tests__/FileItem.test.tsx
index 24af6c8eb91..957d086b538 100644
--- a/src/features/Conversation/WorkingSidebar/Review/__tests__/FileItem.test.tsx
+++ b/src/features/Conversation/WorkingSidebar/Review/__tests__/FileItem.test.tsx
@@ -10,10 +10,6 @@ vi.mock('@/store/global', () => ({
selector({ revealInFilesTab: mockRevealInFilesTab }),
}));
-vi.mock('@/components/AntdStaticMethods', () => ({
- message: { error: vi.fn(), success: vi.fn() },
-}));
-
vi.mock('@lobehub/ui/base-ui', () => ({
ActionIcon: ({ onClick, ...props }: React.ButtonHTMLAttributes<HTMLButtonElement>) => (
<button type="button" {...props} onClick={onClick} />
diff --git a/src/features/Conversation/store/slices/generation/continueHeteroAfterError.test.ts b/src/features/Conversation/store/slices/generation/continueHeteroAfterError.test.ts
index 2c13eb1825d..9388c906a07 100644
--- a/src/features/Conversation/store/slices/generation/continueHeteroAfterError.test.ts
+++ b/src/features/Conversation/store/slices/generation/continueHeteroAfterError.test.ts
@@ -114,10 +114,6 @@ vi.mock('@/store/user', () => ({
}),
}));
-vi.mock('@/components/AntdStaticMethods', () => ({
- message: { info: vi.fn() },
-}));
-
const mockChatDeleteMessage = vi.fn(async () => {});
const mockExecuteGatewayAgent = vi.fn(async () => {});
const noop = vi.fn();
diff --git a/src/features/Conversation/store/slices/generation/regenerateHeteroImages.test.ts b/src/features/Conversation/store/slices/generation/regenerateHeteroImages.test.ts
index 42f5ebe4a21..ea5e62845ed 100644
--- a/src/features/Conversation/store/slices/generation/regenerateHeteroImages.test.ts
+++ b/src/features/Conversation/store/slices/generation/regenerateHeteroImages.test.ts
@@ -79,10 +79,6 @@ vi.mock('@/store/electron', () => ({
getElectronStoreState: () => ({ gatewayDeviceInfo: { deviceId: 'device-1' } }),
}));
-vi.mock('@/components/AntdStaticMethods', () => ({
- message: { info: vi.fn() },
-}));
-
const noop = vi.fn();
vi.mock('@/store/chat', () => ({
useChatStore: {
diff --git a/src/layout/GlobalProvider/AppTheme.tsx b/src/layout/GlobalProvider/AppTheme.tsx
index 5d00834d04a..8df9dc6c657 100644
--- a/src/layout/GlobalProvider/AppTheme.tsx
+++ b/src/layout/GlobalProvider/AppTheme.tsx
@@ -9,7 +9,6 @@ import * as m from 'motion/react-m';
import { type ReactNode } from 'react';
import { memo, useEffect, useMemo, useState } from 'react';
-import AntdStaticMethods from '@/components/AntdStaticMethods';
import Link from '@/components/Link';
import { genFontFamily, genFontFamilyCode } from '@/const/font';
import { LOBE_THEME_NEUTRAL_COLOR, LOBE_THEME_PRIMARY_COLOR } from '@/const/theme';
@@ -180,7 +179,6 @@ const AppTheme = memo<AppThemeProps>(
>
{!!customFontURL && <FontLoader url={customFontURL} />}
<GlobalStyle />
- <AntdStaticMethods />
<ConfigProvider
locale={uiLocale}
motion={m}
diff --git a/src/routes/(main)/agent/profile/features/Header/index.test.tsx b/src/routes/(main)/agent/profile/features/Header/index.test.tsx
index 226e98eb754..8bb4495b4b3 100644
--- a/src/routes/(main)/agent/profile/features/Header/index.test.tsx
+++ b/src/routes/(main)/agent/profile/features/Header/index.test.tsx
@@ -152,14 +152,6 @@ vi.mock('react-router', () => ({
useNavigate: () => mocks.navigate,
}));
-vi.mock('@/components/AntdStaticMethods', () => ({
- message: {
- error: vi.fn(),
- success: vi.fn(),
- warning: vi.fn(),
- },
-}));
-
vi.mock('@/const/layoutTokens', () => ({
DESKTOP_HEADER_ICON_SMALL_SIZE: 24,
}));
diff --git a/src/store/file/slices/fileManager/action.test.ts b/src/store/file/slices/fileManager/action.test.ts
index ec462d93414..b38f5e059ca 100644
--- a/src/store/file/slices/fileManager/action.test.ts
+++ b/src/store/file/slices/fileManager/action.test.ts
@@ -26,13 +26,6 @@ vi.mock('i18next', () => ({
}));
// Mock message
-vi.mock('@/components/AntdStaticMethods', () => ({
- message: {
- info: vi.fn(),
- warning: vi.fn(),
- },
-}));
-
// Mock unzipFile
vi.mock('@/utils/unzipFile', () => ({
unzipFile: vi.fn(),
diff --git a/src/store/task/slices/detail/action.test.ts b/src/store/task/slices/detail/action.test.ts
index 2dd3a59d92e..ec213943aaa 100644
--- a/src/store/task/slices/detail/action.test.ts
+++ b/src/store/task/slices/detail/action.test.ts
@@ -34,11 +34,6 @@ vi.mock('@/libs/swr', () => ({
useClientDataSWR: vi.fn(),
}));
-vi.mock('@/components/AntdStaticMethods', () => ({
- modal: { confirm: vi.fn() },
- notification: { error: vi.fn() },
-}));
-
vi.mock('@lobehub/ui/base-ui', async (importOriginal) => ({
...(await importOriginal<object>()),
...(await import('~base-ui-stubs')).baseUiStubs,