mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-06-05 07:26:46 +00:00
live2d初始化方式调整
This commit is contained in:
@@ -2,32 +2,28 @@
|
|||||||
import BLOG from '@/blog.config'
|
import BLOG from '@/blog.config'
|
||||||
import { useGlobal } from '@/lib/global'
|
import { useGlobal } from '@/lib/global'
|
||||||
import { loadExternalResource } from '@/lib/utils'
|
import { loadExternalResource } from '@/lib/utils'
|
||||||
import { useEffect, useState } from 'react'
|
import { useEffect } from 'react'
|
||||||
|
|
||||||
export default function Live2D () {
|
export default function Live2D() {
|
||||||
if (!BLOG.WIDGET_PET) {
|
if (!BLOG.WIDGET_PET) {
|
||||||
return <></>
|
return <></>
|
||||||
}
|
}
|
||||||
const [init, setInit] = useState()
|
|
||||||
const { switchTheme } = useGlobal()
|
const { switchTheme } = useGlobal()
|
||||||
|
|
||||||
function handleClick () {
|
function handleClick() {
|
||||||
if (BLOG.WIDGET_PET_SWITCH_THEME) {
|
if (BLOG.WIDGET_PET_SWITCH_THEME) {
|
||||||
switchTheme()
|
switchTheme()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!init) {
|
initLive2D()
|
||||||
initLive2D()
|
}, [])
|
||||||
setInit(true)
|
|
||||||
}
|
|
||||||
}, [init])
|
|
||||||
|
|
||||||
return <canvas id="live2d" className='cursor-pointer' width="280" height="250" onClick={handleClick} alt='切换主题' title='切换主题'/>
|
return <canvas id="live2d" className='cursor-pointer' width="280" height="250" onClick={handleClick} alt='切换主题' title='切换主题' />
|
||||||
}
|
}
|
||||||
|
|
||||||
function initLive2D () {
|
function initLive2D() {
|
||||||
// 加载 waifu.css live2d.min.js waifu-tips.js
|
// 加载 waifu.css live2d.min.js waifu-tips.js
|
||||||
if (screen.width >= 768) {
|
if (screen.width >= 768) {
|
||||||
Promise.all([
|
Promise.all([
|
||||||
|
|||||||
Reference in New Issue
Block a user