diff --git a/.env b/.env index 371506d..7dcfd84 100644 --- a/.env +++ b/.env @@ -1 +1 @@ -REACT_APP_WS_URL=localhost:8080/ws +REACT_APP_WS_URL=192.168.1.100:8080/ws diff --git a/.env.production b/.env.production new file mode 100644 index 0000000..de133cd --- /dev/null +++ b/.env.production @@ -0,0 +1 @@ +REACT_APP_WS_URL=127.0.0.1:8080/ws diff --git a/src/App.tsx b/src/App.tsx index 88309a9..75098a8 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -11,7 +11,7 @@ import icon_3_u from './assets/tabIcon/icon_tab3_u.svg'; import icon_4_s from './assets/tabIcon/icon_tab4_s.svg'; import icon_4_u from './assets/tabIcon/icon_tab4_u.svg'; import { appWebview, bridgeOb, emitBridgeEvent, registerBridgeFunc } from './utils/bridge'; -import { useAppDispatch } from './utils/hooks'; +import { useAppDispatch, useAppSelector } from './utils/hooks'; import { addNewPoint, updateTaskState } from './store/features/measureSlice'; import { updateBleList, updateDevice, updateSyncProgress } from './store/features/contextSlice'; import { createWebSocket, sharedWsUrl } from './services/socket'; @@ -69,7 +69,10 @@ const BottomBar = () => { function App() { const dispatch = useAppDispatch(); - dispatch(fetchRailTypes()); + const baseState = useAppSelector((state) => state.baseData); + if (baseState.railTypes.length === 0) { + dispatch(fetchRailTypes()); + } useEffect(() => { const subscription = bridgeOb.subscribe((datagram) => { diff --git a/src/pages/MeasureRecord.tsx b/src/pages/MeasureRecord.tsx index 214f03c..6684ff1 100644 --- a/src/pages/MeasureRecord.tsx +++ b/src/pages/MeasureRecord.tsx @@ -38,9 +38,10 @@ export default function MeasureRecord() { } } - function drawMeasurePoints(points: string) { + function drawMeasurePoints(leftPoints: string, rightPoints: string) { if (canvasRef.current) { - canvasRef.current.setMeasurementData(JSON.parse(points)) + canvasRef.current.setMeasurementDataLeft(JSON.parse(leftPoints)); + canvasRef.current.setMeasurementDataRight(JSON.parse(rightPoints)); } } @@ -50,14 +51,14 @@ export default function MeasureRecord() { if (!r) return; if (!!r.points) { drawRailBaseLine(r.points); - drawMeasurePoints(measure.points); + drawMeasurePoints(measure.leftPoints, measure.rightPoints); return; } Bridge.getTrackPoint({ code: r.code }).then((res) => { if (res.success) { dispatch(updateRailPoints(res.data)); drawRailBaseLine(res.data.points!); - drawMeasurePoints(measure.points); + drawMeasurePoints(measure.leftPoints, measure.rightPoints); } else { Toast.show(res.message); } diff --git a/src/services/apiTypes.ts b/src/services/apiTypes.ts index 6259f69..c9629fb 100644 --- a/src/services/apiTypes.ts +++ b/src/services/apiTypes.ts @@ -8,8 +8,8 @@ export type Measurement = { location: string; direction: string; createTime: string; // Date; - points: string; // json: 坐标数组 - // rightPoints: string; // json: 坐标数组 + leftPoints: string; // json: 坐标数组 + rightPoints: string; // json: 坐标数组 upload: boolean; syncStatus: 'wait' | 'finish' | 'fail'; };