diff --git a/blog.config.js b/blog.config.js
index ad68ee11..e9c2f96a 100644
--- a/blog.config.js
+++ b/blog.config.js
@@ -28,8 +28,8 @@ const BLOG = {
FONT_STYLE: process.env.NEXT_PUBLIC_FONT_STYLE || 'font-serif', // ['font-serif','font-sans'] 两种可选,分别是衬线和无衬线: 参考 https://www.jianshu.com/p/55e410bd2115
FONT_URL: [// 字体CSS 例如 https://npm.elemecdn.com/lxgw-wenkai-webfont@1.6.0/style.css
'https://fonts.googleapis.com/css?family=Bitter&display=swap',
- 'https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@500&display=swap',
- 'https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@500&display=swap'
+ 'https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@300&display=swap',
+ 'https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@300&display=swap'
],
FONT_SANS: [// 无衬线字体 例如'LXGW WenKai'
'Bitter', '"PingFang SC"', '-apple-system', 'BlinkMacSystemFont', '"Hiragino Sans GB"',
@@ -111,7 +111,7 @@ const BLOG = {
MUSIC_PLAYER: process.env.NEXT_PUBLIC_MUSIC_PLAYER || false, // 是否使用音乐播放插件
MUSIC_PLAYER_VISIBLE: process.env.NEXT_PUBLIC_MUSIC_PLAYER_VISIBLE || true, // 是否在左下角显示播放和切换,如果使用播放器,打开自动播放再隐藏,就会以类似背景音乐的方式播放,无法取消和暂停
MUSIC_PLAYER_AUTO_PLAY: process.env.NEXT_PUBLIC_MUSIC_PLAYER_AUTO_PLAY || true, // 是否自动播放,不过自动播放时常不生效(移动设备不支持自动播放)
- MUSIC_PLAYER_SHOW_LRC: process.env.NEXT_PUBLIC_MUSIC_PLAYER_SHOW_LRC || false, // 是否展示歌词(前提是有配置歌词路径,对 meting 无效)
+ MUSIC_PLAYER_LRC_TYPE: process.env.NEXT_PUBLIC_MUSIC_PLAYER_LRC_TYPE || '0', // 歌词显示类型,可选值: 3 | 1 | 0(0:禁用 lrc 歌词,1:lrc 格式的字符串,3:lrc 文件 url)(前提是有配置歌词路径,对 meting 无效)
MUSIC_PLAYER_CDN_URL: process.env.NEXT_PUBLIC_MUSIC_PLAYER_CDN_URL || 'https://lf9-cdn-tos.bytecdntp.com/cdn/expire-1-M/aplayer/1.10.1/APlayer.min.js',
MUSIC_PLAYER_ORDER: process.env.NEXT_PUBLIC_MUSIC_PLAYER_ORDER || 'list', // 默认播放方式,顺序 list,随机 random
MUSIC_PLAYER_AUDIO_LIST: [ // 示例音乐列表。除了以下配置外,还可配置歌词,具体配置项看此文档 https://aplayer.js.org/#/zh-Hans/
diff --git a/components/Collapse.js b/components/Collapse.js
index a787bfa2..99629604 100644
--- a/components/Collapse.js
+++ b/components/Collapse.js
@@ -1,4 +1,4 @@
-import React from 'react'
+import React, { useEffect, useImperativeHandle } from 'react'
/**
* 折叠面板组件,支持水平折叠、垂直折叠
@@ -6,12 +6,27 @@ import React from 'react'
* @returns
*/
const Collapse = props => {
- const collapseRef = React.useRef(null)
+ const { collapseRef } = props
+ const ref = React.useRef(null)
const type = props.type || 'vertical'
+
+ useImperativeHandle(collapseRef, () => {
+ return {
+ /**
+ * 当子元素高度变化时,可调用此方法更新折叠组件的高度
+ * @param {*} param0
+ */
+ updateCollapseHeight: ({ height, increase }) => {
+ ref.current.style.height = ref.current.scrollHeight
+ ref.current.style.height = 'auto'
+ }
+ }
+ })
+
/**
- * 折叠
- * @param {*} element
- */
+ * 折叠
+ * @param {*} element
+ */
const collapseSection = element => {
const sectionHeight = element.scrollHeight
const sectionWidth = element.scrollWidth
@@ -34,9 +49,9 @@ const Collapse = props => {
}
/**
- * 展开
- * @param {*} element
- */
+ * 展开
+ * @param {*} element
+ */
const expandSection = element => {
const sectionHeight = element.scrollHeight
const sectionWidth = element.scrollWidth
@@ -58,22 +73,20 @@ const Collapse = props => {
clearTimeout(clearTime)
}
- const updateHeight = () => {
- collapseRef.current.style.height = 'auto'
- }
-
- React.useEffect(() => {
+ useEffect(() => {
if (props.isOpen) {
- expandSection(collapseRef.current)
+ expandSection(ref.current)
} else {
- collapseSection(collapseRef.current)
+ collapseSection(ref.current)
}
+ // 通知父组件高度变化
+ props?.onHeightChange && props.onHeightChange({ height: ref.current.scrollHeight, increase: props.isOpen })
}, [props.isOpen])
return (
-
+ return
diff --git a/components/FlutteringRibbon.js b/components/FlutteringRibbon.js
index a615d533..301fbd23 100644
--- a/components/FlutteringRibbon.js
+++ b/components/FlutteringRibbon.js
@@ -1,10 +1,21 @@
/* eslint-disable */
import React from 'react'
-
+const id = 'canvasFlutteringRibbon'
export const FlutteringRibbon = () => {
+ const destroyRibbon = ()=>{
+ const ribbon = document.getElementById(id)
+ if(ribbon && ribbon.parentNode){
+ ribbon.parentNode.removeChild(ribbon)
+ }
+ }
+
React.useEffect(() => {
createFlutteringRibbon()
+ return () => destroyRibbon()
+
}, [])
+ return <>>
+
}
/**
@@ -125,6 +136,7 @@ function createFlutteringRibbon() {
init: function () {
try {
;(this._canvas = document.createElement('canvas')),
+ (this._canvas.id = id),
(this._canvas.style.display = 'block'),
(this._canvas.style.position = 'fixed'),
(this._canvas.style.margin = '0'),
diff --git a/components/Nest.js b/components/Nest.js
index 781cb2bf..74fa85e3 100644
--- a/components/Nest.js
+++ b/components/Nest.js
@@ -1,10 +1,19 @@
/* eslint-disable */
-import React from 'react'
-
+import { useEffect } from 'react'
+const id = 'canvasNestCreated'
export const Nest = () => {
- React.useEffect(() => {
+ const destroyNest = ()=>{
+ const nest = document.getElementById(id)
+ if(nest && nest.parentNode){
+ nest.parentNode.removeChild(nest)
+ }
+ }
+
+ useEffect(() => {
createNest()
+ return () => destroyNest()
}, [])
+ return <>>
}
/**
@@ -65,7 +74,7 @@ function createNest() {
m(o)
}
var i = document.createElement('canvas')
- i.id = 'canvasNestCreated'
+ i.id = id
var a = (function () {
const t = e
return {
diff --git a/components/NotionPage.js b/components/NotionPage.js
index abb8586e..85b5573e 100644
--- a/components/NotionPage.js
+++ b/components/NotionPage.js
@@ -1,7 +1,7 @@
import { NotionRenderer } from 'react-notion-x'
import dynamic from 'next/dynamic'
-import mediumZoom from '@fisch0920/medium-zoom'
-import React from 'react'
+// import mediumZoom from '@fisch0920/medium-zoom'
+import React, { useEffect } from 'react'
import { isBrowser } from '@/lib/utils'
import { Code } from 'react-notion-x/build/third-party/code'
import TweetEmbed from 'react-tweet-embed'
@@ -42,16 +42,16 @@ const Tweet = ({ id }) => {
}
const NotionPage = ({ post, className }) => {
- const zoom = isBrowser() && mediumZoom({
- container: '.notion-viewport',
- background: 'rgba(0, 0, 0, 0.2)',
- scrollOffset: 200,
- margin: getMediumZoomMargin()
- })
+// const zoom = isBrowser() && mediumZoom({
+// container: '.notion-viewport',
+// background: 'rgba(0, 0, 0, 0.2)',
+// scrollOffset: 200,
+// margin: getMediumZoomMargin()
+// })
- const zoomRef = React.useRef(zoom ? zoom.clone() : null)
+ // const zoomRef = React.useRef(zoom ? zoom.clone() : null)
- React.useEffect(() => {
+ useEffect(() => {
setTimeout(() => {
if (window.location.hash) {
const tocNode = document.getElementById(window.location.hash.substring(1))
@@ -64,18 +64,18 @@ const NotionPage = ({ post, className }) => {
setTimeout(() => {
if (isBrowser()) {
// 将相册gallery下的图片加入放大功能
- const imgList = document.querySelectorAll('.notion-collection-card-cover img')
- if (imgList && zoomRef.current) {
- for (let i = 0; i < imgList.length; i++) {
- (zoomRef.current).attach(imgList[i])
- }
- }
+ // const imgList = document.querySelectorAll('.notion-collection-card-cover img')
+ // if (imgList && zoomRef.current) {
+ // for (let i = 0; i < imgList.length; i++) {
+ // (zoomRef.current).attach(imgList[i])
+ // }
+ // }
- // 相册图片点击不跳转
- const cards = document.getElementsByClassName('notion-collection-card')
- for (const e of cards) {
- e.removeAttribute('href')
- }
+ // 相册图片禁止跳转页面,改为放大图片功能功能
+ // const cards = document.getElementsByClassName('notion-collection-card')
+ // for (const e of cards) {
+ // e.removeAttribute('href')
+ // }
}
}, 800)
}, [])
@@ -84,7 +84,7 @@ const NotionPage = ({ post, className }) => {
return <>{post?.summary || ''}>
}
- return
+ return
{
return '/' + id.replace(/-/g, '')
}
-function getMediumZoomMargin() {
- const width = window.innerWidth
+// function getMediumZoomMargin() {
+// const width = window.innerWidth
- if (width < 500) {
- return 8
- } else if (width < 800) {
- return 20
- } else if (width < 1280) {
- return 30
- } else if (width < 1600) {
- return 40
- } else if (width < 1920) {
- return 48
- } else {
- return 72
- }
-}
+// if (width < 500) {
+// return 8
+// } else if (width < 800) {
+// return 20
+// } else if (width < 1280) {
+// return 30
+// } else if (width < 1600) {
+// return 40
+// } else if (width < 1920) {
+// return 48
+// } else {
+// return 72
+// }
+// }
export default NotionPage
diff --git a/components/Player.js b/components/Player.js
index ec0ea461..98da72c3 100644
--- a/components/Player.js
+++ b/components/Player.js
@@ -5,7 +5,7 @@ const Player = () => {
const [player, setPlayer] = React.useState()
const ref = React.useRef(null)
- const showLrc = JSON.parse(BLOG.MUSIC_PLAYER_SHOW_LRC)
+ const lrcType = JSON.parse(BLOG.MUSIC_PLAYER_LRC_TYPE)
const playerVisible = JSON.parse(BLOG.MUSIC_PLAYER_VISIBLE)
const autoPlay = JSON.parse(BLOG.MUSIC_PLAYER_AUTO_PLAY)
@@ -16,7 +16,7 @@ const Player = () => {
setPlayer(new window.APlayer({
container: ref.current,
fixed: true,
- showlrc: showLrc,
+ lrcType: lrcType,
autoplay: autoPlay,
order: BLOG.MUSIC_PLAYER_ORDER,
audio: BLOG.MUSIC_PLAYER_AUDIO_LIST
diff --git a/components/Ribbon.js b/components/Ribbon.js
index d96e3591..2c6855fc 100644
--- a/components/Ribbon.js
+++ b/components/Ribbon.js
@@ -1,10 +1,20 @@
/* eslint-disable */
-import React from 'react'
+import { useEffect } from 'react'
+const id = 'canvasRibbon'
export const Ribbon = () => {
- React.useEffect(() => {
+ const destroyRibbon = ()=>{
+ const ribbon = document.getElementById(id)
+ if(ribbon && ribbon.parentNode){
+ ribbon.parentNode.removeChild(ribbon)
+ }
+ }
+
+ useEffect(() => {
createRibbon()
+ return () => destroyRibbon()
}, [])
+ return <>>
}
/**
@@ -29,6 +39,7 @@ function createRibbon() {
a = window.innerWidth,
l = window.innerHeight,
d = e.s
+ i.id= id
let r, s
const u = Math
let h = 0
diff --git a/components/Sakura.js b/components/Sakura.js
index 3f69cc25..7898b3cc 100644
--- a/components/Sakura.js
+++ b/components/Sakura.js
@@ -1,10 +1,19 @@
/* eslint-disable */
-import React from 'react'
-
+import { useEffect } from 'react'
+const id = 'canvas_sakura'
export const Sakura = () => {
- React.useEffect(() => {
+ const destroySakura = ()=>{
+ const sakura = document.getElementById(id)
+ if(sakura && sakura.parentNode){
+ sakura.parentNode.removeChild(sakura)
+ }
+ }
+
+ useEffect(() => {
createSakura({})
+ return () => destroySakura()
}, [])
+ return <>>
}
/**
@@ -129,7 +138,7 @@ function createSakura() {
'style',
'position: fixed;left: 0;top: 0;pointer-events: none;'
)
- canvas.setAttribute('id', 'canvas_sakura')
+ canvas.setAttribute('id', id)
document.getElementsByTagName('body')[0].appendChild(canvas)
cxt = canvas.getContext('2d')
var sakuraList = new SakuraList()
@@ -165,15 +174,12 @@ function createSakura() {
stop = requestAnimationFrame(asd)
}
}
- window.onresize = function () {
- var canvasSnow = document.getElementById('canvas_snow')
- }
img.onload = function () {
startSakura()
}
function stopp() {
if (staticx) {
- var child = document.getElementById('canvas_sakura')
+ var child = document.getElementById(id)
child.parentNode.removeChild(child)
window.cancelAnimationFrame(stop)
staticx = false
diff --git a/components/SideBarDrawer.js b/components/SideBarDrawer.js
index 47052db9..0db865cb 100644
--- a/components/SideBarDrawer.js
+++ b/components/SideBarDrawer.js
@@ -1,5 +1,5 @@
import { useRouter } from 'next/router'
-import React from 'react'
+import { useEffect } from 'react'
/**
* 侧边栏抽屉面板,可以从侧面拉出
@@ -8,7 +8,7 @@ import React from 'react'
*/
const SideBarDrawer = ({ children, isOpen, onOpen, onClose, className }) => {
const router = useRouter()
- React.useEffect(() => {
+ useEffect(() => {
const sideBarDrawerRouteListener = () => {
switchSideDrawerVisible(false)
}
@@ -37,8 +37,8 @@ const SideBarDrawer = ({ children, isOpen, onOpen, onClose, className }) => {
}
}
- return