7 changed files with 158 additions and 84 deletions
-
12src/App.tsx
-
49src/components/CustomNavBar.tsx
-
44src/pages/Measure.tsx
-
35src/store/features/contextSlice.ts
-
2src/store/features/measureSlice.ts
-
4src/store/index.ts
@ -0,0 +1,35 @@ |
|||
import { createSlice, PayloadAction } from '@reduxjs/toolkit'; |
|||
import { DeviceStatus } from '../../services/wsTypes'; |
|||
|
|||
interface ContextState { |
|||
device: DeviceStatus['data']; |
|||
currRailTypeId: number; |
|||
} |
|||
|
|||
const initialState: ContextState = { |
|||
device: { |
|||
isConnected: true, //是否链接
|
|||
power: 60, //电量
|
|||
inclinatorX: 0.276, //x轴倾斜
|
|||
inclinatorY: 3.019, //y轴倾斜
|
|||
temperature: 32.026, //温度
|
|||
}, |
|||
// 当前选择的轨型
|
|||
currRailTypeId: 1, |
|||
}; |
|||
|
|||
export const contextSlice = createSlice({ |
|||
name: 'context', |
|||
initialState, |
|||
reducers: { |
|||
updateDevice: (state, action: PayloadAction<DeviceStatus['data']>) => { |
|||
state.device = action.payload; |
|||
}, |
|||
updateRailTypeId: (state, action: PayloadAction<number>) => { |
|||
state.currRailTypeId = action.payload; |
|||
}, |
|||
}, |
|||
}); |
|||
|
|||
export const { updateDevice, updateRailTypeId } = contextSlice.actions; |
|||
export default contextSlice.reducer; |
@ -1,5 +1,5 @@ |
|||
import { createSlice, PayloadAction } from '@reduxjs/toolkit'; |
|||
import { TaskState, TrackRecordSig } from '../services/wsTypes'; |
|||
import { TaskState, TrackRecordSig } from '../../services/wsTypes'; |
|||
|
|||
export interface MeasureState { |
|||
taskState?: TaskState['data']; |
Write
Preview
Loading…
Cancel
Save
Reference in new issue