From 0ff7bb1c15cdf752f674c4c2d6892d363e261b13 Mon Sep 17 00:00:00 2001 From: ZLY Date: Mon, 25 Aug 2025 17:25:57 +0800 Subject: [PATCH] =?UTF-8?q?feat(logBar):=20=E5=AE=9E=E7=8E=B0=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E6=A0=8F=E7=9A=84=E6=8A=98=E5=8F=A0=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加收起状态,默认为收起 - 实现 Tab 点击事件的自定义处理 - 根据收起状态动态调整日志栏高度 - 优化 Tabs 组件的使用,移除不必要的属性 --- src/pages/ideContainer/logBar.tsx | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/src/pages/ideContainer/logBar.tsx b/src/pages/ideContainer/logBar.tsx index c886421..24a05f5 100644 --- a/src/pages/ideContainer/logBar.tsx +++ b/src/pages/ideContainer/logBar.tsx @@ -1,11 +1,9 @@ import React, { useState } from 'react'; -import { ResizeBox } from '@arco-design/web-react'; +import { ResizeBox, Tabs } from '@arco-design/web-react'; import styles from './style/logBar.module.less'; -import { Tabs, Typography } from '@arco-design/web-react'; const TabPane = Tabs.TabPane; - interface LogBarProps { a?: string; } @@ -34,9 +32,22 @@ const data = [ ]; const LogBar: React.FC = () => { - const [tabs, setTabs] = useState(data); + const [tabs] = useState(data); const [activeTab, setActiveTab] = useState('1'); + const [collapsed, setCollapsed] = useState(true); // 添加收起状态,默认为收起 + // 处理 Tab 点击事件 + const handleTabClick = (key: string) => { + // 如果点击当前激活的 tab,则切换收起状态 + if (key === activeTab) { + setCollapsed(!collapsed); + } + else { + // 如果点击的是其他 tab,则切换到该 tab 并展开 + setActiveTab(key); + setCollapsed(false); + } + }; return ( <> @@ -44,15 +55,15 @@ const LogBar: React.FC = () => { className={styles.logBar} directions={['top']} style={{ - height: 250 + height: collapsed ? 40 : 250 // 收起时只显示 tab 高度,展开时显示完整高度 }} > - {tabs.map((x, i) => ( + {tabs.map((x) => ( {x.content}