fix(analysis): 统一方案名与接口错误提示
Generic Container CI/CD / test-build-publish (push) Successful in 1m2s
Frontend CI/CD v2 / build-test-publish-and-deploy (push) Successful in 1m2s

This commit is contained in:
2026-08-17 18:54:29 +08:00
parent 9e79d52dc8
commit 45def5bba3
12 changed files with 720 additions and 55 deletions
+47
View File
@@ -0,0 +1,47 @@
export const SCHEME_NAME_PREFIXES = {
dmaLeakIdentification: "dma_leak",
flushingAnalysis: "flush",
burstDetection: "burst_detect",
burstAnalysis: "burst_sim",
burstLocation: "burst_locate",
contaminantAnalysis: "water_quality",
sensorPlacement: "sensor_place",
} as const;
export type SchemeNamePrefix =
(typeof SCHEME_NAME_PREFIXES)[keyof typeof SCHEME_NAME_PREFIXES];
export const SCHEME_NAME_MAX_LENGTH = 32;
export const normalizeSchemeName = (value: string) =>
value
.normalize("NFC")
.replace(/\p{Default_Ignorable_Code_Point}/gu, "")
.trim();
export const isSchemeNameValid = (value: string) => {
const normalized = normalizeSchemeName(value);
return normalized.length > 0 && normalized.length <= SCHEME_NAME_MAX_LENGTH;
};
const padNumber = (value: number, length = 2) =>
String(value).padStart(length, "0");
export const createSchemeName = (
prefix: SchemeNamePrefix,
date = new Date(),
) => {
const timestamp = [
padNumber(date.getFullYear() % 100),
padNumber(date.getMonth() + 1),
padNumber(date.getDate()),
].join("");
const time = [
padNumber(date.getHours()),
padNumber(date.getMinutes()),
padNumber(date.getSeconds()),
padNumber(date.getMilliseconds(), 3),
].join("");
return `${prefix}_${timestamp}_${time}`;
};