From fcc9837d84d7f7c8cac443eda9b908e236eb2578 Mon Sep 17 00:00:00 2001 From: eafonyang Date: Fri, 28 Aug 2026 18:47:26 +0800 Subject: [PATCH] =?UTF-8?q?feat(eq):=20=E4=BD=BF=E7=94=A8=E5=B9=B3?= =?UTF-8?q?=E7=9B=B4=E6=9B=B2=E7=BA=BF=E4=BD=9C=E4=B8=BA=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E9=A2=84=E8=AE=BE=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增 FLAT_BANDS 平直曲线预设,包含10个增益为0的PEAK滤波器 - 默认初始化bandsByMode状态使用FLAT_BANDS替代旧的DEFAULT_BANDS - 在无远程peq数据或切换耳机时,默认设置为FLAT_BANDS - 无滤波器时恢复平直曲线并清空原始参考线状态 - 保持FLAT_BANDS预设一致性优化未加载状态的体验 --- client/src/pages/EQPage.tsx | 18 +++++++++++++----- client/src/pages/eq/constants.ts | 14 ++++++++++++++ 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/client/src/pages/EQPage.tsx b/client/src/pages/EQPage.tsx index fee403b..d81455c 100644 --- a/client/src/pages/EQPage.tsx +++ b/client/src/pages/EQPage.tsx @@ -53,6 +53,7 @@ import { BAND_Q_MAX, BAND_PARAM_VALUE_BOX_STYLE, DEFAULT_BANDS, + FLAT_BANDS, FLAT_PRESET_FILTERS, PEQ_PRESET_MAX, type BandParamKind, @@ -136,8 +137,8 @@ export default function EQPage() { const [bandsByMode, setBandsByMode] = useState< Record<"A" | "B", typeof DEFAULT_BANDS> >({ - A: cloneBands(DEFAULT_BANDS), - B: cloneBands(DEFAULT_BANDS), + A: cloneBands(FLAT_BANDS), + B: cloneBands(FLAT_BANDS), }); const [selectedBandByMode, setSelectedBandByMode] = useState< Record<"A" | "B", number> @@ -605,7 +606,7 @@ export default function EQPage() { const items = remote.peq ?? []; if (items.length === 0) { - setBandsForBothModes(DEFAULT_BANDS); + setBandsForBothModes(FLAT_BANDS); setSelectedBandByMode({ A: 0, B: 0 }); return; } @@ -1043,7 +1044,7 @@ export default function EQPage() { setHeadphoneModels([]); setPeqItems([]); selectHeadphone(0, ""); - setBandsForBothModes(DEFAULT_BANDS); + setBandsForBothModes(FLAT_BANDS); setSelectedBandByMode({ A: 0, B: 0 }); setCurrentRawCurve(null); } @@ -1102,7 +1103,14 @@ export default function EQPage() { // 切换耳机型号后,从 peqItems 加载该型号的 filters(暂停一次上报避免错写) useEffect(() => { const peq = peqItems[headphoneIdx]; - if (!peq) return; + if (!peq) { + // 列表为空(如设备端删光全部预设):恢复平直曲线并清空 Raw 参考线 + setBandsForBothModes(FLAT_BANDS); + setSelectedBandByMode({ A: 0, B: 0 }); + setCurrentRawCurve(null); + setRawCurveLoading(false); + return; + } const nextBands = normalizeFiltersFromPeq(peq); if (!nextBands.length) return; syncingHeadphoneRef.current = true; diff --git a/client/src/pages/eq/constants.ts b/client/src/pages/eq/constants.ts index 0211b81..a57152a 100644 --- a/client/src/pages/eq/constants.ts +++ b/client/src/pages/eq/constants.ts @@ -55,6 +55,20 @@ export const DEFAULT_BANDS = [ { freq: 10000, gain: 0, q: 1.41, type: "HSHELF", enabled: true }, ]; +/* ── Flat bands:无预设/未加载时展示的平直曲线(10 个 gain=0 的 PEAK) ── */ +export const FLAT_BANDS: typeof DEFAULT_BANDS = [ + { freq: 80, gain: 0, q: 1.41, type: "PEAK", enabled: true }, + { freq: 150, gain: 0, q: 1.41, type: "PEAK", enabled: true }, + { freq: 350, gain: 0, q: 1.41, type: "PEAK", enabled: true }, + { freq: 750, gain: 0, q: 1.41, type: "PEAK", enabled: true }, + { freq: 1500, gain: 0, q: 1.41, type: "PEAK", enabled: true }, + { freq: 3000, gain: 0, q: 1.41, type: "PEAK", enabled: true }, + { freq: 6000, gain: 0, q: 1.41, type: "PEAK", enabled: true }, + { freq: 10000, gain: 0, q: 1.41, type: "PEAK", enabled: true }, + { freq: 14000, gain: 0, q: 1.41, type: "PEAK", enabled: true }, + { freq: 18000, gain: 0, q: 1.41, type: "PEAK", enabled: true }, +]; + /* ── PEQ catalog item type ── */ export type PeqCatalogItem = NonNullable[number];