refactor(frontend): normalize naming conventions

This commit is contained in:
2026-06-13 13:07:16 +08:00
parent 6ff8886524
commit 0dea655f68
30 changed files with 87 additions and 33 deletions
@@ -73,7 +73,7 @@ const AnalysisParameters: React.FC<Props> = ({ onResult }) => {
setSchemeLoading(true);
try {
const response = await api.get(`${config.BACKEND_URL}/api/v1/getallschemes/`, {
const response = await api.get(`${config.BACKEND_URL}/api/v1/schemes`, {
params: { network: NETWORK_NAME },
});
const burstSchemes = (response.data as SchemeItem[]).filter(
@@ -80,7 +80,7 @@ const AnalysisParameters: React.FC<Props> = ({ onResult }) => {
setSchemeLoading(true);
try {
const response = await api.get(`${config.BACKEND_URL}/api/v1/getallschemes/`, {
const response = await api.get(`${config.BACKEND_URL}/api/v1/schemes`, {
params: { network: NETWORK_NAME },
});
const burstSchemes = (response.data as SchemeItem[]).filter(
@@ -280,7 +280,7 @@ const AnalysisParameters: React.FC = () => {
};
try {
await api.get(`${config.BACKEND_URL}/api/v1/burst_analysis/`, {
await api.get(`${config.BACKEND_URL}/api/v1/burst-analysis`, {
params,
paramsSerializer: {
indexes: null, // 移除数组索引,即由 burst_ID[] 变为 burst_ID
@@ -110,7 +110,7 @@ const SchemeQuery: React.FC<SchemeQueryProps> = ({
setLoading(true);
try {
const response = await api.get(
`${config.BACKEND_URL}/api/v1/getallschemes/?network=${network}`,
`${config.BACKEND_URL}/api/v1/schemes?network=${network}`,
);
let filteredResults = response.data;
@@ -271,7 +271,7 @@ const ValveIsolation: React.FC<ValveIsolationProps> = ({
params.disabled_valves = disabled;
}
const response = await api.get(
`${config.BACKEND_URL}/api/v1/valve_isolation_analysis/`,
`${config.BACKEND_URL}/api/v1/valve-isolation-analysis`,
{
params,
paramsSerializer: {
@@ -189,7 +189,7 @@ const AnalysisParameters: React.FC = () => {
scheme_name: schemeName,
};
await api.get(`${config.BACKEND_URL}/api/v1/contaminant_simulation/`, {
await api.get(`${config.BACKEND_URL}/api/v1/contaminant-simulation`, {
params,
});
@@ -181,7 +181,7 @@ const SchemeQuery: React.FC<SchemeQueryProps> = ({
setLoading(true);
try {
const response = await api.get(
`${config.BACKEND_URL}/api/v1/getallschemes/?network=${network}`,
`${config.BACKEND_URL}/api/v1/schemes?network=${network}`,
);
let filteredResults = response.data;
@@ -242,7 +242,7 @@ const AnalysisParameters: React.FC = () => {
// but axios usually handles array as valves[]=1&valves[]=2
// FastAPI default expects repeated query params.
const response = await api.get(`${config.BACKEND_URL}/api/v1/flushing_analysis/`, {
const response = await api.get(`${config.BACKEND_URL}/api/v1/flushing-analysis`, {
params,
// Ensure arrays are sent as repeated keys: valves=1&valves=2
paramsSerializer: {
@@ -222,7 +222,7 @@ const SchemeQuery: React.FC<SchemeQueryProps> = ({
setLoading(true);
try {
const response = await api.get(
`${config.BACKEND_URL}/api/v1/getallschemes/?network=${network}`,
`${config.BACKEND_URL}/api/v1/schemes?network=${network}`,
);
let filteredResults = response.data;
@@ -94,7 +94,7 @@ const OptimizationParameters: React.FC = () => {
try {
// 发送优化请求
const response = await api.post(
`${config.BACKEND_URL}/api/v1/sensorplacementscheme/create`,
`${config.BACKEND_URL}/api/v1/sensor-placement-schemes`,
null,
{
params: {
@@ -149,7 +149,7 @@ const SchemeQuery: React.FC<SchemeQueryProps> = ({
setLoading(true);
try {
const response = await api.get(
`${config.BACKEND_URL}/api/v1/getallsensorplacements/?network=${network}`,
`${config.BACKEND_URL}/api/v1/sensor-placement-schemes?network=${network}`,
);
let filteredResults = response.data;
@@ -643,7 +643,7 @@ const Timeline: React.FC<TimelineProps> = ({
};
const response = await apiFetch(
`${config.BACKEND_URL}/api/v1/runsimulationmanuallybydate/`,
`${config.BACKEND_URL}/api/v1/simulations/run-by-date`,
{
method: "POST",
headers: {
@@ -1,6 +1,6 @@
import { FlatStyleLike } from "ol/style/flat";
import { calculateClassification } from "@utils/breaks_classification";
import { calculateClassification } from "@utils/breaksClassification";
import { parseColor } from "@utils/parseColor";
import {
@@ -31,7 +31,7 @@ import {
StyleEditorStateProps,
} from "./styleEditorTypes";
import { LegendStyleConfig } from "./StyleLegend";
import { calculateClassification } from "@utils/breaks_classification";
import { calculateClassification } from "@utils/breaksClassification";
const UNIT_HEADLOSS_RANGE: [number, number] = [0, 5];