From a884b28fef7352b5f5c100588a59afa62917d205 Mon Sep 17 00:00:00 2001 From: wyc <1104749580@qq.com> Date: Thu, 6 Aug 2026 12:30:14 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.tsx | 83 +++++++++++++++++++++++++++-------------------------- 1 file changed, 43 insertions(+), 40 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index f20d6c2..d61c64f 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,28 +1,29 @@ -import { Settings } from "./Setting.tsx"; // 保留导入,不修改 -import { Leaflet_Map } from "./Map/Leaflet_Map.tsx" -import { Aircraft_List } from "./Map/Aircraft_List.tsx"; +import {Settings} from "./Setting.tsx"; // 保留导入,不修改 +import {Leaflet_Map} from "./Map/Leaflet_Map.tsx" +import {Aircraft_List} from "./Map/Aircraft_List.tsx"; import enhance from './core/enhance.tsx'; -import { useEffect, useState } from 'react'; +import {useEffect, useState} from 'react'; // @ts-ignore -import { AppstoreOutlined, MailOutlined, SettingOutlined } from '@ant-design/icons'; -import { Flex, Menu, MenuProps, Switch, message } from 'antd'; +import {AppstoreOutlined, MailOutlined, SettingOutlined} from '@ant-design/icons'; +import {Flex, Menu, MenuProps, Switch, message} from 'antd'; -import { Routes, Route, Link, useNavigate, NavigateFunction, useLocation } from 'react-router-dom'; +import {Routes, Route, Link, useNavigate, NavigateFunction, useLocation} from 'react-router-dom'; import React from 'react'; -import ReactDOM, { Root } from 'react-dom/client'; +import ReactDOM, {Root} from 'react-dom/client'; -import { BrowserRouter } from 'react-router-dom'; +import {BrowserRouter} from 'react-router-dom'; import FileList from "./FileList.tsx"; -import { DSP } from "./DSP/DSP.tsx"; -import { Navigate, Router } from "react-router"; +import {DSP} from "./DSP/DSP.tsx"; +import {Navigate, Router} from "react-router"; import axios from "axios"; -import { baseURL } from "./Global.tsx"; +import {baseURL} from "./Global.tsx"; import {is_cesium_webgl_available, webgl_unavailable_message} from "./Map/WebGL_Support.ts"; import L from 'leaflet'; + const Cesium_Map_View = React.lazy(() => import("./Map/Cesium_Map.tsx")); delete (L.Icon.Default.prototype as any)._getIconUrl; @@ -61,23 +62,23 @@ class App extends enhance.Base { this.menuItems = [ { label: '2D地图', - icon: , + icon: , key: '/map', }, { label: this.webgl_supported ? '3D地图' : '3D地图(WebGL不可用)', - icon: , + icon: , key: '/map3d', disabled: !this.webgl_supported, }, { label: '设置', - icon: , + icon: , key: '/settings', }, { label: '飞机列表', - icon: , + icon: , key: '/aircraftlist', }, // { @@ -105,13 +106,13 @@ class App extends enhance.Base { this.leaflet_map = new Leaflet_Map(); this.aircraft_list = new Aircraft_List(); this.dsp = new DSP(); - + // 延迟初始化Settings,避免“初始化前访问”错误 setTimeout(() => { - this.setting = new Settings(); - this.flush(); + this.setting = new Settings(); + this.flush(); }, 0); - }; + }; use_hook() { this.navigate = useNavigate(); @@ -174,7 +175,7 @@ class App extends enhance.Base { render(props: any) { // ************************ 优化:渲染前校验子组件是否初始化完成,避免报错 ************************ if (!this.leaflet_map || !this.setting || !this.aircraft_list || !this.dsp) { - return
组件初始化中...
; + return
组件初始化中...
; } return ( @@ -216,56 +217,56 @@ class App extends enhance.Base { fontWeight: 'bold', padding: '0 20px 0 8px' }}> - {`开机时间:${this.formatTimestamp(this.start_device_time)} 版本:${this.version}`} + {`服务开启时间:${this.formatTimestamp(this.start_device_time)} 版本:${this.version}`} - +
+
)} /> - +
+
)} /> + )} /> + )} /> + this.webgl_supported ?
3D地图加载中...
}> - + - : + : )} /> + this.webgl_supported ?
3D地图加载中...
}> - + - : + : )} /> - + )} /> @@ -290,7 +291,7 @@ class App extends enhance.Base { {/* */} {/* )}*/} {/*/>*/} - } /> + }/>
@@ -302,8 +303,10 @@ class App extends enhance.Base { export let app = new App(); const container = document.getElementById('root'); if (container) { - // 清空容器现有内容(避免热更新重复绑定) - container.innerHTML = ''; - const root = ReactDOM.createRoot(container); - root.render(); + // 清空容器现有内容(避免热更新重复绑定) + container.innerHTML = ''; + const root = ReactDOM.createRoot(container); + root.render( + + ); }