修复星空雨特效BUG

This commit is contained in:
tangly1024.com
2023-10-19 11:02:53 +08:00
parent 6156c854bb
commit e75f45957d

View File

@@ -1,23 +1,24 @@
/* eslint-disable */ /* eslint-disable */
import React from 'react' import { useEffect } from 'react'
const StarrySky = () => { const StarrySky = () => {
React.useEffect(() => { useEffect(() => {
dark() renderStarrySky()
}, []) }, [])
return ( return (
<div className="relative"> <div className="relative">
<canvas id="starry-sky-vixcity" style={{zIndex:1}} className="top-0 fixed pointer-events-none"></canvas> <canvas id="starry-sky-vixcity" style={{zIndex:5}} className="top-0 fixed pointer-events-none"></canvas>
</div> </div>
) )
} }
export default StarrySky export default StarrySky
/** /**
* 创建星空雨 * 创建星空雨
* @param config * @param config
*/ */
function dark() { function renderStarrySky() {
window.requestAnimationFrame = window.requestAnimationFrame =
window.requestAnimationFrame || window.requestAnimationFrame ||
window.mozRequestAnimationFrame || window.mozRequestAnimationFrame ||
@@ -124,7 +125,7 @@ function dark() {
u() u()
})(), })(),
(function t() { (function t() {
document.getElementsByTagName('html')[0].className == 'dark' && u(), document.getElementsByTagName('html')[0].className.indexOf('dark')>=0 && u(),
window.requestAnimationFrame(t) window.requestAnimationFrame(t)
})() })()
} }