Update Vite configuration to deduplicate React and React-DOM; enhance DeviceContext with syncPeqCatalog method for improved PEQ state management; refactor LuxsinAPI to streamline PEQ filter updates; replace range input with ThumbOnlyRangeSlider in Home component for better user experience.

This commit is contained in:
yangy
2026-05-28 15:18:17 +08:00
parent e6b7dcc89c
commit ce55be295a
12 changed files with 1090 additions and 772 deletions
+41
View File
@@ -0,0 +1,41 @@
import { getFilterType } from "@/lib/peqAudio";
import type { PeqFilter, PeqState } from "@/lib/luxsinApi";
import type { EqBand } from "./types";
export function cloneBands(source: EqBand[]) {
return source.map((band) => ({ ...band }));
}
export function buildPeqCatalogSyncKey(
remote: Pick<PeqState, "peq" | "peqSelect"> | null | undefined,
devicePeqSelect?: number,
): string {
const items = remote?.peq;
if (!items?.length) return items ? "empty" : "";
const select = devicePeqSelect ?? remote?.peqSelect ?? 0;
return `${select}|${items.map((p) => p.name).join("\u0001")}`;
}
export function getUniquePresetName(base: string, existingNames: string[]) {
if (!existingNames.includes(base)) return base;
let index = 1;
while (existingNames.includes(`${base}_${index}`)) {
index += 1;
}
return `${base}_${index}`;
}
/** UI band row → device `PeqFilter` (fc + numeric type), same as legacy `getFilterVal` mapping via `getFilterType`. */
export function bandToPeqFilter(b: {
freq: number;
gain: number;
q: number;
type: string | number;
}): PeqFilter {
return {
fc: b.freq,
gain: b.gain,
q: b.q,
type: getFilterType(b.type),
};
}