mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-31 07:26:43 +00:00
优化加载
This commit is contained in:
@@ -1,13 +1,16 @@
|
|||||||
import BLOG from '@/blog.config'
|
import BLOG from '@/blog.config'
|
||||||
import { loadExternalResource } from '@/lib/utils'
|
import { isBrowser, loadExternalResource } from '@/lib/utils'
|
||||||
import React from 'react'
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 自定义引入外部JS 和 CSS
|
* 自定义引入外部JS 和 CSS
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
const ExternalScript = () => {
|
const ExternalScript = () => {
|
||||||
React.useEffect(() => {
|
if (isBrowser) {
|
||||||
|
// 静态导入本地自定义样式
|
||||||
|
loadExternalResource(BLOG.FONT_AWESOME, 'css')
|
||||||
|
loadExternalResource('/css/custom.css', 'css')
|
||||||
|
loadExternalResource('/js/custom.js', 'js')
|
||||||
if (BLOG.CUSTOM_EXTERNAL_JS && BLOG.CUSTOM_EXTERNAL_JS.length > 0) {
|
if (BLOG.CUSTOM_EXTERNAL_JS && BLOG.CUSTOM_EXTERNAL_JS.length > 0) {
|
||||||
for (const url of BLOG.CUSTOM_EXTERNAL_JS) {
|
for (const url of BLOG.CUSTOM_EXTERNAL_JS) {
|
||||||
loadExternalResource(url, 'js')
|
loadExternalResource(url, 'js')
|
||||||
@@ -18,16 +21,12 @@ const ExternalScript = () => {
|
|||||||
loadExternalResource(url, 'css')
|
loadExternalResource(url, 'css')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 静态导入本地自定义样式
|
|
||||||
loadExternalResource('/css/all.min.css', 'css')
|
|
||||||
loadExternalResource('/css/custom.css', 'css')
|
|
||||||
loadExternalResource('/js/custom.js', 'js')
|
|
||||||
|
|
||||||
// 渲染所有字体
|
// 渲染所有字体
|
||||||
BLOG.FONT_URL?.forEach(e => {
|
BLOG.FONT_URL?.forEach(e => {
|
||||||
loadExternalResource(e, 'css')
|
loadExternalResource(e, 'css')
|
||||||
})
|
})
|
||||||
}, [])
|
}
|
||||||
|
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user