Skip to content

Commit

Permalink
修复 Client异常
Browse files Browse the repository at this point in the history
  • Loading branch information
tangly1024 committed Nov 19, 2022
1 parent 3f6079e commit ba9794e
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 26 deletions.
49 changes: 27 additions & 22 deletions components/PrismMac.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,37 +40,42 @@ function renderPrismMac() {
const container = document?.getElementById('container-inner')
const codeToolBars = container?.getElementsByClassName('code-toolbar')

Array.from(codeToolBars).forEach(item => {
const codeBlocks = item.getElementsByTagName('pre')
if (codeBlocks.length === 0) {
item.remove()
}
})

if (codeToolBars) {
Array.from(codeToolBars).forEach(item => {
const codeBlocks = item.getElementsByTagName('pre')
if (codeBlocks.length === 0) {
item.remove()
}
})
}
// 重新渲染之前检查所有的多余text

try {
Prism.highlightAll()
// Add line numbers
const codeBlocks = container?.getElementsByTagName('pre')
Array.from(codeBlocks).forEach(item => {
if (!item.classList.contains('line-numbers')) {
item.classList.add('line-numbers')
item.style.whiteSpace = 'pre-wrap'
}
})
if (codeBlocks) {
Array.from(codeBlocks).forEach(item => {
if (!item.classList.contains('line-numbers')) {
item.classList.add('line-numbers')
item.style.whiteSpace = 'pre-wrap'
}
})
}

setTimeout(() => {
// Add pre-mac element for Mac Style UI
Array.from(codeToolBars).forEach(item => {
const existPreMac = item.getElementsByClassName('pre-mac')
if (existPreMac.length < codeToolBars.length) {
const preMac = document.createElement('div')
preMac.classList.add('pre-mac')
preMac.innerHTML = '<span></span><span></span><span></span>'
item?.appendChild(preMac, item)
}
})
if (codeToolBars) {
Array.from(codeToolBars).forEach(item => {
const existPreMac = item.getElementsByClassName('pre-mac')
if (existPreMac.length < codeToolBars.length) {
const preMac = document.createElement('div')
preMac.classList.add('pre-mac')
preMac.innerHTML = '<span></span><span></span><span></span>'
item?.appendChild(preMac, item)
}
})
}
}, 0)
} catch (err) {
console.log('代码渲染', err)
Expand Down
2 changes: 1 addition & 1 deletion themes/example/LayoutBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const LayoutBase = props => {
<Nav {...props} />

{/* 主体 */}
<div className="w-full">
<div id='container-inner' className="w-full">

<Title {...props} />

Expand Down
2 changes: 1 addition & 1 deletion themes/fukasawa/LayoutBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const LayoutBase = (props) => {
<div className='flex'>
<AsideLeft {...props} slot={leftAreaSlot}/>
<main id='wrapper' className='flex w-full py-8 justify-center'>
<div className='2xl:max-w-6xl md:max-w-4xl w-full'>
<div id='container-inner' className='2xl:max-w-6xl md:max-w-4xl w-full'>
<div> {headerSlot} </div>
<div>{children}</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion themes/medium/LayoutBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const LayoutBase = props => {
{/* 桌面端左侧菜单 */}
{/* <LeftMenuBar/> */}

<div className='w-full'>
<div id='container-inner' className='w-full'>
{/* 移动端顶部菜单 */}
<TopNavBar {...props}/>
<div className='px-5 max-w-5xl justify-center mx-auto min-h-screen'>
Expand Down
2 changes: 1 addition & 1 deletion themes/next/LayoutBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const LayoutBase = (props) => {

<main id='wrapper' className='flex justify-center flex-1 pb-12'>
<SideAreaLeft slot={leftAreaSlot} targetRef={targetRef} {...props}/>
<section id='center' className={`${CONFIG_NEXT.NAV_TYPE !== 'normal' ? 'mt-40' : ''} lg:max-w-3xl xl:max-w-4xl flex-grow md:mt-0 min-h-screen w-full`} ref={targetRef}>
<section id='container-inner' className={`${CONFIG_NEXT.NAV_TYPE !== 'normal' ? 'mt-40' : ''} lg:max-w-3xl xl:max-w-4xl flex-grow md:mt-0 min-h-screen w-full`} ref={targetRef}>
{onLoading ? <LoadingCover/> : <> {children}</> }
</section>
{/* 右侧栏样式 */}
Expand Down

0 comments on commit ba9794e

Please sign in to comment.