删除多余的依赖变量

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

@@ -188,8 +188,8 @@ const StyleEditorPanel: React.FC<StyleEditorPanelProps> = ({
currentPipeCalData,
junctionText,
pipeText,
setShowJunctionText,
setShowPipeText,
setShowJunctionTextLayer,
setShowPipeTextLayer,
setShowContourLayer,
setJunctionText,
setPipeText,
@@ -354,9 +354,9 @@ const StyleEditorPanel: React.FC<StyleEditorPanelProps> = ({
}
// 更新文字标签设置
if (layerId === "junctions") {
if (setJunctionText && setShowJunctionText) {
if (setJunctionText && setShowJunctionTextLayer) {
setJunctionText(property);
setShowJunctionText(styleConfig.showLabels);
setShowJunctionTextLayer(styleConfig.showLabels);
setApplyJunctionStyle(true);
saveLayerStyle(layerId);
open?.({
@@ -366,9 +366,9 @@ const StyleEditorPanel: React.FC<StyleEditorPanelProps> = ({
}
}
if (layerId === "pipes") {
if (setPipeText && setShowPipeText) {
if (setPipeText && setShowPipeTextLayer) {
setPipeText(property);
setShowPipeText(styleConfig.showLabels);
setShowPipeTextLayer(styleConfig.showLabels);
setApplyPipeStyle(true);
saveLayerStyle(layerId);
open?.({
@@ -414,7 +414,6 @@ const StyleEditorPanel: React.FC<StyleEditorPanelProps> = ({
// 如果不足则补齐最后一个值
while (breaks.length < desired)
breaks.push(breaks[breaks.length - 1] ?? 0);
console.log(breaks);
} else {
const calc = calculateClassification(
currentJunctionCalData.map((d) => d.value),
@@ -676,11 +675,11 @@ const StyleEditorPanel: React.FC<StyleEditorPanelProps> = ({
// 重置样式应用状态
if (layerId === "junctions") {
setApplyJunctionStyle(false);
if (setShowJunctionText) setShowJunctionText(false);
if (setShowJunctionTextLayer) setShowJunctionTextLayer(false);
if (setJunctionText) setJunctionText("");
} else if (layerId === "pipes") {
setApplyPipeStyle(false);
if (setShowPipeText) setShowPipeText(false);
if (setShowPipeTextLayer) setShowPipeTextLayer(false);
if (setPipeText) setPipeText("");
}
}

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,
}}