删除多余的依赖变量
This commit is contained in:
@@ -188,8 +188,8 @@ const StyleEditorPanel: React.FC<StyleEditorPanelProps> = ({
|
|||||||
currentPipeCalData,
|
currentPipeCalData,
|
||||||
junctionText,
|
junctionText,
|
||||||
pipeText,
|
pipeText,
|
||||||
setShowJunctionText,
|
setShowJunctionTextLayer,
|
||||||
setShowPipeText,
|
setShowPipeTextLayer,
|
||||||
setShowContourLayer,
|
setShowContourLayer,
|
||||||
setJunctionText,
|
setJunctionText,
|
||||||
setPipeText,
|
setPipeText,
|
||||||
@@ -354,9 +354,9 @@ const StyleEditorPanel: React.FC<StyleEditorPanelProps> = ({
|
|||||||
}
|
}
|
||||||
// 更新文字标签设置
|
// 更新文字标签设置
|
||||||
if (layerId === "junctions") {
|
if (layerId === "junctions") {
|
||||||
if (setJunctionText && setShowJunctionText) {
|
if (setJunctionText && setShowJunctionTextLayer) {
|
||||||
setJunctionText(property);
|
setJunctionText(property);
|
||||||
setShowJunctionText(styleConfig.showLabels);
|
setShowJunctionTextLayer(styleConfig.showLabels);
|
||||||
setApplyJunctionStyle(true);
|
setApplyJunctionStyle(true);
|
||||||
saveLayerStyle(layerId);
|
saveLayerStyle(layerId);
|
||||||
open?.({
|
open?.({
|
||||||
@@ -366,9 +366,9 @@ const StyleEditorPanel: React.FC<StyleEditorPanelProps> = ({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (layerId === "pipes") {
|
if (layerId === "pipes") {
|
||||||
if (setPipeText && setShowPipeText) {
|
if (setPipeText && setShowPipeTextLayer) {
|
||||||
setPipeText(property);
|
setPipeText(property);
|
||||||
setShowPipeText(styleConfig.showLabels);
|
setShowPipeTextLayer(styleConfig.showLabels);
|
||||||
setApplyPipeStyle(true);
|
setApplyPipeStyle(true);
|
||||||
saveLayerStyle(layerId);
|
saveLayerStyle(layerId);
|
||||||
open?.({
|
open?.({
|
||||||
@@ -414,7 +414,6 @@ const StyleEditorPanel: React.FC<StyleEditorPanelProps> = ({
|
|||||||
// 如果不足则补齐最后一个值
|
// 如果不足则补齐最后一个值
|
||||||
while (breaks.length < desired)
|
while (breaks.length < desired)
|
||||||
breaks.push(breaks[breaks.length - 1] ?? 0);
|
breaks.push(breaks[breaks.length - 1] ?? 0);
|
||||||
console.log(breaks);
|
|
||||||
} else {
|
} else {
|
||||||
const calc = calculateClassification(
|
const calc = calculateClassification(
|
||||||
currentJunctionCalData.map((d) => d.value),
|
currentJunctionCalData.map((d) => d.value),
|
||||||
@@ -676,11 +675,11 @@ const StyleEditorPanel: React.FC<StyleEditorPanelProps> = ({
|
|||||||
// 重置样式应用状态
|
// 重置样式应用状态
|
||||||
if (layerId === "junctions") {
|
if (layerId === "junctions") {
|
||||||
setApplyJunctionStyle(false);
|
setApplyJunctionStyle(false);
|
||||||
if (setShowJunctionText) setShowJunctionText(false);
|
if (setShowJunctionTextLayer) setShowJunctionTextLayer(false);
|
||||||
if (setJunctionText) setJunctionText("");
|
if (setJunctionText) setJunctionText("");
|
||||||
} else if (layerId === "pipes") {
|
} else if (layerId === "pipes") {
|
||||||
setApplyPipeStyle(false);
|
setApplyPipeStyle(false);
|
||||||
if (setShowPipeText) setShowPipeText(false);
|
if (setShowPipeTextLayer) setShowPipeTextLayer(false);
|
||||||
if (setPipeText) setPipeText("");
|
if (setPipeText) setPipeText("");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,8 +47,8 @@ interface DataContextType {
|
|||||||
setCurrentPipeCalData?: React.Dispatch<React.SetStateAction<any[]>>;
|
setCurrentPipeCalData?: React.Dispatch<React.SetStateAction<any[]>>;
|
||||||
showJunctionText?: boolean; // 是否显示节点文本
|
showJunctionText?: boolean; // 是否显示节点文本
|
||||||
showPipeText?: boolean; // 是否显示管道文本
|
showPipeText?: boolean; // 是否显示管道文本
|
||||||
setShowJunctionText?: React.Dispatch<React.SetStateAction<boolean>>;
|
setShowJunctionTextLayer?: React.Dispatch<React.SetStateAction<boolean>>;
|
||||||
setShowPipeText?: React.Dispatch<React.SetStateAction<boolean>>;
|
setShowPipeTextLayer?: React.Dispatch<React.SetStateAction<boolean>>;
|
||||||
setShowContourLayer?: React.Dispatch<React.SetStateAction<boolean>>;
|
setShowContourLayer?: React.Dispatch<React.SetStateAction<boolean>>;
|
||||||
junctionText: string;
|
junctionText: string;
|
||||||
pipeText: string;
|
pipeText: string;
|
||||||
@@ -108,11 +108,9 @@ const MapComponent: React.FC<MapComponentProps> = ({ children }) => {
|
|||||||
const tileJunctionDataBuffer = useRef<any[]>([]);
|
const tileJunctionDataBuffer = useRef<any[]>([]);
|
||||||
const tilePipeDataBuffer = useRef<any[]>([]);
|
const tilePipeDataBuffer = useRef<any[]>([]);
|
||||||
|
|
||||||
const [showJunctionText, setShowJunctionText] = useState(false); // 控制节点文本显示
|
const [showJunctionTextLayer, setShowJunctionTextLayer] = useState(false); // 控制节点文本图层显示
|
||||||
const [showPipeText, setShowPipeText] = useState(false); // 控制管道文本显示
|
const [showPipeTextLayer, setShowPipeTextLayer] = useState(false); // 控制管道文本图层显示
|
||||||
const [showJunctionTextLayer, setShowJunctionTextLayer] = useState(true); // 控制节点文本图层显示
|
const [showContourLayer, setShowContourLayer] = useState(false); // 控制等高线图层显示
|
||||||
const [showPipeTextLayer, setShowPipeTextLayer] = useState(true); // 控制管道文本图层显示
|
|
||||||
const [showContourLayer, setShowContourLayer] = useState(true); // 控制等高线图层显示
|
|
||||||
const [junctionText, setJunctionText] = useState("pressure");
|
const [junctionText, setJunctionText] = useState("pressure");
|
||||||
const [pipeText, setPipeText] = useState("flow");
|
const [pipeText, setPipeText] = useState("flow");
|
||||||
const flowAnimation = useRef(false); // 添加动画控制标志
|
const flowAnimation = useRef(false); // 添加动画控制标志
|
||||||
@@ -675,12 +673,10 @@ const MapComponent: React.FC<MapComponentProps> = ({ children }) => {
|
|||||||
if (!deckLayer) return; // 如果 deck 实例还未创建,则退出
|
if (!deckLayer) return; // 如果 deck 实例还未创建,则退出
|
||||||
if (!junctionData.length) return;
|
if (!junctionData.length) return;
|
||||||
if (!pipeData.length) return;
|
if (!pipeData.length) return;
|
||||||
console.log(pipeData);
|
|
||||||
console.log(pipeText);
|
|
||||||
const junctionTextLayer = new TextLayer({
|
const junctionTextLayer = new TextLayer({
|
||||||
id: "junctionTextLayer",
|
id: "junctionTextLayer",
|
||||||
zIndex: 10,
|
zIndex: 10,
|
||||||
data: showJunctionText ? junctionData : [],
|
data: junctionData,
|
||||||
getPosition: (d: any) => d.position,
|
getPosition: (d: any) => d.position,
|
||||||
fontFamily: "Monaco, monospace",
|
fontFamily: "Monaco, monospace",
|
||||||
getText: (d: any) =>
|
getText: (d: any) =>
|
||||||
@@ -710,7 +706,7 @@ const MapComponent: React.FC<MapComponentProps> = ({ children }) => {
|
|||||||
const pipeTextLayer = new TextLayer({
|
const pipeTextLayer = new TextLayer({
|
||||||
id: "pipeTextLayer",
|
id: "pipeTextLayer",
|
||||||
zIndex: 10,
|
zIndex: 10,
|
||||||
data: showPipeText ? pipeData : [],
|
data: pipeData,
|
||||||
getPosition: (d: any) => d.position,
|
getPosition: (d: any) => d.position,
|
||||||
fontFamily: "Monaco, monospace",
|
fontFamily: "Monaco, monospace",
|
||||||
getText: (d: any) =>
|
getText: (d: any) =>
|
||||||
@@ -753,8 +749,6 @@ const MapComponent: React.FC<MapComponentProps> = ({ children }) => {
|
|||||||
junctionData,
|
junctionData,
|
||||||
pipeData,
|
pipeData,
|
||||||
currentZoom,
|
currentZoom,
|
||||||
showJunctionText,
|
|
||||||
showPipeText,
|
|
||||||
showJunctionTextLayer,
|
showJunctionTextLayer,
|
||||||
showPipeTextLayer,
|
showPipeTextLayer,
|
||||||
showContourLayer,
|
showContourLayer,
|
||||||
@@ -775,7 +769,7 @@ const MapComponent: React.FC<MapComponentProps> = ({ children }) => {
|
|||||||
|
|
||||||
// 动画循环
|
// 动画循环
|
||||||
const animate = () => {
|
const animate = () => {
|
||||||
if (!deckRef.current || !flowAnimation.current) return; // 添加检查,防止空数据或停止旧循环
|
if (!flowAnimation.current) return; // 添加检查,防止空数据或停止旧循环
|
||||||
// 动画总时长(秒)
|
// 动画总时长(秒)
|
||||||
if (pipeData.length === 0) {
|
if (pipeData.length === 0) {
|
||||||
animationFrameId = requestAnimationFrame(animate);
|
animationFrameId = requestAnimationFrame(animate);
|
||||||
@@ -887,13 +881,11 @@ const MapComponent: React.FC<MapComponentProps> = ({ children }) => {
|
|||||||
setCurrentJunctionCalData,
|
setCurrentJunctionCalData,
|
||||||
currentPipeCalData,
|
currentPipeCalData,
|
||||||
setCurrentPipeCalData,
|
setCurrentPipeCalData,
|
||||||
setShowJunctionText,
|
setShowJunctionTextLayer,
|
||||||
setShowPipeText,
|
setShowPipeTextLayer,
|
||||||
setShowContourLayer,
|
setShowContourLayer,
|
||||||
setJunctionText,
|
setJunctionText,
|
||||||
setPipeText,
|
setPipeText,
|
||||||
showJunctionText,
|
|
||||||
showPipeText,
|
|
||||||
junctionText,
|
junctionText,
|
||||||
pipeText,
|
pipeText,
|
||||||
}}
|
}}
|
||||||
|
|||||||
Reference in New Issue
Block a user