From 130c15332b606bc6558a3e867f942d57416bfb46 Mon Sep 17 00:00:00 2001 From: ZLY Date: Tue, 11 Nov 2025 14:26:52 +0800 Subject: [PATCH] =?UTF-8?q?feat(componentCoding):=20=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E9=80=9A=E8=BF=87=E4=BA=8B=E4=BB=B6=E5=AF=BC=E8=88=AA=E5=88=B0?= =?UTF-8?q?=E6=8C=87=E5=AE=9A=E9=A1=B9=E7=9B=AE=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../componentCoding/index.tsx | 24 +++++++++++--- src/pages/ideContainer/sideBar.tsx | 32 ++++++++++++++++++- 2 files changed, 51 insertions(+), 5 deletions(-) diff --git a/src/pages/componentDevelopment/componentCoding/index.tsx b/src/pages/componentDevelopment/componentCoding/index.tsx index 7309ad9..3354bd5 100644 --- a/src/pages/componentDevelopment/componentCoding/index.tsx +++ b/src/pages/componentDevelopment/componentCoding/index.tsx @@ -7,15 +7,31 @@ const Option = Select.Option; const ComponentCoding = () => { const [serverUrl, setServerUrl] = useState('https://arco.design/vue/component/button'); + const [localProjectPath, setLocalProjectPath] = useState(''); + useEffect(() => { + // 监听导航事件 + const handleNavigateToTab = (event: CustomEvent) => { + if (event.detail.path === 'componentCoding' && event.detail.localProjectPath) { + setLocalProjectPath(event.detail.localProjectPath); + } + }; + + document.addEventListener('navigateToTab', handleNavigateToTab as EventListener); + + return () => { + document.removeEventListener('navigateToTab', handleNavigateToTab as EventListener); + }; + }, []); useEffect(() => { const uri = process.env.NEXT_PUBLIC_DEV_CODE_SERVER_HOST; const codeServerFolderPre = '/app/data'; - const tempData = '/000000/admin_testcode1/master'; - setServerUrl(`${uri}?folder=${codeServerFolderPre}${tempData}`); - - }); + + // 使用传入的localProjectPath或默认值 + const path = localProjectPath || '/000000/admin_testcode1/master'; + setServerUrl(`${uri}?folder=${codeServerFolderPre}${path}`); + }, [localProjectPath]); const componentScreening = () => { // 将数据结构修改为级联结构 diff --git a/src/pages/ideContainer/sideBar.tsx b/src/pages/ideContainer/sideBar.tsx index f53bbc0..5fc022c 100644 --- a/src/pages/ideContainer/sideBar.tsx +++ b/src/pages/ideContainer/sideBar.tsx @@ -585,12 +585,42 @@ const SideBar: React.FC = ({ } }; + // 监听导航到Tab的事件 + const handleNavigateToTab = (event: CustomEvent) => { + const { path } = event.detail; + + // 查找对应的菜单项 + const menuItems = menuData[identity]; + if (!menuItems) return; + + const findMenuItem = (items: any[]): any => { + for (const item of items) { + if (item.path === path) { + return item; + } + if (item.children) { + const found = findMenuItem(item.children); + if (found) return found; + } + } + return null; + }; + + const menuItem = findMenuItem(menuItems); + if (menuItem) { + // 触发菜单选择 + onMenuSelect?.({ ...menuItem }); + } + }; + document.addEventListener('toggleNodeVisibility', handleToggleNodeVisibility as EventListener); + document.addEventListener('navigateToTab', handleNavigateToTab as EventListener); return () => { document.removeEventListener('toggleNodeVisibility', handleToggleNodeVisibility as EventListener); + document.removeEventListener('navigateToTab', handleNavigateToTab as EventListener); }; - }, []); + }, [menuData, identity, onMenuSelect]); // 渲染节点的额外操作按钮 const renderNodeExtra = (node) => {