新增氛围灯功能,对 EQ 名称长度做限制

This commit is contained in:
eafonyang
2026-06-30 15:28:53 +08:00
parent 98e8738e79
commit 8283ffcf14
18 changed files with 407 additions and 66 deletions
+5 -3
View File
@@ -1,6 +1,7 @@
import { getFilterType } from "@/lib/peqAudio";
import { normalizePeqFiltersForSubmit, type PeqFilter, type PeqState } from "@/lib/luxsinApi";
import type { EqBand } from "./types";
import { clampPeqPresetName } from "./peqPresetName";
export function cloneBands(source: EqBand[]) {
return source.map((band) => ({ ...band }));
@@ -32,12 +33,13 @@ export function buildPeqCatalogSyncKey(
}
export function getUniquePresetName(base: string, existingNames: string[]) {
if (!existingNames.includes(base)) return base;
const clippedBase = clampPeqPresetName(base);
if (!existingNames.includes(clippedBase)) return clippedBase;
let index = 1;
while (existingNames.includes(`${base}_${index}`)) {
while (existingNames.includes(clampPeqPresetName(`${clippedBase}_${index}`))) {
index += 1;
}
return `${base}_${index}`;
return clampPeqPresetName(`${clippedBase}_${index}`);
}
/** UI band row → device `PeqFilter` (fc + numeric type), same as legacy `getFilterVal` mapping via `getFilterType`. */