Browse Source

测量记录坐标分为左右两组

master
zhangjiming 4 months ago
parent
commit
6be9ef45e0
  1. 2
      .env
  2. 1
      .env.production
  3. 7
      src/App.tsx
  4. 9
      src/pages/MeasureRecord.tsx
  5. 4
      src/services/apiTypes.ts

2
.env

@ -1 +1 @@
REACT_APP_WS_URL=localhost:8080/ws
REACT_APP_WS_URL=192.168.1.100:8080/ws

1
.env.production

@ -0,0 +1 @@
REACT_APP_WS_URL=127.0.0.1:8080/ws

7
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) => {

9
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);
}

4
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';
};

Loading…
Cancel
Save