Skip to content

Commit

Permalink
magzine - 移动端菜单OpenWrite限制
Browse files Browse the repository at this point in the history
  • Loading branch information
tangly1024 committed Sep 18, 2024
1 parent 7476b6d commit ea4daca
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
3 changes: 2 additions & 1 deletion components/OpenWrite.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,14 @@ const OpenWrite = () => {
return
}
if (isBrowser && blogId) {
toggleTocItems(true) // 禁止目录项的点击

// Check if the element with id 'read-more-wrap' already exists
const readMoreWrap = document.getElementById('read-more-wrap')

// Only load the script if the element doesn't exist
if (!readMoreWrap) {
loadOpenWrite()
toggleTocItems(true) // 禁止目录项的点击
}
}
})
Expand Down
6 changes: 3 additions & 3 deletions themes/magzine/components/Catalog.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,22 +70,22 @@ const Catalog = ({ toc, className }) => {
<div
className='overflow-y-auto scroll-hidden lg:max-h-dvh max-h-44'
ref={tRef}>
<nav className='h-full text-black'>
<nav className='h-full text-black'>
{toc.map(tocItem => {
const id = uuidToId(tocItem.id)
tocIds.push(id)
return (
<a
key={id}
href={`#${id}`}
className={`notion-table-of-contents-item duration-300 transform dark:text-gray-300
className={`notion-table-of-contents-item duration-300 transform dark:text-gray-400
notion-table-of-contents-item-indent-level-${tocItem.indentLevel} `}>
<span
style={{
display: 'inline-block',
marginLeft: tocItem.indentLevel * 16
}}
className={`truncate ${activeSection === id ? 'font-bold text-gray-500 underline' : ''}`}>
className={`truncate ${activeSection === id ? 'font-bold text-gray-500 dark:text-white underline' : ''}`}>
{tocItem.text}
</span>
</a>
Expand Down
14 changes: 7 additions & 7 deletions themes/magzine/components/Progress.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useEffect, useState } from 'react'
import { isBrowser } from '@/lib/utils'
import { useEffect, useState } from 'react'

/**
* 顶部页面阅读进度条
Expand All @@ -10,7 +10,8 @@ const Progress = ({ targetRef, showPercent = true }) => {
const currentRef = targetRef?.current || targetRef
const [percent, changePercent] = useState(0)
const scrollListener = () => {
const target = currentRef || (isBrowser && document.getElementById('article-wrapper'))
const target =
currentRef || (isBrowser && document.getElementById('article-wrapper'))
if (target) {
const clientHeight = target.clientHeight
const scrollY = window.pageYOffset
Expand All @@ -28,13 +29,12 @@ const Progress = ({ targetRef, showPercent = true }) => {
}, [])

return (
<div className="h-4 w-full shadow-2xl bg-hexo-light-gray dark:bg-black">
<div className='h-4 w-full shadow-2xl bg-hexo-light-gray dark:bg-black'>
<div
className="h-4 bg-gray-600 duration-200"
style={{ width: `${percent}%` }}
>
className='h-4 bg-gray-600 dark:bg-hexo-black-gray duration-200'
style={{ width: `${percent}%` }}>
{showPercent && (
<div className="text-right text-white text-xs">{percent}%</div>
<div className='text-right text-white text-xs'>{percent}%</div>
)}
</div>
</div>
Expand Down

0 comments on commit ea4daca

Please sign in to comment.