💄 style: Pre render ModelSwitchPanel (#9499)

 feat: (预渲染模型切换浮窗)支持 ActionDropdown 组件的预渲染功能
This commit is contained in:
sxjeru
2025-10-27 17:18:17 +08:00
committed by GitHub
parent bf53c116dd
commit 840382b5b5
2 changed files with 22 additions and 1 deletions

View File

@@ -23,16 +23,36 @@ export interface ActionDropdownProps extends DropdownProps {
maxHeight?: number | string;
maxWidth?: number | string;
minWidth?: number | string;
/**
* 是否在挂载时预渲染弹层,避免首次触发展开时的渲染卡顿
*/
prefetch?: boolean;
}
const ActionDropdown = memo<ActionDropdownProps>(
({ menu, maxHeight, minWidth, maxWidth, children, placement = 'top', ...rest }) => {
({
menu,
maxHeight,
minWidth,
maxWidth,
children,
placement = 'top',
prefetch = false,
destroyOnHidden,
forceRender,
...rest
}) => {
const { cx, styles } = useStyles();
const isMobile = useIsMobile();
const dropdownForceRender = prefetch ? true : forceRender;
const dropdownDestroyOnHidden = prefetch ? false : destroyOnHidden;
return (
<Dropdown
arrow={false}
destroyOnHidden={dropdownDestroyOnHidden}
forceRender={dropdownForceRender}
menu={{
...menu,
className: cx(styles.dropdownMenu, menu.className),

View File

@@ -161,6 +161,7 @@ const ModelSwitchPanel = memo<IProps>(({ children, onOpenChange, open }) => {
onOpenChange={onOpenChange}
open={open}
placement={'topLeft'}
prefetch
>
{icon}
</ActionDropdown>