feat:来回自由切换
This commit is contained in:
parent
13a9830aa6
commit
172723e3b0
4
main.js
4
main.js
|
@ -66,6 +66,10 @@ app.whenReady().then(() => {
|
|||
})
|
||||
ipcMain.handle("electronStoreSave",(listen,key,value)=>{
|
||||
console.log("electronStoreSave",key,value)
|
||||
if (store.get(key)===value){
|
||||
return ;
|
||||
}
|
||||
console.log("electronStoreSaveDisk",key,value)
|
||||
return store.set(key,value)
|
||||
})
|
||||
ipcMain.handle("electronStoreGet",(listen,args)=>{
|
||||
|
|
|
@ -9,7 +9,7 @@ import './index.less'
|
|||
import {store} from "../../redux/store";
|
||||
import {isEmpty} from "../../utils/ObjectUtils";
|
||||
import {useSelector, useDispatch} from "react-redux";
|
||||
import {addTableBarItem} from "../../redux/tableBarItem_reducer"
|
||||
import {addTableBarItem, removeTableBarItem} from "../../redux/tableBarItem_reducer"
|
||||
|
||||
const {Header, Sider, Content} = Layout;
|
||||
const Note = () => {
|
||||
|
@ -62,6 +62,7 @@ const Note = () => {
|
|||
setActiveKey(newActiveKey);
|
||||
};
|
||||
const remove = (targetKey) => {
|
||||
console.log("remove = (targetKey):",targetKey)
|
||||
let newActiveKey = activeKey;
|
||||
let lastIndex = -1;
|
||||
items.forEach((item, i) => {
|
||||
|
@ -69,6 +70,7 @@ const Note = () => {
|
|||
lastIndex = i - 1;
|
||||
}
|
||||
});
|
||||
dispatch(removeTableBarItem(targetKey));
|
||||
const newPanes = items.filter((item) => item.key !== targetKey);
|
||||
if (newPanes.length && newActiveKey === targetKey) {
|
||||
if (lastIndex >= 0) {
|
||||
|
@ -77,6 +79,7 @@ const Note = () => {
|
|||
newActiveKey = newPanes[0].key;
|
||||
}
|
||||
}
|
||||
console.log("remove = (newActiveKey):",newActiveKey)
|
||||
// setItems(newPanes);
|
||||
setActiveKey(newActiveKey);
|
||||
};
|
||||
|
|
|
@ -9,17 +9,24 @@ export const tableBarItemSlice = createSlice({
|
|||
},
|
||||
reducers: {
|
||||
addTableBarItem: (state, action) => {
|
||||
console.log("tableBarItemSlice:tableBarItem=====", state, action,)
|
||||
console.log("tableBarItemSlice:tableBarItem", state, action,)
|
||||
if (state.data.filter(file=>file.key===action.payload.key).length===0){
|
||||
state.data.push(action.payload)
|
||||
}
|
||||
},
|
||||
removeTableBarItem: (state, action) => {
|
||||
console.log("tableBarItemSlice:removeTableBarItem",action.payload)
|
||||
state.data=state.data.filter(file=>file.key!==action.payload)
|
||||
},
|
||||
setActiveKey:(state,action)=>{
|
||||
console.log("tableBarItemSlice:setActiveKey",action.payload)
|
||||
if (state.activeKey!==action.payload){
|
||||
state.activeKey=action.payload;
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
export const { addTableBarItem,setActiveKey } = tableBarItemSlice.actions
|
||||
export const { addTableBarItem,
|
||||
removeTableBarItem,
|
||||
setActiveKey } = tableBarItemSlice.actions
|
||||
export default tableBarItemSlice.reducer
|
||||
|
|
Loading…
Reference in New Issue