From b45c7bae52449c3bc18f0a212ec4559a144bf0ba Mon Sep 17 00:00:00 2001 From: ZLY Date: Wed, 20 Aug 2025 10:57:00 +0800 Subject: [PATCH] =?UTF-8?q?feat(ideContainer):=20=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E4=BE=A7=E8=BE=B9=E6=A0=8F=E7=BB=84=E4=BB=B6=E5=92=8C=E8=8F=9C?= =?UTF-8?q?=E5=8D=95=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/ideContainer/config/menuData.ts | 37 ++++++++ src/pages/ideContainer/sideBar.tsx | 95 +++++++++++++++++++ .../ideContainer/style/index.module.less | 4 + .../ideContainer/style/sideBar.module.less | 28 ++++++ 4 files changed, 164 insertions(+) create mode 100644 src/pages/ideContainer/config/menuData.ts create mode 100644 src/pages/ideContainer/sideBar.tsx create mode 100644 src/pages/ideContainer/style/index.module.less create mode 100644 src/pages/ideContainer/style/sideBar.module.less diff --git a/src/pages/ideContainer/config/menuData.ts b/src/pages/ideContainer/config/menuData.ts new file mode 100644 index 0000000..d63fd59 --- /dev/null +++ b/src/pages/ideContainer/config/menuData.ts @@ -0,0 +1,37 @@ +export const menuData = [ + { + title: '应用编排', + children: null, + path: 'appFlow' + }, + { + title: '应用列表', + children: [ + { + title: '应用A', + children: [ + { + title: '组件列表', + children: null, + path: 'compList' + }, + { + title: '应用实例', + children: null, + path: 'appInstance' + } + ] + } + ] + }, + { + title: '事件', + children: null, + path: 'event' + }, + { + title: '全局变量', + children: null, + path: 'globalVar' + } +]; \ No newline at end of file diff --git a/src/pages/ideContainer/sideBar.tsx b/src/pages/ideContainer/sideBar.tsx new file mode 100644 index 0000000..ae9bfcb --- /dev/null +++ b/src/pages/ideContainer/sideBar.tsx @@ -0,0 +1,95 @@ +import React, { useState } from 'react'; +import styles from './style/sideBar.module.less'; +import { Layout, Menu } from '@arco-design/web-react'; +import { IconApps, IconMenuFold, IconMenuUnfold } from '@arco-design/web-react/icon'; +import { GlobalState } from '@/store'; +import { useSelector } from 'react-redux'; +import getUrlParams from '@/utils/getUrlParams'; +import { menuData } from './config/menuData'; + +const Sider = Layout.Sider; + +const MenuItem = Menu.Item; +const SubMenu = Menu.SubMenu; + +interface MenuItemType { + title: string; + children?: MenuItemType[]; + path?: string; +} + +interface SideBarProps { + onMenuSelect?: ({ currentPath, currentKey }) => void; + selectedKey?: string; +} + +const SideBar: React.FC = ({ onMenuSelect, selectedKey }) => { + const urlParams = getUrlParams(); + const [collapsed, setCollapsed] = useState(false); + const { userInfo, settings, userLoading } = useSelector( + (state: GlobalState) => state + ); + + const navbarHeight = 60; + const menuWidth = collapsed ? 48 : settings?.menuWidth; + + const showNavbar = settings?.navbar && urlParams.navbar !== false; + const paddingTop = showNavbar ? { paddingTop: navbarHeight } : {}; + + function toggleCollapse() { + setCollapsed((collapsed) => !collapsed); + } + + // 递归渲染菜单项 + const renderMenuItems = (items: MenuItemType[], parentKey = '') => { + return items.map((item, index) => { + const currentKey = (parentKey ? `${parentKey}_${index}` : `${index}`); + + if (!item.children) { + return ( + { + onMenuSelect?.({ currentPath: item.path, currentKey }); + }} + > + {item.title} + + ); + } + + return ( + + {renderMenuItems(item.children, currentKey)} + + ); + }); + }; + + return ( + <> + + + + {renderMenuItems(menuData)} + + {/*
*/} + {/* {collapsed ? : }*/} + {/*
*/} +
+
+ + ); +}; + +export default SideBar; diff --git a/src/pages/ideContainer/style/index.module.less b/src/pages/ideContainer/style/index.module.less new file mode 100644 index 0000000..85bbbcd --- /dev/null +++ b/src/pages/ideContainer/style/index.module.less @@ -0,0 +1,4 @@ +.IDEContainer { + width: 100%; + height: 100%; +} \ No newline at end of file diff --git a/src/pages/ideContainer/style/sideBar.module.less b/src/pages/ideContainer/style/sideBar.module.less new file mode 100644 index 0000000..50e32cc --- /dev/null +++ b/src/pages/ideContainer/style/sideBar.module.less @@ -0,0 +1,28 @@ +.sider { + position: fixed; + height: 100%; + top: 0; + left: 0; + z-index: 99; + box-sizing: border-box; + + .collapse-btn { + height: 24px; + width: 24px; + background-color: var(--color-fill-1); + color: var(--color-text-3); + border-radius: 2px; + cursor: pointer; + display: flex; + justify-content: center; + align-items: center; + // 位置 + position: absolute; + bottom: 12px; + right: 12px; + + &:hover { + background-color: var(--color-fill-3); + } + } +} \ No newline at end of file