Merge branch 'main' into feat/multi-languages

This commit is contained in:
tangly1024.com
2024-04-09 18:03:27 +08:00

View File

@@ -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 <canvas id="live2d" width="280" height="250" onClick={handleClick}
className="cursor-grab"
onMouseDown={(e) => e.target.classList.add('cursor-grabbing')}
onMouseUp={(e) => e.target.classList.remove('cursor-grabbing')}
return (
<canvas
id='live2d'
width='280'
height='250'
onClick={handleClick}
className='cursor-grab'
onMouseDown={e => e.target.classList.add('cursor-grabbing')}
onMouseUp={e => e.target.classList.remove('cursor-grabbing')}
/>
)
}