From 1a655f777572dd44f1f3c4649552cfd83c266e68 Mon Sep 17 00:00:00 2001 From: xueweihan <595666367@qq.com> Date: Fri, 20 Sep 2024 23:31:02 +0800 Subject: [PATCH] fix: header bug --- public/locales/en/periodical.json | 2 ++ public/locales/zh/periodical.json | 2 ++ src/components/ImageWithPreview.tsx | 16 +++++++++------- src/components/buttons/HeaderBtn.tsx | 2 +- src/components/layout/Header.tsx | 4 ++-- src/components/pagination/Pagination.tsx | 12 ++++++------ src/pages/article/[aid].tsx | 5 ++--- src/pages/periodical/category/[name].tsx | 8 +++++++- src/pages/periodical/volume/[id].tsx | 8 ++++---- 9 files changed, 35 insertions(+), 24 deletions(-) diff --git a/public/locales/en/periodical.json b/public/locales/en/periodical.json index 2f5d9b9e..2dae9a3a 100644 --- a/public/locales/en/periodical.json +++ b/public/locales/en/periodical.json @@ -15,6 +15,8 @@ "order_t7": "Projects", "order_t8": "Items", "order_t9": "Welcome to recommend", + "vol_prev": "Previous", + "vol_next": "Next", "page_prev": "Previous", "page_next": "Next", "category": { diff --git a/public/locales/zh/periodical.json b/public/locales/zh/periodical.json index 5560c7f4..11ebafe1 100644 --- a/public/locales/zh/periodical.json +++ b/public/locales/zh/periodical.json @@ -15,6 +15,8 @@ "order_t7": "项目数", "order_t8": "个", "order_t9": "欢迎推荐和自荐项目", + "vol_prev": "上一期", + "vol_next": "下一期", "page_prev": "上一页", "page_next": "下一页", "category": { diff --git a/src/components/ImageWithPreview.tsx b/src/components/ImageWithPreview.tsx index 26f3ad9c..9cf9cfda 100644 --- a/src/components/ImageWithPreview.tsx +++ b/src/components/ImageWithPreview.tsx @@ -1,4 +1,4 @@ -import RcImage, { ImageProps } from 'rc-image'; +import RcImage from 'rc-image'; import { useEffect, useState } from 'react'; import { AiOutlineClose } from 'react-icons/ai'; @@ -8,11 +8,13 @@ import GifPlayButton from './loading/GifPlayButton'; const gifCoverImage = '!gif'; -const ImageWithPreview = (props: ImageProps) => { +const ImageWithPreview = (props: { + src: string; + alt: string; + [key: string]: any; +}) => { const [imgSrc, setImgSrc] = useState( - props.src?.endsWith('gif') - ? `${props.src}${gifCoverImage}` - : (props.src as string) + props.src?.endsWith('gif') ? `${props.src}${gifCoverImage}` : props.src ); const isGifThumb = imgSrc.endsWith(gifCoverImage); const isGif = imgSrc?.endsWith('gif') && !isGifThumb; @@ -22,11 +24,11 @@ const ImageWithPreview = (props: ImageProps) => { if (props.src?.endsWith('gif')) { setImgSrc(`${props.src}${gifCoverImage}`); } else { - setImgSrc(props.src as string); + setImgSrc(props.src); } }, [props.src]); - const handleLoadGif = (e: any) => { + const handleLoadGif = (e: React.MouseEvent) => { e.stopPropagation(); setTimeout(() => { if (sourceIsGif) { diff --git a/src/components/buttons/HeaderBtn.tsx b/src/components/buttons/HeaderBtn.tsx index 25de6012..48f93ea6 100644 --- a/src/components/buttons/HeaderBtn.tsx +++ b/src/components/buttons/HeaderBtn.tsx @@ -15,7 +15,7 @@ const HeaderBtn = (props: HeaderBtnProps) => { return (