diff --git a/.prettierignore b/.prettierignore
new file mode 100644
index 00000000000..9a5de93f7ec
--- /dev/null
+++ b/.prettierignore
@@ -0,0 +1,43 @@
+# 构建输出
+.next/
+out/
+build/
+dist/
+
+# 依赖
+node_modules/
+
+# 日志
+logs/
+*.log
+npm-debug.log*
+yarn-debug.log*
+yarn-error.log*
+
+# 缓存目录
+.npm
+.eslintcache
+.vercel
+
+# 特定项目文件
+public/
+.github/
+lib/plugins/
+
+# 包锁文件
+package-lock.json
+yarn.lock
+pnpm-lock.yaml
+
+# 静态资源
+*.svg
+*.ico
+*.jpg
+*.jpeg
+*.png
+*.gif
+*.webp
+*.pdf
+*.ttf
+*.woff
+*.woff2
\ No newline at end of file
diff --git a/.prettierrc.json b/.prettierrc.json
index 213aca02dcd..48507ec849e 100644
--- a/.prettierrc.json
+++ b/.prettierrc.json
@@ -6,5 +6,5 @@
"printWidth": 80,
"bracketSpacing": true,
"jsxSingleQuote": true,
- "jsxBracketSameLine": true
+ "bracketSameLine": true
}
diff --git a/blog.config.js b/blog.config.js
index a8a972a702f..c563d56b82d 100644
--- a/blog.config.js
+++ b/blog.config.js
@@ -20,7 +20,8 @@ const BLOG = {
KEYWORDS: process.env.NEXT_PUBLIC_KEYWORD || 'Notion, 博客', // 网站关键词 英文逗号隔开
BLOG_FAVICON: process.env.NEXT_PUBLIC_FAVICON || '/favicon.ico', // blog favicon 配置, 默认使用 /public/favicon.ico,支持在线图片,如 https://img.imesong.com/favicon.png
BEI_AN: process.env.NEXT_PUBLIC_BEI_AN || '', // 备案号 闽ICP备XXXXXX
- BEI_AN_LINK: process.env.NEXT_PUBLIC_BEI_AN_LINK || 'https://beian.miit.gov.cn/', // 备案查询链接,如果用了萌备等备案请在这里填写
+ BEI_AN_LINK:
+ process.env.NEXT_PUBLIC_BEI_AN_LINK || 'https://beian.miit.gov.cn/', // 备案查询链接,如果用了萌备等备案请在这里填写
// RSS订阅
ENABLE_RSS: process.env.NEXT_PUBLIC_ENABLE_RSS || true, // 是否开启RSS订阅功能
diff --git a/components/Ackee.js b/components/Ackee.js
index 88618369976..cb84718ef41 100644
--- a/components/Ackee.js
+++ b/components/Ackee.js
@@ -62,16 +62,18 @@ const handleAckee = async function (pathname, environment, options = {}) {
const instance = ackeeTracker?.create(environment.server, options)
if (instance == null) {
- console.warn('Skipped record creation because useAckee has been called in a non-browser environment')
+ console.warn(
+ 'Skipped record creation because useAckee has been called in a non-browser environment'
+ )
return
}
- const hasPathname = (
- pathname != null && pathname !== ''
- )
+ const hasPathname = pathname != null && pathname !== ''
if (hasPathname === false) {
- console.warn('Skipped record creation because useAckee has been called without pathname')
+ console.warn(
+ 'Skipped record creation because useAckee has been called without pathname'
+ )
return
}
diff --git a/components/AdBlockDetect.js b/components/AdBlockDetect.js
index 00758a08caa..84596fd8408 100644
--- a/components/AdBlockDetect.js
+++ b/components/AdBlockDetect.js
@@ -14,10 +14,13 @@ export default function AdBlockDetect() {
const wwadsCns = document.getElementsByClassName('wwads-cn')
if (wwadsCns && wwadsCns.length > 0) {
for (const wwadsCn of wwadsCns) {
- wwadsCn.insertAdjacentHTML('beforeend', "
"
+ )
}
}
- };
+ }
// check document ready
function docReady(t) {
diff --git a/components/Artalk.js b/components/Artalk.js
index c7ac5441213..40095aed271 100644
--- a/components/Artalk.js
+++ b/components/Artalk.js
@@ -28,8 +28,8 @@ const Artalk = ({ siteInfo }) => {
darkMode: document.documentElement.classList.contains('dark')
})
- const observer = new MutationObserver((mutations) => {
- mutations.forEach((mutation) => {
+ const observer = new MutationObserver(mutations => {
+ mutations.forEach(mutation => {
if (mutation.attributeName === 'class') {
const isDark = document.documentElement.classList.contains('dark')
artalk?.setDarkMode(isDark)
@@ -45,7 +45,7 @@ const Artalk = ({ siteInfo }) => {
return () => observer.disconnect()
}
- return
+ return
}
export default Artalk
diff --git a/components/Badge.js b/components/Badge.js
index 9eab49a2787..8fcbe80e8a4 100644
--- a/components/Badge.js
+++ b/components/Badge.js
@@ -2,10 +2,13 @@
* 红点
*/
export default function Badge() {
- return <>
- {/* 红点 */}
-
-
-
- >
+ return (
+ <>
+ {/* 红点 */}
+
+
+
+
+ >
+ )
}
diff --git a/components/Busuanzi.js b/components/Busuanzi.js
index ebdab36fd56..6a0a9a06bc7 100644
--- a/components/Busuanzi.js
+++ b/components/Busuanzi.js
@@ -6,7 +6,7 @@ import { useEffect } from 'react'
let path = ''
-export default function Busuanzi () {
+export default function Busuanzi() {
const { theme } = useGlobal()
const router = useRouter()
router.events.on('routeChangeComplete', (url, option) => {
diff --git a/components/ChatBase.js b/components/ChatBase.js
index b114fdf6a13..679afb04ade 100644
--- a/components/ChatBase.js
+++ b/components/ChatBase.js
@@ -10,10 +10,11 @@ export default function ChatBase() {
return <>>
}
- return
+ return (
+
+ )
}
diff --git a/components/CursorDot.js b/components/CursorDot.js
index 7fb36603c2c..1d01857e68f 100644
--- a/components/CursorDot.js
+++ b/components/CursorDot.js
@@ -1,107 +1,109 @@
-import { useRouter } from 'next/router';
-import { useEffect } from 'react';
+import { useRouter } from 'next/router'
+import { useEffect } from 'react'
/**
* 白点鼠标跟随
- * @returns
+ * @returns
*/
const CursorDot = () => {
- const router = useRouter();
- useEffect(() => {
- // 创建小白点元素
- const dot = document.createElement('div');
- dot.classList.add('cursor-dot');
- document.body.appendChild(dot);
+ const router = useRouter()
+ useEffect(() => {
+ // 创建小白点元素
+ const dot = document.createElement('div')
+ dot.classList.add('cursor-dot')
+ document.body.appendChild(dot)
- // 鼠标坐标和缓动目标坐标
- let mouse = { x: -100, y: -100 }; // 初始位置在屏幕外
- let dotPos = { x: mouse.x, y: mouse.y };
+ // 鼠标坐标和缓动目标坐标
+ let mouse = { x: -100, y: -100 } // 初始位置在屏幕外
+ let dotPos = { x: mouse.x, y: mouse.y }
- // 监听鼠标移动
- const handleMouseMove = (e) => {
- mouse.x = e.clientX;
- mouse.y = e.clientY;
- };
- document.addEventListener('mousemove', handleMouseMove);
+ // 监听鼠标移动
+ const handleMouseMove = e => {
+ mouse.x = e.clientX
+ mouse.y = e.clientY
+ }
+ document.addEventListener('mousemove', handleMouseMove)
- // 监听鼠标悬停在可点击对象上的事件
- const handleMouseEnter = () => {
- dot.classList.add('cursor-dot-hover'); // 添加放大样式
- };
- const handleMouseLeave = () => {
- dot.classList.remove('cursor-dot-hover'); // 移除放大样式
- };
+ // 监听鼠标悬停在可点击对象上的事件
+ const handleMouseEnter = () => {
+ dot.classList.add('cursor-dot-hover') // 添加放大样式
+ }
+ const handleMouseLeave = () => {
+ dot.classList.remove('cursor-dot-hover') // 移除放大样式
+ }
+ // 为所有可点击元素和包含 hover 或 group-hover 类名的元素添加事件监听
+ setTimeout(() => {
+ const clickableElements = document.querySelectorAll(
+ 'a, button, [role="button"], [onclick], [cursor="pointer"], [class*="hover"], [class*="group-hover"], [class*="cursor-pointer"]'
+ )
+ clickableElements.forEach(el => {
+ el.addEventListener('mouseenter', handleMouseEnter)
+ el.addEventListener('mouseleave', handleMouseLeave)
+ })
+ }, 200) // 延时 200ms 执行
- // 为所有可点击元素和包含 hover 或 group-hover 类名的元素添加事件监听
- setTimeout(() => {
- const clickableElements = document.querySelectorAll(
- 'a, button, [role="button"], [onclick], [cursor="pointer"], [class*="hover"], [class*="group-hover"], [class*="cursor-pointer"]'
- );
- clickableElements.forEach((el) => {
- el.addEventListener('mouseenter', handleMouseEnter);
- el.addEventListener('mouseleave', handleMouseLeave);
- });
- }, 200); // 延时 200ms 执行
+ // 动画循环:延迟更新小白点位置
+ const updateDotPosition = () => {
+ const damping = 0.2 // 阻尼系数,值越小延迟越明显
+ dotPos.x += (mouse.x - dotPos.x) * damping
+ dotPos.y += (mouse.y - dotPos.y) * damping
- // 动画循环:延迟更新小白点位置
- const updateDotPosition = () => {
- const damping = 0.2; // 阻尼系数,值越小延迟越明显
- dotPos.x += (mouse.x - dotPos.x) * damping;
- dotPos.y += (mouse.y - dotPos.y) * damping;
+ // 更新DOM
+ dot.style.left = `${dotPos.x}px`
+ dot.style.top = `${dotPos.y}px`
- // 更新DOM
- dot.style.left = `${dotPos.x}px`;
- dot.style.top = `${dotPos.y}px`;
+ requestAnimationFrame(updateDotPosition)
+ }
- requestAnimationFrame(updateDotPosition);
- };
+ // 启动动画
+ updateDotPosition()
- // 启动动画
- updateDotPosition();
+ // 清理函数
+ return () => {
+ document.removeEventListener('mousemove', handleMouseMove)
+ const clickableElements = document.querySelectorAll(
+ 'a, button, [role="button"], [onclick], [cursor="pointer"], [class*="hover"], [class*="group-hover"], [class*="cursor-pointer"]'
+ )
+ clickableElements.forEach(el => {
+ el.removeEventListener('mouseenter', handleMouseEnter)
+ el.removeEventListener('mouseleave', handleMouseLeave)
+ })
+ document.body.removeChild(dot)
+ }
+ }, [router])
- // 清理函数
- return () => {
- document.removeEventListener('mousemove', handleMouseMove);
- const clickableElements = document.querySelectorAll(
- 'a, button, [role="button"], [onclick], [cursor="pointer"], [class*="hover"], [class*="group-hover"], [class*="cursor-pointer"]'
- );
- clickableElements.forEach((el) => {
- el.removeEventListener('mouseenter', handleMouseEnter);
- el.removeEventListener('mouseleave', handleMouseLeave);
- });
- document.body.removeChild(dot);
- };
- }, [router]);
+ return (
+
+ )
+}
- .dark .cursor-dot-hover {
- border: 1px solid rgba(66, 66, 66, 0.66); /* 鼠标悬停时的深灰色边框,厚度为1px */
- }
- `}
- );
-};
-
-export default CursorDot;
\ No newline at end of file
+export default CursorDot
diff --git a/components/CusdisComponent.js b/components/CusdisComponent.js
index 148ee0c7d5c..fefe117606d 100644
--- a/components/CusdisComponent.js
+++ b/components/CusdisComponent.js
@@ -8,8 +8,14 @@ const CusdisComponent = ({ frontMatter }) => {
const router = useRouter()
const { isDarkMode, lang } = useGlobal()
const src = siteConfig('COMMENT_CUSDIS_SCRIPT_SRC')
- const i18nForCusdis = siteConfig('LANG').toLowerCase().indexOf('zh') === 0 ? siteConfig('LANG').toLowerCase() : siteConfig('LANG').toLowerCase().substring(0, 2)
- const langCDN = siteConfig('COMMENT_CUSDIS_LANG_SRC', `https://cusdis.com/js/widget/lang/${i18nForCusdis}.js`)
+ const i18nForCusdis =
+ siteConfig('LANG').toLowerCase().indexOf('zh') === 0
+ ? siteConfig('LANG').toLowerCase()
+ : siteConfig('LANG').toLowerCase().substring(0, 2)
+ const langCDN = siteConfig(
+ 'COMMENT_CUSDIS_LANG_SRC',
+ `https://cusdis.com/js/widget/lang/${i18nForCusdis}.js`
+ )
// 处理cusdis主题
useEffect(() => {
@@ -23,15 +29,17 @@ const CusdisComponent = ({ frontMatter }) => {
window?.CUSDIS?.initial()
}
- return
+ return (
+
+ )
}
export default CusdisComponent
diff --git a/components/CustomContextMenu.js b/components/CustomContextMenu.js
index 19b65395f1d..bd4c6a5c275 100644
--- a/components/CustomContextMenu.js
+++ b/components/CustomContextMenu.js
@@ -117,13 +117,17 @@ export default function CustomContextMenu(props) {
function handleCopy() {
const selectedText = document.getSelection().toString()
if (selectedText) {
- const tempInput = document.createElement('input');
- tempInput.value = selectedText;
- document.body.appendChild(tempInput);
- tempInput.select();
- document.execCommand('copy');
- if (tempInput && tempInput.parentNode && tempInput.parentNode.contains(tempInput)) {
- tempInput.parentNode.removeChild(tempInput);
+ const tempInput = document.createElement('input')
+ tempInput.value = selectedText
+ document.body.appendChild(tempInput)
+ tempInput.select()
+ document.execCommand('copy')
+ if (
+ tempInput &&
+ tempInput.parentNode &&
+ tempInput.parentNode.contains(tempInput)
+ ) {
+ tempInput.parentNode.removeChild(tempInput)
}
// alert("Text copied: " + selectedText);
} else {
diff --git a/components/DifyChatbot.js b/components/DifyChatbot.js
index 6190c58bd23..eea1e2d5f25 100644
--- a/components/DifyChatbot.js
+++ b/components/DifyChatbot.js
@@ -1,34 +1,40 @@
-import { useEffect } from 'react';
-import { siteConfig } from '@/lib/config';
+import { useEffect } from 'react'
+import { siteConfig } from '@/lib/config'
export default function DifyChatbot() {
useEffect(() => {
// 这里使用 siteConfig() 函数调用来获取配置值
if (!siteConfig('DIFY_CHATBOT_ENABLED')) {
- return;
+ return
}
// 配置 DifyChatbot,同样需要调用 siteConfig() 获取相应的配置值
window.difyChatbotConfig = {
token: siteConfig('DIFY_CHATBOT_TOKEN'),
baseUrl: siteConfig('DIFY_CHATBOT_BASE_URL')
- };
+ }
// 加载 DifyChatbot 脚本
- const script = document.createElement('script');
- script.src = `${siteConfig('DIFY_CHATBOT_BASE_URL')}/embed.min.js`; // 注意调用 siteConfig()
- script.id = siteConfig('DIFY_CHATBOT_TOKEN'); // 注意调用 siteConfig()
- script.defer = true;
- document.body.appendChild(script);
+ const script = document.createElement('script')
+ script.src = `${siteConfig('DIFY_CHATBOT_BASE_URL')}/embed.min.js` // 注意调用 siteConfig()
+ script.id = siteConfig('DIFY_CHATBOT_TOKEN') // 注意调用 siteConfig()
+ script.defer = true
+ document.body.appendChild(script)
return () => {
// 在组件卸载时清理 script 标签
- const existingScript = document.getElementById(siteConfig('DIFY_CHATBOT_TOKEN')); // 注意调用 siteConfig()
- if (existingScript && existingScript.parentNode && existingScript.parentNode.contains(existingScript)) {
- existingScript.parentNode.removeChild(existingScript);
+ const existingScript = document.getElementById(
+ siteConfig('DIFY_CHATBOT_TOKEN')
+ ) // 注意调用 siteConfig()
+ if (
+ existingScript &&
+ existingScript.parentNode &&
+ existingScript.parentNode.contains(existingScript)
+ ) {
+ existingScript.parentNode.removeChild(existingScript)
}
- };
- }, []); // 注意依赖数组为空,意味着脚本将仅在加载页面时执行一次
+ }
+ }, []) // 注意依赖数组为空,意味着脚本将仅在加载页面时执行一次
- return null;
+ return null
}
diff --git a/components/Equation.js b/components/Equation.js
index 86685d625f6..a053b857134 100644
--- a/components/Equation.js
+++ b/components/Equation.js
@@ -13,7 +13,13 @@ const katexSettings = {
* @param {} param0
* @returns
*/
-export const Equation = ({ block, math, inline = false, className, ...rest }) => {
+export const Equation = ({
+ block,
+ math,
+ inline = false,
+ className,
+ ...rest
+}) => {
math = math || getBlockTitle(block, null)
if (!math) return null
@@ -21,8 +27,7 @@ export const Equation = ({ block, math, inline = false, className, ...rest }) =>
+ className={`notion-equation ${inline ? 'notion-equation-inline' : 'notion-equation-block'}`}>