forked from Gitlink/gitlink_help_center
Merge pull request '新增功能 去到底部' (#22) from chenxiaofu into master
This commit is contained in:
commit
96189f3096
|
|
@ -97,6 +97,10 @@ module.exports = {
|
|||
type: 'custom-back-to-top',
|
||||
position: 'right'
|
||||
},
|
||||
{
|
||||
type: 'custom-back-to-bottom',
|
||||
position: 'right'
|
||||
},
|
||||
{
|
||||
type: 'custom-qa-button',
|
||||
position: 'right'
|
||||
|
|
|
|||
|
|
@ -0,0 +1,39 @@
|
|||
import React from 'react';
|
||||
import BrowserOnly from '@docusaurus/BrowserOnly';
|
||||
|
||||
function BackToBottomButton() {
|
||||
const handleBackToBottom = () => {
|
||||
window.scrollTo({
|
||||
top: document.documentElement.scrollHeight,
|
||||
behavior: 'smooth'
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<button
|
||||
onClick={handleBackToBottom}
|
||||
style={{
|
||||
fontSize: 14,
|
||||
padding: '0 16px',
|
||||
background: '#466aff',
|
||||
color: '#fff',
|
||||
borderRadius: 4,
|
||||
height: 32,
|
||||
lineHeight: '32px',
|
||||
border: 'none',
|
||||
cursor: 'pointer',
|
||||
display: 'inline-block',
|
||||
marginLeft: 12,
|
||||
boxSizing: 'border-box',
|
||||
}}
|
||||
>
|
||||
去到底部
|
||||
</button>
|
||||
);
|
||||
}
|
||||
|
||||
export default function BackToBottomNavbarItem() {
|
||||
return (
|
||||
<BrowserOnly>{() => <BackToBottomButton />}</BrowserOnly>
|
||||
);
|
||||
}
|
||||
|
|
@ -9,6 +9,7 @@ import SearchNavbarItem from '@theme/NavbarItem/SearchNavbarItem';
|
|||
|
||||
import PdfExportNavbarItem from '../../components/PdfExportNavbarItem';
|
||||
import PdfBackToTopNavbarItem from '../../components/PdfBackToTopNavbarItem';
|
||||
import BackToBottomNavbarItem from '../../components/BackToBottomNavbarItem';
|
||||
import QAButtonNavbarItem from '../../components/QAButtonNavbarItem';
|
||||
import TableOfContentsNavbarItem from '../../components/TableOfContentsNavbarItem';
|
||||
|
||||
|
|
@ -23,6 +24,7 @@ const ComponentTypes = {
|
|||
docSidebar: DocSidebarNavbarItem,
|
||||
'custom-pdf-export': PdfExportNavbarItem,
|
||||
'custom-back-to-top': PdfBackToTopNavbarItem,
|
||||
'custom-back-to-bottom': BackToBottomNavbarItem,
|
||||
'custom-qa-button': QAButtonNavbarItem,
|
||||
'custom-table-of-contents': TableOfContentsNavbarItem,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import React from 'react';
|
|||
import NavbarItem from '@theme-original/NavbarItem';
|
||||
import PdfExportNavbarItem from '../../components/PdfExportNavbarItem';
|
||||
import PdfBackToTopNavbarItem from '../../components/PdfBackToTopNavbarItem';
|
||||
import BackToBottomNavbarItem from '../../components/BackToBottomNavbarItem';
|
||||
import QAButtonNavbarItem from '../../components/QAButtonNavbarItem';
|
||||
|
||||
export default function NavbarItemWrapper(props) {
|
||||
|
|
@ -11,6 +12,9 @@ export default function NavbarItemWrapper(props) {
|
|||
if (props.type === 'custom-back-to-top') {
|
||||
return <PdfBackToTopNavbarItem />;
|
||||
}
|
||||
if (props.type === 'custom-back-to-bottom') {
|
||||
return <BackToBottomNavbarItem />;
|
||||
}
|
||||
if (props.type === 'custom-qa-button') {
|
||||
return <QAButtonNavbarItem />;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue