Skip to content
This repository has been archived by the owner on Oct 28, 2024. It is now read-only.

fix #247 修复执行结果无法关闭,执行sql只显示执行成功 #354

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 31 additions & 15 deletions ali-dbhub-client/src/components/Tabs/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { memo, ReactNode, useState } from 'react';
import styles from './index.less';
import classnames from 'classnames';
import { Tabs as AntdTabs } from 'antd';
import { Tabs as AntdTabs, Button } from 'antd';

export interface ITab {
label: ReactNode;
Expand All @@ -17,21 +17,37 @@ interface IProps {
}

export default memo(function Tabs({ className, tabs, currentTab, onChange, extra }: IProps) {
const [hiddenTabs, setHiddenTabs] = useState<string[]>([]);

function myChange(key: string) {
const index = tabs.findIndex(t => {
return t.key === key
})
onChange(key, index)
const index = tabs.findIndex(t => t.key === key);
onChange(key, index);
}

function handleClose(key: string) {
const updatedHiddenTabs = [...hiddenTabs, key];
setHiddenTabs(updatedHiddenTabs);
}

return <div className={classnames(className, styles.box)}>
<AntdTabs
defaultActiveKey={currentTab}
onChange={myChange}
items={tabs}
/>
<div className={styles.extra}>
{extra}
const visibleTabs = tabs.filter(tab => !hiddenTabs.includes(tab.key));

return (
<div className={classnames(className, styles.box)}>
<AntdTabs defaultActiveKey={currentTab} onChange={myChange}>
{visibleTabs.map(tab => (
<AntdTabs.TabPane tab={
<span>
<span style={{float:'left'}}> {tab.label} </span>
<a onClick={() => handleClose(tab.key)}>X</a>
</span>
} key={tab.key} />
))}
</AntdTabs>
<div className={styles.extra}>

{extra}
</div>
</div>
</div>
})
);
});