diff --git a/components/CusdisComponent.js b/components/CusdisComponent.js index 0e2a4f00..b3fa0bda 100644 --- a/components/CusdisComponent.js +++ b/components/CusdisComponent.js @@ -2,6 +2,7 @@ import { useGlobal } from '@/lib/global' import BLOG from '@/blog.config' import { useRouter } from 'next/router' import { useEffect } from 'react' +import { loadExternalResource } from '@/lib/utils' const CusdisComponent = ({ frontMatter }) => { const { locale } = useGlobal() @@ -10,33 +11,21 @@ const CusdisComponent = ({ frontMatter }) => { // 处理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') - } - } - }) + loadExternalResource(BLOG.COMMENT_CUSDIS_SCRIPT_SRC, 'js').then(url => { + const CUSDIS = window.CUSDIS + CUSDIS.initial() + }) + }, [isDarkMode]) - return
+ return } export default CusdisComponent