system-copyright-react/src/store/index.ts

117 lines
3.1 KiB
TypeScript
Raw Normal View History

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: [],
2025-05-27 10:47:05 +08:00
refunArray: [],
correctionArray: [],
contractArray: [],
contractTotal: 0,
refunTotal: 0,
correctionTotal: 0,
couponModal: false,
projName: '',
projStatus: '',
newRefun: false,
newCorrection: false,
packNum: {
ALL: 0,
MATERIAL: 0,
2025-04-14 17:38:30 +08:00
},
2025-05-27 10:47:05 +08:00
phoneModal: false,
appGoodsListData: {},
2025-05-30 14:34:21 +08:00
replaceArray: [],
replaceTotal: 0,
newReplace: false,
2025-08-07 10:10:19 +08:00
activityModal: false, //活动弹窗
activityImgShow: true, //活动图片是否展示
// 坐标
centerPoint: { x: 0, y: 0 },
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
}
2025-05-30 14:34:21 +08:00
if (action.type == 'upReplaceArray') {
nstate.replaceArray = action.val
}
2024-11-29 17:52:17 +08:00
if (action.type == 'upContractArray') {
nstate.contractArray = action.val
}
if (action.type == 'upContractTotal') {
nstate.contractTotal = action.val
}
2024-08-26 18:03:35 +08:00
if (action.type == 'upCorrectionTotal') {
nstate.correctionTotal = action.val
}
2025-05-30 14:34:21 +08:00
if (action.type == 'upReplaceTotal') {
nstate.replaceTotal = 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-09-11 16:45:19 +08:00
if (action.type == 'newRefun') {
nstate.newRefun = action.val
}
if (action.type == 'newCorrection') {
nstate.newCorrection = action.val
}
2025-03-07 08:45:05 +08:00
if (action.type == 'upPackNum') {
nstate.packNum = action.val
}
2025-05-27 10:47:05 +08:00
if (action.type == 'changePhoneModal') {
2025-04-14 17:38:30 +08:00
nstate.phoneModal = action.val
}
2025-05-27 10:47:05 +08:00
if (action.type == 'upAppGoodsListData') {
nstate.appGoodsListData = action.val
}
2025-05-30 14:34:21 +08:00
if (action.type == 'newReplace') {
nstate.newReplace = action.val
2025-08-05 15:30:31 +08:00
}
2025-08-07 10:10:19 +08:00
if (action.type == 'setActivityModal') {
2025-08-05 15:30:31 +08:00
nstate.activityModal = action.val
2025-05-30 14:34:21 +08:00
}
2025-08-07 10:10:19 +08:00
if (action.type == 'upCenterPoint') {
nstate.centerPoint = action.val
}
if (action.type == 'setActivityImgShow') {
nstate.activityImgShow = action.val
}
2024-07-31 16:00:30 +08:00
return nstate
}
const store = createStore(reducer)
export default store