Skip to content

Commit

Permalink
fix: 🐛 支持开启 layout + ant3应用 显示右上的退出登陆的按钮 (#11146)
Browse files Browse the repository at this point in the history
* fix: 🐛 支持开启 layout + ant3应用 显示右上的退出登陆的按钮

* fix: 🐛 SelectLang 修复

---------

Co-authored-by: pshu <pishu.spf@antfin.com>
  • Loading branch information
stormslowly and stormslowly committed May 16, 2023
1 parent 5564f40 commit d358e81
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 10 deletions.
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

0 comments on commit d358e81

Please sign in to comment.