From 505d1aa405bb58efd9bad05ee4d5543edd532a40 Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Wed, 13 Apr 2022 09:30:40 +0800 Subject: [PATCH] =?UTF-8?q?live2d=E5=88=9D=E5=A7=8B=E5=8C=96=E6=96=B9?= =?UTF-8?q?=E5=BC=8F=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/Live2D.js | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/components/Live2D.js b/components/Live2D.js index 3954decc..43578793 100644 --- a/components/Live2D.js +++ b/components/Live2D.js @@ -2,32 +2,28 @@ import BLOG from '@/blog.config' import { useGlobal } from '@/lib/global' 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) { return <> } - const [init, setInit] = useState() const { switchTheme } = useGlobal() - function handleClick () { + function handleClick() { if (BLOG.WIDGET_PET_SWITCH_THEME) { switchTheme() } } useEffect(() => { - if (!init) { - initLive2D() - setInit(true) - } - }, [init]) + initLive2D() + }, []) - return + return } -function initLive2D () { +function initLive2D() { // 加载 waifu.css live2d.min.js waifu-tips.js if (screen.width >= 768) { Promise.all([