From 1595992758fb586826bde83d40b332c9eb82a5db Mon Sep 17 00:00:00 2001 From: "tangly1024.com" Date: Tue, 9 Apr 2024 14:14:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20Live2D=E5=AE=A0=E7=89=A9?= =?UTF-8?q?=E8=AF=BB=E5=8F=96=E9=85=8D=E7=BD=AE=E5=A4=B1=E8=B4=A5=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/Live2D.js | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/components/Live2D.js b/components/Live2D.js index 84afcdff..9be00066 100644 --- a/components/Live2D.js +++ b/components/Live2D.js @@ -12,12 +12,16 @@ export default function Live2D() { const { theme, switchTheme } = useGlobal() const showPet = JSON.parse(siteConfig('WIDGET_PET')) const petLink = siteConfig('WIDGET_PET_LINK') + const petSwitchTheme = siteConfig('WIDGET_PET_SWITCH_THEME') useEffect(() => { if (showPet && !isMobile()) { Promise.all([ - loadExternalResource('https://cdn.jsdelivr.net/gh/stevenjoezhang/live2d-widget@latest/live2d.min.js', 'js') - ]).then((e) => { + loadExternalResource( + 'https://cdn.jsdelivr.net/gh/stevenjoezhang/live2d-widget@latest/live2d.min.js', + 'js' + ) + ]).then(e => { if (typeof window?.loadlive2d !== 'undefined') { // https://github.com/xiazeyu/live2d-widget-models try { @@ -31,7 +35,7 @@ export default function Live2D() { }, [theme]) function handleClick() { - if (JSON.parse(siteConfig('WIDGET_PET_SWITCH_THEME'))) { + if (petSwitchTheme) { switchTheme() } } @@ -40,9 +44,15 @@ export default function Live2D() { return <> } - return e.target.classList.add('cursor-grabbing')} - onMouseUp={(e) => e.target.classList.remove('cursor-grabbing')} + return ( + e.target.classList.add('cursor-grabbing')} + onMouseUp={e => e.target.classList.remove('cursor-grabbing')} /> + ) }