减少非必要package

This commit is contained in:
tangly1024.com
2024-04-10 14:31:09 +08:00
parent 46f8cfdf3c
commit c43943b0bb
5 changed files with 238 additions and 78 deletions

View File

@@ -17,7 +17,6 @@ const Fireworks = () => {
useEffect(() => {
// 异步加载
async function loadFireworks() {
console.log('加载烟花')
loadExternalResource(
'https://cdn.bootcdn.net/ajax/libs/animejs/3.2.1/anime.min.js',
'js'

View File

@@ -1,6 +1,8 @@
import { siteConfig } from '@/lib/config'
import { useGlobal } from '@/lib/global'
import Giscus from '@giscus/react'
import { loadExternalResource } from '@/lib/utils'
import { useEffect } from 'react'
// import Giscus from '@giscus/react'
/**
* Giscus评论 @see https://giscus.app/zh-CN
@@ -12,21 +14,34 @@ import Giscus from '@giscus/react'
const GiscusComponent = () => {
const { isDarkMode } = useGlobal()
const theme = isDarkMode ? 'dark' : 'light'
useEffect(() => {
loadExternalResource('/js/giscus.js', 'js').then(() => {
if (window.Giscus) {
window.Giscus.init('#giscus')
}
})
return () => {
window.Giscus.destroy()
}
}, [isDarkMode])
return (
<Giscus
repo={siteConfig('COMMENT_GISCUS_REPO')}
repoId={siteConfig('COMMENT_GISCUS_REPO_ID')}
categoryId={siteConfig('COMMENT_GISCUS_CATEGORY_ID')}
mapping={siteConfig('COMMENT_GISCUS_MAPPING')}
reactionsEnabled={siteConfig('COMMENT_GISCUS_REACTIONS_ENABLED')}
emitMetadata={siteConfig('COMMENT_GISCUS_EMIT_METADATA')}
theme={theme}
inputPosition={siteConfig('COMMENT_GISCUS_INPUT_POSITION')}
lang={siteConfig('COMMENT_GISCUS_LANG')}
loading={siteConfig('COMMENT_GISCUS_LOADING')}
crossorigin={siteConfig('COMMENT_GISCUS_CROSSORIGIN')}
/>
<div
id='giscus'
data-repo={siteConfig('COMMENT_GISCUS_REPO')}
data-repo-id={siteConfig('COMMENT_GISCUS_REPO_ID')}
// data-category='{{ $.Site.Params.giscus.dataCategory }}'
data-category-id={siteConfig('COMMENT_GISCUS_CATEGORY_ID')}
data-mapping={siteConfig('COMMENT_GISCUS_MAPPING')}
// data-strict='0'
data-reactions-enabled={siteConfig('COMMENT_GISCUS_REACTIONS_ENABLED')}
data-emit-metadata={siteConfig('COMMENT_GISCUS_EMIT_METADATA')}
data-input-position={siteConfig('COMMENT_GISCUS_INPUT_POSITION')}
data-theme={theme}
data-lang={siteConfig('COMMENT_GISCUS_LANG')}
data-loading={siteConfig('COMMENT_GISCUS_LOADING')}
// crossorigin={siteConfig('COMMENT_GISCUS_CROSSORIGIN')}
></div>
)
}