Match-id-a9c8af2dec397a83d20a0c78a9d464f4ea450dd6

This commit is contained in:
* 2022-03-29 10:53:51 +08:00 committed by *
parent de7d629d30
commit a5f78bf5fb
2 changed files with 34 additions and 8 deletions

View File

@ -1,19 +1,28 @@
@import 'assets.less';
.tree_container {
.treeContainer {
position: relative;
width: 100%;
height: 100%;
overflow-y: auto;
}
.tree_item {
.treeItem {
width: 100%;
position: absolute;
.componentName {
color: @component-name-color;
}
.componentKeyName {
color: @component-key-color;
}
.componentKeyValue {
color: @componentKeyValue-color;
}
}
.tree_icon {
color: @gray;
.treeIcon {
color: @arrow-color;
display: inline-block;
width: 12px
}

View File

@ -23,14 +23,31 @@ const indentationLength = 20;
function Item({ name, style, userKey, hasChild, onCollapse, isCollapsed, id, indentation }: IItem) {
const key = userKey === '' ? '' : ` key = '${userKey}'`;
const isShowKey = userKey !== '';
const showIcon = hasChild ? <Arrow director={isCollapsed ? 'right' : 'down'} /> : '';
const onClickCollapse = () => {
onCollapse(id);
}
return (
<div style={style} className={styles.tree_item}>
<div style={{marginLeft: indentation* indentationLength}} className={styles.tree_icon} onClick={onClickCollapse} >{showIcon}</div>
{name + key}
<div style={style} className={styles.treeItem}>
<div style={{ marginLeft: indentation * indentationLength }} className={styles.treeIcon} onClick={onClickCollapse} >
{showIcon}
</div>
<span className={styles.componentName} >
{name}
</span>
{isShowKey && (
<>
<span className={styles.componentKeyName}>
{' '}key
</span>
{'="'}
<span className={styles.componentKeyValue}>
{userKey}
</span>
{'"'}
</>
)}
</div>
)
}
@ -97,7 +114,7 @@ function VTree({ data }: { data: IData[] }) {
}
return (
<div className={styles.tree_container} onScroll={scroll}>
<div className={styles.treeContainer} onScroll={scroll}>
{showList}
{/* 确保有足够的高度 */}
<div style={{ marginTop: totalHeight }} />