更新api url

This commit is contained in:
JIANG
2026-01-29 11:18:54 +08:00
parent 7122b0b2ac
commit 5cb2d17be1
17 changed files with 85 additions and 84 deletions

View File

@@ -38,8 +38,6 @@ import {
RISK_BREAKS,
} from "./types";
const backendUrl = config.BACKEND_URL;
// 辅助函数将日期向下取整到最近的15分钟
const getRoundedDate = (date: Date): Date => {
const minutes = date.getHours() * 60 + date.getMinutes();
@@ -49,7 +47,7 @@ const getRoundedDate = (date: Date): Date => {
Math.floor(roundedMinutes / 60),
roundedMinutes % 60,
0,
0
0,
);
return roundedDate;
};
@@ -124,7 +122,7 @@ const Timeline: React.FC<TimelineProps> = ({
setCurrentYear(value);
}, 500); // 500ms 防抖延迟
},
[minTime, maxTime]
[minTime, maxTime],
);
// 播放控制
@@ -215,7 +213,7 @@ const Timeline: React.FC<TimelineProps> = ({
}, newInterval);
}
},
[isPlaying]
[isPlaying],
);
// 组件加载时设置初始时间为当前时间的最近15分钟
@@ -245,7 +243,7 @@ const Timeline: React.FC<TimelineProps> = ({
const safeIndex = Math.max(0, Math.min(index, y.length - 1));
return y[safeIndex];
},
[]
[],
);
// 更新管道图层中的 healthRisk 属性
@@ -270,7 +268,7 @@ const Timeline: React.FC<TimelineProps> = ({
});
});
},
[pipeLayer]
[pipeLayer],
);
// 监听瓦片加载,为新瓦片设置 healthRisk 属性
@@ -313,7 +311,7 @@ const Timeline: React.FC<TimelineProps> = ({
predictionResults.forEach((result) => {
const probability = getSurvivalProbabilityAtYear(
result.survival_function,
currentYear - 4 // 使用索引 (0-based)
currentYear - 4, // 使用索引 (0-based)
);
pipeHealthData.set(result.link_id, probability);
});
@@ -347,7 +345,7 @@ const Timeline: React.FC<TimelineProps> = ({
widthCases.push(["<=", ["get", "healthRisk"], breakValue], width);
});
console.log(
`应用健康风险样式,年份: ${currentYear}, 分段: ${breaks.length}`
`应用健康风险样式,年份: ${currentYear}, 分段: ${breaks.length}`,
);
console.log("颜色表达式:", colorCases);
console.log("宽度表达式:", widthCases);
@@ -371,7 +369,7 @@ const Timeline: React.FC<TimelineProps> = ({
const layers = map.getLayers().getArray();
const pipesLayer = layers.find(
(layer) =>
layer instanceof WebGLVectorTileLayer && layer.get("value") === "pipes"
layer instanceof WebGLVectorTileLayer && layer.get("value") === "pipes",
) as WebGLVectorTileLayer | undefined;
if (pipesLayer) {
@@ -426,7 +424,7 @@ const Timeline: React.FC<TimelineProps> = ({
});
try {
const response = await fetch(
`${backendUrl}/timescaledb/composite/pipeline-health-prediction?query_time=${query_time}&network_name=${NETWORK_NAME}`
`${config.BACKEND_URL}/api/v1/composite/pipeline-health-prediction?query_time=${query_time}&network_name=${NETWORK_NAME}`,
);
if (response.ok) {