This commit is contained in:
Mackie 2026-05-24 22:23:01 +08:00
parent a63ba979d4
commit 0aa214e3eb

View file

@ -1,6 +1,7 @@
"use client"; "use client";
import { useThemeMode } from '@/hooks/useThemeMode'
import { useEffect, useRef, useState } from "react"; // REPLACE WITH:
import { useEffect, useRef } from "react";
const STAR_TONES = [255, 210, 160, 110, 65]; const STAR_TONES = [255, 210, 160, 110, 65];
const WAVE_TONES = [55, 90, 125, 165, 205]; const WAVE_TONES = [55, 90, 125, 165, 205];
@ -125,16 +126,17 @@ export default function HeroBackground({
showToggle = true, showToggle = true,
}: HeroBackgroundProps) { }: HeroBackgroundProps) {
const canvasRef = useRef<HTMLCanvasElement>(null); const canvasRef = useRef<HTMLCanvasElement>(null);
const [internalDark, setInternalDark] = useState(true); // REPLACE WITH:
const { isDark: hookDark, toggle } = useThemeMode();
// Use external control if provided, otherwise internal state // Use external control if provided, otherwise hook
const isDark = externalIsDark !== undefined ? externalIsDark : internalDark; const isDark = externalIsDark !== undefined ? externalIsDark : hookDark;
function handleToggle() { // REPLACE WITH:
const next = !isDark; function handleToggle() {
setInternalDark(next); toggle();
onToggle?.(next); onToggle?.(!isDark);
} }
useEffect(() => { useEffect(() => {
const canvas = canvasRef.current; const canvas = canvasRef.current;