diff --git a/src/pages/script/index.tsx b/src/pages/script/index.tsx index 2085ccd4..7863fdbd 100644 --- a/src/pages/script/index.tsx +++ b/src/pages/script/index.tsx @@ -115,10 +115,11 @@ const Script = ({ headerStyle, isPhone, theme }: any) => { node: { title: s, value: s, - key: `${p}-${s}`, + key: p ? `${p}-${s}` : s, parent: p, }, }; + setExpandedKeys([p]); onTreeSelect([`${p}-${s}`], obj); } }; @@ -136,6 +137,10 @@ const Script = ({ headerStyle, isPhone, theme }: any) => { getDetail(node); }; + const onExpand = (expKeys: any) => { + setExpandedKeys(expKeys); + }; + const onTreeSelect = useCallback( (keys: Key[], e: any) => { const content = editorRef.current @@ -468,6 +473,8 @@ const Script = ({ headerStyle, isPhone, theme }: any) => { showIcon={true} height={height} selectedKeys={[select]} + expandedKeys={expandedKeys} + onExpand={onExpand} showLine={{ showLeafIcon: true }} onSelect={onTreeSelect} >