From bb123ae514dea144e6b93b28b0b7dd1d0cf8eaa6 Mon Sep 17 00:00:00 2001 From: shixiaohua Date: Tue, 5 Mar 2024 10:25:53 +0800 Subject: [PATCH] =?UTF-8?q?fix:item=E6=9C=80=E5=90=8E=E4=B8=80=E4=B8=AA?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=85=B3=E9=97=AD=EF=BC=8C=E5=8F=8A=E7=A9=BA?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=8A=A0=E8=BD=BD=E9=97=AE=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/Note/Hlexical/index.jsx | 4 +--- src/pages/Note/index.jsx | 5 +++-- src/redux/tableBarItem_reducer.js | 4 +--- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/pages/Note/Hlexical/index.jsx b/src/pages/Note/Hlexical/index.jsx index e21375b..2e9d7e3 100644 --- a/src/pages/Note/Hlexical/index.jsx +++ b/src/pages/Note/Hlexical/index.jsx @@ -47,12 +47,10 @@ export default function Hlexical(props) { }, nodes: UsefulNodes }; - const [spinningState,setSpinningState]=useState(true) + const [spinningState,setSpinningState]=useState(!isEmpty(props.filePath)) console.log("Hlexical(props):this.props.filePath:", props.filePath) if (!isEmpty(props.filePath)&&props.filePath.endsWith(".md")){ - let promise = importFile(props.filePath); - promise.then(value => { if (isEmpty(value)) { return diff --git a/src/pages/Note/index.jsx b/src/pages/Note/index.jsx index dc7951d..2afb7c7 100644 --- a/src/pages/Note/index.jsx +++ b/src/pages/Note/index.jsx @@ -55,7 +55,7 @@ const Note = () => { }; const remove = (targetKey) => { console.log("remove = (targetKey):",targetKey) - let newActiveKey = activeKey; + let lastIndex = -1; items.forEach((item, i) => { if (item.key === targetKey) { @@ -64,7 +64,8 @@ const Note = () => { }); dispatch(removeTableBarItem(targetKey)); const newPanes = items.filter((item) => item.key !== targetKey); - if (newPanes.length && newActiveKey === targetKey) { + let newActiveKey; + if (newPanes.length) { if (lastIndex >= 0) { newActiveKey = newPanes[lastIndex].key; } else { diff --git a/src/redux/tableBarItem_reducer.js b/src/redux/tableBarItem_reducer.js index aa3b55a..9739b3a 100644 --- a/src/redux/tableBarItem_reducer.js +++ b/src/redux/tableBarItem_reducer.js @@ -38,9 +38,7 @@ export const tableBarItemSlice = createSlice({ }, setActiveKey: (state, action) => { console.log("tableBarItemSlice:setActiveKey",action.payload) - if (action.payload.activeKey){ - state.activeKey=action.payload.activeKey - } + state.activeKey=action.payload.activeKey }, updateFileName:(state,action)=>{ console.log("tableBarItemSlice:updateFileName", state, action)