diff --git a/main.js b/main.js index 462ed43..eabaea7 100644 --- a/main.js +++ b/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)=>{ diff --git a/src/pages/Note/index.jsx b/src/pages/Note/index.jsx index 57be386..f25d97d 100644 --- a/src/pages/Note/index.jsx +++ b/src/pages/Note/index.jsx @@ -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); }; diff --git a/src/redux/tableBarItem_reducer.js b/src/redux/tableBarItem_reducer.js index 75e73e3..9464bce 100644 --- a/src/redux/tableBarItem_reducer.js +++ b/src/redux/tableBarItem_reducer.js @@ -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