Skip to content

Commit

Permalink
编辑器的menu二级菜单问题
Browse files Browse the repository at this point in the history
  • Loading branch information
luoluoTH committed Jan 9, 2024
1 parent 99b7770 commit 6aee73d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion app/renderer/src/main/config-overrides.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ module.exports = {
}
)),
addWebpackPlugin(new NodePolyfillPlugin()),
addWebpackPlugin(new MiniCssExtractPlugin({
!devMode && addWebpackPlugin(new MiniCssExtractPlugin({
filename: '[name].css',
chunkFilename: '[id].css'
})),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, {ReactNode, useMemo} from "react"
import React, {ReactNode, useMemo, useState} from "react"
import {useMemoizedFn} from "ahooks"
import {Menu, MenuProps, Tooltip} from "antd"
import {ItemType} from "antd/lib/menu/hooks/useItems"
Expand Down Expand Up @@ -46,7 +46,7 @@ export const EditorMenu: React.FC<EditorMenuProp> = React.memo((props) => {
size = "default",
...restMenu
} = props

const [openKeys, setOpenKeys] = useState<string[]>([])
const menuTypeClass = useMemo(() => {
if (type === "grey") return styles["yakit-menu-grey"]
return styles["yakit-menu-primary"]
Expand Down Expand Up @@ -127,17 +127,18 @@ export const EditorMenu: React.FC<EditorMenuProp> = React.memo((props) => {
if (data.length > 0) for (let item of data) items.push(generateMenuInfo(item))

return (
<div
className={classNames(
styles["yakit-menu-div-wrapper"],
menuTypeClass,
menuSizeClass
)}
>
<div className={classNames(styles["yakit-menu-div-wrapper"], menuTypeClass, menuSizeClass)}>
<Menu
openKeys={openKeys}
{...restMenu}
className={classNames(styles["yakit-menu-wrapper"], className || "")}
items={data && data.length > 0 ? items : restMenu.items}
onOpenChange={(openKey) => {
setOpenKeys(openKey.filter((key, index) => index === openKey.length - 1))
if (props.onOpenChange) {
props.onOpenChange(openKey)
}
}}
></Menu>
</div>
)
Expand Down

0 comments on commit 6aee73d

Please sign in to comment.