修复星空雨特效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 */
import React from 'react'
import { useEffect } from 'react'
const StarrySky = () => {
React.useEffect(() => {
dark()
useEffect(() => {
renderStarrySky()
}, [])
return (
<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>
)
}
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)
})()
}