部分公共组件配置化

This commit is contained in:
tangly1024.com
2023-11-08 19:05:35 +08:00
parent f96aa2242f
commit b2759c6d5e
34 changed files with 301 additions and 239 deletions

View File

@@ -1,12 +1,13 @@
/* eslint-disable no-undef */
import BLOG from '@/blog.config'
import { siteConfig } from '@/lib/config'
import { useGlobal } from '@/lib/global'
import { loadExternalResource } from '@/lib/utils'
import { useEffect } from 'react'
export default function Live2D() {
const { theme, switchTheme } = useGlobal()
const showPet = JSON.parse(BLOG.WIDGET_PET)
const showPet = JSON.parse(siteConfig('WIDGET_PET'))
const petLink = siteConfig('WIDGET_PET_LINK')
useEffect(() => {
if (showPet) {
@@ -16,7 +17,7 @@ export default function Live2D() {
if (typeof window?.loadlive2d !== 'undefined') {
// https://github.com/xiazeyu/live2d-widget-models
try {
loadlive2d('live2d', BLOG.WIDGET_PET_LINK)
loadlive2d('live2d', petLink)
} catch (error) {
console.error('读取PET模型', error)
}
@@ -26,7 +27,7 @@ export default function Live2D() {
}, [theme])
function handleClick() {
if (JSON.parse(BLOG.WIDGET_PET_SWITCH_THEME)) {
if (JSON.parse(siteConfig('WIDGET_PET_SWITCH_THEME'))) {
switchTheme()
}
}