From aed389c17b56b42384ee634a32c9e3b98a11f54b Mon Sep 17 00:00:00 2001 From: kilo5hz <1005hz@outlook.com> Date: Thu, 18 Nov 2021 17:20:27 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E6=A0=91=E8=8A=82=E7=82=B9?= =?UTF-8?q?=E9=80=89=E4=B8=AD=EF=BC=8C=E7=88=B6=E8=8A=82=E7=82=B9=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E5=B1=95=E5=BC=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/script/index.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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} >