From 6be9ef45e0766092c36594faa9a53e13887c9682 Mon Sep 17 00:00:00 2001 From: zhangjiming Date: Tue, 8 Apr 2025 14:17:39 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E9=87=8F=E8=AE=B0=E5=BD=95=E5=9D=90?= =?UTF-8?q?=E6=A0=87=E5=88=86=E4=B8=BA=E5=B7=A6=E5=8F=B3=E4=B8=A4=E7=BB=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env | 2 +- .env.production | 1 + src/App.tsx | 7 +++++-- src/pages/MeasureRecord.tsx | 9 +++++---- src/services/apiTypes.ts | 4 ++-- 5 files changed, 14 insertions(+), 9 deletions(-) create mode 100644 .env.production 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'; };