mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-28 15:10:04 +00:00
移除Preact框架、引入react-hook检查
This commit is contained in:
@@ -2,26 +2,27 @@
|
||||
import BLOG from '@/blog.config'
|
||||
import { useGlobal } from '@/lib/global'
|
||||
import { loadExternalResource } from '@/lib/utils'
|
||||
import { useEffect } from 'react'
|
||||
import React from 'react'
|
||||
|
||||
export default function Live2D() {
|
||||
if (!BLOG.WIDGET_PET || !JSON.parse(BLOG.WIDGET_PET)) {
|
||||
return <></>
|
||||
}
|
||||
const { switchTheme } = useGlobal()
|
||||
|
||||
React.useEffect(() => {
|
||||
window.addEventListener('scroll', initLive2D)
|
||||
return () => {
|
||||
window.removeEventListener('scroll', initLive2D)
|
||||
}
|
||||
}, [])
|
||||
|
||||
function handleClick() {
|
||||
if (BLOG.WIDGET_PET_SWITCH_THEME) {
|
||||
switchTheme()
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
window.addEventListener('scroll', initLive2D)
|
||||
return () => {
|
||||
window.removeEventListener('scroll', initLive2D)
|
||||
}
|
||||
}, [])
|
||||
if (!BLOG.WIDGET_PET || !JSON.parse(BLOG.WIDGET_PET)) {
|
||||
return <></>
|
||||
}
|
||||
|
||||
return <canvas id="live2d" className='cursor-pointer' width="280" height="250" onClick={handleClick} alt='切换主题' title='切换主题' />
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user