Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 🐛 支持开启 layout + ant3应用 显示右上的退出登陆的按钮 #11146

Merged
merged 2 commits into from
May 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions packages/plugins/src/layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -497,10 +497,25 @@ export function getRightRenderContent (opts: {
],
};
// antd@5 和 4.24 之后推荐使用 menu,性能更好
const dropdownProps =
version.startsWith("5.") || version.startsWith("4.24.")
? { menu: langMenu }
: { overlay: <Menu {...langMenu} /> };
let dropdownProps;
if (version.startsWith("5.") || version.startsWith("4.24.")) {
dropdownProps = { menu: langMenu };
} else if (version.startsWith("3.")) {
dropdownProps = {
overlay: (
<Menu>
{langMenu.items.map((item) => (
<Menu.Item key={item.key} onClick={item.onClick}>
{item.label}
</Menu.Item>
))}
</Menu>
),
};
} else { // 需要 antd 4.20.0 以上版本
dropdownProps = { overlay: <Menu {...langMenu} /> };
}


return (
<div className="umi-plugin-layout-right anticon">
Expand Down
25 changes: 19 additions & 6 deletions packages/plugins/templates/locale/SelectLang.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -442,12 +442,25 @@ export const SelectLang: React.FC<SelectLangProps> = (props) => {
};

// antd@5 和 4.24 之后推荐使用 menu,性能更好
const dropdownProps =
version.startsWith('5.') || version.startsWith('4.24.')
? { menu: langMenu }
: { overlay: <Menu {...langMenu} /> };


let dropdownProps;
if (version.startsWith("5.") || version.startsWith("4.24.")) {
dropdownProps = { menu: langMenu };
} else if (version.startsWith("3.")) {
dropdownProps = {
overlay: (
<Menu>
{langMenu.items.map((item) => (
<Menu.Item key={item.key} onClick={item.onClick}>
{item.label}
</Menu.Item>
))}
</Menu>
),
};
} else { // 需要 antd 4.20.0 以上版本
dropdownProps = { overlay: <Menu {...langMenu} /> };
}

const inlineStyle = {
cursor: "pointer",
padding: "12px",
Expand Down