From 6aee73d532744956e69f922825735504e0b3a272 Mon Sep 17 00:00:00 2001 From: luoluo <1425735414@qq.com> Date: Tue, 9 Jan 2024 15:52:02 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BC=96=E8=BE=91=E5=99=A8=E7=9A=84menu?= =?UTF-8?q?=E4=BA=8C=E7=BA=A7=E8=8F=9C=E5=8D=95=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/renderer/src/main/config-overrides.js | 2 +- .../yakitUI/YakitEditor/EditorMenu.tsx | 19 ++++++++++--------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/app/renderer/src/main/config-overrides.js b/app/renderer/src/main/config-overrides.js index 6c9ea7fe7f..2c97f27d2a 100644 --- a/app/renderer/src/main/config-overrides.js +++ b/app/renderer/src/main/config-overrides.js @@ -43,7 +43,7 @@ module.exports = { } )), addWebpackPlugin(new NodePolyfillPlugin()), - addWebpackPlugin(new MiniCssExtractPlugin({ + !devMode && addWebpackPlugin(new MiniCssExtractPlugin({ filename: '[name].css', chunkFilename: '[id].css' })), diff --git a/app/renderer/src/main/src/components/yakitUI/YakitEditor/EditorMenu.tsx b/app/renderer/src/main/src/components/yakitUI/YakitEditor/EditorMenu.tsx index 12285bbb71..d420ed4132 100644 --- a/app/renderer/src/main/src/components/yakitUI/YakitEditor/EditorMenu.tsx +++ b/app/renderer/src/main/src/components/yakitUI/YakitEditor/EditorMenu.tsx @@ -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" @@ -46,7 +46,7 @@ export const EditorMenu: React.FC = React.memo((props) => { size = "default", ...restMenu } = props - + const [openKeys, setOpenKeys] = useState([]) const menuTypeClass = useMemo(() => { if (type === "grey") return styles["yakit-menu-grey"] return styles["yakit-menu-primary"] @@ -127,17 +127,18 @@ export const EditorMenu: React.FC = React.memo((props) => { if (data.length > 0) for (let item of data) items.push(generateMenuInfo(item)) return ( -
+
0 ? items : restMenu.items} + onOpenChange={(openKey) => { + setOpenKeys(openKey.filter((key, index) => index === openKey.length - 1)) + if (props.onOpenChange) { + props.onOpenChange(openKey) + } + }} >
)