// 天然气流量 import { createSlice } from "@reduxjs/toolkit"; export const initialState = { history: { gasIHistory: { // 历史数据 // GAS1: [...Array.from({ length: 7 }, () => Math.floor(Math.random() * 100))], GAS1: [...Array.from({ length: 7 }, () => 0)], GAS2: [...Array.from({ length: 7 }, () => 0)], GAS3: [...Array.from({ length: 7 }, () => 0)], GAS4: [...Array.from({ length: 7 }, () => 0)], GAS5: [...Array.from({ length: 7 }, () => 0)], GAS6: [...Array.from({ length: 7 }, () => 0)], GAS7: [...Array.from({ length: 7 }, () => 0)], GAS8: [...Array.from({ length: 7 }, () => 0)], }, gasIIHistory: { GAS1: [...Array.from({ length: 7 }, () => 0)], GAS2: [...Array.from({ length: 7 }, () => 0)], GAS3: [...Array.from({ length: 7 }, () => 0)], GAS4: [...Array.from({ length: 7 }, () => 0)], }, }, runtime: { gasIRuntime: [ // 实时数据 ...Array.from( { length: 8 }, // () => Math.floor(Math.random() * 100) + "m³/h" () => "0m³/h" ), ], gasIIRuntime: [ // 实时数据 ...Array.from({ length: 8 }, () => "0m³/h"), ], }, }; const gasSlice = createSlice({ name: "natGas", initialState, reducers: { setGasIHistory: (state, action) => { state.history.gasIHistory = action.payload; }, setGasIIHistory: (state, action) => { state.history.gasIIHistory = action.payload; }, setGasIRuntime: (state, action) => { state.runtime.gasIRuntime = action.payload; }, setGasIIRuntime: (state, action) => { state.runtime.gasIIRuntime = action.payload; }, }, }); export default gasSlice.reducer; export const { setHistory, setRuntime } = gasSlice.actions;