Skip to content

Commit a461ee5

Browse files
committed
fix: header bug
1 parent 119f234 commit a461ee5

File tree

9 files changed

+39
-27
lines changed

9 files changed

+39
-27
lines changed

public/locales/en/periodical.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
"order_t7": "Projects",
1616
"order_t8": "Items",
1717
"order_t9": "Welcome to recommend",
18+
"vol_prev": "Previous",
19+
"vol_next": "Next",
1820
"page_prev": "Previous",
1921
"page_next": "Next",
2022
"category": {

public/locales/zh/periodical.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
"order_t7": "项目数",
1616
"order_t8": "",
1717
"order_t9": "欢迎推荐和自荐项目",
18+
"vol_prev": "上一期",
19+
"vol_next": "下一期",
1820
"page_prev": "上一页",
1921
"page_next": "下一页",
2022
"category": {

src/components/ImageWithPreview.tsx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import RcImage, { ImageProps } from 'rc-image';
1+
import RcImage from 'rc-image';
22
import { useEffect, useState } from 'react';
33
import { AiOutlineClose } from 'react-icons/ai';
44

@@ -8,11 +8,13 @@ import GifPlayButton from './loading/GifPlayButton';
88

99
const gifCoverImage = '!gif';
1010

11-
const ImageWithPreview = (props: ImageProps) => {
11+
const ImageWithPreview = (props: {
12+
src: string;
13+
alt: string;
14+
[key: string]: any;
15+
}) => {
1216
const [imgSrc, setImgSrc] = useState(
13-
props.src?.endsWith('gif')
14-
? `${props.src}${gifCoverImage}`
15-
: (props.src as string)
17+
props.src?.endsWith('gif') ? `${props.src}${gifCoverImage}` : props.src
1618
);
1719
const isGifThumb = imgSrc.endsWith(gifCoverImage);
1820
const isGif = imgSrc?.endsWith('gif') && !isGifThumb;
@@ -22,11 +24,11 @@ const ImageWithPreview = (props: ImageProps) => {
2224
if (props.src?.endsWith('gif')) {
2325
setImgSrc(`${props.src}${gifCoverImage}`);
2426
} else {
25-
setImgSrc(props.src as string);
27+
setImgSrc(props.src);
2628
}
2729
}, [props.src]);
2830

29-
const handleLoadGif = (e: any) => {
31+
const handleLoadGif = (e: React.MouseEvent) => {
3032
e.stopPropagation();
3133
setTimeout(() => {
3234
if (sourceIsGif) {

src/components/buttons/HeaderBtn.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const HeaderBtn = (props: HeaderBtnProps) => {
1515

1616
return (
1717
<Button
18-
className='font-normal text-current hover:bg-transparent dark:text-gray-300 dark:hover:bg-gray-700'
18+
className='font-normal text-current hover:bg-transparent dark:hover:bg-transparent'
1919
variant='ghost'
2020
onClick={debounce(() => {
2121
router.push(pathname);

src/components/layout/Header.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,11 @@ const Header = () => {
2828

2929
const liClassName = (path: string) =>
3030
classNames(
31-
'hidden md:block hover:font-bold hover:text-gray-800 hover:border-blue-500 hover:border-b-2 h-12',
31+
'hidden md:block hover:font-bold hover:text-gray-700 dark:hover:text-gray-100 hover:border-blue-500 hover:border-b-2 h-12',
3232
{
33-
'text-blue-500': curPath === path,
34-
'text-gray-500': curPath !== path,
33+
'text-blue-500':
34+
curPath === path || (path !== '/' && curPath.startsWith(path)),
35+
'text-gray-500 dark:text-gray-300': curPath !== path,
3536
}
3637
);
3738

src/components/pagination/Pagination.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ type PaginationProps = {
1212

1313
export default function Pagination({
1414
className,
15-
PreviousText = '上一期',
16-
NextText = '下一期',
15+
PreviousText,
16+
NextText,
1717
total,
1818
current = 1,
1919
onPageChange,
@@ -56,13 +56,13 @@ export default function Pagination({
5656
return (
5757
<div className={clsxm('', className)} {...rest}>
5858
<nav className='flex items-center justify-center space-x-2'>
59-
<a
59+
<div
6060
onClick={() => handlePageChange(page - 1)}
6161
className={JumpBtnClass(-1)}
6262
>
6363
<span aria-hidden='true'>«</span>
6464
<span>{PreviousText}</span>
65-
</a>
65+
</div>
6666

6767
<input
6868
type='number'
@@ -91,13 +91,13 @@ export default function Pagination({
9191
<span className='mx-0 inline-flex h-10 w-10 items-center rounded-full p-4 font-medium text-gray-500 dark:text-gray-400'>
9292
{total}
9393
</span>
94-
<a
94+
<div
9595
onClick={() => handlePageChange(page + 1)}
9696
className={JumpBtnClass(1)}
9797
>
9898
<span>{NextText}</span>
9999
<span aria-hidden='true'>»</span>
100-
</a>
100+
</div>
101101
</nav>
102102
</div>
103103
);

src/pages/article/[aid].tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { useTranslation } from 'next-i18next';
33
import { serverSideTranslations } from 'next-i18next/serverSideTranslations';
44

55
import ItemBottom from '@/components/home/ItemBottom';
6-
import ImageWithPreview from '@/components/ImageWithPreview';
76
import { MDRender } from '@/components/mdRender/MDRender';
87
import Navbar from '@/components/navbar/Navbar';
98
import Seo from '@/components/Seo';
@@ -29,8 +28,8 @@ const ArticlePage: NextPage<ArticleProps> = ({ article }) => {
2928
</article>
3029
{i18n.language === 'zh' ? (
3130
<div className='my-2 flex justify-center'>
32-
<ImageWithPreview
33-
className='hidden cursor-zoom-in rounded-lg md:block'
31+
<img
32+
className='hidden rounded-lg md:block'
3433
src='https://img.hellogithub.com/ad/footer.png'
3534
alt='weixin_footer'
3635
/>

src/pages/periodical/category/[name].tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,13 @@ const PeriodicalCategoryPage: NextPage<CategoryPageProps> = ({ category }) => {
8888
</div>
8989

9090
{allItems?.map((item: PeriodicalItem, index: number) => {
91-
return <PeriodItem key={index} item={item} index={index} />;
91+
return (
92+
<PeriodItem
93+
key={index}
94+
item={item}
95+
index={(category?.current_page - 1) * 10 + index}
96+
/>
97+
);
9298
})}
9399
</div>
94100

src/pages/periodical/volume/[id].tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,8 @@ const PeriodicalVolumePage: NextPage<VolumePageProps> = ({ volume }) => {
233233
total={volume?.total}
234234
current={volume?.current_num}
235235
onPageChange={onPageChange}
236-
PreviousText={t('page_prev')}
237-
NextText={t('page_next')}
236+
PreviousText={t('vol_prev')}
237+
NextText={t('vol_next')}
238238
/>
239239
</div>
240240

@@ -296,8 +296,8 @@ const PeriodicalVolumePage: NextPage<VolumePageProps> = ({ volume }) => {
296296
total={volume?.total}
297297
current={volume?.current_num}
298298
onPageChange={onPageChange}
299-
PreviousText={t('page_prev')}
300-
NextText={t('page_next')}
299+
PreviousText={t('vol_prev')}
300+
NextText={t('vol_next')}
301301
/>
302302

303303
<div className='hidden md:block'>
@@ -311,9 +311,9 @@ const PeriodicalVolumePage: NextPage<VolumePageProps> = ({ volume }) => {
311311
<div>
312312
<div className='top-15 fixed w-full max-w-[244px]'>
313313
<div className='mt-2 ml-3 bg-white p-4 dark:bg-gray-800 md:rounded-lg'>
314-
<h4 className='mb-2 border-b border-gray-200 pb-2 dark:border-gray-700'>
314+
<h3 className='mb-2 border-b border-gray-200 pb-2 text-lg dark:border-gray-700'>
315315
{t('volume.catalog')}
316-
</h4>
316+
</h3>
317317
<ul
318318
className='custom-scrollbar overflow-scroll'
319319
style={{ maxHeight: 560 }}

0 commit comments

Comments
 (0)