2024-08-12 14:43:58 +08:00
|
|
|
import { createStore } from "redux"
|
2024-07-31 16:00:30 +08:00
|
|
|
// 设置数据
|
|
|
|
const baseState = {
|
2024-08-12 14:43:58 +08:00
|
|
|
// msg: '嘻嘻嘻嘻嘻嘻',
|
|
|
|
// num: 10,
|
|
|
|
// shuju: {
|
|
|
|
// name: '小白',
|
|
|
|
// hobby: '吃饭',
|
|
|
|
// val: ''
|
|
|
|
// },
|
2024-08-23 11:16:52 +08:00
|
|
|
belongArray: [],
|
|
|
|
refunArray:[],
|
2024-08-26 18:03:35 +08:00
|
|
|
correctionArray:[],
|
|
|
|
refunTotal:0,
|
2024-09-02 16:41:02 +08:00
|
|
|
correctionTotal:0,
|
|
|
|
couponModal:false,
|
|
|
|
projName:'',
|
|
|
|
projStatus:''
|
2024-07-31 16:00:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// 创建仓库
|
2024-08-12 14:43:58 +08:00
|
|
|
const reducer = (state = baseState, action: any) => {
|
|
|
|
const nstate: any = JSON.parse(JSON.stringify(state))
|
|
|
|
// if (action.type == "numadd") {
|
|
|
|
// nstate.num++
|
|
|
|
// // console.log('123');
|
|
|
|
// }
|
|
|
|
// if (action.type == 'new') {
|
|
|
|
// nstate.shuju.val = action.val
|
|
|
|
// console.log(nstate.shuju.val);
|
|
|
|
// }
|
2024-07-31 16:00:30 +08:00
|
|
|
// redux 要求 state必须深拷贝一次 才能返回
|
2024-08-12 14:43:58 +08:00
|
|
|
if (action.type == 'uparray') {
|
2024-07-31 16:00:30 +08:00
|
|
|
nstate.belongArray = action.val
|
|
|
|
}
|
2024-08-23 11:16:52 +08:00
|
|
|
if (action.type == 'upRefunArray') {
|
|
|
|
nstate.refunArray = action.val
|
|
|
|
}
|
|
|
|
if (action.type == 'upRefunTotal') {
|
|
|
|
nstate.refunTotal = action.val
|
|
|
|
}
|
2024-08-26 18:03:35 +08:00
|
|
|
if (action.type == 'upCorrectionArray') {
|
|
|
|
nstate.correctionArray = action.val
|
|
|
|
}
|
|
|
|
if (action.type == 'upCorrectionTotal') {
|
|
|
|
nstate.correctionTotal = action.val
|
|
|
|
}
|
2024-09-02 16:41:02 +08:00
|
|
|
if (action.type == 'changeCouponModal') {
|
|
|
|
nstate.couponModal = action.val
|
|
|
|
}
|
|
|
|
if (action.type == 'upProjName') {
|
|
|
|
nstate.projName = action.val
|
|
|
|
}
|
|
|
|
if (action.type == 'upProjStatus') {
|
|
|
|
nstate.projStatus = action.val
|
|
|
|
}
|
2024-07-31 16:00:30 +08:00
|
|
|
return nstate
|
|
|
|
}
|
|
|
|
const store = createStore(reducer)
|
|
|
|
export default store
|