add redux
This commit is contained in:
38
src/store/features/kilnSlice.js
Normal file
38
src/store/features/kilnSlice.js
Normal file
@@ -0,0 +1,38 @@
|
||||
import { createSlice } from "@reduxjs/toolkit";
|
||||
|
||||
export const initialState = {
|
||||
kilnPressure: "0Pa",
|
||||
waterTemp: "0℃",
|
||||
waterFlow: "0m³/h",
|
||||
waterPressure: "0Pa",
|
||||
combustionAirPressure: "0Pa",
|
||||
topTemp: "0℃",
|
||||
compressedAirPressure: "0Pa",
|
||||
meltTemp: "0℃",
|
||||
};
|
||||
|
||||
export const stateNameMap = {
|
||||
kilnPressure: "窑炉压力",
|
||||
waterTemp: "循环水温度",
|
||||
waterFlow: "循环水流量",
|
||||
waterPressure: "循环水压力",
|
||||
combustionAirPressure: "助燃风压力",
|
||||
topTemp: "碹顶加权温度",
|
||||
compressedAirPressure: "压缩气压力",
|
||||
meltTemp: "融化加权温度",
|
||||
};
|
||||
|
||||
const kilnSlice = createSlice({
|
||||
name: "kiln",
|
||||
initialState,
|
||||
reducers: {
|
||||
setKilnInfo: (state, action) => {
|
||||
Object.keys(action.payload).forEach((key) => {
|
||||
state[key] = action.payload[key];
|
||||
});
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export default kilnSlice.reducer;
|
||||
export const { setKilnInfo } = kilnSlice.actions;
|
||||
@@ -1,8 +1,8 @@
|
||||
import { configureStore } from "@reduxjs/toolkit";
|
||||
// import counterReducer from '../features/kiln/KilnSlice'
|
||||
import kilnReducer from "./features/kilnSlice";
|
||||
|
||||
export const store = configureStore({
|
||||
reducer: {
|
||||
// counter: counterReducer,
|
||||
kiln: kilnReducer,
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user