fix:item最后一个文件关闭,及空文件加载问题。
This commit is contained in:
parent
bbcd633d02
commit
bb123ae514
|
@ -47,12 +47,10 @@ export default function Hlexical(props) {
|
||||||
},
|
},
|
||||||
nodes: UsefulNodes
|
nodes: UsefulNodes
|
||||||
};
|
};
|
||||||
const [spinningState,setSpinningState]=useState(true)
|
const [spinningState,setSpinningState]=useState(!isEmpty(props.filePath))
|
||||||
console.log("Hlexical(props):this.props.filePath:", props.filePath)
|
console.log("Hlexical(props):this.props.filePath:", props.filePath)
|
||||||
if (!isEmpty(props.filePath)&&props.filePath.endsWith(".md")){
|
if (!isEmpty(props.filePath)&&props.filePath.endsWith(".md")){
|
||||||
|
|
||||||
let promise = importFile(props.filePath);
|
let promise = importFile(props.filePath);
|
||||||
|
|
||||||
promise.then(value => {
|
promise.then(value => {
|
||||||
if (isEmpty(value)) {
|
if (isEmpty(value)) {
|
||||||
return
|
return
|
||||||
|
|
|
@ -55,7 +55,7 @@ const Note = () => {
|
||||||
};
|
};
|
||||||
const remove = (targetKey) => {
|
const remove = (targetKey) => {
|
||||||
console.log("remove = (targetKey):",targetKey)
|
console.log("remove = (targetKey):",targetKey)
|
||||||
let newActiveKey = activeKey;
|
|
||||||
let lastIndex = -1;
|
let lastIndex = -1;
|
||||||
items.forEach((item, i) => {
|
items.forEach((item, i) => {
|
||||||
if (item.key === targetKey) {
|
if (item.key === targetKey) {
|
||||||
|
@ -64,7 +64,8 @@ const Note = () => {
|
||||||
});
|
});
|
||||||
dispatch(removeTableBarItem(targetKey));
|
dispatch(removeTableBarItem(targetKey));
|
||||||
const newPanes = items.filter((item) => item.key !== targetKey);
|
const newPanes = items.filter((item) => item.key !== targetKey);
|
||||||
if (newPanes.length && newActiveKey === targetKey) {
|
let newActiveKey;
|
||||||
|
if (newPanes.length) {
|
||||||
if (lastIndex >= 0) {
|
if (lastIndex >= 0) {
|
||||||
newActiveKey = newPanes[lastIndex].key;
|
newActiveKey = newPanes[lastIndex].key;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -38,9 +38,7 @@ export const tableBarItemSlice = createSlice({
|
||||||
},
|
},
|
||||||
setActiveKey: (state, action) => {
|
setActiveKey: (state, action) => {
|
||||||
console.log("tableBarItemSlice:setActiveKey",action.payload)
|
console.log("tableBarItemSlice:setActiveKey",action.payload)
|
||||||
if (action.payload.activeKey){
|
|
||||||
state.activeKey=action.payload.activeKey
|
state.activeKey=action.payload.activeKey
|
||||||
}
|
|
||||||
},
|
},
|
||||||
updateFileName:(state,action)=>{
|
updateFileName:(state,action)=>{
|
||||||
console.log("tableBarItemSlice:updateFileName", state, action)
|
console.log("tableBarItemSlice:updateFileName", state, action)
|
||||||
|
|
Loading…
Reference in New Issue