From 2bb2434c7eee0d6d899392a6aae9d7335e6b52e6 Mon Sep 17 00:00:00 2001 From: chenpei Date: Mon, 17 Aug 2026 12:10:22 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=8E=92=E8=A1=8C=E6=A6=9C=E5=88=9D?= =?UTF-8?q?=E5=A7=8B=E4=BD=8D=E7=BD=AE=E9=81=BF=E5=BC=80=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E7=AB=AF=E8=AF=BB=E5=8F=96=20window?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/RankingPanel.tsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/components/RankingPanel.tsx b/components/RankingPanel.tsx index 1eaa250..5f0dc39 100644 --- a/components/RankingPanel.tsx +++ b/components/RankingPanel.tsx @@ -27,12 +27,18 @@ export default function RankingPanel() { likes: [] }) const [loading, setLoading] = useState(true) - const [position, setPosition] = useState({ x: 32, y: window.innerHeight / 2 - 200 }) + const [position, setPosition] = useState(() => ({ + x: 32, + y: typeof window === 'undefined' ? 200 : window.innerHeight / 2 - 200, + })) const [isDragging, setIsDragging] = useState(false) const [dragOffset, setDragOffset] = useState({ x: 0, y: 0 }) const panelRef = useRef(null) const buttonRef = useRef(null) - const [buttonPosition, setButtonPosition] = useState({ x: 32, y: window.innerHeight / 2 - 24 }) + const [buttonPosition, setButtonPosition] = useState(() => ({ + x: 32, + y: typeof window === 'undefined' ? 200 : window.innerHeight / 2 - 24, + })) const [isButtonDragging, setIsButtonDragging] = useState(false) const [buttonDragOffset, setButtonDragOffset] = useState({ x: 0, y: 0 }) const clickStartRef = useRef<{ x: number; y: number; time: number } | null>(null)