fix:item最后一个文件关闭,及空文件加载问题。

This commit is contained in:
shixiaohua 2024-03-05 10:25:53 +08:00
parent bbcd633d02
commit bb123ae514
3 changed files with 5 additions and 8 deletions

View File

@ -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

View File

@ -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 {

View File

@ -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
}
},
updateFileName:(state,action)=>{
console.log("tableBarItemSlice:updateFileName", state, action)