mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-14 07:26:52 +00:00
cusdis夜间模式
This commit is contained in:
@@ -2,10 +2,31 @@ import { useGlobal } from '@/lib/global'
|
||||
import { ReactCusdis } from 'react-cusdis'
|
||||
import BLOG from '@/blog.config'
|
||||
import { useRouter } from 'next/router'
|
||||
import { useEffect } from 'react'
|
||||
|
||||
const CusdisComponent = ({ frontMatter }) => {
|
||||
const { locale } = useGlobal()
|
||||
const router = useRouter()
|
||||
const { isDarkMode } = useGlobal()
|
||||
|
||||
// 处理cusdis主题
|
||||
useEffect(() => {
|
||||
const cusdisThread = document?.getElementById('cusdis_thread')
|
||||
const cusdisIframe = cusdisThread?.getElementsByTagName('iframe')
|
||||
if (cusdisIframe) {
|
||||
const cusdisWrapper = cusdisIframe[0]?.contentDocument?.getElementById('root')
|
||||
if (isDarkMode) {
|
||||
cusdisWrapper?.classList?.remove('light')
|
||||
cusdisWrapper?.classList?.add('dark')
|
||||
} else {
|
||||
cusdisWrapper?.classList?.remove('dark')
|
||||
cusdisWrapper?.classList?.add('light')
|
||||
}
|
||||
if (!cusdisWrapper?.firstElementChild?.classList?.contains('dark:text-gray-100')) {
|
||||
cusdisWrapper?.firstElementChild?.classList?.add('dark:text-gray-100')
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
return <ReactCusdis
|
||||
lang={locale.LOCALE.toLowerCase()}
|
||||
|
||||
Reference in New Issue
Block a user