2024-01-24 04:59:31 -05:00
|
|
|
import { createSlice } from '@reduxjs/toolkit'
|
2024-01-24 21:07:09 -05:00
|
|
|
import {Alert} from "antd";
|
2024-01-24 04:59:31 -05:00
|
|
|
|
|
|
|
export const dirMessageSlice = createSlice({
|
|
|
|
name: 'dirMessage',
|
|
|
|
initialState: {
|
|
|
|
data: []
|
|
|
|
},
|
|
|
|
reducers: {
|
|
|
|
dirAdd: (state, action) => {
|
|
|
|
console.log("dirMessage:dirAdd", state, action)
|
|
|
|
if(action.payload){
|
2024-01-24 21:07:09 -05:00
|
|
|
// 新添加进来的目录,要判断是否重复,如果重复则提示
|
|
|
|
let filter = state.data.filter((fileMessage)=>
|
|
|
|
fileMessage.filePath===action.payload[0].filePath
|
|
|
|
);
|
|
|
|
if (filter.length>0){
|
|
|
|
console.log('filter',filter)
|
|
|
|
}else {
|
|
|
|
// 添加进当前目录
|
|
|
|
state.data=[...new Set([...state.data,...action.payload])];
|
|
|
|
console.log('state.data:',state.data)
|
|
|
|
}
|
2024-01-24 04:59:31 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
export const { dirAdd } = dirMessageSlice.actions
|
|
|
|
|
|
|
|
export default dirMessageSlice.reducer
|