isBrowser方法调整

This commit is contained in:
tangly1024.com
2023-08-01 12:47:33 +08:00
parent 115b43b429
commit 6eb50b1138
28 changed files with 41 additions and 42 deletions

View File

@@ -62,7 +62,7 @@ const ValineComponent = dynamic(() => import('@/components/ValineComponent'), {
const Comment = ({ frontMatter, className }) => {
const router = useRouter()
if (isBrowser() && ('giscus' in router.query || router.query.target === 'comment')) {
if (isBrowser && ('giscus' in router.query || router.query.target === 'comment')) {
setTimeout(() => {
const url = router.asPath.replace('?target=comment', '')
history.replaceState({}, '', url)

View File

@@ -8,7 +8,7 @@ import { isBrowser, loadExternalResource } from '@/lib/utils'
* @returns
*/
const ExternalScript = () => {
if (isBrowser()) {
if (isBrowser) {
// 静态导入本地自定义样式
loadExternalResource('/css/custom.css', 'css')
loadExternalResource('/js/custom.js', 'js')

View File

@@ -9,7 +9,7 @@ const FullScreenButton = () => {
const [isFullScreen, setIsFullScreen] = useState(false)
const handleFullScreenClick = () => {
if (!isBrowser()) {
if (!isBrowser) {
return
}
const element = document.documentElement

View File

@@ -65,7 +65,7 @@ const NotionPage = ({ post, className }) => {
// 将相册gallery下的图片加入放大功能
if (JSON.parse(BLOG.POST_DISABLE_GALLERY_CLICK)) {
setTimeout(() => {
if (isBrowser()) {
if (isBrowser) {
const imgList = document?.querySelectorAll('.notion-collection-card-cover img')
if (imgList && zoomRef.current) {
for (let i = 0; i < imgList.length; i++) {

View File

@@ -13,8 +13,7 @@ import { useEffect } from 'react'
const Twikoo = ({ isDarkMode }) => {
const loadTwikoo = async () => {
try {
const url = await loadExternalResource(BLOG.COMMENT_TWIKOO_CDN_URL, 'js')
console.log('twikoo 加载成功', url)
await loadExternalResource(BLOG.COMMENT_TWIKOO_CDN_URL, 'js')
const twikoo = window.twikoo
twikoo.init({
envId: BLOG.COMMENT_TWIKOO_ENV_ID, // 腾讯云环境填 envIdVercel 环境填地址https://xxx.vercel.app