删除多余的依赖变量

This commit is contained in:
JIANG
2025-11-24 15:23:19 +08:00
parent b4aef962dd
commit 543725ee1f
2 changed files with 18 additions and 27 deletions

View File

@@ -47,8 +47,8 @@ interface DataContextType {
setCurrentPipeCalData?: React.Dispatch<React.SetStateAction<any[]>>;
showJunctionText?: boolean; // 是否显示节点文本
showPipeText?: boolean; // 是否显示管道文本
setShowJunctionText?: React.Dispatch<React.SetStateAction<boolean>>;
setShowPipeText?: React.Dispatch<React.SetStateAction<boolean>>;
setShowJunctionTextLayer?: React.Dispatch<React.SetStateAction<boolean>>;
setShowPipeTextLayer?: React.Dispatch<React.SetStateAction<boolean>>;
setShowContourLayer?: React.Dispatch<React.SetStateAction<boolean>>;
junctionText: string;
pipeText: string;
@@ -108,11 +108,9 @@ const MapComponent: React.FC<MapComponentProps> = ({ children }) => {
const tileJunctionDataBuffer = useRef<any[]>([]);
const tilePipeDataBuffer = useRef<any[]>([]);
const [showJunctionText, setShowJunctionText] = useState(false); // 控制节点文本显示
const [showPipeText, setShowPipeText] = useState(false); // 控制管道文本显示
const [showJunctionTextLayer, setShowJunctionTextLayer] = useState(true); // 控制节点文本图层显示
const [showPipeTextLayer, setShowPipeTextLayer] = useState(true); // 控制管道文本图层显示
const [showContourLayer, setShowContourLayer] = useState(true); // 控制等高线图层显示
const [showJunctionTextLayer, setShowJunctionTextLayer] = useState(false); // 控制节点文本图层显示
const [showPipeTextLayer, setShowPipeTextLayer] = useState(false); // 控制管道文本图层显示
const [showContourLayer, setShowContourLayer] = useState(false); // 控制等高线图层显示
const [junctionText, setJunctionText] = useState("pressure");
const [pipeText, setPipeText] = useState("flow");
const flowAnimation = useRef(false); // 添加动画控制标志
@@ -675,12 +673,10 @@ const MapComponent: React.FC<MapComponentProps> = ({ children }) => {
if (!deckLayer) return; // 如果 deck 实例还未创建,则退出
if (!junctionData.length) return;
if (!pipeData.length) return;
console.log(pipeData);
console.log(pipeText);
const junctionTextLayer = new TextLayer({
id: "junctionTextLayer",
zIndex: 10,
data: showJunctionText ? junctionData : [],
data: junctionData,
getPosition: (d: any) => d.position,
fontFamily: "Monaco, monospace",
getText: (d: any) =>
@@ -710,7 +706,7 @@ const MapComponent: React.FC<MapComponentProps> = ({ children }) => {
const pipeTextLayer = new TextLayer({
id: "pipeTextLayer",
zIndex: 10,
data: showPipeText ? pipeData : [],
data: pipeData,
getPosition: (d: any) => d.position,
fontFamily: "Monaco, monospace",
getText: (d: any) =>
@@ -753,8 +749,6 @@ const MapComponent: React.FC<MapComponentProps> = ({ children }) => {
junctionData,
pipeData,
currentZoom,
showJunctionText,
showPipeText,
showJunctionTextLayer,
showPipeTextLayer,
showContourLayer,
@@ -775,7 +769,7 @@ const MapComponent: React.FC<MapComponentProps> = ({ children }) => {
// 动画循环
const animate = () => {
if (!deckRef.current || !flowAnimation.current) return; // 添加检查,防止空数据或停止旧循环
if (!flowAnimation.current) return; // 添加检查,防止空数据或停止旧循环
// 动画总时长(秒)
if (pipeData.length === 0) {
animationFrameId = requestAnimationFrame(animate);
@@ -887,13 +881,11 @@ const MapComponent: React.FC<MapComponentProps> = ({ children }) => {
setCurrentJunctionCalData,
currentPipeCalData,
setCurrentPipeCalData,
setShowJunctionText,
setShowPipeText,
setShowJunctionTextLayer,
setShowPipeTextLayer,
setShowContourLayer,
setJunctionText,
setPipeText,
showJunctionText,
showPipeText,
junctionText,
pipeText,
}}