From bdd3352646368fde469f131143622eafd03e8edf Mon Sep 17 00:00:00 2001 From: zhangjiming Date: Wed, 9 Apr 2025 20:46:13 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=96=E5=B1=82=E5=A5=97=E4=B8=80=E5=B1=82Ap?= =?UTF-8?q?pTab?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.tsx | 104 +++++++++++++++----------------------------------- src/AppTab.tsx | 77 +++++++++++++++++++++++++++++++++++++ src/index.tsx | 7 ++-- src/pages/Measure.tsx | 13 ------- src/setupProxy.js | 8 ++++ 5 files changed, 120 insertions(+), 89 deletions(-) create mode 100644 src/AppTab.tsx diff --git a/src/App.tsx b/src/App.tsx index 69d2805..8066faf 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,81 +1,35 @@ import React, { useEffect } from 'react'; -import { Outlet, useLocation, useNavigate } from 'react-router'; -import { SafeArea, TabBar, Toast } from 'antd-mobile'; +import { Outlet } from 'react-router'; +import { Toast } from 'antd-mobile'; -import icon_1_s from './assets/tabIcon/icon_tab1_s.svg'; -import icon_1_u from './assets/tabIcon/icon_tab1_u.svg'; -// import icon_2_s from './assets/tabIcon/icon_tab2_s.svg'; -// import icon_2_u from './assets/tabIcon/icon_tab2_u.svg'; -import icon_3_s from './assets/tabIcon/icon_tab3_s.svg'; -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 Bridge, { bridgeOb, emitBridgeEvent } from './utils/bridge'; import { useAppDispatch, useAppSelector } from './utils/hooks'; import { addNewPoint, updateTaskState } from './store/features/measureSlice'; -import { updateBleList, updateDevice, updateSyncProgress } from './store/features/contextSlice'; +import { + refreshStationList, + updateBleList, + updateDevice, + updateSyncProgress, +} from './store/features/contextSlice'; import { createWebSocket, sharedWsUrl } from './services/socket'; -import { fetchOrgTree, fetchRailTypes, syncBaseData, updateSyncBaseProgress } from './store/features/baseData'; - -const BottomBar = () => { - const navigate = useNavigate(); - const location = useLocation(); - const { pathname } = location; - const setRouteActive = (value: string) => { - navigate(value, { replace: true }); - }; - - const tabs = [ - { - key: '/home/measure', - title: '测量', - icon_s: icon_1_s, - icon_n: icon_1_u, - }, - // { - // key: '/home/setting', - // title: '设置', - // icon_s: icon_2_s, - // icon_n: icon_2_u, - // }, - { - key: '/home/bluetooth', - title: '蓝牙', - icon_s: icon_3_s, - icon_n: icon_3_u, - }, - { - key: '/home/mine', - title: '我的', - icon_s: icon_4_s, - icon_n: icon_4_u, - }, - ]; - - return ( - setRouteActive(value)}> - {tabs.map((item) => ( - - active ? icon : icon - } - title={item.title} - /> - ))} - - ); -}; +import { + fetchOrgTree, + fetchRailTypes, + syncBaseData, + updateSyncBaseProgress, +} from './store/features/baseData'; function App() { const dispatch = useAppDispatch(); const baseState = useAppSelector((state) => state.baseData); + const contextState = useAppSelector((state) => state.context); + // 获取轨型数据 useEffect(() => { if (baseState.railTypes.length === 0) { dispatch(fetchRailTypes()); } - },[baseState.railTypes.length, dispatch]) + }, [baseState.railTypes.length, dispatch]); // 监听推送消息,更新store useEffect(() => { @@ -134,18 +88,22 @@ function App() { }); }, [dispatch]); + // 预获取车站信息 + useEffect(() => { + if (contextState.currXMCode) { + dispatch( + refreshStationList({ + tljCode: contextState.currOrgCode, + gwdCode: contextState.currGWDCode, + xmCode: contextState.currXMCode, + }) + ); + } + }, [contextState.currGWDCode, contextState.currOrgCode, contextState.currXMCode, dispatch]); + return ( <> -
- -
- -
-
- -
- -
+ {/*
diff --git a/src/AppTab.tsx b/src/AppTab.tsx new file mode 100644 index 0000000..89be274 --- /dev/null +++ b/src/AppTab.tsx @@ -0,0 +1,77 @@ +import React from 'react'; +import { Outlet, useLocation, useNavigate } from 'react-router'; +import { SafeArea, TabBar } from 'antd-mobile'; + +import icon_1_s from './assets/tabIcon/icon_tab1_s.svg'; +import icon_1_u from './assets/tabIcon/icon_tab1_u.svg'; +// import icon_2_s from './assets/tabIcon/icon_tab2_s.svg'; +// import icon_2_u from './assets/tabIcon/icon_tab2_u.svg'; +import icon_3_s from './assets/tabIcon/icon_tab3_s.svg'; +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'; + +const BottomBar = () => { + const navigate = useNavigate(); + const location = useLocation(); + const { pathname } = location; + const setRouteActive = (value: string) => { + navigate(value, { replace: true }); + }; + + const tabs = [ + { + key: '/home/measure', + title: '测量', + icon_s: icon_1_s, + icon_n: icon_1_u, + }, + // { + // key: '/home/setting', + // title: '设置', + // icon_s: icon_2_s, + // icon_n: icon_2_u, + // }, + { + key: '/home/bluetooth', + title: '蓝牙', + icon_s: icon_3_s, + icon_n: icon_3_u, + }, + { + key: '/home/mine', + title: '我的', + icon_s: icon_4_s, + icon_n: icon_4_u, + }, + ]; + + return ( + setRouteActive(value)}> + {tabs.map((item) => ( + + active ? icon : icon + } + title={item.title} + /> + ))} + + ); +}; + +export default function AppTab() { + return ( +
+ +
+ +
+
+ +
+ +
+ ); +} diff --git a/src/index.tsx b/src/index.tsx index 33a82f3..2de43c3 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -2,6 +2,7 @@ import React from 'react'; import ReactDOM from 'react-dom/client'; import './index.css'; import App from './App'; +import AppTab from './AppTab'; import reportWebVitals from './reportWebVitals'; import { createHashRouter, @@ -16,7 +17,7 @@ import store from './store/index'; import Measure from './pages/Measure'; import Setting from './pages/Setting'; import Bluetooth from './pages/Bluetooth'; -import Mine from './pages/Mine'; +// import Mine from './pages/Mine'; import Mine2 from './pages/Mine2'; import MeasureSave from './pages/MeasureSave'; import MeasureRecord from './pages/MeasureRecord'; @@ -26,9 +27,9 @@ import UploadList from './pages/UploadList'; const router = createHashRouter( createRoutesFromElements( - + }> } /> - }> + }> }> {/* }> */} }> diff --git a/src/pages/Measure.tsx b/src/pages/Measure.tsx index 6e5069c..a8cf7f3 100644 --- a/src/pages/Measure.tsx +++ b/src/pages/Measure.tsx @@ -37,19 +37,6 @@ export default function Measure() { } }, [baseState.railTypes]); - // 预获取车站信息 - useEffect(() => { - if (contextState.currXMCode) { - dispatch( - refreshStationList({ - tljCode: contextState.currOrgCode, - gwdCode: contextState.currGWDCode, - xmCode: contextState.currXMCode, - }) - ); - } - },[contextState.currGWDCode, contextState.currOrgCode, contextState.currXMCode, dispatch]); - function drawRailBaseLine(points: string) { const benchmarkShapes = JSON.parse(points) as BenchmarkShape[]; if (canvasRef.current) { diff --git a/src/setupProxy.js b/src/setupProxy.js index 0cf504e..d27b47b 100644 --- a/src/setupProxy.js +++ b/src/setupProxy.js @@ -8,6 +8,14 @@ module.exports = function (app) { // changeOrigin: true, // }) // ); + // app.use( + // '/api/basic', + // createProxyMiddleware({ + // target: 'http://localhost:8080/api/basic', + // changeOrigin: true, + // pathFilter: ['/ktj', '/org', '/station'], + // }) + // ); app.use( '/api', createProxyMiddleware({