From e75f45957d199a686306cd649b7227d032ef0eca Mon Sep 17 00:00:00 2001 From: "tangly1024.com" Date: Thu, 19 Oct 2023 11:02:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=98=9F=E7=A9=BA=E9=9B=A8?= =?UTF-8?q?=E7=89=B9=E6=95=88BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/StarrySky.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/components/StarrySky.js b/components/StarrySky.js index 5479df93..e0fd3ac4 100644 --- a/components/StarrySky.js +++ b/components/StarrySky.js @@ -1,23 +1,24 @@ /* eslint-disable */ -import React from 'react' +import { useEffect } from 'react' const StarrySky = () => { - React.useEffect(() => { - dark() + useEffect(() => { + renderStarrySky() }, []) return (
- +
) } export default StarrySky + /** * 创建星空雨 * @param config */ -function dark() { +function renderStarrySky() { window.requestAnimationFrame = window.requestAnimationFrame || window.mozRequestAnimationFrame || @@ -124,7 +125,7 @@ function dark() { u() })(), (function t() { - document.getElementsByTagName('html')[0].className == 'dark' && u(), + document.getElementsByTagName('html')[0].className.indexOf('dark')>=0 && u(), window.requestAnimationFrame(t) })() }