From 3442807918b6768e38ea508e6db96839a114313d Mon Sep 17 00:00:00 2001 From: eafonyang Date: Thu, 5 Nov 2026 10:07:15 +0800 Subject: [PATCH] =?UTF-8?q?feat(freqchart):=20=E4=BC=98=E5=8C=96Y=E8=BD=B4?= =?UTF-8?q?=E5=88=BB=E5=BA=A6=E8=8C=83=E5=9B=B4=E9=80=89=E6=8B=A9=E4=BA=A4?= =?UTF-8?q?=E4=BA=92=E4=BD=93=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加Y轴刻度范围的下拉菜单按钮,代替原先的按钮组展示 - 实现菜单外点击关闭下拉功能,提升操作便捷性 - 调整刻度范围按钮样式,使其更美观且易于点击 - 修正dB刻度网格标签显示,避免顶部标签与范围按钮重叠 - 优化相关样式和布局,提升整体界面一致性与视觉效果 --- client/src/pages/eq/components/FreqChart.tsx | 85 ++++++++++++++------ 1 file changed, 59 insertions(+), 26 deletions(-) diff --git a/client/src/pages/eq/components/FreqChart.tsx b/client/src/pages/eq/components/FreqChart.tsx index 9c0e0fd..c41a954 100644 --- a/client/src/pages/eq/components/FreqChart.tsx +++ b/client/src/pages/eq/components/FreqChart.tsx @@ -1,4 +1,5 @@ import { useState, useEffect, useRef, useMemo } from "react"; +import { ChevronDown, ZoomIn } from "lucide-react"; import { toast } from "sonner"; import { useStrokeDrawAnimation } from "@/lib/useStrokeDrawAnimation"; import { @@ -113,6 +114,22 @@ export function FreqChart({ } }; + const [isYRangeMenuOpen, setIsYRangeMenuOpen] = useState(false); + const yRangeMenuRef = useRef(null); + + // 点击菜单外部收起下拉 + useEffect(() => { + if (!isYRangeMenuOpen) return; + const onPointerDown = (event: PointerEvent) => { + const target = event.target as Node; + if (!(yRangeMenuRef.current?.contains(target) ?? false)) { + setIsYRangeMenuOpen(false); + } + }; + document.addEventListener("pointerdown", onPointerDown); + return () => document.removeEventListener("pointerdown", onPointerDown); + }, [isYRangeMenuOpen]); + useEffect(() => { const node = chartContainerRef.current; if (!node) return; @@ -317,27 +334,6 @@ export function FreqChart({ Equalized - {/* Y 轴刻度范围切换 */} -
- {Y_RANGE_OPTIONS.map((r) => ( - - ))} -
{/* A/B + DIFF controls */} @@ -399,9 +395,43 @@ export function FreqChart({ {/* SVG chart */}
+ {/* Y 轴刻度范围:Y 轴顶端单按钮,点击展开下拉选项 */} +
+ + {isYRangeMenuOpen && ( +
+ {Y_RANGE_OPTIONS.map((r) => ( + + ))} +
+ )} +
{/* dB grid */} - {gainLabels.map((g) => ( + {gainLabels.map((g, gi) => ( - - {formatGainLabel(g)} - + {/* 顶格标签位置被 Y 轴范围按钮占用,避免文字重叠 */} + {gi > 0 && ( + + {formatGainLabel(g)} + + )} ))} {/* Freq grid */}