From fc6f89b5f403bfb8c0cc21220a881fad9f5fe8f4 Mon Sep 17 00:00:00 2001 From: eafonyang Date: Wed, 10 Jun 2026 17:52:38 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=20modelCurve=20=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E7=9A=84=E8=B0=83=E7=94=A8=E6=97=B6=E6=9C=BA=EF=BC=8C?= =?UTF-8?q?=E5=8A=A0=E4=B8=8A=E7=BC=93=E5=AD=98=EF=BC=8C=E5=87=8F=E5=B0=91?= =?UTF-8?q?=E8=B0=83=E7=94=A8=E9=A2=91=E7=8E=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/src/pages/EQPage.tsx | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/client/src/pages/EQPage.tsx b/client/src/pages/EQPage.tsx index a77de24..ae144e4 100644 --- a/client/src/pages/EQPage.tsx +++ b/client/src/pages/EQPage.tsx @@ -68,6 +68,8 @@ import { bandToPeqFilter, buildPeqCatalogSyncKey, cloneBands, getUniquePresetNam import type { BandParamKind, PeqCatalogItem, PeqEqUi, PeqPresetLocalCache } from "./eq/types"; /* ── Main Component ── */ +const rawCurveCache = new Map(); + export default function EQPage() { const [, setLocation] = useLocation(); const { @@ -158,6 +160,7 @@ export default function EQPage() { const [isConfirmingTarget, setIsConfirmingTarget] = useState(false); const [currentRawCurve, setCurrentRawCurve] = useState(null); const [rawCurveLoading, setRawCurveLoading] = useState(false); + const rawCurveCacheRef = useRef(rawCurveCache); const allowPeqRemoteSyncRef = useRef(false); const lastPeqCatalogSyncKeyRef = useRef(""); const syncingHeadphoneRef = useRef(false); @@ -828,6 +831,17 @@ export default function EQPage() { const model = peq?.model?.trim() ?? ""; if (!brand || !model) return null; + const cacheKey = `${brand}|${model}`; + if (rawCurveCacheRef.current.has(cacheKey)) { + const cached = rawCurveCacheRef.current.get(cacheKey); + if (cached) { + console.log("[modelCurve] cache hit", { brand, model, rawLength: cached.length }); + } else { + console.log("[modelCurve] cache hit (no raw)", { brand, model }); + } + return cached ?? null; + } + const modelCurve = await getModelCurve(brand, model); if (modelCurve && typeof modelCurve === "object") { const payload = modelCurve as { @@ -853,6 +867,7 @@ export default function EQPage() { }) : null; const cleanedRaw = raw && raw.every((v) => Number.isFinite(v)) ? (raw as number[]) : null; + rawCurveCacheRef.current.set(cacheKey, cleanedRaw); console.log("[modelCurve] raw check", { brand, model,