Skip to content

Commit 6c03068

Browse files
committed
gitbook主题变量名调整
1 parent 8c25823 commit 6c03068

File tree

5 files changed

+477
-334
lines changed

5 files changed

+477
-334
lines changed

themes/gitbook/components/ArticleLock.js

+22-13
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { useEffect, useRef } from 'react'
1111
export const ArticleLock = props => {
1212
const { validPassword } = props
1313
const { locale } = useGlobal()
14+
console.log('locale', locale)
1415

1516
const submitPassword = () => {
1617
const p = document.getElementById('password')
@@ -29,25 +30,33 @@ export const ArticleLock = props => {
2930
passwordInputRef.current.focus()
3031
}, [])
3132

32-
return <div id='container' className='w-full flex justify-center items-center h-96 '>
33-
<div className='text-center space-y-3'>
34-
<div className='font-bold'>{locale.COMMON.ARTICLE_LOCK_TIPS}</div>
35-
<div className='flex mx-4'>
36-
<input id="password" type='password'
37-
onKeyDown={(e) => {
33+
return (
34+
<div
35+
id='container'
36+
className='w-full flex justify-center items-center h-96 '>
37+
<div className='text-center space-y-3'>
38+
<div className='font-bold'>{locale.COMMON.ARTICLE_LOCK_TIPS}</div>
39+
<div className='flex mx-4'>
40+
<input
41+
id='password'
42+
type='password'
43+
onKeyDown={e => {
3844
if (e.key === 'Enter') {
3945
submitPassword()
4046
}
4147
}}
4248
ref={passwordInputRef} // 绑定ref到passwordInputRef变量
43-
className='outline-none w-full text-sm pl-5 rounded-l transition focus:shadow-lg dark:text-gray-300 font-light leading-10 text-black bg-gray-100 dark:bg-gray-500'>
44-
</input>
45-
<div onClick={submitPassword} className="px-3 whitespace-nowrap cursor-pointer items-center justify-center py-2 bg-green-500 hover:bg-green-400 text-white rounded-r duration-300" >
46-
<i className={'duration-200 cursor-pointer fas fa-key'} >&nbsp;{locale.COMMON.SUBMIT}</i>
49+
className='outline-none w-full text-sm pl-5 rounded-l transition focus:shadow-lg dark:text-gray-300 font-light leading-10 text-black bg-gray-100 dark:bg-gray-500'></input>
50+
<div
51+
onClick={submitPassword}
52+
className='px-3 whitespace-nowrap cursor-pointer items-center justify-center py-2 bg-green-500 hover:bg-green-400 text-white rounded-r duration-300'>
53+
<i className={'duration-200 cursor-pointer fas fa-key'}>
54+
&nbsp;{locale.COMMON.SUBMIT}
55+
</i>
56+
</div>
4757
</div>
48-
</div>
49-
<div id='tips'>
58+
<div id='tips'></div>
5059
</div>
5160
</div>
52-
</div>
61+
)
5362
}

themes/gitbook/components/Header.js

+109
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
import Collapse from '@/components/Collapse'
2+
import DarkModeButton from '@/components/DarkModeButton'
3+
import { siteConfig } from '@/lib/config'
4+
import { useGlobal } from '@/lib/global'
5+
import { useRef, useState } from 'react'
6+
import CONFIG from '../config'
7+
import LogoBar from './LogoBar'
8+
import { MenuBarMobile } from './MenuBarMobile'
9+
import { MenuItemDrop } from './MenuItemDrop'
10+
11+
/**
12+
* 页头:顶部导航栏 + 菜单
13+
* @param {} param0
14+
* @returns
15+
*/
16+
export default function Header(props) {
17+
const { className, customNav, customMenu } = props
18+
const [isOpen, changeShow] = useState(false)
19+
const collapseRef = useRef(null)
20+
21+
const { locale } = useGlobal()
22+
23+
const defaultLinks = [
24+
{
25+
icon: 'fas fa-th',
26+
name: locale.COMMON.CATEGORY,
27+
to: '/category',
28+
show: siteConfig('GITBOOK_MENU_CATEGORY', null, CONFIG)
29+
},
30+
{
31+
icon: 'fas fa-tag',
32+
name: locale.COMMON.TAGS,
33+
to: '/tag',
34+
show: siteConfig('GITBOOK_BOOK_MENU_TAG', null, CONFIG)
35+
},
36+
{
37+
icon: 'fas fa-archive',
38+
name: locale.NAV.ARCHIVE,
39+
to: '/archive',
40+
show: siteConfig('GITBOOK_MENU_ARCHIVE', null, CONFIG)
41+
},
42+
{
43+
icon: 'fas fa-search',
44+
name: locale.NAV.SEARCH,
45+
to: '/search',
46+
show: siteConfig('GITBOOK_MENU_SEARCH', null, CONFIG)
47+
}
48+
]
49+
50+
let links = defaultLinks.concat(customNav)
51+
52+
const toggleMenuOpen = () => {
53+
changeShow(!isOpen)
54+
}
55+
56+
// 如果 开启自定义菜单,则覆盖Page生成的菜单
57+
if (siteConfig('CUSTOM_MENU')) {
58+
links = customMenu
59+
}
60+
61+
return (
62+
<div id='top-nav' className={'fixed top-0 w-full z-20 ' + className}>
63+
{/* 移动端折叠菜单 */}
64+
<Collapse
65+
type='vertical'
66+
collapseRef={collapseRef}
67+
isOpen={isOpen}
68+
className='md:hidden'>
69+
<div className='bg-white dark:bg-hexo-black-gray pt-1 py-2 lg:hidden '>
70+
<MenuBarMobile
71+
{...props}
72+
onHeightChange={param =>
73+
collapseRef.current?.updateCollapseHeight(param)
74+
}
75+
/>
76+
</div>
77+
</Collapse>
78+
79+
{/* 导航栏菜单 */}
80+
<div className='flex w-full h-14 shadow glassmorphism bg-white dark:bg-hexo-black-gray px-7 items-between'>
81+
{/* 左侧图标Logo */}
82+
<LogoBar {...props} />
83+
84+
{/* 折叠按钮、仅移动端显示 */}
85+
<div className='mr-1 flex md:hidden justify-end items-center space-x-4 dark:text-gray-200'>
86+
<DarkModeButton className='flex text-md items-center h-full' />
87+
<div
88+
onClick={toggleMenuOpen}
89+
className='cursor-pointer text-lg hover:scale-110 duration-150'>
90+
{isOpen ? (
91+
<i className='fas fa-times' />
92+
) : (
93+
<i className='fa-solid fa-ellipsis-vertical' />
94+
)}
95+
</div>
96+
</div>
97+
98+
{/* 桌面端顶部菜单 */}
99+
<div className='hidden md:flex'>
100+
{links &&
101+
links?.map((link, index) => (
102+
<MenuItemDrop key={index} link={link} />
103+
))}
104+
<DarkModeButton className='text-sm flex items-center h-full' />
105+
</div>
106+
</div>
107+
</div>
108+
)
109+
}

themes/gitbook/components/LogoBar.js

+21-10
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import LazyImage from '@/components/LazyImage'
2+
import { siteConfig } from '@/lib/config'
23
import { useGitBookGlobal } from '@/themes/gitbook'
34
import Link from 'next/link'
4-
import { siteConfig } from '@/lib/config'
55
import CONFIG from '../config'
66

77
/**
@@ -17,14 +17,25 @@ export default function LogoBar(props) {
1717
changePageNavVisible(!pageNavVisible)
1818
}
1919
return (
20-
<div id='top-wrapper' className='w-full flex items-center'>
21-
<div onClick={togglePageNavVisible} className='cursor-pointer md:hidden text-xl pr-3 hover:scale-110 duration-150'>
22-
<i className={`fa-solid ${pageNavVisible ? 'fa-align-justify' : 'fa-indent'}`}></i>
23-
</div>
24-
<Link href={`/${siteConfig('GITBOOK_INDEX_PAGE', '', CONFIG)}`} className='flex text-md md:text-xl dark:text-gray-200'>
25-
<LazyImage src={siteInfo?.icon} width={24} height={24} alt={siteConfig('AUTHOR')} className='mr-2 hidden md:block' />
26-
{siteConfig('TITLE')}
27-
</Link>
28-
</div>
20+
<div id='top-wrapper' className='w-full flex items-center'>
21+
<div
22+
onClick={togglePageNavVisible}
23+
className='cursor-pointer md:hidden text-xl pr-3 hover:scale-110 duration-150'>
24+
<i
25+
className={`fa-solid ${pageNavVisible ? 'fa-align-justify' : 'fa-indent'}`}></i>
26+
</div>
27+
<Link
28+
href={`/${siteConfig('GITBOOK_INDEX_PAGE', '', CONFIG)}`}
29+
className='flex text-md md:text-xl dark:text-gray-200'>
30+
<LazyImage
31+
src={siteInfo?.icon}
32+
width={24}
33+
height={24}
34+
alt={siteConfig('AUTHOR')}
35+
className='mr-2 hidden md:block'
36+
/>
37+
{siteInfo?.title || siteConfig('TITLE')}
38+
</Link>
39+
</div>
2940
)
3041
}

themes/gitbook/components/TopNavBar.js

-73
This file was deleted.

0 commit comments

Comments
 (0)