From 172723e3b0209d9643b84364fa4bd3c2998c5ad6 Mon Sep 17 00:00:00 2001 From: shixiaohua Date: Sun, 4 Feb 2024 11:08:49 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E6=9D=A5=E5=9B=9E=E8=87=AA=E7=94=B1?= =?UTF-8?q?=E5=88=87=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.js | 4 ++++ src/pages/Note/index.jsx | 5 ++++- src/redux/tableBarItem_reducer.js | 11 +++++++++-- 3 files changed, 17 insertions(+), 3 deletions(-) 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