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.

♻️ refactor(ui): migrate from Dropdown to DropdownMenu/ContextMenuTrigger components (#11539)

Innei9c9d4b17a96a
diff --git a/package.json b/package.json
index 7c90009382c..821000b7fbf 100644
--- a/package.json
+++ b/package.json
@@ -206,7 +206,7 @@
"@lobehub/icons": "^4.0.2",
"@lobehub/market-sdk": "0.29.0",
"@lobehub/tts": "^4.0.2",
- "@lobehub/ui": "^4.19.0",
+ "@lobehub/ui": "^4.21.0",
"@modelcontextprotocol/sdk": "^1.25.1",
"@neondatabase/serverless": "^1.0.2",
"@next/third-parties": "^16.1.1",
diff --git a/src/app/[variants]/(main)/agent/_layout/Sidebar/Cron/Actions.tsx b/src/app/[variants]/(main)/agent/_layout/Sidebar/Cron/Actions.tsx
index f4824edf3b9..38b4ceb6189 100644
--- a/src/app/[variants]/(main)/agent/_layout/Sidebar/Cron/Actions.tsx
+++ b/src/app/[variants]/(main)/agent/_layout/Sidebar/Cron/Actions.tsx
@@ -1,4 +1,4 @@
-import { ActionIcon, Dropdown } from '@lobehub/ui';
+import { ActionIcon, DropdownMenu } from '@lobehub/ui';
import { MoreHorizontal } from 'lucide-react';
import { memo } from 'react';
@@ -10,21 +10,12 @@ interface ActionsProps {
}
const Actions = memo<ActionsProps>(({ cronJobId, topics }) => {
- const dropdownMenu = useCronJobDropdownMenu(cronJobId, topics);
+ const menuItems = useCronJobDropdownMenu(cronJobId, topics);
return (
- <Dropdown
- arrow={false}
- menu={{
- items: dropdownMenu,
- onClick: ({ domEvent }) => {
- domEvent.stopPropagation();
- },
- }}
- trigger={['click']}
- >
+ <DropdownMenu items={menuItems}>
<ActionIcon icon={MoreHorizontal} size={'small'} />
- </Dropdown>
+ </DropdownMenu>
);
});
diff --git a/src/app/[variants]/(main)/agent/_layout/Sidebar/Topic/Actions.tsx b/src/app/[variants]/(main)/agent/_layout/Sidebar/Topic/Actions.tsx
index d07e82e2ab2..ffa604fb7db 100644
--- a/src/app/[variants]/(main)/agent/_layout/Sidebar/Topic/Actions.tsx
+++ b/src/app/[variants]/(main)/agent/_layout/Sidebar/Topic/Actions.tsx
@@ -1,25 +1,16 @@
-import { ActionIcon, Dropdown } from '@lobehub/ui';
+import { ActionIcon, DropdownMenu } from '@lobehub/ui';
import { MoreHorizontal } from 'lucide-react';
import { memo } from 'react';
import { useTopicActionsDropdownMenu } from './useDropdownMenu';
const Actions = memo(() => {
- const dropdownMenu = useTopicActionsDropdownMenu();
+ const menuItems = useTopicActionsDropdownMenu();
return (
- <Dropdown
- arrow={false}
- menu={{
- items: dropdownMenu,
- onClick: ({ domEvent }) => {
- domEvent.stopPropagation();
- },
- }}
- trigger={['click']}
- >
+ <DropdownMenu items={menuItems}>
<ActionIcon icon={MoreHorizontal} size={'small'} />
- </Dropdown>
+ </DropdownMenu>
);
});
diff --git a/src/app/[variants]/(main)/agent/_layout/Sidebar/Topic/index.tsx b/src/app/[variants]/(main)/agent/_layout/Sidebar/Topic/index.tsx
index 0569cfeb974..49a6bd1fd57 100644
--- a/src/app/[variants]/(main)/agent/_layout/Sidebar/Topic/index.tsx
+++ b/src/app/[variants]/(main)/agent/_layout/Sidebar/Topic/index.tsx
@@ -1,6 +1,6 @@
'use client';
-import { AccordionItem, Dropdown, Flexbox, Text } from '@lobehub/ui';
+import { AccordionItem, ContextMenuTrigger, Flexbox, Text } from '@lobehub/ui';
import React, { Suspense, memo } from 'react';
import { useTranslation } from 'react-i18next';
@@ -28,14 +28,7 @@ const Topic = memo<TopicProps>(({ itemKey }) => {
<AccordionItem
action={<Actions />}
headerWrapper={(header) => (
- <Dropdown
- menu={{
- items: dropdownMenu,
- }}
- trigger={['contextMenu']}
- >
- {header}
- </Dropdown>
+ <ContextMenuTrigger items={dropdownMenu}>{header}</ContextMenuTrigger>
)}
itemKey={itemKey}
paddingBlock={4}
diff --git a/src/app/[variants]/(main)/agent/features/Conversation/Header/Tags/KnowledgeTag.tsx b/src/app/[variants]/(main)/agent/features/Conversation/Header/Tags/KnowledgeTag.tsx
index 2e6465d9e7d..4871bd89cde 100644
--- a/src/app/[variants]/(main)/agent/features/Conversation/Header/Tags/KnowledgeTag.tsx
+++ b/src/app/[variants]/(main)/agent/features/Conversation/Header/Tags/KnowledgeTag.tsx
@@ -1,7 +1,6 @@
'use client';
-import { Dropdown, Icon, type MenuProps, Tag } from '@lobehub/ui';
-import { Flexbox } from '@lobehub/ui';
+import { DropdownMenu, Flexbox, Icon, type MenuProps, Tag } from '@lobehub/ui';
import { LibraryBig } from 'lucide-react';
import { memo } from 'react';
@@ -25,7 +24,7 @@ const PluginTag = memo<PluginTagProps>(({ data }) => {
const count = data.length;
return (
- <Dropdown menu={{ items }}>
+ <DropdownMenu items={items}>
<div>
<Tag>
{<Icon icon={LibraryBig} />}
@@ -35,7 +34,7 @@ const PluginTag = memo<PluginTagProps>(({ data }) => {
{count > 1 && <div>({data.length - 1}+)</div>}
</Tag>
</div>
- </Dropdown>
+ </DropdownMenu>
);
});
diff --git a/src/app/[variants]/(main)/agent/profile/features/ProfileEditor/MentionList/types.ts b/src/app/[variants]/(main)/agent/profile/features/ProfileEditor/MentionList/types.ts
index 9fff5c2a430..7a41ea948af 100644
--- a/src/app/[variants]/(main)/agent/profile/features/ProfileEditor/MentionList/types.ts
+++ b/src/app/[variants]/(main)/agent/profile/features/ProfileEditor/MentionList/types.ts
@@ -1,5 +1,5 @@
import type { API } from '@lobechat/prompts';
-import type { DropdownMenuItemType } from '@lobehub/ui';
+import type { DropdownItem } from '@lobehub/ui';
export type MentionEntityType = 'collection' | 'api';
@@ -14,7 +14,9 @@ export interface MentionMetadata {
type?: MentionEntityType;
}
-export type MentionListOption = DropdownMenuItemType & {
+type MentionMenuItem = Extract<DropdownItem, { type?: 'item' }>;
+
+export type MentionListOption = MentionMenuItem & {
description?: string;
metadata?: MentionMetadata;
};
diff --git a/src/app/[variants]/(main)/community/(detail)/model/features/Sidebar/ActionButton/ChatWithModel.tsx b/src/app/[variants]/(main)/community/(detail)/model/features/Sidebar/ActionButton/ChatWithModel.tsx
index eee7cfb56a9..c8bdd365db1 100644
--- a/src/app/[variants]/(main)/community/(detail)/model/features/Sidebar/ActionButton/ChatWithModel.tsx
+++ b/src/app/[variants]/(main)/community/(detail)/model/features/Sidebar/ActionButton/ChatWithModel.tsx
@@ -1,7 +1,7 @@
'use client';
import { ProviderIcon } from '@lobehub/icons';
-import { Button, Icon } from '@lobehub/ui';
+import { Button, DropdownMenu, Icon } from '@lobehub/ui';
import { Dropdown } from 'antd';
import { createStaticStyles } from 'antd-style';
import { ChevronDownIcon } from 'lucide-react';
@@ -69,12 +69,7 @@ const ChatWithModel = memo(() => {
);
return (
- <Dropdown
- menu={{
- items,
- }}
- trigger={['click']}
- >
+ <DropdownMenu data-no-highlight items={items}>
<Button
className={styles.button}
size={'large'}
@@ -83,7 +78,7 @@ const ChatWithModel = memo(() => {
>
{t('models.guide')}
</Button>
- </Dropdown>
+ </DropdownMenu>
);
});
diff --git a/src/app/[variants]/(main)/community/(list)/assistant/features/MarketSourceSwitch.tsx b/src/app/[variants]/(main)/community/(list)/assistant/features/MarketSourceSwitch.tsx
index 29a1d006865..8377b0a0c60 100644
--- a/src/app/[variants]/(main)/community/(list)/assistant/features/MarketSourceSwitch.tsx
+++ b/src/app/[variants]/(main)/community/(list)/assistant/features/MarketSourceSwitch.tsx
@@ -1,6 +1,12 @@
'use client';
-import { Dropdown, type DropdownMenuItemType, Icon , Button } from '@lobehub/ui';
+import {
+ Button,
+ type DropdownItem,
+ DropdownMenu,
+ type DropdownMenuCheckboxItem,
+ Icon,
+} from '@lobehub/ui';
import { ChevronDown, Store } from 'lucide-react';
import { memo, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
@@ -15,18 +21,22 @@ const MarketSourceSwitch = memo(() => {
const query = useQuery() as { source?: AssistantMarketSource };
const currentSource = (query.source as AssistantMarketSource) ?? 'new';
- const items = useMemo(
- () =>
- [
- {
- key: 'new',
- label: t('assistants.marketSource.new'),
- },
- {
- key: 'legacy',
- label: t('assistants.marketSource.legacy'),
- },
- ] satisfies DropdownMenuItemType[],
+ type MarketSourceItem = Extract<DropdownItem, { type?: 'item' }> & {
+ key: AssistantMarketSource;
+ label: string;
+ };
+
+ const items = useMemo<MarketSourceItem[]>(
+ () => [
+ {
+ key: 'new',
+ label: t('assistants.marketSource.new'),
+ },
+ {
+ key: 'legacy',
+ label: t('assistants.marketSource.legacy'),
+ },
+ ],
[t],
);
@@ -39,22 +49,33 @@ const MarketSourceSwitch = memo(() => {
});
};
+ const menuItems = useMemo<DropdownMenuCheckboxItem[]>(
+ () =>
+ items.map(
+ (item): DropdownMenuCheckboxItem => ({
+ checked: item.key === currentSource,
+ closeOnClick: true,
+ key: item.key,
+ label: item.label,
+ onCheckedChange: (checked: boolean) => {
+ if (checked) {
+ handleChange(item.key);
+ }
+ },
+ type: 'checkbox',
+ }),
+ ),
+ [currentSource, handleChange, items],
+ );
+
return (
- <Dropdown
- menu={{
- // @ts-expect-error 等待 antd 修复
- activeKey: currentSource,
- items,
- onClick: ({ key }) => handleChange(key as AssistantMarketSource),
- }}
- trigger={['click', 'hover']}
- >
+ <DropdownMenu items={menuItems} trigger="both">
<Button icon={<Icon icon={Store} />} type={'text'}>
{t('assistants.marketSource.label')}:{' '}
{items.find((item) => item.key === currentSource)?.label}
<Icon icon={ChevronDown} />
</Button>
- </Dropdown>
+ </DropdownMenu>
);
});
diff --git a/src/app/[variants]/(main)/community/(list)/features/SortButton/index.tsx b/src/app/[variants]/(main)/community/(list)/features/SortButton/index.tsx
index aab56b8ef1b..cf4fbeff09c 100644
--- a/src/app/[variants]/(main)/community/(list)/features/SortButton/index.tsx
+++ b/src/app/[variants]/(main)/community/(list)/features/SortButton/index.tsx
@@ -1,11 +1,17 @@
-import { Button, Dropdown, type DropdownMenuItemType, Icon } from '@lobehub/ui';
+import {
+ Button,
+ type DropdownItem,
+ DropdownMenu,
+ type DropdownMenuCheckboxItem,
+ Icon,
+} from '@lobehub/ui';
import { ArrowDownWideNarrow, ChevronDown } from 'lucide-react';
import { memo, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
import { useQueryRoute } from '@/hooks/useQueryRoute';
import { useMarketAuth } from '@/layout/AuthProvider/MarketAuth';
-import { usePathname , useQuery } from '@/libs/router/navigation';
+import { usePathname, useQuery } from '@/libs/router/navigation';
import {
AssistantSorts,
DiscoverTab,
@@ -22,7 +28,11 @@ const SortButton = memo(() => {
const router = useQueryRoute();
const { isAuthenticated, getCurrentUserInfo } = useMarketAuth();
const activeTab = useMemo(() => pathname.split('community/')[1] as DiscoverTab, [pathname]);
- const items = useMemo(() => {
+ type SortItem = Extract<DropdownItem, { type?: 'item' }> & {
+ key: string;
+ };
+
+ const items = useMemo<SortItem[]>(() => {
switch (activeTab) {
case DiscoverTab.Assistants: {
const baseItems = [
@@ -153,8 +163,8 @@ const SortButton = memo(() => {
label: t('mcp.sorts.updatedAt'),
},
{
+ key: McpSorts.CreatedAt,
label: t('mcp.sorts.createdAt'),
- value: McpSorts.CreatedAt,
},
];
}
@@ -164,12 +174,12 @@ const SortButton = memo(() => {
}
}, [t, activeTab, isAuthenticated]);
- const activeItem: any = useMemo(() => {
+ const activeItem = useMemo<SortItem | undefined>(() => {
if (sort) {
- const findItem = items?.find((item: any) => item.key === sort);
+ const findItem = items.find((item) => String(item.key) === sort);
if (findItem) return findItem;
}
- return items?.[0];
+ return items[0];
}, [items, sort]);
const handleSort = (config: string) => {
@@ -187,23 +197,34 @@ const SortButton = memo(() => {
router.push(pathname, { query });
};
- if (items?.length === 0) return null;
+ const menuItems = useMemo<DropdownMenuCheckboxItem[]>(
+ () =>
+ items.map(
+ (item): DropdownMenuCheckboxItem => ({
+ checked: item.key === activeItem?.key,
+ closeOnClick: true,
+ key: item.key,
+ label: item.label,
+ onCheckedChange: (checked: boolean) => {
+ if (checked) {
+ handleSort(String(item.key));
+ }
+ },
+ type: 'checkbox',
+ }),
+ ),
+ [activeItem?.key, handleSort, items],
+ );
+
+ if (menuItems.length === 0) return null;
return (
- <Dropdown
- menu={{
- // @ts-expect-error 等待 antd 修复
- activeKey: activeItem.key,
- items: items as DropdownMenuItemType[],
- onClick: ({ key }) => handleSort(key),
- }}
- trigger={['click', 'hover']}
- >
+ <DropdownMenu items={menuItems} trigger="both">
<Button data-testid="sort-dropdown" icon={<Icon icon={ArrowDownWideNarrow} />} type={'text'}>
- {activeItem.label}
+ {activeItem?.label ?? menuItems[0]?.label}
<Icon icon={ChevronDown} />
</Button>
- </Dropdown>
+ </DropdownMenu>
);
});
diff --git a/src/app/[variants]/(main)/group/_layout/Sidebar/Topic/Actions.tsx b/src/app/[variants]/(main)/group/_layout/Sidebar/Topic/Actions.tsx
index d07e82e2ab2..ffa604fb7db 100644
--- a/src/app/[variants]/(main)/group/_layout/Sidebar/Topic/Actions.tsx
+++ b/src/app/[variants]/(main)/group/_layout/Sidebar/Topic/Actions.tsx
@@ -1,25 +1,16 @@
-import { ActionIcon, Dropdown } from '@lobehub/ui';
+import { ActionIcon, DropdownMenu } from '@lobehub/ui';
import { MoreHorizontal } from 'lucide-react';
import { memo } from 'react';
import { useTopicActionsDropdownMenu } from './useDropdownMenu';
const Actions = memo(() => {
- const dropdownMenu = useTopicActionsDropdownMenu();
+ const menuItems = useTopicActionsDropdownMenu();
return (
- <Dropdown
- arrow={false}
- menu={{
- items: dropdownMenu,
- onClick: ({ domEvent }) => {
- domEvent.stopPropagation();
- },
- }}
- trigger={['click']}
- >
+ <DropdownMenu items={menuItems}>
<ActionIcon icon={MoreHorizontal} size={'small'} />
- </Dropdown>
+ </DropdownMenu>
);
});
diff --git a/src/app/[variants]/(main)/group/_layout/Sidebar/Topic/index.tsx b/src/app/[variants]/(main)/group/_layout/Sidebar/Topic/index.tsx
index deeb346a4f9..a7b022cd9ba 100644
--- a/src/app/[variants]/(main)/group/_layout/Sidebar/Topic/index.tsx
+++ b/src/app/[variants]/(main)/group/_layout/Sidebar/Topic/index.tsx
@@ -1,6 +1,6 @@
'use client';
-import { AccordionItem, Dropdown, Flexbox, Text } from '@lobehub/ui';
+import { AccordionItem, ContextMenuTrigger, Flexbox, Text } from '@lobehub/ui';
import React, { Suspense, memo } from 'react';
import { useTranslation } from 'react-i18next';
@@ -28,14 +28,7 @@ const Topic = memo<TopicProps>(({ itemKey }) => {
<AccordionItem
action={<Actions />}
headerWrapper={(header) => (
- <Dropdown
- menu={{
- items: dropdownMenu,
- }}
- trigger={['contextMenu']}
- >
- {header}
- </Dropdown>
+ <ContextMenuTrigger items={dropdownMenu}>{header}</ContextMenuTrigger>
)}
itemKey={itemKey}
paddingBlock={4}
diff --git a/src/app/[variants]/(main)/group/features/Conversation/Header/Tags/KnowledgeTag.tsx b/src/app/[variants]/(main)/group/features/Conversation/Header/Tags/KnowledgeTag.tsx
index 2e6465d9e7d..4871bd89cde 100644
--- a/src/app/[variants]/(main)/group/features/Conversation/Header/Tags/KnowledgeTag.tsx
+++ b/src/app/[variants]/(main)/group/features/Conversation/Header/Tags/KnowledgeTag.tsx
@@ -1,7 +1,6 @@
'use client';
-import { Dropdown, Icon, type MenuProps, Tag } from '@lobehub/ui';
-import { Flexbox } from '@lobehub/ui';
+import { DropdownMenu, Flexbox, Icon, type MenuProps, Tag } from '@lobehub/ui';
import { LibraryBig } from 'lucide-react';
import { memo } from 'react';
@@ -25,7 +24,7 @@ const PluginTag = memo<PluginTagProps>(({ data }) => {
const count = data.length;
return (
- <Dropdown menu={{ items }}>
+ <DropdownMenu items={items}>
<div>
<Tag>
{<Icon icon={LibraryBig} />}
@@ -35,7 +34,7 @@ const PluginTag = memo<PluginTagProps>(({ data }) => {
{count > 1 && <div>({data.length - 1}+)</div>}
</Tag>
</div>
- </Dropdown>
+ </DropdownMenu>
);
});
diff --git a/src/app/[variants]/(main)/group/profile/features/MemberProfile/MentionList/types.ts b/src/app/[variants]/(main)/group/profile/features/MemberProfile/MentionList/types.ts
index 9fff5c2a430..7a41ea948af 100644
--- a/src/app/[variants]/(main)/group/profile/features/MemberProfile/MentionList/types.ts
+++ b/src/app/[variants]/(main)/group/profile/features/MemberProfile/MentionList/types.ts
@@ -1,5 +1,5 @@
import type { API } from '@lobechat/prompts';
-import type { DropdownMenuItemType } from '@lobehub/ui';
+import type { DropdownItem } from '@lobehub/ui';
export type MentionEntityType = 'collection' | 'api';
@@ -14,7 +14,9 @@ export interface MentionMetadata {
type?: MentionEntityType;
}
-export type MentionListOption = DropdownMenuItemType & {
+type MentionMenuItem = Extract<DropdownItem, { type?: 'item' }>;
+
+export type MentionListOption = MentionMenuItem & {
description?: string;
metadata?: MentionMetadata;
};
diff --git a/src/app/[variants]/(main)/home/_layout/Body/Agent/Actions.tsx b/src/app/[variants]/(main)/home/_layout/Body/Agent/Actions.tsx
index ccc5e6e4768..3d3f8297f73 100644
--- a/src/app/[variants]/(main)/home/_layout/Body/Agent/Actions.tsx
+++ b/src/app/[variants]/(main)/home/_layout/Body/Agent/Actions.tsx
@@ -1,4 +1,4 @@
-import { ActionIcon, Dropdown, type MenuProps } from '@lobehub/ui';
+import { ActionIcon, DropdownMenu, type MenuProps } from '@lobehub/ui';
import { MoreHorizontalIcon } from 'lucide-react';
import { memo } from 'react';
@@ -9,22 +9,14 @@ interface ActionsProps {
const Actions = memo<ActionsProps>(({ dropdownMenu, isLoading }) => {
return (
- <Dropdown
- menu={{
- items: dropdownMenu,
- onClick: ({ domEvent }) => {
- domEvent.stopPropagation();
- },
- }}
- trigger={['click']}
- >
+ <DropdownMenu items={dropdownMenu}>
<ActionIcon
icon={MoreHorizontalIcon}
loading={isLoading}
size={'small'}
style={{ flex: 'none' }}
/>
- </Dropdown>
+ </DropdownMenu>
);
});
diff --git a/src/app/[variants]/(main)/home/_layout/Body/Agent/List/Group/Actions.tsx b/src/app/[variants]/(main)/home/_layout/Body/Agent/List/Group/Actions.tsx
index c959a77dae8..b3e0c87f1e5 100644
--- a/src/app/[variants]/(main)/home/_layout/Body/Agent/List/Group/Actions.tsx
+++ b/src/app/[variants]/(main)/home/_layout/Body/Agent/List/Group/Actions.tsx
@@ -1,4 +1,4 @@
-import { ActionIcon, Dropdown, type MenuProps } from '@lobehub/ui';
+import { ActionIcon, DropdownMenu, type MenuProps } from '@lobehub/ui';
import { MoreHorizontalIcon } from 'lucide-react';
import { memo } from 'react';
@@ -9,16 +9,7 @@ interface ActionsProps {
const Actions = memo<ActionsProps>(({ dropdownMenu, isLoading }) => {
return (
- <Dropdown
- arrow={false}
- menu={{
- items: dropdownMenu,
- onClick: ({ domEvent }) => {
- domEvent.stopPropagation();
- },
- }}
- trigger={['click']}
- >
+ <DropdownMenu items={dropdownMenu}>
<ActionIcon
icon={MoreHorizontalIcon}
loading={isLoading}
@@ -27,7 +18,7 @@ const Actions = memo<ActionsProps>(({ dropdownMenu, isLoading }) => {
}}
size={'small'}
/>
- </Dropdown>
+ </DropdownMenu>
);
});
diff --git a/src/app/[variants]/(main)/home/_layout/Body/Agent/List/Group/Item.tsx b/src/app/[variants]/(main)/home/_layout/Body/Agent/List/Group/Item.tsx
index 3d76a6c3e75..18b4b7b3c0e 100644
--- a/src/app/[variants]/(main)/home/_layout/Body/Agent/List/Group/Item.tsx
+++ b/src/app/[variants]/(main)/home/_layout/Body/Agent/List/Group/Item.tsx
@@ -1,5 +1,5 @@
import type { SidebarGroup } from '@lobechat/types';
-import { AccordionItem, Dropdown, Flexbox, Icon, Text } from '@lobehub/ui';
+import { AccordionItem, ContextMenuTrigger, Flexbox, Icon, Text } from '@lobehub/ui';
import { createStaticStyles } from 'antd-style';
import { HashIcon, Loader2 } from 'lucide-react';
import React, { memo, useCallback, useMemo } from 'react';
@@ -61,14 +61,7 @@ const GroupItem = memo<SidebarGroup>(({ items, id, name }) => {
action={<Actions dropdownMenu={dropdownMenu} isLoading={isLoading} />}
disabled={editing || isUpdating}
headerWrapper={(header) => (
- <Dropdown
- menu={{
- items: dropdownMenu,
- }}
- trigger={['contextMenu']}
- >
- {header}
- </Dropdown>
+ <ContextMenuTrigger items={dropdownMenu}>{header}</ContextMenuTrigger>
)}
itemKey={id}
key={id}
diff --git a/src/app/[variants]/(main)/home/_layout/Body/Agent/index.tsx b/src/app/[variants]/(main)/home/_layout/Body/Agent/index.tsx
index 3f4508dc712..033ad5e794e 100644
--- a/src/app/[variants]/(main)/home/_layout/Body/Agent/index.tsx
+++ b/src/app/[variants]/(main)/home/_layout/Body/Agent/index.tsx
@@ -1,6 +1,6 @@
'use client';
-import { AccordionItem, Dropdown, Flexbox, Text } from '@lobehub/ui';
+import { AccordionItem, ContextMenuTrigger, Flexbox, Text } from '@lobehub/ui';
import React, { Suspense, memo, useCallback } from 'react';
import { useTranslation } from 'react-i18next';
@@ -39,14 +39,7 @@ const Agent = memo<AgentProps>(({ itemKey }) => {
<AccordionItem
action={<Actions dropdownMenu={dropdownMenu} isLoading={isLoading} />}
headerWrapper={(header) => (
- <Dropdown
- menu={{
- items: dropdownMenu,
- }}
- trigger={['contextMenu']}
- >
- {header}
- </Dropdown>
+ <ContextMenuTrigger items={dropdownMenu}>{header}</ContextMenuTrigger>
)}
itemKey={itemKey}
paddingBlock={4}
diff --git a/src/app/[variants]/(main)/home/_layout/Body/Project/index.tsx b/src/app/[variants]/(main)/home/_layout/Body/Project/index.tsx
index 2190b1bbd6b..332e99e3f52 100644
--- a/src/app/[variants]/(main)/home/_layout/Body/Project/index.tsx
+++ b/src/app/[variants]/(main)/home/_layout/Body/Project/index.tsx
@@ -1,6 +1,6 @@
'use client';
-import { AccordionItem, Dropdown, Text } from '@lobehub/ui';
+import { AccordionItem, ContextMenuTrigger, Text } from '@lobehub/ui';
import React, { Suspense, memo } from 'react';
import { useTranslation } from 'react-i18next';
@@ -21,14 +21,7 @@ const Project = memo<ProjectProps>(({ itemKey }) => {
<AccordionItem
action={<Actions />}
headerWrapper={(header) => (
- <Dropdown
- menu={{
- items: dropdownMenu,
- }}
- trigger={['contextMenu']}
- >
- {header}
- </Dropdown>
+ <ContextMenuTrigger items={dropdownMenu}>{header}</ContextMenuTrigger>
)}
itemKey={itemKey}
paddingBlock={4}
diff --git a/src/app/[variants]/(main)/home/features/CommunityAgents/index.tsx b/src/app/[variants]/(main)/home/features/CommunityAgents/index.tsx
index 8fb50cdadf3..a3cd0a98cf6 100644
--- a/src/app/[variants]/(main)/home/features/CommunityAgents/index.tsx
+++ b/src/app/[variants]/(main)/home/features/CommunityAgents/index.tsx
@@ -1,6 +1,6 @@
'use client';
-import { ActionIcon, Dropdown } from '@lobehub/ui';
+import { ActionIcon, DropdownMenu } from '@lobehub/ui';
import { BotIcon, MoreHorizontal } from 'lucide-react';
import { Suspense, memo } from 'react';
import { useTranslation } from 'react-i18next';
@@ -18,21 +18,19 @@ const CommunityAgents = memo(() => {
return (
<GroupBlock
action={
- <Dropdown
- menu={{
- items: [
- {
- key: 'all-assistants',
- label: t('home.more'),
- onClick: () => {
- navigate('/community/assistant');
- },
+ <DropdownMenu
+ items={[
+ {
+ key: 'all-assistants',
+ label: t('home.more'),
+ onClick: () => {
+ navigate('/community/assistant');
},
- ],
- }}
+ },
+ ]}
>
<ActionIcon icon={MoreHorizontal} size="small" />
- </Dropdown>
+ </DropdownMenu>
}
icon={BotIcon}
title={t('home.communityAgents')}
diff --git a/src/app/[variants]/(main)/home/features/FeaturedPlugins/index.tsx b/src/app/[variants]/(main)/home/features/FeaturedPlugins/index.tsx
index 437b02b3bf9..440198eee52 100644
--- a/src/app/[variants]/(main)/home/features/FeaturedPlugins/index.tsx
+++ b/src/app/[variants]/(main)/home/features/FeaturedPlugins/index.tsx
@@ -1,7 +1,7 @@
'use client';
import { MCP } from '@lobehub/icons';
-import { ActionIcon, Dropdown, Grid } from '@lobehub/ui';
+import { ActionIcon, DropdownMenu, Grid } from '@lobehub/ui';
import { cssVar } from 'antd-style';
import { MoreHorizontal } from 'lucide-react';
import { Suspense, memo } from 'react';
@@ -20,21 +20,19 @@ const FeaturedPlugins = memo(() => {
return (
<GroupBlock
action={
- <Dropdown
- menu={{
- items: [
- {
- key: 'all-plugins',
- label: t('home.more'),
- onClick: () => {
- navigate('/community/mcp');
- },
+ <DropdownMenu
+ items={[
+ {
+ key: 'all-plugins',
+ label: t('home.more'),
+ onClick: () => {
+ navigate('/community/mcp');
},
- ],
- }}
+ },
+ ]}
>
<ActionIcon icon={MoreHorizontal} size="small" />
- </Dropdown>
+ </DropdownMenu>
}
icon={<MCP color={cssVar.colorTextDescription} size={18} />}
title={t('home.featuredPlugins')}
diff --git a/src/app/[variants]/(main)/home/features/RecentPage/index.tsx b/src/app/[variants]/(main)/home/features/RecentPage/index.tsx
index a417d61df59..aab82aab18f 100644
--- a/src/app/[variants]/(main)/home/features/RecentPage/index.tsx
+++ b/src/app/[variants]/(main)/home/features/RecentPage/index.tsx
@@ -1,6 +1,6 @@
'use client';
-import { ActionIcon, Dropdown } from '@lobehub/ui';
+import { ActionIcon, DropdownMenu } from '@lobehub/ui';
import { FileTextIcon, MoreHorizontal } from 'lucide-react';
import { Suspense, memo } from 'react';
import { useTranslation } from 'react-i18next';
@@ -37,22 +37,20 @@ const RecentPage = memo(() => {
action={
<>
{isRevalidating && <NeuralNetworkLoading size={14} />}
- <Dropdown
- menu={{
- items: [
- {
- key: 'all-documents',
- label: t('menu.allPages'),
- onClick: () => {
- setCategory(FilesTabs.Pages);
- navigate('/resource');
- },
+ <DropdownMenu
+ items={[
+ {
+ key: 'all-documents',
+ label: t('menu.allPages'),
+ onClick: () => {
+ setCategory(FilesTabs.Pages);
+ navigate('/resource');
},
- ],
- }}
+ },
+ ]}
>
<ActionIcon icon={MoreHorizontal} size="small" />
- </Dropdown>
+ </DropdownMenu>
</>
}
icon={FileTextIcon}
diff --git a/src/app/[variants]/(main)/home/features/RecentResource/index.tsx b/src/app/[variants]/(main)/home/features/RecentResource/index.tsx
index 40c56884977..e4398f538fa 100644
--- a/src/app/[variants]/(main)/home/features/RecentResource/index.tsx
+++ b/src/app/[variants]/(main)/home/features/RecentResource/index.tsx
@@ -1,6 +1,6 @@
'use client';
-import { ActionIcon, Dropdown } from '@lobehub/ui';
+import { ActionIcon, DropdownMenu } from '@lobehub/ui';
import { Clock, MoreHorizontal } from 'lucide-react';
import { Suspense, memo } from 'react';
import { useTranslation } from 'react-i18next';
@@ -37,22 +37,20 @@ const RecentResource = memo(() => {
action={
<>
{isRevalidating && <NeuralNetworkLoading size={14} />}
- <Dropdown
- menu={{
- items: [
- {
- key: 'all-files',
- label: t('menu.allFiles'),
- onClick: () => {
- setCategory(FilesTabs.All);
- navigate('/resource');
- },
+ <DropdownMenu
+ items={[
+ {
+ key: 'all-files',
+ label: t('menu.allFiles'),
+ onClick: () => {
+ setCategory(FilesTabs.All);
+ navigate('/resource');
},
- ],
- }}
+ },
+ ]}
>
<ActionIcon icon={MoreHorizontal} size="small" />
- </Dropdown>
+ </DropdownMenu>
</>
}
icon={Clock}
diff --git a/src/app/[variants]/(main)/memory/contexts/features/ContextDropdown.tsx b/src/app/[variants]/(main)/memory/contexts/features/ContextDropdown.tsx
index 2ea02e0974d..62199178f44 100644
--- a/src/app/[variants]/(main)/memory/contexts/features/ContextDropdown.tsx
+++ b/src/app/[variants]/(main)/memory/contexts/features/ContextDropdown.tsx
@@ -1,4 +1,4 @@
-import { ActionIcon, type ActionIconProps, Dropdown } from '@lobehub/ui';
+import { ActionIcon, type ActionIconProps, DropdownMenu } from '@lobehub/ui';
import { App } from 'antd';
import { MoreHorizontal, Pencil, Trash2 } from 'lucide-react';
import { type KeyboardEvent, type MouseEvent, memo } from 'react';
@@ -47,19 +47,21 @@ const ContextDropdown = memo<ContextDropdownProps>(({ id, size = 'small' }) => {
icon: <Pencil size={14} />,
key: 'edit',
label: t('context.actions.edit'),
+ onClick: handleMenuClick,
},
{
danger: true,
icon: <Trash2 size={14} />,
key: 'delete',
label: t('context.actions.delete'),
+ onClick: handleMenuClick,
},
];
return (
- <Dropdown menu={{ items: menuItems, onClick: handleMenuClick }} trigger={['click']}>
+ <DropdownMenu items={menuItems}>
<ActionIcon icon={MoreHorizontal} size={size} />
- </Dropdown>
+ </DropdownMenu>
);
});
diff --git a/src/app/[variants]/(main)/memory/experiences/features/ExperienceDropdown.tsx b/src/app/[variants]/(main)/memory/experiences/features/ExperienceDropdown.tsx
index 1f55244d364..a035e3dadb9 100644
--- a/src/app/[variants]/(main)/memory/experiences/features/ExperienceDropdown.tsx
+++ b/src/app/[variants]/(main)/memory/experiences/features/ExperienceDropdown.tsx
@@ -1,4 +1,4 @@
-import { ActionIcon, type ActionIconProps, Dropdown } from '@lobehub/ui';
+import { ActionIcon, type ActionIconProps, DropdownMenu } from '@lobehub/ui';
import { App } from 'antd';
import { MoreHorizontal, Pencil, Trash2 } from 'lucide-react';
import { type KeyboardEvent, type MouseEvent, memo } from 'react';
@@ -47,19 +47,21 @@ const ExperienceDropdown = memo<ExperienceDropdownProps>(({ id, size = 'small' }
icon: <Pencil size={14} />,
key: 'edit',
label: t('experience.actions.edit'),
+ onClick: handleMenuClick,
},
{
danger: true,
icon: <Trash2 size={14} />,
key: 'delete',
label: t('experience.actions.delete'),
+ onClick: handleMenuClick,
},
];
return (
- <Dropdown menu={{ items: menuItems, onClick: handleMenuClick }} trigger={['click']}>
+ <DropdownMenu items={menuItems}>
<ActionIcon icon={MoreHorizontal} size={size} />
- </Dropdown>
+ </DropdownMenu>
);
});
diff --git a/src/app/[variants]/(main)/memory/identities/features/IdentityDropdown.tsx b/src/app/[variants]/(main)/memory/identities/features/IdentityDropdown.tsx
index b745d791121..34d2daf0c35 100644
--- a/src/app/[variants]/(main)/memory/identities/features/IdentityDropdown.tsx
+++ b/src/app/[variants]/(main)/memory/identities/features/IdentityDropdown.tsx
@@ -1,4 +1,4 @@
-import { ActionIcon, type ActionIconProps, Dropdown } from '@lobehub/ui';
+import { ActionIcon, type ActionIconProps, DropdownMenu } from '@lobehub/ui';
import { App } from 'antd';
import { MoreHorizontal, Pencil, Trash2 } from 'lucide-react';
import { type KeyboardEvent, type MouseEvent, memo } from 'react';
@@ -47,19 +47,21 @@ const IdentityDropdown = memo<IdentityDropdownProps>(({ id, size = 'small' }) =>
icon: <Pencil size={14} />,
key: 'edit',
label: t('edit', { ns: 'common' }),
+ onClick: handleMenuClick,
},
{
danger: true,
icon: <Trash2 size={14} />,
key: 'delete',
label: t('delete', { ns: 'common' }),
+ onClick: handleMenuClick,
},
];
return (
- <Dropdown menu={{ items: menuItems, onClick: handleMenuClick }} trigger={['click']}>
+ <DropdownMenu items={menuItems}>
<ActionIcon icon={MoreHorizontal} size={size} />
- </Dropdown>
+ </DropdownMenu>
);
});
diff --git a/src/app/[variants]/(main)/memory/preferences/features/PreferenceDropdown.tsx b/src/app/[variants]/(main)/memory/preferences/features/PreferenceDropdown.tsx
index 3ac522ca454..228869168fd 100644
--- a/src/app/[variants]/(main)/memory/preferences/features/PreferenceDropdown.tsx
+++ b/src/app/[variants]/(main)/memory/preferences/features/PreferenceDropdown.tsx
@@ -1,4 +1,4 @@
-import { ActionIcon, type ActionIconProps, Dropdown } from '@lobehub/ui';
+import { ActionIcon, type ActionIconProps, DropdownMenu } from '@lobehub/ui';
import { App } from 'antd';
import { MoreHorizontal, Pencil, Trash2 } from 'lucide-react';
import { type KeyboardEvent, type MouseEvent, memo } from 'react';
@@ -47,19 +47,21 @@ const PreferenceDropdown = memo<PreferenceDropdownProps>(({ id, size = 'small' }
icon: <Pencil size={14} />,
key: 'edit',
label: t('preference.actions.edit'),
+ onClick: handleMenuClick,
},
{
danger: true,
icon: <Trash2 size={14} />,
key: 'delete',
label: t('preference.actions.delete'),
+ onClick: handleMenuClick,
},
];
return (
- <Dropdown menu={{ items: menuItems, onClick: handleMenuClick }} trigger={['click']}>
+ <DropdownMenu items={menuItems}>
<ActionIcon icon={MoreHorizontal} size={size} />
- </Dropdown>
+ </DropdownMenu>
);
});
diff --git a/src/app/[variants]/(main)/page/_layout/Body/Actions.tsx b/src/app/[variants]/(main)/page/_layout/Body/Actions.tsx
index cac03aa1690..62a896fddca 100644
--- a/src/app/[variants]/(main)/page/_layout/Body/Actions.tsx
+++ b/src/app/[variants]/(main)/page/_layout/Body/Actions.tsx
@@ -1,7 +1,6 @@
'use client';
-import { ActionIcon, Dropdown } from '@lobehub/ui';
-import type { MenuProps } from '@lobehub/ui';
+import { ActionIcon, DropdownMenu, type MenuProps } from '@lobehub/ui';
import { MoreHorizontal } from 'lucide-react';
import { memo } from 'react';
@@ -11,18 +10,9 @@ const Actions = memo(() => {
const items: MenuProps['items'] = useDropdownMenu();
return (
- <Dropdown
- arrow={false}
- menu={{
- items,
- onClick: ({ domEvent }) => {
- domEvent.stopPropagation();
- },
- }}
- trigger={['click']}
- >
+ <DropdownMenu items={items}>
<ActionIcon icon={MoreHorizontal} size={'small'} />
- </Dropdown>
+ </DropdownMenu>
);
});
diff --git a/src/app/[variants]/(main)/page/_layout/Body/index.tsx b/src/app/[variants]/(main)/page/_layout/Body/index.tsx
index 77087371137..4006b50609f 100644
--- a/src/app/[variants]/(main)/page/_layout/Body/index.tsx
+++ b/src/app/[variants]/(main)/page/_layout/Body/index.tsx
@@ -1,6 +1,6 @@
'use client';
-import { Accordion, AccordionItem, Dropdown, Flexbox, Text } from '@lobehub/ui';
+import { Accordion, AccordionItem, ContextMenuTrigger, Flexbox, Text } from '@lobehub/ui';
import React, { Suspense, memo } from 'react';
import { useTranslation } from 'react-i18next';
@@ -44,14 +44,7 @@ const Body = memo(() => {
<AccordionItem
action={<Actions />}
headerWrapper={(header) => (
- <Dropdown
- menu={{
- items: dropdownMenu,
- }}
- trigger={['contextMenu']}
- >
- {header}
- </Dropdown>
+ <ContextMenuTrigger items={dropdownMenu}>{header}</ContextMenuTrigger>
)}
itemKey={GroupKey.AllPages}
paddingBlock={4}
diff --git a/src/app/[variants]/(main)/resource/features/DndContextWrapper.tsx b/src/app/[variants]/(main)/resource/features/DndContextWrapper.tsx
index 2571f280e36..25319dd82a7 100644
--- a/src/app/[variants]/(main)/resource/features/DndContextWrapper.tsx
+++ b/src/app/[variants]/(main)/resource/features/DndContextWrapper.tsx
@@ -61,7 +61,7 @@ interface DragState {
const DragStateContext = createContext<{
currentDrag: DragState | null;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
- setCurrentDrag: (state: DragState | null) => void;
+ setCurrentDrag: (_state: DragState | null) => void;
}>({
currentDrag: null,
setCurrentDrag: () => {},
diff --git a/src/app/[variants]/(main)/settings/profile/features/SSOProvidersList/index.tsx b/src/app/[variants]/(main)/settings/profile/features/SSOProvidersList/index.tsx
index b70db2e2c93..00a3cc5b7b4 100644
--- a/src/app/[variants]/(main)/settings/profile/features/SSOProvidersList/index.tsx
+++ b/src/app/[variants]/(main)/settings/profile/features/SSOProvidersList/index.tsx
@@ -1,5 +1,5 @@
import { isDesktop } from '@lobechat/const';
-import { ActionIcon, Dropdown, Flexbox, type MenuProps, Text } from '@lobehub/ui';
+import { ActionIcon, DropdownMenu, Flexbox, type MenuProps, Text } from '@lobehub/ui';
import { ArrowRight, Plus, Unlink } from 'lucide-react';
import { type CSSProperties, memo, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
@@ -120,13 +120,13 @@ export const SSOProvidersList = memo(() => {
{/* Link Account Button - Only show for Better-Auth users with available providers */}
{enableBetterAuthActions && availableProviders.length > 0 && (
- <Dropdown menu={{ items: linkMenuItems, style: { maxWidth: '200px' } }} trigger={['click']}>
+ <DropdownMenu items={linkMenuItems} popupProps={{ style: { maxWidth: '200px' } }}>
<Flexbox align={'center'} gap={6} horizontal style={{ cursor: 'pointer', fontSize: 12 }}>
<Plus size={14} />
<span>{t('profile.sso.link.button')}</span>
<ArrowRight size={14} />
</Flexbox>
- </Dropdown>
+ </DropdownMenu>
)}
</Flexbox>
);
diff --git a/src/app/[variants]/(main)/settings/provider/ProviderMenu/Actions.tsx b/src/app/[variants]/(main)/settings/provider/ProviderMenu/Actions.tsx
index 136a0e10ea9..c0d39497153 100644
--- a/src/app/[variants]/(main)/settings/provider/ProviderMenu/Actions.tsx
+++ b/src/app/[variants]/(main)/settings/provider/ProviderMenu/Actions.tsx
@@ -1,4 +1,4 @@
-import { ActionIcon, Dropdown, type MenuProps } from '@lobehub/ui';
+import { ActionIcon, DropdownMenu, type MenuProps } from '@lobehub/ui';
import { MoreHorizontalIcon } from 'lucide-react';
import { memo } from 'react';
@@ -8,17 +8,9 @@ interface ActionsProps {
const Actions = memo<ActionsProps>(({ dropdownMenu }) => {
return (
- <Dropdown
- menu={{
- items: dropdownMenu,
- onClick: ({ domEvent }) => {
- domEvent.stopPropagation();
- },
- }}
- trigger={['click']}
- >
+ <DropdownMenu items={dropdownMenu}>
<ActionIcon icon={MoreHorizontalIcon} size={'small'} style={{ flex: 'none' }} />
- </Dropdown>
+ </DropdownMenu>
);
});
diff --git a/src/app/[variants]/(main)/settings/provider/ProviderMenu/List.tsx b/src/app/[variants]/(main)/settings/provider/ProviderMenu/List.tsx
index 5577578575d..1fc7ecd543e 100644
--- a/src/app/[variants]/(main)/settings/provider/ProviderMenu/List.tsx
+++ b/src/app/[variants]/(main)/settings/provider/ProviderMenu/List.tsx
@@ -1,6 +1,13 @@
'use client';
-import { Accordion, AccordionItem, ActionIcon, Dropdown, Flexbox, Text } from '@lobehub/ui';
+import {
+ Accordion,
+ AccordionItem,
+ ActionIcon,
+ ContextMenuTrigger,
+ Flexbox,
+ Text,
+} from '@lobehub/ui';
import isEqual from 'fast-deep-equal';
import { ArrowDownUpIcon } from 'lucide-react';
import { useCallback, useMemo, useState } from 'react';
@@ -113,16 +120,7 @@ const ProviderList = (props: {
/>
</div>
}
- headerWrapper={(header) => (
- <Dropdown
- menu={{
- items: [],
- }}
- trigger={['contextMenu']}
- >
- {header}
- </Dropdown>
- )}
+ headerWrapper={(header) => <ContextMenuTrigger items={[]}>{header}</ContextMenuTrigger>}
itemKey="enabled"
paddingBlock={4}
paddingInline={'8px 4px'}
@@ -142,16 +140,7 @@ const ProviderList = (props: {
{/* Custom Providers */}
{disabledCustomProviderList.length > 0 && (
<AccordionItem
- headerWrapper={(header) => (
- <Dropdown
- menu={{
- items: [],
- }}
- trigger={['contextMenu']}
- >
- {header}
- </Dropdown>
- )}
+ headerWrapper={(header) => <ContextMenuTrigger items={[]}>{header}</ContextMenuTrigger>}
itemKey="custom"
paddingBlock={4}
paddingInline={'8px 4px'}
@@ -177,14 +166,9 @@ const ProviderList = (props: {
) : undefined
}
headerWrapper={(header) => (
- <Dropdown
- menu={{
- items: disabledModelProviderList.length > 1 ? dropdownMenu : [],
- }}
- trigger={['contextMenu']}
- >
+ <ContextMenuTrigger items={disabledModelProviderList.length > 1 ? dropdownMenu : []}>
{header}
- </Dropdown>
+ </ContextMenuTrigger>
)}
itemKey="disabled"
paddingBlock={4}
diff --git a/src/app/[variants]/(main)/settings/provider/features/ModelList/DisabledModels.tsx b/src/app/[variants]/(main)/settings/provider/features/ModelList/DisabledModels.tsx
index 8913b1bdaba..85508cc825a 100644
--- a/src/app/[variants]/(main)/settings/provider/features/ModelList/DisabledModels.tsx
+++ b/src/app/[variants]/(main)/settings/provider/features/ModelList/DisabledModels.tsx
@@ -1,4 +1,4 @@
-import { ActionIcon, Dropdown, Flexbox, Icon, Text, TooltipGroup } from '@lobehub/ui';
+import { ActionIcon, DropdownMenu, Flexbox, Icon, Text, TooltipGroup } from '@lobehub/ui';
import type { ItemType } from 'antd/es/menu/interface';
import isEqual from 'fast-deep-equal';
import { ArrowDownUpIcon, LucideCheck } from 'lucide-react';
@@ -240,9 +240,9 @@ const DisabledModels = memo<DisabledModelsProps>(({ activeTab, providerId }) =>
{t('providerModels.list.disabled')}
</Text>
{sourceDisabledModels.length > 1 && (
- <Dropdown
- menu={{
- items: [
+ <DropdownMenu
+ items={
+ [
{
icon: sortType === SortType.Default ? <Icon icon={LucideCheck} /> : <div />,
key: 'default',
@@ -286,16 +286,15 @@ const DisabledModels = memo<DisabledModelsProps>(({ activeTab, providerId }) =>
label: t('providerModels.list.disabledActions.sortReleasedAtDesc'),
onClick: () => updateSortType(SortType.ReleasedAtDesc),
},
- ] as ItemType[],
- }}
- trigger={['click']}
+ ] as ItemType[]
+ }
>
<ActionIcon
icon={ArrowDownUpIcon}
size={'small'}
title={t('providerModels.list.disabledActions.sort')}
/>
- </Dropdown>
+ </DropdownMenu>
)}
</Flexbox>
<TooltipGroup>
diff --git a/src/app/[variants]/(main)/settings/provider/features/ModelList/ModelTitle/index.tsx b/src/app/[variants]/(main)/settings/provider/features/ModelList/ModelTitle/index.tsx
index 562844a1f6e..5840629d2dc 100644
--- a/src/app/[variants]/(main)/settings/provider/features/ModelList/ModelTitle/index.tsx
+++ b/src/app/[variants]/(main)/settings/provider/features/ModelList/ModelTitle/index.tsx
@@ -1,4 +1,4 @@
-import { ActionIcon, Button, Dropdown, Flexbox, Skeleton, Text } from '@lobehub/ui';
+import { ActionIcon, Button, DropdownMenu, Flexbox, Skeleton, Text } from '@lobehub/ui';
import { App, Space } from 'antd';
import { cssVar } from 'antd-style';
import { CircleX, EllipsisVertical, LucideRefreshCcwDot, PlusIcon } from 'lucide-react';
@@ -137,28 +137,26 @@ const ModelTitle = memo<ModelFetcherProps>(
<CreateNewModelModal open={showModal} setOpen={setShowModal} />
</>
)}
- <Dropdown
- menu={{
- items: [
- {
- key: 'reset',
- label: t('providerModels.list.resetAll.title'),
- onClick: async () => {
- modal.confirm({
- content: t('providerModels.list.resetAll.conform'),
- onOk: async () => {
- await clearModelsByProvider(provider);
- message.success(t('providerModels.list.resetAll.success'));
- },
- title: t('providerModels.list.resetAll.title'),
- });
- },
+ <DropdownMenu
+ items={[
+ {
+ key: 'reset',
+ label: t('providerModels.list.resetAll.title'),
+ onClick: async () => {
+ modal.confirm({
+ content: t('providerModels.list.resetAll.conform'),
+ onOk: async () => {
+ await clearModelsByProvider(provider);
+ message.success(t('providerModels.list.resetAll.success'));
+ },
+ title: t('providerModels.list.resetAll.title'),
+ });
},
- ],
- }}
+ },
+ ]}
>
<Button icon={EllipsisVertical} size={'small'} />
- </Dropdown>
+ </DropdownMenu>
</Space.Compact>
</Flexbox>
)}
diff --git a/src/app/[variants]/(mobile)/(home)/features/SessionListContent/CollapseGroup/Actions.tsx b/src/app/[variants]/(mobile)/(home)/features/SessionListContent/CollapseGroup/Actions.tsx
index f44d9764154..22544fefac1 100644
--- a/src/app/[variants]/(mobile)/(home)/features/SessionListContent/CollapseGroup/Actions.tsx
+++ b/src/app/[variants]/(mobile)/(home)/features/SessionListContent/CollapseGroup/Actions.tsx
@@ -1,4 +1,10 @@
-import { ActionIcon, Dropdown, type DropdownProps, Icon, type MenuProps } from '@lobehub/ui';
+import {
+ ActionIcon,
+ DropdownMenu,
+ type DropdownMenuProps,
+ Icon,
+ type MenuProps,
+} from '@lobehub/ui';
import { App } from 'antd';
import { createStaticStyles } from 'antd-style';
import { MoreVertical, PencilLine, Plus, Settings2, Trash, UsersRound } from 'lucide-react';
@@ -15,7 +21,7 @@ const styles = createStaticStyles(({ css }) => ({
z-index: 2000;
`,
}));
-interface ActionsProps extends Pick<DropdownProps, 'onOpenChange'> {
+interface ActionsProps extends Pick<DropdownMenuProps, 'onOpenChange'> {
id?: string;
isCustomGroup?: boolean;
isPinned?: boolean;
@@ -170,17 +176,7 @@ const Actions = memo<ActionsProps>(
return (
<>
- <Dropdown
- arrow={false}
- menu={{
- items: menuItems,
- onClick: ({ domEvent }) => {
- domEvent.stopPropagation();
- },
- }}
- onOpenChange={onOpenChange}
- trigger={['click']}
- >
+ <DropdownMenu items={menuItems} onOpenChange={onOpenChange}>
<ActionIcon
active={isMobile ? true : false}
icon={MoreVertical}
@@ -191,7 +187,7 @@ const Actions = memo<ActionsProps>(
size={{ blockSize: 22, size: 16 }}
style={{ background: isMobile ? 'transparent' : '', marginRight: -8 }}
/>
- </Dropdown>
+ </DropdownMenu>
<MemberSelectionModal
mode="create"
diff --git a/src/app/[variants]/(mobile)/(home)/features/SessionListContent/List/Item/Actions.tsx b/src/app/[variants]/(mobile)/(home)/features/SessionListContent/List/Item/Actions.tsx
index 255165f1a74..98dc3fe6236 100644
--- a/src/app/[variants]/(mobile)/(home)/features/SessionListContent/List/Item/Actions.tsx
+++ b/src/app/[variants]/(mobile)/(home)/features/SessionListContent/List/Item/Actions.tsx
@@ -1,4 +1,4 @@
-import { ActionIcon, Dropdown, Icon } from '@lobehub/ui';
+import { ActionIcon, DropdownMenu, Icon } from '@lobehub/ui';
import { App } from 'antd';
import { createStaticStyles } from 'antd-style';
import { type ItemType } from 'antd/es/menu/interface';
@@ -183,17 +183,7 @@ const Actions = memo<ActionProps>(({ group, id, openCreateGroupModal, parentType
);
return (
- <Dropdown
- arrow={false}
- menu={{
- items,
- onClick: ({ domEvent }) => {
- domEvent.stopPropagation();
- },
- }}
- onOpenChange={setOpen}
- trigger={['click']}
- >
+ <DropdownMenu items={items} onOpenChange={setOpen}>
<ActionIcon
icon={MoreVertical}
size={{
@@ -201,7 +191,7 @@ const Actions = memo<ActionProps>(({ group, id, openCreateGroupModal, parentType
size: 16,
}}
/>
- </Dropdown>
+ </DropdownMenu>
);
});
diff --git a/src/business/server/lambda-routers/file.ts b/src/business/server/lambda-routers/file.ts
index 53a1df58604..4f6ea131de9 100644
--- a/src/business/server/lambda-routers/file.ts
+++ b/src/business/server/lambda-routers/file.ts
@@ -8,5 +8,5 @@ export interface BusinessFileUploadCheckParams {
export async function businessFileUploadCheck(
// eslint-disable-next-line @typescript-eslint/no-unused-vars
- params: BusinessFileUploadCheckParams,
+ _params: BusinessFileUploadCheckParams,
): Promise<void> {}
diff --git a/src/features/ChatInput/ActionBar/History/index.tsx b/src/features/ChatInput/ActionBar/History/index.tsx
index 78eb7c030b6..98477ad4c84 100644
--- a/src/features/ChatInput/ActionBar/History/index.tsx
+++ b/src/features/ChatInput/ActionBar/History/index.tsx
@@ -55,7 +55,7 @@ const History = memo(() => {
popover={{
content: <Controls setUpdating={setUpdating} updating={updating} />,
minWidth: 240,
- trigger: isMobile ? ['click'] : ['hover'],
+ trigger: isMobile ? 'click' : 'hover',
}}
showTooltip={false}
title={title}
diff --git a/src/features/ChatInput/ActionBar/STT/common.tsx b/src/features/ChatInput/ActionBar/STT/common.tsx
index efa45d4bebb..fd4a5975aa8 100644
--- a/src/features/ChatInput/ActionBar/STT/common.tsx
+++ b/src/features/ChatInput/ActionBar/STT/common.tsx
@@ -104,7 +104,7 @@ const CommonSTT = memo<{
/>
)
: undefined,
- trigger: ['click'],
+ trigger: 'click',
}}
icon={isLoading ? MicOff : Mic}
onClick={handleTriggerStartStop}
diff --git a/src/features/ChatInput/ActionBar/Search/index.tsx b/src/features/ChatInput/ActionBar/Search/index.tsx
index 634b3fc595f..95934eaf3fa 100644
--- a/src/features/ChatInput/ActionBar/Search/index.tsx
+++ b/src/features/ChatInput/ActionBar/Search/index.tsx
@@ -51,7 +51,7 @@ const Search = memo(() => {
padding: 4,
},
},
- trigger: isMobile ? ['click'] : ['hover'],
+ trigger: isMobile ? 'click' : 'hover',
}}
showTooltip={false}
title={t('search.title')}
diff --git a/src/features/ChatInput/ActionBar/Upload/ServerMode.tsx b/src/features/ChatInput/ActionBar/Upload/ServerMode.tsx
index 2798fb5a235..48be399a9e9 100644
--- a/src/features/ChatInput/ActionBar/Upload/ServerMode.tsx
+++ b/src/features/ChatInput/ActionBar/Upload/ServerMode.tsx
@@ -231,6 +231,7 @@ const FileUpload = memo(() => {
loading={updating}
showTooltip={false}
title={t('upload.action.tooltip')}
+ trigger={'both'}
/>
);
diff --git a/src/features/ChatInput/ActionBar/components/Action.tsx b/src/features/ChatInput/ActionBar/components/Action.tsx
index c0fc19564bf..d6709936a3d 100644
--- a/src/features/ChatInput/ActionBar/components/Action.tsx
+++ b/src/features/ChatInput/ActionBar/components/Action.tsx
@@ -1,6 +1,6 @@
'use client';
-import { ActionIcon, type ActionIconProps } from '@lobehub/ui';
+import { ActionIcon, type ActionIconProps, type PopoverTrigger } from '@lobehub/ui';
import { isUndefined } from 'es-toolkit/compat';
import { memo } from 'react';
import useMergeState from 'use-merge-value';
@@ -12,12 +12,12 @@ import ActionDropdown, { type ActionDropdownProps } from './ActionDropdown';
import ActionPopover, { type ActionPopoverProps } from './ActionPopover';
interface ActionProps extends Omit<ActionIconProps, 'popover'> {
- dropdown?: ActionDropdownProps;
+ dropdown?: Omit<ActionDropdownProps, 'children'>;
onOpenChange?: (open: boolean) => void;
open?: boolean;
popover?: ActionPopoverProps;
showTooltip?: boolean;
- trigger?: ActionDropdownProps['trigger'];
+ trigger?: PopoverTrigger;
}
const Action = memo<ActionProps>(
@@ -84,11 +84,7 @@ const Action = memo<ActionProps>(
<ActionPopover
onOpenChange={setShow}
open={show}
- trigger={
- Array.isArray(trigger)
- ? (trigger.filter((t) => t !== 'contextMenu') as ('click' | 'hover')[])
- : trigger
- }
+ trigger={trigger}
{...popover}
minWidth={mobile ? '100%' : popover.minWidth}
placement={mobile ? 'top' : (dropdownPlacement ?? popover.placement)}
diff --git a/src/features/ChatInput/ActionBar/components/ActionDropdown.tsx b/src/features/ChatInput/ActionBar/components/ActionDropdown.tsx
index 3278436da46..e31f86f020b 100644
--- a/src/features/ChatInput/ActionBar/components/ActionDropdown.tsx
+++ b/src/features/ChatInput/ActionBar/components/ActionDropdown.tsx
@@ -1,68 +1,256 @@
'use client';
-import { Dropdown, type DropdownProps } from '@lobehub/ui';
+import {
+ DropdownMenuPopup,
+ type DropdownMenuPopupProps,
+ DropdownMenuPortal,
+ DropdownMenuPositioner,
+ type DropdownMenuProps,
+ DropdownMenuRoot,
+ DropdownMenuTrigger,
+ type MenuProps,
+ type PopoverTrigger,
+ renderDropdownMenuItems,
+} from '@lobehub/ui';
import { createStaticStyles, cx } from 'antd-style';
-import { memo } from 'react';
+import {
+ type CSSProperties,
+ type ReactNode,
+ memo,
+ useCallback,
+ useEffect,
+ useMemo,
+ useRef,
+ useState,
+} from 'react';
import { useIsMobile } from '@/hooks/useIsMobile';
-const prefixCls = 'ant';
-
const styles = createStaticStyles(({ css }) => ({
dropdownMenu: css`
- &.${prefixCls}-dropdown-menu {
- .${prefixCls}-dropdown-menu-item-group-list {
- margin: 0;
- }
- .${prefixCls}-avatar {
- margin-inline-end: var(--ant-margin-xs);
- }
+ .ant-avatar {
+ margin-inline-end: var(--ant-margin-xs);
}
`,
}));
-export interface ActionDropdownProps extends DropdownProps {
+type ActionDropdownMenu = Omit<Pick<MenuProps, 'className' | 'onClick' | 'style'>, 'items'> & {
+ items: MenuProps['items'] | (() => MenuProps['items']);
+};
+
+export interface ActionDropdownProps extends Omit<DropdownMenuProps, 'items'> {
maxHeight?: number | string;
maxWidth?: number | string;
+ menu: ActionDropdownMenu;
minHeight?: number | string;
minWidth?: number | string;
+ popupRender?: (menu: ReactNode) => ReactNode;
/**
* 是否在挂载时预渲染弹层,避免首次触发展开时的渲染卡顿
*/
prefetch?: boolean;
+ trigger?: PopoverTrigger;
}
const ActionDropdown = memo<ActionDropdownProps>(
- ({ menu, maxHeight, minWidth, maxWidth, children, placement = 'top', minHeight, ...rest }) => {
+ ({
+ children,
+ defaultOpen,
+ menu,
+ trigger,
+ maxHeight,
+ maxWidth,
+ minHeight,
+ minWidth,
+ onOpenChange,
+ onOpenChangeComplete,
+ open,
+ placement = 'top',
+ popupProps,
+ popupRender,
+ portalProps,
+ positionerProps,
+ prefetch,
+
+ triggerProps,
+ ...rest
+ }) => {
const isMobile = useIsMobile();
+ const [uncontrolledOpen, setUncontrolledOpen] = useState(Boolean(defaultOpen));
+ const menuItemsRef = useRef<ReactNode[] | null>(null);
+
+ useEffect(() => {
+ if (open === undefined) return;
+ setUncontrolledOpen(open);
+ }, [open]);
+
+ const handleOpenChange = useCallback(
+ (nextOpen: boolean, details: Parameters<NonNullable<typeof onOpenChange>>[1]) => {
+ onOpenChange?.(nextOpen, details);
+ if (open === undefined) setUncontrolledOpen(nextOpen);
+ },
+ [onOpenChange, open],
+ );
+
+ const handleOpenChangeComplete = useCallback(
+ (nextOpen: boolean) => {
+ onOpenChangeComplete?.(nextOpen);
+ if (!nextOpen) menuItemsRef.current = null;
+ },
+ [onOpenChangeComplete],
+ );
+
+ const isOpen = open ?? uncontrolledOpen;
+ const openOnHover = useMemo(() => {
+ if (!trigger) return undefined;
+ if (trigger === 'both') return true;
+ if (Array.isArray(trigger)) return trigger.includes('hover');
+ return trigger === 'hover';
+ }, [trigger]);
+ const resolvedTriggerProps = useMemo(() => {
+ if (openOnHover === undefined) return triggerProps;
+ return {
+ ...triggerProps,
+ openOnHover,
+ };
+ }, [openOnHover, triggerProps]);
+
+ const decorateMenuItems = useCallback(
+ (items: MenuProps['items']): MenuProps['items'] => {
+ if (!items) return items;
+
+ return items.map((item) => {
+ if (!item) return item;
+ if ('type' in item && item.type === 'divider') return item;
+ if ('type' in item && item.type === 'group') {
+ return {
+ ...item,
+ children: item.children ? decorateMenuItems(item.children) : item.children,
+ };
+ }
+
+ if ('children' in item && item.children) {
+ return {
+ ...item,
+ children: decorateMenuItems(item.children),
+ };
+ }
+ const itemOnClick = 'onClick' in item ? item.onClick : undefined;
+
+ return {
+ ...item,
+ onClick: (info) => {
+ info.domEvent.preventDefault();
+ menu.onClick?.(info);
+ itemOnClick?.(info);
+ },
+ };
+ });
+ },
+ [menu],
+ );
+
+ const renderedItems = useMemo(() => {
+ if (!prefetch && !isOpen) return menuItemsRef.current;
+ const sourceItems = typeof menu.items === 'function' ? menu.items() : menu.items;
+ const nextItems = renderDropdownMenuItems(decorateMenuItems(sourceItems ?? []));
+
+ menuItemsRef.current = nextItems;
+
+ return nextItems;
+ }, [decorateMenuItems, isOpen, menu.items, prefetch]);
+
+ const menuContent = useMemo(() => {
+ if (!popupRender) return renderedItems;
+ return popupRender(renderedItems ?? null);
+ }, [popupRender, renderedItems]);
+
+ const resolvedPopupClassName = useMemo<DropdownMenuPopupProps['className']>(() => {
+ const popupClassName = popupProps?.className;
+ if (typeof popupClassName === 'function') {
+ return (state) => cx(styles.dropdownMenu, menu.className, popupClassName(state));
+ }
+ return cx(styles.dropdownMenu, menu.className, popupClassName);
+ }, [menu.className, popupProps?.className]);
+
+ const resolvedPopupStyle = useMemo<DropdownMenuPopupProps['style']>(() => {
+ const baseStyle: CSSProperties = {
+ maxHeight,
+ maxWidth: isMobile ? undefined : maxWidth,
+ minHeight,
+ minWidth: isMobile ? undefined : minWidth,
+ overflowX: 'hidden',
+ overflowY: 'scroll',
+ width: isMobile ? '100vw' : undefined,
+ };
+ const popupStyle = popupProps?.style;
+
+ if (typeof popupStyle === 'function') {
+ return (state) => ({
+ ...baseStyle,
+ ...menu.style,
+ ...popupStyle(state),
+ });
+ }
+
+ return {
+ ...baseStyle,
+ ...menu.style,
+ ...popupStyle,
+ };
+ }, [isMobile, maxHeight, maxWidth, menu.style, minHeight, minWidth, popupProps?.style]);
+
+ const resolvedPopupProps = useMemo(() => {
+ if (!popupProps) {
+ return {
+ className: resolvedPopupClassName,
+ style: resolvedPopupStyle,
+ };
+ }
+
+ return {
+ ...popupProps,
+ className: resolvedPopupClassName,
+ style: resolvedPopupStyle,
+ };
+ }, [popupProps, resolvedPopupClassName, resolvedPopupStyle]);
+
+ const { container: portalContainer, ...restPortalProps } = portalProps ?? {};
+ const resolvedPortalContainer = useMemo<HTMLElement | null | undefined>(() => {
+ if (!portalContainer) return portalContainer ?? undefined;
+ if (typeof portalContainer === 'object' && 'current' in portalContainer) {
+ const current = portalContainer.current;
+ if (!current) return null;
+ if (typeof ShadowRoot !== 'undefined' && current instanceof ShadowRoot) {
+ return current.host as HTMLElement;
+ }
+ return current as HTMLElement;
+ }
+ if (typeof ShadowRoot !== 'undefined' && portalContainer instanceof ShadowRoot) {
+ return portalContainer.host as HTMLElement;
+ }
+ return portalContainer as HTMLElement;
+ }, [portalContainer]);
return (
- <Dropdown
- arrow={false}
- destroyOnHidden={false}
- menu={{
- ...menu,
- className: cx(styles.dropdownMenu, menu.className),
- onClick: (e) => {
- e.domEvent.preventDefault();
- menu.onClick?.(e);
- },
- style: {
- maxHeight,
- maxWidth: isMobile ? undefined : maxWidth,
- minHeight,
- minWidth: isMobile ? undefined : minWidth,
- overflowX: 'hidden',
- overflowY: 'scroll',
- width: isMobile ? '100vw' : undefined,
- ...menu.style,
- },
- }}
- placement={isMobile ? 'top' : placement}
+ <DropdownMenuRoot
{...rest}
+ defaultOpen={defaultOpen}
+ onOpenChange={handleOpenChange}
+ onOpenChangeComplete={handleOpenChangeComplete}
+ open={open}
>
- {children}
- </Dropdown>
+ <DropdownMenuTrigger {...resolvedTriggerProps}>{children}</DropdownMenuTrigger>
+ <DropdownMenuPortal container={resolvedPortalContainer} {...restPortalProps}>
+ <DropdownMenuPositioner
+ {...positionerProps}
+ hoverTrigger={Boolean(resolvedTriggerProps?.openOnHover)}
+ placement={isMobile ? 'top' : placement}
+ >
+ <DropdownMenuPopup {...resolvedPopupProps}>{menuContent}</DropdownMenuPopup>
+ </DropdownMenuPositioner>
+ </DropdownMenuPortal>
+ </DropdownMenuRoot>
);
},
);
diff --git a/src/features/Conversation/Messages/Assistant/Actions/index.tsx b/src/features/Conversation/Messages/Assistant/Actions/index.tsx
index deba6088dc1..ec0a23e64f2 100644
--- a/src/features/Conversation/Messages/Assistant/Actions/index.tsx
+++ b/src/features/Conversation/Messages/Assistant/Actions/index.tsx
@@ -22,16 +22,20 @@ import { useAssistantActions } from './useAssistantActions';
// Helper to strip handleClick from action items before passing to ActionIconGroup
const stripHandleClick = (item: MessageActionItemOrDivider): ActionIconGroupItemType => {
if ('type' in item && item.type === 'divider') return item as unknown as ActionIconGroupItemType;
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
- const { handleClick, children, ...rest } = item as MessageActionItem;
+ const { children, ...rest } = item as MessageActionItem;
+ const baseItem = { ...rest } as MessageActionItem;
+ delete (baseItem as { handleClick?: unknown }).handleClick;
if (children) {
return {
- ...rest,
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
- children: children.map(({ handleClick: _, ...child }) => child),
+ ...baseItem,
+ children: children.map((child) => {
+ const nextChild = { ...child } as MessageActionItem;
+ delete (nextChild as { handleClick?: unknown }).handleClick;
+ return nextChild;
+ }),
} as ActionIconGroupItemType;
}
- return rest as ActionIconGroupItemType;
+ return baseItem as ActionIconGroupItemType;
};
// Build action items map for handleAction lookup
diff --git a/src/features/Conversation/Messages/AssistantGroup/Actions/index.tsx b/src/features/Conversation/Messages/AssistantGroup/Actions/index.tsx
index 372439cff44..0a14c3788d1 100644
--- a/src/features/Conversation/Messages/AssistantGroup/Actions/index.tsx
+++ b/src/features/Conversation/Messages/AssistantGroup/Actions/index.tsx
@@ -21,16 +21,20 @@ import { useGroupActions } from './useGroupActions';
// Helper to strip handleClick from action items before passing to ActionIconGroup
const stripHandleClick = (item: MessageActionItemOrDivider): ActionIconGroupItemType => {
if ('type' in item && item.type === 'divider') return item as unknown as ActionIconGroupItemType;
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
- const { handleClick, children, ...rest } = item as MessageActionItem;
+ const { children, ...rest } = item as MessageActionItem;
+ const baseItem = { ...rest } as MessageActionItem;
+ delete (baseItem as { handleClick?: unknown }).handleClick;
if (children) {
return {
- ...rest,
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
- children: children.map(({ handleClick: _, ...child }) => child),
+ ...baseItem,
+ children: children.map((child) => {
+ const nextChild = { ...child } as MessageActionItem;
+ delete (nextChild as { handleClick?: unknown }).handleClick;
+ return nextChild;
+ }),
} as ActionIconGroupItemType;
}
- return rest as ActionIconGroupItemType;
+ return baseItem as ActionIconGroupItemType;
};
// Build action items map for handleAction lookup
diff --git a/src/features/Conversation/Messages/AssistantGroup/Tool/Detail/Intervention/ApprovalActions.tsx b/src/features/Conversation/Messages/AssistantGroup/Tool/Detail/Intervention/ApprovalActions.tsx
index 07ec0863c92..b110d2197ca 100644
--- a/src/features/Conversation/Messages/AssistantGroup/Tool/Detail/Intervention/ApprovalActions.tsx
+++ b/src/features/Conversation/Messages/AssistantGroup/Tool/Detail/Intervention/ApprovalActions.tsx
@@ -1,4 +1,4 @@
-import { Button, Dropdown, Flexbox, Popover } from '@lobehub/ui';
+import { Button, DropdownMenu, Flexbox, Popover } from '@lobehub/ui';
import { Input, Space } from 'antd';
import { ChevronDown } from 'lucide-react';
import { memo, useState } from 'react';
@@ -140,17 +140,15 @@ const ApprovalActions = memo<ApprovalActionsProps>(
>
{t('tool.intervention.approveAndRemember')}
</Button>
- <Dropdown
- menu={{
- items: [
- {
- disabled: approveLoading || isMessageCreating,
- key: 'once',
- label: t('tool.intervention.approveOnce'),
- onClick: () => handleApprove(false),
- },
- ],
- }}
+ <DropdownMenu
+ items={[
+ {
+ disabled: approveLoading || isMessageCreating,
+ key: 'once',
+ label: t('tool.intervention.approveOnce'),
+ onClick: () => handleApprove(false),
+ },
+ ]}
>
<Button
disabled={approveLoading || isMessageCreating}
@@ -158,7 +156,7 @@ const ApprovalActions = memo<ApprovalActionsProps>(
size="small"
type="primary"
/>
- </Dropdown>
+ </DropdownMenu>
</Space.Compact>
) : (
<Button
diff --git a/src/features/Conversation/Messages/AssistantGroup/Tool/Detail/Intervention/ModeSelector.tsx b/src/features/Conversation/Messages/AssistantGroup/Tool/Detail/Intervention/ModeSelector.tsx
index 63307d5678c..f4fb8b3954b 100644
--- a/src/features/Conversation/Messages/AssistantGroup/Tool/Detail/Intervention/ModeSelector.tsx
+++ b/src/features/Conversation/Messages/AssistantGroup/Tool/Detail/Intervention/ModeSelector.tsx
@@ -1,7 +1,6 @@
-import { Button, Dropdown, Icon, type MenuProps } from '@lobehub/ui';
-import { Center } from '@lobehub/ui';
+import { Button, Center, DropdownMenu, Icon, type MenuProps } from '@lobehub/ui';
import { createStaticStyles } from 'antd-style';
-import { ChevronDown, Hand, ListChecks, Zap } from 'lucide-react';
+import { Check, ChevronDown, Hand, ListChecks, Zap } from 'lucide-react';
import { memo, useCallback, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
@@ -61,6 +60,7 @@ const ModeSelector = memo(() => {
const menuItems = useMemo<MenuProps['items']>(
() => [
{
+ extra: approvalMode === 'auto-run' ? <Icon icon={Check} /> : undefined,
icon: (
<Center className={styles.icon} height={32} width={32}>
<Icon icon={Zap} />
@@ -76,6 +76,7 @@ const ModeSelector = memo(() => {
onClick: () => handleModeChange('auto-run'),
},
{
+ extra: approvalMode === 'allow-list' ? <Icon icon={Check} /> : undefined,
icon: (
<Center className={styles.icon} height={32} width={32}>
<Icon icon={ListChecks} />
@@ -91,6 +92,7 @@ const ModeSelector = memo(() => {
onClick: () => handleModeChange('allow-list'),
},
{
+ extra: approvalMode === 'manual' ? <Icon icon={Check} /> : undefined,
icon: (
<Center className={styles.icon} height={32} width={32}>
<Icon icon={Hand} />
@@ -106,15 +108,11 @@ const ModeSelector = memo(() => {
onClick: () => handleModeChange('manual'),
},
],
- [modeLabels, handleModeChange, styles, t],
+ [approvalMode, modeLabels, handleModeChange, styles, t],
);
return (
- <Dropdown
- // @ts-expect-error activeKey 没在 Dropdown key 里很奇怪
- menu={{ activeKey: approvalMode, items: menuItems }}
- placement="bottomLeft"
- >
+ <DropdownMenu items={menuItems} placement="bottomLeft">
<Button
className={styles.modeButton}
color={'default'}
@@ -125,7 +123,7 @@ const ModeSelector = memo(() => {
>
{modeLabels[approvalMode]}
</Button>
- </Dropdown>
+ </DropdownMenu>
);
});
diff --git a/src/features/Conversation/Messages/Supervisor/Actions/index.tsx b/src/features/Conversation/Messages/Supervisor/Actions/index.tsx
index 58e55e211d0..98ad60222d8 100644
--- a/src/features/Conversation/Messages/Supervisor/Actions/index.tsx
+++ b/src/features/Conversation/Messages/Supervisor/Actions/index.tsx
@@ -21,16 +21,20 @@ import { useGroupActions } from './useGroupActions';
// Helper to strip handleClick from action items before passing to ActionIconGroup
const stripHandleClick = (item: MessageActionItemOrDivider): ActionIconGroupItemType => {
if ('type' in item && item.type === 'divider') return item as unknown as ActionIconGroupItemType;
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
- const { handleClick, children, ...rest } = item as MessageActionItem;
+ const { children, ...rest } = item as MessageActionItem;
+ const baseItem = { ...rest } as MessageActionItem;
+ delete (baseItem as { handleClick?: unknown }).handleClick;
if (children) {
return {
- ...rest,
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
- children: children.map(({ handleClick: _, ...child }) => child),
+ ...baseItem,
+ children: children.map((child) => {
+ const nextChild = { ...child } as MessageActionItem;
+ delete (nextChild as { handleClick?: unknown }).handleClick;
+ return nextChild;
+ }),
} as ActionIconGroupItemType;
}
- return rest as ActionIconGroupItemType;
+ return baseItem as ActionIconGroupItemType;
};
// Build action items map for handleAction lookup
diff --git a/src/features/Conversation/Messages/Task/Actions/index.tsx b/src/features/Conversation/Messages/Task/Actions/index.tsx
index 82502202aa4..29a410891cf 100644
--- a/src/features/Conversation/Messages/Task/Actions/index.tsx
+++ b/src/features/Conversation/Messages/Task/Actions/index.tsx
@@ -18,16 +18,20 @@ import { useAssistantActions } from './useAssistantActions';
// Helper to strip handleClick from action items before passing to ActionIconGroup
const stripHandleClick = (item: MessageActionItemOrDivider): ActionIconGroupItemType => {
if ('type' in item && item.type === 'divider') return item as unknown as ActionIconGroupItemType;
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
- const { handleClick, children, ...rest } = item as MessageActionItem;
+ const { children, ...rest } = item as MessageActionItem;
+ const baseItem = { ...rest } as MessageActionItem;
+ delete (baseItem as { handleClick?: unknown }).handleClick;
if (children) {
return {
- ...rest,
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
- children: children.map(({ handleClick: _, ...child }) => child),
+ ...baseItem,
+ children: children.map((child) => {
+ const nextChild = { ...child } as MessageActionItem;
+ delete (nextChild as { handleClick?: unknown }).handleClick;
+ return nextChild;
+ }),
} as ActionIconGroupItemType;
}
- return rest as ActionIconGroupItemType;
+ return baseItem as ActionIconGroupItemType;
};
// Build action items map for handleAction lookup
diff --git a/src/features/Conversation/Messages/User/Actions/index.tsx b/src/features/Conversation/Messages/User/Actions/index.tsx
index 7812fc6246c..e2732ef7bd5 100644
--- a/src/features/Conversation/Messages/User/Actions/index.tsx
+++ b/src/features/Conversation/Messages/User/Actions/index.tsx
@@ -16,16 +16,20 @@ import { useUserActions } from './useUserActions';
// Helper to strip handleClick from action items before passing to ActionIconGroup
const stripHandleClick = (item: MessageActionItemOrDivider): ActionIconGroupItemType => {
if ('type' in item && item.type === 'divider') return item as unknown as ActionIconGroupItemType;
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
- const { handleClick, children, ...rest } = item as MessageActionItem;
+ const { children, ...rest } = item as MessageActionItem;
+ const baseItem = { ...rest } as MessageActionItem;
+ delete (baseItem as { handleClick?: unknown }).handleClick;
if (children) {
return {
- ...rest,
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
- children: children.map(({ handleClick: _, ...child }) => child),
+ ...baseItem,
+ children: children.map((child) => {
+ const nextChild = { ...child } as MessageActionItem;
+ delete (nextChild as { handleClick?: unknown }).handleClick;
+ return nextChild;
+ }),
} as ActionIconGroupItemType;
}
- return rest as ActionIconGroupItemType;
+ return baseItem as ActionIconGroupItemType;
};
// Build action items map for handleAction lookup
diff --git a/src/features/LibraryModal/AssignKnowledgeBase/Item/Action.tsx b/src/features/LibraryModal/AssignKnowledgeBase/Item/Action.tsx
index 90b07f9d803..413c05e2233 100644
--- a/src/features/LibraryModal/AssignKnowledgeBase/Item/Action.tsx
+++ b/src/features/LibraryModal/AssignKnowledgeBase/Item/Action.tsx
@@ -1,4 +1,4 @@
-import { ActionIcon, Button, Dropdown, Flexbox, Icon } from '@lobehub/ui';
+import { ActionIcon, Button, DropdownMenu, Flexbox, Icon } from '@lobehub/ui';
import { InfoIcon, MoreVerticalIcon, Trash2 } from 'lucide-react';
import { memo, useState } from 'react';
import { useTranslation } from 'react-i18next';
@@ -54,36 +54,33 @@ const Actions = memo<ActionsProps>(({ id, type, enabled }) => {
return (
<Flexbox align={'center'} horizontal>
{enabled ? (
- <Dropdown
- menu={{
- items: [
- {
- icon: <Icon icon={InfoIcon} />,
- key: 'detail',
- label: t('knowledgeBase.library.action.detail'),
- onClick: () => {
- if (type === KnowledgeType.KnowledgeBase) {
- window.open(`/resource/library/${id}`);
- return;
- }
+ <DropdownMenu
+ items={[
+ {
+ icon: <Icon icon={InfoIcon} />,
+ key: 'detail',
+ label: t('knowledgeBase.library.action.detail'),
+ onClick: () => {
+ if (type === KnowledgeType.KnowledgeBase) {
+ window.open(`/resource/library/${id}`);
+ return;
+ }
- window.open(`/knowledge?file=${id}`);
- },
+ window.open(`/knowledge?file=${id}`);
},
- {
- danger: true,
- icon: <Icon icon={Trash2} />,
- key: 'remove',
- label: t('knowledgeBase.library.action.remove'),
- onClick: removeKnowledge,
- },
- ],
- }}
+ },
+ {
+ danger: true,
+ icon: <Icon icon={Trash2} />,
+ key: 'remove',
+ label: t('knowledgeBase.library.action.remove'),
+ onClick: removeKnowledge,
+ },
+ ]}
placement="bottomRight"
- trigger={['click']}
>
<ActionIcon icon={MoreVerticalIcon} loading={loading} />
- </Dropdown>
+ </DropdownMenu>
) : (
<Button
loading={loading}
diff --git a/src/features/ModelSwitchPanel/components/List/MultipleProvidersModelItem.tsx b/src/features/ModelSwitchPanel/components/List/MultipleProvidersModelItem.tsx
index 64f141d2c87..41a63f27a6a 100644
--- a/src/features/ModelSwitchPanel/components/List/MultipleProvidersModelItem.tsx
+++ b/src/features/ModelSwitchPanel/components/List/MultipleProvidersModelItem.tsx
@@ -1,6 +1,5 @@
-import { ActionIcon, Dropdown } from '@lobehub/ui';
-import { MenuItemType } from 'antd/es/menu/interface';
-import { LucideBolt } from 'lucide-react';
+import { ActionIcon, type DropdownItem, DropdownMenu } from '@lobehub/ui';
+import { Check, LucideBolt } from 'lucide-react';
import { memo, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
import { useNavigate } from 'react-router-dom';
@@ -34,6 +33,8 @@ export const MultipleProvidersModelItem = memo<MultipleProvidersModelItemProps>(
type: 'group',
},
...data.providers.map((p) => {
+ const key = menuKey(p.id, data.model.id);
+
return {
extra: (
<ActionIcon
@@ -53,7 +54,8 @@ export const MultipleProvidersModelItem = memo<MultipleProvidersModelItemProps>(
title={t('ModelSwitchPanel.goToSettings')}
/>
),
- key: menuKey(p.id, data.model.id),
+ icon: activeKey === key ? Check : undefined,
+ key,
label: (
<ProviderItemRender
logo={p.logo}
@@ -70,23 +72,19 @@ export const MultipleProvidersModelItem = memo<MultipleProvidersModelItemProps>(
},
};
}),
- ] as MenuItemType[],
- [data.model.id, data.providers, navigate, onModelChange, onClose, t],
+ ] as DropdownItem[],
+ [activeKey, data.model.id, data.providers, navigate, onModelChange, onClose, t],
);
return (
- <Dropdown
- align={{ offset: [12, -48] }}
- arrow={false}
- classNames={{
- item: styles.menuItem,
- }}
- menu={{
- items,
- selectedKeys: [activeKey],
- }}
- // @ts-ignore
+ <DropdownMenu
+ items={items}
placement="rightTop"
+ popupProps={{ className: styles.dropdownMenu }}
+ positionerProps={{
+ alignOffset: -48,
+ sideOffset: 12,
+ }}
>
<ModelItemRender
{...data.model}
@@ -95,7 +93,7 @@ export const MultipleProvidersModelItem = memo<MultipleProvidersModelItemProps>(
newBadgeLabel={newLabel}
showInfoTag={true}
/>
- </Dropdown>
+ </DropdownMenu>
);
},
);
diff --git a/src/features/ModelSwitchPanel/styles.ts b/src/features/ModelSwitchPanel/styles.ts
index 2b13878e320..54f7f1d1a40 100644
--- a/src/features/ModelSwitchPanel/styles.ts
+++ b/src/features/ModelSwitchPanel/styles.ts
@@ -5,10 +5,27 @@ export const styles = createStaticStyles(({ css, cssVar }) => ({
overflow: hidden;
padding: 0 !important;
`,
+ dropdownMenu: css`
+ [role='menuitem'] {
+ margin-block: 1px;
+ margin-inline: 4px;
+ padding-block: 8px;
+ padding-inline: 8px;
+ border-radius: ${cssVar.borderRadiusSM};
+ }
+
+ [role='menuitem'] .settings-icon {
+ opacity: 0;
+ }
+
+ [role='menuitem']:hover .settings-icon {
+ opacity: 1;
+ }
+ `,
+
footer: css`
border-block-start: 1px solid ${cssVar.colorBorderSecondary};
`,
-
groupHeader: css`
width: 100%;
color: ${cssVar.colorTextSecondary};
diff --git a/src/features/PageEditor/Copilot/AgentSelector/Actions.tsx b/src/features/PageEditor/Copilot/AgentSelector/Actions.tsx
index 365aff14a9f..e6e920fa26b 100644
--- a/src/features/PageEditor/Copilot/AgentSelector/Actions.tsx
+++ b/src/features/PageEditor/Copilot/AgentSelector/Actions.tsx
@@ -1,4 +1,4 @@
-import { ActionIcon, Dropdown, type MenuProps } from '@lobehub/ui';
+import { ActionIcon, DropdownMenu, type MenuProps } from '@lobehub/ui';
import { MoreHorizontalIcon } from 'lucide-react';
import { memo } from 'react';
@@ -7,21 +7,14 @@ interface ActionsProps {
}
const Actions = memo<ActionsProps>(({ dropdownMenu }) => {
- if (!dropdownMenu || dropdownMenu.length === 0) return null;
+ const menuItems = dropdownMenu ?? [];
+
+ if (menuItems.length === 0) return null;
return (
- <Dropdown
- arrow={false}
- menu={{
- items: dropdownMenu,
- onClick: ({ domEvent }) => {
- domEvent.stopPropagation();
- },
- }}
- trigger={['click']}
- >
+ <DropdownMenu items={menuItems}>
<ActionIcon icon={MoreHorizontalIcon} size={'small'} />
- </Dropdown>
+ </DropdownMenu>
);
});
diff --git a/src/features/PluginStore/InstalledList/List/Item/Action.tsx b/src/features/PluginStore/InstalledList/List/Item/Action.tsx
index 27ddf7075b2..13904a62350 100644
--- a/src/features/PluginStore/InstalledList/List/Item/Action.tsx
+++ b/src/features/PluginStore/InstalledList/List/Item/Action.tsx
@@ -1,4 +1,4 @@
-import { ActionIcon, Button, Dropdown, Flexbox, Icon } from '@lobehub/ui';
+import { ActionIcon, Button, DropdownMenu, Flexbox, Icon } from '@lobehub/ui';
import { App } from 'antd';
import { InfoIcon, MoreVerticalIcon, PackageSearch, Settings, Trash2 } from 'lucide-react';
import { memo, useState } from 'react';
@@ -72,46 +72,43 @@ const Actions = memo<ActionsProps>(({ identifier, type, isMCP }) => {
title={t('store.actions.settings')}
/>
)}
- <Dropdown
- menu={{
- items: [
- {
- icon: <Icon icon={InfoIcon} />,
- key: 'detail',
- label: t('store.actions.detail'),
- onClick: () => {
- setOpen(true);
- setTab('info');
- },
+ <DropdownMenu
+ items={[
+ {
+ icon: <Icon icon={InfoIcon} />,
+ key: 'detail',
+ label: t('store.actions.detail'),
+ onClick: () => {
+ setOpen(true);
+ setTab('info');
},
- {
- danger: true,
- icon: <Icon icon={Trash2} />,
- key: 'uninstall',
- label: t('store.actions.uninstall'),
- onClick: () => {
- modal.confirm({
- centered: true,
- okButtonProps: { danger: true },
- onOk: async () => {
- // If plugin is enabled in current agent, disable it first
- if (isPluginEnabledInAgent) {
- await togglePlugin(identifier, false);
- }
- await unInstallPlugin(identifier);
- },
- title: t('store.actions.confirmUninstall'),
- type: 'error',
- });
- },
+ },
+ {
+ danger: true,
+ icon: <Icon icon={Trash2} />,
+ key: 'uninstall',
+ label: t('store.actions.uninstall'),
+ onClick: () => {
+ modal.confirm({
+ centered: true,
+ okButtonProps: { danger: true },
+ onOk: async () => {
+ // If plugin is enabled in current agent, disable it first
+ if (isPluginEnabledInAgent) {
+ await togglePlugin(identifier, false);
+ }
+ await unInstallPlugin(identifier);
+ },
+ title: t('store.actions.confirmUninstall'),
+ type: 'error',
+ });
},
- ],
- }}
+ },
+ ]}
placement="bottomRight"
- trigger={['click']}
>
<ActionIcon icon={MoreVerticalIcon} loading={installing} />
- </Dropdown>
+ </DropdownMenu>
</>
) : (
<Button
diff --git a/src/features/PluginStore/McpList/List/Action.tsx b/src/features/PluginStore/McpList/List/Action.tsx
index 4859edd04af..1008bb82441 100644
--- a/src/features/PluginStore/McpList/List/Action.tsx
+++ b/src/features/PluginStore/McpList/List/Action.tsx
@@ -1,4 +1,4 @@
-import { ActionIcon, Button, Dropdown, Flexbox, Icon } from '@lobehub/ui';
+import { ActionIcon, Button, DropdownMenu, Flexbox, Icon } from '@lobehub/ui';
import { App } from 'antd';
import { MoreVerticalIcon, Trash2 } from 'lucide-react';
import { memo } from 'react';
@@ -39,34 +39,31 @@ const Actions = memo<ActionsProps>(({ identifier }) => {
return (
<Flexbox align={'center'} horizontal>
{installed ? (
- <Dropdown
- menu={{
- items: [
- {
- danger: true,
- icon: <Icon icon={Trash2} />,
- key: 'uninstall',
- label: t('store.actions.uninstall'),
- onClick: () => {
- modal.confirm({
- centered: true,
- okButtonProps: { danger: true },
- onOk: async () => {
- // If plugin is enabled in current agent, disable it first
- if (isPluginEnabledInAgent) {
- await togglePlugin(identifier, false);
- }
- await unInstallPlugin(identifier);
- },
- title: t('store.actions.confirmUninstall'),
- type: 'error',
- });
- },
+ <DropdownMenu
+ items={[
+ {
+ danger: true,
+ icon: <Icon icon={Trash2} />,
+ key: 'uninstall',
+ label: t('store.actions.uninstall'),
+ onClick: () => {
+ modal.confirm({
+ centered: true,
+ okButtonProps: { danger: true },
+ onOk: async () => {
+ // If plugin is enabled in current agent, disable it first
+ if (isPluginEnabledInAgent) {
+ await togglePlugin(identifier, false);
+ }
+ await unInstallPlugin(identifier);
+ },
+ title: t('store.actions.confirmUninstall'),
+ type: 'error',
+ });
},
- ],
- }}
+ },
+ ]}
placement="bottomRight"
- trigger={['click']}
>
<ActionIcon
icon={MoreVerticalIcon}
@@ -75,7 +72,7 @@ const Actions = memo<ActionsProps>(({ identifier }) => {
e.stopPropagation();
}}
/>
- </Dropdown>
+ </DropdownMenu>
) : installing ? (
<Button
onClick={async (e) => {
diff --git a/src/features/PluginStore/PluginList/List/Action.tsx b/src/features/PluginStore/PluginList/List/Action.tsx
index 3fa293b5a5e..10c531e4d75 100644
--- a/src/features/PluginStore/PluginList/List/Action.tsx
+++ b/src/features/PluginStore/PluginList/List/Action.tsx
@@ -1,4 +1,4 @@
-import { ActionIcon, Button, Dropdown, Flexbox, Icon } from '@lobehub/ui';
+import { ActionIcon, Button, DropdownMenu, Flexbox, Icon } from '@lobehub/ui';
import { App } from 'antd';
import { MoreVerticalIcon, Trash2 } from 'lucide-react';
import { memo } from 'react';
@@ -31,37 +31,34 @@ const Actions = memo<ActionsProps>(({ identifier }) => {
return (
<Flexbox align={'center'} horizontal>
{installed ? (
- <Dropdown
- menu={{
- items: [
- {
- danger: true,
- icon: <Icon icon={Trash2} />,
- key: 'uninstall',
- label: t('store.actions.uninstall'),
- onClick: () => {
- modal.confirm({
- centered: true,
- okButtonProps: { danger: true },
- onOk: async () => {
- // If plugin is enabled in current agent, disable it first
- if (isPluginEnabledInAgent) {
- await togglePlugin(identifier, false);
- }
- await unInstallPlugin(identifier);
- },
- title: t('store.actions.confirmUninstall'),
- type: 'error',
- });
- },
+ <DropdownMenu
+ items={[
+ {
+ danger: true,
+ icon: <Icon icon={Trash2} />,
+ key: 'uninstall',
+ label: t('store.actions.uninstall'),
+ onClick: () => {
+ modal.confirm({
+ centered: true,
+ okButtonProps: { danger: true },
+ onOk: async () => {
+ // If plugin is enabled in current agent, disable it first
+ if (isPluginEnabledInAgent) {
+ await togglePlugin(identifier, false);
+ }
+ await unInstallPlugin(identifier);
+ },
+ title: t('store.actions.confirmUninstall'),
+ type: 'error',
+ });
},
- ],
- }}
+ },
+ ]}
placement="bottomRight"
- trigger={['click']}
>
<ActionIcon icon={MoreVerticalIcon} loading={installing} />
- </Dropdown>
+ </DropdownMenu>
) : (
<Button
loading={installing}
diff --git a/src/features/PluginTag/index.tsx b/src/features/PluginTag/index.tsx
index 760cb1c1fa9..8e5a18c16ba 100644
--- a/src/features/PluginTag/index.tsx
+++ b/src/features/PluginTag/index.tsx
@@ -1,7 +1,6 @@
'use client';
-import { Dropdown, Icon, type MenuProps, Tag } from '@lobehub/ui';
-import { Center } from '@lobehub/ui';
+import { Center, DropdownMenu, Icon, type MenuProps, Tag } from '@lobehub/ui';
import isEqual from 'fast-deep-equal';
import { LucideToyBrick } from 'lucide-react';
import { memo } from 'react';
@@ -49,7 +48,7 @@ const PluginTag = memo<PluginTagProps>(({ plugins }) => {
const count = plugins.length;
return (
- <Dropdown menu={{ items }}>
+ <DropdownMenu items={items}>
<div>
<Tag>
{<Icon icon={LucideToyBrick} />}
@@ -57,7 +56,7 @@ const PluginTag = memo<PluginTagProps>(({ plugins }) => {
{count > 1 && <div>({plugins.length - 1}+)</div>}
</Tag>
</div>
- </Dropdown>
+ </DropdownMenu>
);
});
diff --git a/src/features/Portal/Artifacts/Body/Renderer/SVG.tsx b/src/features/Portal/Artifacts/Body/Renderer/SVG.tsx
index 4410aeedf09..3e50cd2f43b 100644
--- a/src/features/Portal/Artifacts/Body/Renderer/SVG.tsx
+++ b/src/features/Portal/Artifacts/Body/Renderer/SVG.tsx
@@ -1,6 +1,6 @@
import { BRANDING_NAME } from '@lobechat/business-const';
import { copyImageToClipboard, sanitizeSVGContent } from '@lobechat/utils/client';
-import { Button, Center, Dropdown, Flexbox, Tooltip } from '@lobehub/ui';
+import { Button, Center, DropdownMenu, Flexbox, Tooltip } from '@lobehub/ui';
import { snapdom } from '@zumer/snapdom';
import { App, Space } from 'antd';
import { css, cx } from 'antd-style';
@@ -98,19 +98,22 @@ const SVGRenderer = ({ content }: SVGRendererProps) => {
/>
<Flexbox className={cx(actions)}>
<Space.Compact>
- <Dropdown
- menu={{
- items: [
- { key: 'png', label: t('artifacts.svg.download.png') },
- { key: 'svg', label: t('artifacts.svg.download.svg') },
- ],
- onClick: ({ key }) => {
- downloadImage(key);
+ <DropdownMenu
+ items={[
+ {
+ key: 'png',
+ label: t('artifacts.svg.download.png'),
+ onClick: () => downloadImage('png'),
},
- }}
+ {
+ key: 'svg',
+ label: t('artifacts.svg.download.svg'),
+ onClick: () => downloadImage('svg'),
+ },
+ ]}
>
<Button icon={DownloadIcon} />
- </Dropdown>
+ </DropdownMenu>
<Tooltip title={t('artifacts.svg.copyAsImage')}>
<Button
icon={CopyIcon}
diff --git a/src/features/ProfileEditor/AgentTool.tsx b/src/features/ProfileEditor/AgentTool.tsx
index 4f04c4cd113..75f71240ec1 100644
--- a/src/features/ProfileEditor/AgentTool.tsx
+++ b/src/features/ProfileEditor/AgentTool.tsx
@@ -617,7 +617,7 @@ const AgentTool = memo<AgentToolProps>(
</div>
</div>
)}
- trigger={['click']}
+ trigger={'click'}
>
{button}
</ActionDropdown>
diff --git a/src/features/ResourceManager/components/Explorer/ToolBar/SortDropdown.tsx b/src/features/ResourceManager/components/Explorer/ToolBar/SortDropdown.tsx
index cceb3a4e276..61b0e624a38 100644
--- a/src/features/ResourceManager/components/Explorer/ToolBar/SortDropdown.tsx
+++ b/src/features/ResourceManager/components/Explorer/ToolBar/SortDropdown.tsx
@@ -1,9 +1,8 @@
-import { Dropdown } from '@lobehub/ui';
+import { DropdownMenu, type DropdownMenuCheckboxItem } from '@lobehub/ui';
import { ArrowDownAZ } from 'lucide-react';
import { memo, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
-import { type MenuProps } from '@/components/Menu';
import { useResourceManagerStore } from '@/app/[variants]/(main)/resource/features/store';
import ActionIconWithChevron from './ActionIconWithChevron';
@@ -22,30 +21,34 @@ const SortDropdown = memo(() => {
[t],
);
- const menuItems: MenuProps['items'] = useMemo(
+ const selectedKey = sorter || 'createdAt';
+
+ const menuItems = useMemo<DropdownMenuCheckboxItem[]>(
() =>
- sortOptions.map((option) => ({
- key: option.key,
- label: option.label,
- onClick: () => setSorter(option.key as 'name' | 'createdAt' | 'size'),
- })),
- [setSorter, sortOptions],
+ sortOptions.map(
+ (option): DropdownMenuCheckboxItem => ({
+ checked: option.key === selectedKey,
+ closeOnClick: true,
+ key: option.key,
+ label: option.label,
+ onCheckedChange: (checked: boolean) => {
+ if (checked) {
+ setSorter(option.key as 'name' | 'createdAt' | 'size');
+ }
+ },
+ type: 'checkbox',
+ }),
+ ),
+ [selectedKey, setSorter, sortOptions],
);
const currentSortLabel =
sortOptions.find((option) => option.key === sorter)?.label || t('FileManager.sort.dateAdded');
return (
- <Dropdown
- arrow={false}
- menu={{
- items: menuItems,
- selectable: true,
- selectedKeys: [sorter || 'createdAt'],
- }}
- >
+ <DropdownMenu items={menuItems}>
<ActionIconWithChevron icon={ArrowDownAZ} title={currentSortLabel} />
- </Dropdown>
+ </DropdownMenu>
);
});
diff --git a/src/features/ResourceManager/components/Explorer/ToolBar/ViewSwitcher.tsx b/src/features/ResourceManager/components/Explorer/ToolBar/ViewSwitcher.tsx
index dda59299a0b..12666515e0b 100644
--- a/src/features/ResourceManager/components/Explorer/ToolBar/ViewSwitcher.tsx
+++ b/src/features/ResourceManager/components/Explorer/ToolBar/ViewSwitcher.tsx
@@ -1,5 +1,5 @@
-import { Dropdown, Icon } from '@lobehub/ui';
-import { Grid3x3Icon, ListIcon } from 'lucide-react';
+import { DropdownMenu, Icon } from '@lobehub/ui';
+import { Check, Grid3x3Icon, ListIcon } from 'lucide-react';
import { memo, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
@@ -23,33 +23,27 @@ const ViewSwitcher = memo(() => {
const menuItems: MenuProps['items'] = useMemo(
() => [
{
+ extra: viewMode === 'list' ? <Icon icon={Check} /> : undefined,
icon: <Icon icon={ListIcon} />,
key: 'list',
label: t('FileManager.view.list'),
onClick: () => setViewMode('list'),
},
{
+ extra: viewMode === 'masonry' ? <Icon icon={Check} /> : undefined,
icon: <Icon icon={Grid3x3Icon} />,
key: 'masonry',
label: t('FileManager.view.masonry'),
onClick: () => setViewMode('masonry'),
},
],
- [setViewMode, t],
+ [setViewMode, t, viewMode],
);
return (
- <Dropdown
- arrow={false}
- menu={{
- items: menuItems,
- selectable: true,
- selectedKeys: [viewMode],
- }}
- placement="bottomRight"
- >
+ <DropdownMenu items={menuItems} placement="bottomRight">
<ActionIconWithChevron icon={currentViewIcon} title={currentViewLabel} />
- </Dropdown>
+ </DropdownMenu>
);
});
diff --git a/src/features/ResourceManager/components/Header/AddButton.tsx b/src/features/ResourceManager/components/Header/AddButton.tsx
index b7773c66e38..6eca7044c06 100644
--- a/src/features/ResourceManager/components/Header/AddButton.tsx
+++ b/src/features/ResourceManager/components/Header/AddButton.tsx
@@ -2,7 +2,7 @@
import { FILE_URL } from '@lobechat/business-const';
import { Notion } from '@lobehub/icons';
-import { Button, Dropdown, Icon, type MenuProps } from '@lobehub/ui';
+import { Button, DropdownMenu, Icon, type MenuProps } from '@lobehub/ui';
import { Upload } from 'antd';
import { FilePenLine, FileUp, FolderIcon, FolderUp, Link, Plus } from 'lucide-react';
import { useCallback, useMemo } from 'react';
@@ -211,18 +211,11 @@ const AddButton = () => {
return (
<>
- <Dropdown menu={{ items }} placement="bottomRight" trigger={['hover']}>
- <Button
- icon={Plus}
- onClick={(e) => {
- // Prevent default button behavior that might interfere with dropdown
- e.stopPropagation();
- }}
- type="primary"
- >
+ <DropdownMenu items={items} placement="bottomRight" trigger="both">
+ <Button data-no-highlight icon={Plus} type="primary">
{t('addLibrary')}
</Button>
- </Dropdown>
+ </DropdownMenu>
<GuideModal
cancelText={t('header.actions.notionGuide.cancel')}
cover={<GuideVideo height={269} src={FILE_URL.importFromNotionGuide} width={358} />}
diff --git a/src/features/User/UserPanel/LangButton.tsx b/src/features/User/UserPanel/LangButton.tsx
index f972b864ee9..4d714ea3b8e 100644
--- a/src/features/User/UserPanel/LangButton.tsx
+++ b/src/features/User/UserPanel/LangButton.tsx
@@ -1,74 +1,86 @@
-import { ActionIcon, Dropdown, DropdownProps, Flexbox, Text } from '@lobehub/ui';
+import {
+ ActionIcon,
+ DropdownMenu,
+ type DropdownMenuCheckboxItem,
+ type DropdownMenuProps,
+ Flexbox,
+ Text,
+} from '@lobehub/ui';
import { Languages } from 'lucide-react';
import { memo, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
-import { type MenuProps } from '@/components/Menu';
import { localeOptions } from '@/locales/resources';
import { useGlobalStore } from '@/store/global';
import { globalGeneralSelectors } from '@/store/global/selectors';
-import { type LocaleMode } from '@/types/locale';
-const LangButton = memo<{ placement?: DropdownProps['placement']; size?: number }>(
+const LangButton = memo<{ placement?: DropdownMenuProps['placement']; size?: number }>(
({ placement, size }) => {
const [language, switchLocale] = useGlobalStore((s) => [
globalGeneralSelectors.language(s),
s.switchLocale,
]);
- const handleLangChange = (value: LocaleMode) => {
- switchLocale(value);
- };
-
const { t } = useTranslation(['setting', 'common']);
- const items: MenuProps['items'] = useMemo(
- () => [
- {
- key: 'auto',
- label: (
- <Flexbox gap={4}>
- <Text style={{ lineHeight: 1.2 }}>{t('settingCommon.lang.autoMode')}</Text>
- <Text fontSize={12} style={{ lineHeight: 1.2 }} type={'secondary'}>
- {t(`lang.auto` as any, { ns: 'common' })}
- </Text>
- </Flexbox>
- ),
- onClick: () => handleLangChange('auto'),
+ const items = useMemo<DropdownMenuCheckboxItem[]>(() => {
+ const autoItem: DropdownMenuCheckboxItem = {
+ checked: language === 'auto',
+ closeOnClick: true,
+ key: 'auto',
+ label: (
+ <Flexbox gap={4}>
+ <Text style={{ lineHeight: 1.2 }}>{t('settingCommon.lang.autoMode')}</Text>
+ <Text fontSize={12} style={{ lineHeight: 1.2 }} type={'secondary'}>
+ {t(`lang.auto` as any, { ns: 'common' })}
+ </Text>
+ </Flexbox>
+ ),
+ onCheckedChange: (checked: boolean) => {
+ if (checked) {
+ switchLocale('auto');
+ }
},
- ...localeOptions.map((item) => ({
- key: item.value,
- label: (
- <Flexbox gap={4} key={item.value}>
- <Text style={{ lineHeight: 1.2 }}>{item.label}</Text>
- <Text fontSize={12} style={{ lineHeight: 1.2 }} type={'secondary'}>
- {t(`lang.${item.value}` as any, { ns: 'common' })}
- </Text>
- </Flexbox>
- ),
- onClick: () => handleLangChange(item.value),
- })),
- ],
- [t],
- );
+ type: 'checkbox',
+ };
+
+ const localeItems = localeOptions.map<DropdownMenuCheckboxItem>((item) => ({
+ checked: language === item.value,
+ closeOnClick: true,
+ key: item.value,
+ label: (
+ <Flexbox gap={4} key={item.value}>
+ <Text style={{ lineHeight: 1.2 }}>{item.label}</Text>
+ <Text fontSize={12} style={{ lineHeight: 1.2 }} type={'secondary'}>
+ {t(`lang.${item.value}` as any, { ns: 'common' })}
+ </Text>
+ </Flexbox>
+ ),
+ onCheckedChange: (checked: boolean) => {
+ if (checked) {
+ switchLocale(item.value);
+ }
+ },
+ type: 'checkbox',
+ }));
+
+ return [autoItem, ...localeItems];
+ }, [language, switchLocale, t]);
return (
- <Dropdown
- arrow={false}
- menu={{
- items,
- selectable: true,
- selectedKeys: [language],
+ <DropdownMenu
+ items={items}
+ placement={placement}
+ popupProps={{
style: {
maxHeight: 360,
minWidth: 240,
overflow: 'auto',
},
}}
- placement={placement}
>
<ActionIcon icon={Languages} size={size || { blockSize: 32, size: 16 }} />
- </Dropdown>
+ </DropdownMenu>
);
},
);
diff --git a/src/layout/AuthProvider/MarketAuth/MarketAuthProvider.tsx b/src/layout/AuthProvider/MarketAuth/MarketAuthProvider.tsx
index 5ac521082eb..c242a251746 100644
--- a/src/layout/AuthProvider/MarketAuth/MarketAuthProvider.tsx
+++ b/src/layout/AuthProvider/MarketAuth/MarketAuthProvider.tsx
@@ -151,7 +151,7 @@ export const MarketAuthProvider = ({ children, isDesktop }: MarketAuthProviderPr
null,
);
const [pendingProfileSuccessCallback, setPendingProfileSuccessCallback] = useState<
- ((profile: MarketUserProfile) => void) | null
+ ((_profile: MarketUserProfile) => void) | null
>(null);
// 订阅 user store 的初始化状态,当 isUserStateInit 为 true 时,settings 数据已加载完成
diff --git a/src/styles/global.ts b/src/styles/global.ts
index fe0a63f4d2b..c1e0a5ab0f3 100644
--- a/src/styles/global.ts
+++ b/src/styles/global.ts
@@ -55,8 +55,8 @@ export default ({ token }: { prefixCls: string; token: Theme }) => css`
-webkit-app-region: no-drag;
}
- .${CLASSNAMES.ContextTrigger}[data-popup-open],
- .${CLASSNAMES.DropdownMenuTrigger}[data-popup-open] {
+ .${CLASSNAMES.ContextTrigger}[data-popup-open]:not([data-no-highlight]),
+ .${CLASSNAMES.DropdownMenuTrigger}[data-popup-open]:not([data-no-highlight]) {
background: ${token.colorFillTertiary};
}
`;
diff --git a/src/types/shim-lobe-ui.d.ts b/src/types/shim-lobe-ui.d.ts
new file mode 100644
index 00000000000..d17d76ad1d2
--- /dev/null
+++ b/src/types/shim-lobe-ui.d.ts
@@ -0,0 +1,7 @@
+declare module '@lobehub/ui' {
+ export interface DropdownMenuProps {
+ 'data-no-highlight'?: boolean;
+ }
+}
+
+export {};