|
import Head from 'next/head' |
|
import { useEffect } from 'react' |
|
import { loadExternalResource } from '@/lib/utils' |
|
|
|
export default function Live2DWife() { |
|
useEffect(() => { |
|
initLive2DWife() |
|
}, []) |
|
return <> |
|
<Head><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/font-awesome/css/font-awesome.min.css" /></Head> |
|
</> |
|
} |
|
|
|
function initLive2DWife() { |
|
|
|
const live2dPath = 'https://cdn.jsdelivr.net/gh/stevenjoezhang/live2d-widget@latest/' |
|
|
|
|
|
|
|
if (screen.width >= 768) { |
|
Promise.all([ |
|
loadExternalResource(live2dPath + 'waifu.css', 'css'), |
|
loadExternalResource(live2dPath + 'live2d.min.js', 'js'), |
|
loadExternalResource(live2dPath + 'waifu-tips.js', 'js') |
|
]).then(() => { |
|
|
|
initWidget({ |
|
waifuPath: live2dPath + 'waifu-tips.json', |
|
|
|
cdnPath: 'https://cdn.jsdelivr.net/gh/fghrsh/live2d_api/' |
|
}) |
|
}) |
|
} |
|
|
|
|
|
|
|
} |
|
|