Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,13 @@ declare global {
}

import * as Cesium from 'cesium';
// 仅在需要时挂载到 window,避免全局污染
// 仅在需要时挂载到 window,避免全局污染;同时统一初始化 Cesium Ion token
if (typeof window !== 'undefined' && !window.Cesium) {
window.Cesium = Cesium;
}
if (typeof CESIUM_ION_TOKEN !== 'undefined' && CESIUM_ION_TOKEN) {
Cesium.Ion.defaultAccessToken = CESIUM_ION_TOKEN as string;
}

// NOTE:全局初始化数据配置,用于 Layout 用户信息和权限初始化
// 更多信息见文档:https://umijs.org/docs/api/runtime-config#getinitialstate
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
import { createBehavior } from '@pind/designable-core';
import { AllLocales } from '../../locales';
import { AllSchemas } from '../../schemas';
Expand Down
1 change: 1 addition & 0 deletions src/components/Designable/src/components/Field/preview.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
import { FormItem } from '@formily/antd-v5';
import { FormPath } from '@formily/core';
import { ArrayField, ISchema, Field as InternalField, ObjectField, Schema, VoidField, observer } from '@formily/react';
Expand Down
2 changes: 1 addition & 1 deletion src/components/Designable/widgets/LogoWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const logo = {
};

export const LogoWidget: React.FC = () => {
const url = logo[useTheme()];
const url = logo[(useTheme() ?? 'light') as keyof typeof logo];
return (
<div style={{ display: 'flex', alignItems: 'center', fontSize: 14 }}>
<img src={url} style={{ margin: '12px 8px', height: 18, width: 'auto' }} />
Expand Down
1 change: 1 addition & 0 deletions src/components/Designable/widgets/MarkupSchemaWidget.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
// 该文件不做 ESLint 检测
/* eslint-disable */
import { isEmpty, isPlainObj } from '@formily/shared';
Expand Down
12 changes: 9 additions & 3 deletions src/pages/Feature/AudioFeature/AudioPlayer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ import 'xgplayer-music/dist/index.min.css';
import 'xgplayer/dist/index.min.css';
import { AudioPlayerStyles } from './AudioPlayerStyle';

declare global {
interface Window {
analyze: InstanceType<typeof Analyze> | undefined;
}
}

export default function AudioPlayer() {
useMount(() => {
function initEvents() {
Expand Down Expand Up @@ -53,13 +59,13 @@ export default function AudioPlayer() {

// 初始化频谱
// eslint-disable-next-line @typescript-eslint/no-unused-vars
let analyze = new Analyze(player, document.querySelector('canvas'), {
let analyze = new Analyze(player, document.querySelector('canvas') as HTMLElement, {
bgColor: 'rgba(0,0,0,0.7)',
stroke: 3,
});

// 初始化歌词模块
let lyric = new Lyric([lyricTxts], document.querySelector('#gc'), {});
let lyric = new Lyric([lyricTxts], document.querySelector('#gc'));
lyric.bind(player);
// eslint-disable-next-line @typescript-eslint/no-unused-vars
let nullText = 0;
Expand All @@ -71,7 +77,7 @@ export default function AudioPlayer() {

player.on('playing', function () {
lyric.show();
player.mode = 2;
(player as any).mode = 2;
});
let canvasDom = document.getElementById('canvas') as HTMLCanvasElement;
canvasDom.width = window.innerWidth;
Expand Down
11 changes: 6 additions & 5 deletions src/pages/Feature/AudioFeature/AudioVisible/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import Timeline from 'wavesurfer.js/plugins/timeline';
import { AudioVisibleStyles } from './AudioVisible.style';

// WaveSurfer hook
const useWavesurfer = (containerRef, options) => {
const [wavesurfer, setWavesurfer] = useState(null);
const useWavesurfer = (containerRef: React.RefObject<HTMLDivElement>, options: any) => {
const [wavesurfer, setWavesurfer] = useState<WaveSurfer | null>(null);

// Initialize wavesurfer when the container mounts
// or any of the props change
Expand All @@ -25,21 +25,22 @@ const useWavesurfer = (containerRef, options) => {
return () => {
ws.destroy();
};
}, [options, containerRef]);
}, []); // eslint-disable-line react-hooks/exhaustive-deps

return wavesurfer;
};

// Create a React component that will render wavesurfer.
// Props are wavesurfer options.
const WaveSurferPlayer = (props: any) => {
const containerRef = useRef();
const containerRef = useRef<HTMLDivElement>(null);
const [isPlaying, setIsPlaying] = useState(false);
const [currentTime, setCurrentTime] = useState(0);
const wavesurfer = useWavesurfer(containerRef, props);

// On play button click
const onPlayClick = useCallback(() => {
if (!wavesurfer) return;
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
wavesurfer.isPlaying() ? wavesurfer.pause() : wavesurfer.play();
}, [wavesurfer]);
Expand All @@ -55,7 +56,7 @@ const WaveSurferPlayer = (props: any) => {
const subscriptions = [
wavesurfer.on('play', () => setIsPlaying(true)),
wavesurfer.on('pause', () => setIsPlaying(false)),
wavesurfer.on('timeupdate', (currentTime) => setCurrentTime(currentTime)),
wavesurfer.on('timeupdate', (currentTime: number) => setCurrentTime(currentTime)),
];

return () => {
Expand Down
1 change: 1 addition & 0 deletions src/pages/Feature/D3/DataDemo.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ProCard } from '@ant-design/pro-components';
import * as d3 from 'd3';
import { axisBottom, axisTop, pointer, select } from 'd3';
import { useEffect, useRef } from 'react';
import { data, frequencyTicks } from './components/DataUnit.ts';
Expand Down
5 changes: 3 additions & 2 deletions src/pages/Feature/D3/Frequency.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ProCard } from '@ant-design/pro-components';
import * as d3 from 'd3';
import { axisBottom, axisTop, pointer, select } from 'd3';
import { useEffect, useRef } from 'react';
import { data, frequencyTicks } from './components/DataUnit.ts';
Expand Down Expand Up @@ -62,7 +63,7 @@ const Frequency = () => {

// 设置尺寸和边距
const margin = { top: 50, right: 0, bottom: 50, left: 0 };
const width = Math.max(containerRef.current.clientWidth - margin.left - margin.right, 800);
const width = Math.max((containerRef.current?.clientWidth ?? 800) - margin.left - margin.right, 800);
// const typeHeight = 150;
// const height = data.length * typeHeight + margin.top + margin.bottom;

Expand Down Expand Up @@ -135,7 +136,7 @@ const Frequency = () => {

// 创建hover tooltip
const hoverTooltip = d3
.select(svgRef.current.parentNode)
.select(svgRef.current.parentNode as Element)
.append('div')
.attr('class', 'hover-tooltip')
.style('position', 'absolute')
Expand Down
6 changes: 4 additions & 2 deletions src/pages/Feature/Map/AutonaviMap/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { useState } from 'react';
import { AutonaviMapStyle } from './AutonaviMapStyle';

export default function AutonaviMap() {
const [position, setPosition] = useState<ReactAMap.Position>();
const [position, setPosition] = useState<[number, number] | undefined>();

const mapEvents: MapProps['events'] = {
click: (event: any) => {
Expand All @@ -27,7 +27,9 @@ export default function AutonaviMap() {
<AutonaviMapStyle>
<ProCard>
<div style={{ height: 500 }}>
<Map events={mapEvents}>{position && <Marker position={position} />}</Map>
<Map WebGLParams={{}} events={mapEvents}>
{position && <Marker position={position} />}
</Map>
</div>
</ProCard>
</AutonaviMapStyle>
Expand Down
3 changes: 1 addition & 2 deletions src/pages/Feature/Map/Cesium/DirectionDistance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import 'cesium/Build/Cesium/Widgets/widgets.css';
import React, { useEffect, useState } from 'react';

const DirectionDistance: React.FC = () => {
Cesium.Ion.defaultAccessToken = CESIUM_ION_TOKEN as string;
const [viewer, setViewer] = useState(null as any);

useEffect(() => {
Expand Down Expand Up @@ -55,7 +54,7 @@ const DirectionDistance: React.FC = () => {

// 销毁
return () => {
viewer.destroy();
if (!viewer.isDestroyed()) viewer.destroy();
};
}, []);

Expand Down
10 changes: 5 additions & 5 deletions src/pages/Feature/Map/Cesium/GeoHash.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ const InfoGeoHash: React.FC = () => {
const [viewer, setViewer] = useState<Cesium.Viewer | null>(null);
const [messageApi, contextHolder] = message.useMessage();

Cesium.Ion.defaultAccessToken = CESIUM_ION_TOKEN as string;

useEffect(() => {
// 创建一个 Cesium Viewer 实例
const viewer = new Cesium.Viewer('cesiumContainer', {
Expand Down Expand Up @@ -69,7 +67,7 @@ const InfoGeoHash: React.FC = () => {

// 销毁
return () => {
viewer.destroy();
if (!viewer.isDestroyed()) viewer.destroy();
};
}, []);

Expand Down Expand Up @@ -140,6 +138,7 @@ const InfoGeoHash: React.FC = () => {
//获取四角经纬度
// 获取当前视图范围
let extent = viewer.camera.computeViewRectangle();
if (!extent) return;

// 提取四个角的经纬度
let southwest = Cesium.Rectangle.southwest(extent);
Expand Down Expand Up @@ -185,6 +184,7 @@ const InfoGeoHash: React.FC = () => {

// 获取当前地图的显示范围
function getMapViewRectangle() {
if (viewer === null) return null;
const rectangle = viewer.camera.computeViewRectangle();
if (rectangle) {
return {
Expand Down Expand Up @@ -223,7 +223,7 @@ const InfoGeoHash: React.FC = () => {
});

// 在 Cesium 中绘制子区域
viewer.entities.add({
viewer?.entities.add({
rectangle: {
coordinates: Cesium.Rectangle.fromDegrees(subWest, subSouth, subEast, subNorth),
material: Cesium.Color.RED.withAlpha(0.3),
Expand All @@ -249,7 +249,7 @@ const InfoGeoHash: React.FC = () => {

// NOTE 清除所有实体
const handleRemoveAll = () => {
viewer.entities.removeAll();
viewer?.entities.removeAll();
};

return (
Expand Down
3 changes: 1 addition & 2 deletions src/pages/Feature/Map/Cesium/HaiAirPosture.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ const HaiAirPosture = () => {
const [messageApi, contextHolder] = message.useMessage();
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const [data, setData] = useState([]);
Cesium.Ion.defaultAccessToken = CESIUM_ION_TOKEN as string;
// setTimeout(() => {
// let CesiumNavigation = window.CesiumNavigation;
// console.log('CesiumNavigation:', window);
Expand Down Expand Up @@ -153,7 +152,7 @@ const HaiAirPosture = () => {

// 销毁
return () => {
viewer.destroy();
if (!viewer.isDestroyed()) viewer.destroy();
};
}, []);

Expand Down
32 changes: 22 additions & 10 deletions src/pages/Feature/Map/Cesium/ThermalMap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,23 @@ import { ProCard } from '@ant-design/pro-components';
import { Alert, Button, Modal, Spin, message } from 'antd';
import * as Cesium from 'cesium';
import 'cesium/Build/Cesium/Widgets/widgets.css';
import { useEffect, useState } from 'react';
import { useEffect, useRef, useState } from 'react';

const ThermalMap = () => {
const [viewer, setViewer] = useState(null as any);
const infoDivRef = useRef<HTMLDivElement | null>(null);
const [messageApi, contextHolder] = message.useMessage();
const [data, setData] = useState([] as any);
const [thermalData, setThermalData] = useState(null as any); // 保存完整的热力图数据
const [loading, setLoading] = useState(true);
Cesium.Ion.defaultAccessToken = CESIUM_ION_TOKEN as string;

// 动态加载热力图数据
useEffect(() => {
const loadThermalData = async () => {
try {
const thermal = await import('@/utils/MapCompute/ThermalMapData.json');
const obj = structuredClone(thermal.default);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const obj: any = structuredClone(thermal.default);
const arrayResult = obj.coverageData.arrayResult;
setData(arrayResult);
setThermalData(obj); // 保存完整数据供其他功能使用
Expand Down Expand Up @@ -100,6 +101,10 @@ const ThermalMap = () => {
if (newViewer && !newViewer.isDestroyed()) {
newViewer.destroy();
}
if (infoDivRef.current) {
document.body.removeChild(infoDivRef.current);
infoDivRef.current = null;
}
};
}, [loading, messageApi]);

Expand Down Expand Up @@ -363,12 +368,16 @@ const ThermalMap = () => {
fieldStrength: point.fieldStrength,
};
});
let infoDiv = document.createElement('div');
document.body.appendChild(infoDiv);
infoDiv.style.position = 'absolute';
infoDiv.style.background = 'white';
infoDiv.style.padding = '5px';
infoDiv.style.display = 'none';
if (!infoDivRef.current) {
const infoDiv = document.createElement('div');
infoDiv.style.position = 'absolute';
infoDiv.style.background = 'white';
infoDiv.style.padding = '5px';
infoDiv.style.display = 'none';
document.body.appendChild(infoDiv);
infoDivRef.current = infoDiv;
}
const infoDiv = infoDivRef.current;

// 鼠标放到点上时根据点的名称显示信息
viewer.screenSpaceEventHandler.setInputAction(function onMouseMove(movement: any) {
Expand Down Expand Up @@ -468,7 +477,10 @@ const ThermalMap = () => {
<Modal
title=""
open={isModalOpen}
style={{ top: positionInfo.y + 100, left: positionInfo.x - 300 }}
style={{
top: Math.min((positionInfo.y ?? 0) + 100, window.innerHeight - 200),
left: Math.max(Math.min((positionInfo.x ?? 0) - 300, window.innerWidth - 320), 8),
}}
onCancel={() => setIsModalOpen(false)}
footer={null}
width={300}
Expand Down
3 changes: 1 addition & 2 deletions src/pages/Feature/Map/Cesium/Trajectory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import React, { useEffect, useState } from 'react';

const Trajectory: React.FC = () => {
const [messageApi, contextHolder] = message.useMessage();
Cesium.Ion.defaultAccessToken = CESIUM_ION_TOKEN as string;
const [viewer, setViewer] = useState(null as any);
// let turf = window.turf;
// console.log(turf);
Expand Down Expand Up @@ -59,7 +58,7 @@ const Trajectory: React.FC = () => {

// 销毁
return () => {
viewer.destroy();
if (!viewer.isDestroyed()) viewer.destroy();
};
}, []);

Expand Down
Loading