add more slices

This commit is contained in:
lb
2023-11-10 10:09:50 +08:00
parent a18cb7a1c7
commit 3821121a6f
8 changed files with 487 additions and 285 deletions

View File

@@ -0,0 +1,74 @@
// 风机运行频率
import { createSlice } from "@reduxjs/toolkit";
/**
* 由于接口并没有经过合理的评审,所以这里的数据结构是不确定的,需要根据实际情况进行调整
*/
export const initialState = {
history: {
// 历史数据
FLIIA1: [
// 帮我生成7个随机整数
...Array.from({ length: 7 }, () => Math.floor(Math.random() * 100)),
],
// 帮我重复上面的模式十次
FLIIA2: [
...Array.from({ length: 7 }, () => Math.floor(Math.random() * 100)),
],
FLIIA3: [
...Array.from({ length: 7 }, () => Math.floor(Math.random() * 100)),
],
FLIIA4: [
...Array.from({ length: 7 }, () => Math.floor(Math.random() * 100)),
],
FLIIA5: [
...Array.from({ length: 7 }, () => Math.floor(Math.random() * 100)),
],
FLIIA6: [
...Array.from({ length: 7 }, () => Math.floor(Math.random() * 100)),
],
FLIIA7: [
...Array.from({ length: 7 }, () => Math.floor(Math.random() * 100)),
],
FLIIA8: [
...Array.from({ length: 7 }, () => Math.floor(Math.random() * 100)),
],
FLIIB1: [
...Array.from({ length: 7 }, () => Math.floor(Math.random() * 100)),
],
FLIIB2: [
...Array.from({ length: 7 }, () => Math.floor(Math.random() * 100)),
],
},
runtime: [
// 实时数据
...Array.from(
{ length: 16 },
() => Math.floor(Math.random() * 100) + "m³/h"
),
],
};
// export const stateNameMap = {
// lastFireChangeTime: "10分20秒",
// fireChangeTime: "10:23",
// fireDirection: "东火",
// };
const fanFrequenceSlice = createSlice({
name: "fanFrequence",
initialState,
reducers: {
setHistory: (state, action) => {
state.history = action.payload;
},
setRuntime: (state, action) => {
state.runtime = action.payload;
},
},
});
export default fanFrequenceSlice.reducer;
export const { setHistory, setRuntime } = fanFrequenceSlice.actions;

View File

@@ -0,0 +1,50 @@
// 风机运行频率
import { createSlice } from "@reduxjs/toolkit";
/**
* 由于接口并没有经过合理的评审,所以这里的数据结构是不确定的,需要根据实际情况进行调整
*/
export const initialState = {
history: {
// 历史数据
GAS1: [...Array.from({ length: 7 }, () => Math.floor(Math.random() * 100))],
GAS2: [...Array.from({ length: 7 }, () => Math.floor(Math.random() * 100))],
GAS3: [...Array.from({ length: 7 }, () => Math.floor(Math.random() * 100))],
GAS4: [...Array.from({ length: 7 }, () => Math.floor(Math.random() * 100))],
GAS5: [...Array.from({ length: 7 }, () => Math.floor(Math.random() * 100))],
GAS6: [...Array.from({ length: 7 }, () => Math.floor(Math.random() * 100))],
GAS7: [...Array.from({ length: 7 }, () => Math.floor(Math.random() * 100))],
GAS8: [...Array.from({ length: 7 }, () => Math.floor(Math.random() * 100))],
},
runtime: [
// 实时数据
...Array.from(
{ length: 8 },
() => Math.floor(Math.random() * 100) + "m³/h"
),
],
};
// export const stateNameMap = {
// lastFireChangeTime: "10分20秒",
// fireChangeTime: "10:23",
// fireDirection: "东火",
// };
const gasSlice = createSlice({
name: "wind",
initialState,
reducers: {
setHistory: (state, action) => {
state.history = action.payload;
},
setRuntime: (state, action) => {
state.runtime = action.payload;
},
},
});
export default gasSlice.reducer;
export const { setHistory, setRuntime } = gasSlice.actions;

View File

@@ -1,10 +1,14 @@
import { configureStore } from "@reduxjs/toolkit";
import kilnReducer from "./features/kilnSlice";
import fireReducer from "./features/fireSlice";
import fanFrequenceReducer from "./features/fanFrequenceSlice";
import gasReducer from "./features/gasSlice";
export const store = configureStore({
reducer: {
kiln: kilnReducer,
fireInfo: fireReducer,
fanFrequence: fanFrequenceReducer,
wind: gasReducer,
},
});