diff --git a/src/components/dropdown/AvatarWithDropdown.tsx b/src/components/dropdown/AvatarWithDropdown.tsx index 89e4ed31..f126e774 100644 --- a/src/components/dropdown/AvatarWithDropdown.tsx +++ b/src/components/dropdown/AvatarWithDropdown.tsx @@ -4,7 +4,7 @@ import { useLoginContext } from '@/hooks/useLoginContext'; import LanguageSwitcher from '@/components/buttons/LanguageSwitcher'; import ThemeSwitcher from '@/components/buttons/ThemeSwitcher'; -import CustomLink from '@/components/links/CustomLink'; +import { CustomLink } from '@/components/links/CustomLink'; import { DEFAULT_AVATAR } from '@/utils/constants'; diff --git a/src/components/home/Item.tsx b/src/components/home/Item.tsx index 7767764b..78222d8b 100644 --- a/src/components/home/Item.tsx +++ b/src/components/home/Item.tsx @@ -2,7 +2,7 @@ import Link from 'next/link'; import { AiFillFire, AiOutlineEye } from 'react-icons/ai'; import { GoStar, GoVerified } from 'react-icons/go'; -import CustomLink from '@/components/links/CustomLink'; +import { CustomLink } from '@/components/links/CustomLink'; import { fromNow } from '@/utils/day'; import { numFormat } from '@/utils/util'; diff --git a/src/components/layout/ErrorPage.tsx b/src/components/layout/ErrorPage.tsx index 29e7de97..eb481aa7 100644 --- a/src/components/layout/ErrorPage.tsx +++ b/src/components/layout/ErrorPage.tsx @@ -1,8 +1,8 @@ -import Link from 'next/link'; import { IoIosArrowForward } from 'react-icons/io'; import LanguageSwitcher from '@/components/buttons/LanguageSwitcher'; import ThemeSwitcher from '@/components/buttons/ThemeSwitcher'; +import { NoPrefetchLink } from '@/components/links/CustomLink'; type Props = { httpCode: number; @@ -24,7 +24,7 @@ const ErrorPage = ({ t, httpCode }: Props) => { width={500} /> - +
@@ -36,9 +36,9 @@ const ErrorPage = ({ t, httpCode }: Props) => {
- +
- + { > {t('footer.feedback')} - + · - + { > {t('footer.source')} - +

diff --git a/src/components/layout/Footer.tsx b/src/components/layout/Footer.tsx index f5b63d07..5f654159 100644 --- a/src/components/layout/Footer.tsx +++ b/src/components/layout/Footer.tsx @@ -2,7 +2,7 @@ import { AiFillWechat, AiFillWeiboCircle } from 'react-icons/ai'; import { IoLogoRss } from 'react-icons/io'; import { FeedbackModal } from '@/components/dialog/Feedback'; -import CustomLink from '@/components/links/CustomLink'; +import { CustomLink } from '@/components/links/CustomLink'; import FooterLink from './FooterLink'; @@ -30,7 +30,11 @@ const Footer = ({ t }: SideProps) => {

- {t('footer.agreement')} + + + {t('footer.agreement')} + + · {t('footer.source')} diff --git a/src/components/links/CustomLink.tsx b/src/components/links/CustomLink.tsx index f5b67f8e..2a0fb160 100644 --- a/src/components/links/CustomLink.tsx +++ b/src/components/links/CustomLink.tsx @@ -9,7 +9,7 @@ type Props = { onClick?: any; } & React.ComponentPropsWithoutRef<'div'>; -const CustomLink = ({ href, className, children, onClick }: Props) => { +export const CustomLink = ({ href, className, children, onClick }: Props) => { const [isMobile, setIsMobile] = useState(false); useEffect(() => { if ( @@ -35,4 +35,10 @@ const CustomLink = ({ href, className, children, onClick }: Props) => { ); }; -export default CustomLink; +export const NoPrefetchLink = ({ href, children }: Props) => { + return ( + + {children} + + ); +}; diff --git a/src/components/links/TagItem.tsx b/src/components/links/TagItem.tsx index 86a40d59..1878e975 100644 --- a/src/components/links/TagItem.tsx +++ b/src/components/links/TagItem.tsx @@ -1,4 +1,4 @@ -import Link from 'next/link'; +import { NoPrefetchLink } from '@/components/links/CustomLink'; interface Props { name: string; @@ -7,11 +7,11 @@ interface Props { const TagItem = ({ name, tid }: Props) => { return ( - + {name} - + ); }; diff --git a/src/components/links/TagLink.tsx b/src/components/links/TagLink.tsx index 104c3494..192bcaf9 100644 --- a/src/components/links/TagLink.tsx +++ b/src/components/links/TagLink.tsx @@ -1,4 +1,4 @@ -import Link from 'next/link'; +import { NoPrefetchLink } from '@/components/links/CustomLink'; import { TagType } from '@/types/tag'; @@ -15,7 +15,9 @@ export default function TagLink(props: Props) { {props.items.map((item: TagType) => { return (

  • - + {props.tid == item.tid ? ( {item.name} @@ -25,7 +27,7 @@ export default function TagLink(props: Props) { {item.name} )} - +
  • ); })} diff --git a/src/components/navbar/ArticleBar.tsx b/src/components/navbar/ArticleBar.tsx index b5713f5a..7d10b2aa 100644 --- a/src/components/navbar/ArticleBar.tsx +++ b/src/components/navbar/ArticleBar.tsx @@ -1,8 +1,9 @@ import classNames from 'classnames'; -import Link from 'next/link'; import { useRouter } from 'next/router'; import { AiOutlineArrowLeft } from 'react-icons/ai'; +import { NoPrefetchLink } from '@/components/links/CustomLink'; + type Props = { t: (key: string) => string; }; @@ -41,12 +42,12 @@ const ArticleNavbar = ({ t }: Props) => { {t('nav.title')}
    - + {t('nav.last')} - - + + {t('nav.hot')} - +
    diff --git a/src/components/navbar/IndexBar.tsx b/src/components/navbar/IndexBar.tsx index a78c00e8..19614294 100644 --- a/src/components/navbar/IndexBar.tsx +++ b/src/components/navbar/IndexBar.tsx @@ -1,10 +1,10 @@ import classNames from 'classnames'; import { NextPage } from 'next'; -import Link from 'next/link'; import useTagHandling from '@/hooks/useTagHandling'; import { RepoModal } from '@/components/dialog/RepoModal'; +import { NoPrefetchLink } from '@/components/links/CustomLink'; import TagLink from '@/components/links/TagLink'; type Props = { @@ -31,12 +31,12 @@ const IndexBar: NextPage = ({ t, i18n_lang, tid, sort_by }) => { return (
    - + {t('nav.featured')} - - + + {t('nav.all')} - + {t('nav.tag')} diff --git a/src/components/navbar/RepoNavbar.tsx b/src/components/navbar/RepoNavbar.tsx index 06a0cb13..5d3c89a8 100644 --- a/src/components/navbar/RepoNavbar.tsx +++ b/src/components/navbar/RepoNavbar.tsx @@ -1,7 +1,8 @@ -import Link from 'next/link'; import { useRouter } from 'next/router'; import { AiOutlineArrowLeft } from 'react-icons/ai'; +import { NoPrefetchLink } from '@/components/links/CustomLink'; + interface Props { avatar: string; uid: string; @@ -31,7 +32,7 @@ const RepoDetailNavbar = ({ avatar, uid, t }: Props) => {
    {t('nav.title')}
    - +
    {t('nav.desc')} @@ -45,7 +46,7 @@ const RepoDetailNavbar = ({ avatar, uid, t }: Props) => { {t('nav.desc2')}
    - +
    ); diff --git a/src/components/periodical/item.tsx b/src/components/periodical/item.tsx index 61575a26..e3d6f10a 100644 --- a/src/components/periodical/item.tsx +++ b/src/components/periodical/item.tsx @@ -1,16 +1,16 @@ import { NextPage } from 'next'; -import Link from 'next/link'; import { useTranslation } from 'next-i18next'; import { GoClock, GoRepoForked } from 'react-icons/go'; import { IoIosStarOutline } from 'react-icons/io'; +import { CustomLink, NoPrefetchLink } from '@/components/links/CustomLink'; + import { redirectRecord } from '@/services/home'; import { fromNow } from '@/utils/day'; import { numFormat } from '@/utils/util'; import Button from '../buttons/Button'; import ImageWithPreview from '../ImageWithPreview'; -import CustomLink from '../links/CustomLink'; import { MDRender } from '../mdRender/MDRender'; import { PeriodicalItem, PeriodicalItemProps } from '@/types/periodical'; @@ -54,7 +54,7 @@ const PeriodItem: NextPage = ({ item, index }) => {
    - +
    - + diff --git a/src/components/respository/CommentItem.tsx b/src/components/respository/CommentItem.tsx index 3041b75d..d160ba25 100644 --- a/src/components/respository/CommentItem.tsx +++ b/src/components/respository/CommentItem.tsx @@ -1,10 +1,10 @@ -import Link from 'next/link'; import { useEffect, useState } from 'react'; import { AiFillFire } from 'react-icons/ai'; import { GoCommentDiscussion, GoThumbsup } from 'react-icons/go'; import { useLoginContext } from '@/hooks/useLoginContext'; +import { NoPrefetchLink } from '@/components/links/CustomLink'; import Message from '@/components/message'; import Rating from '@/components/respository/Rating'; @@ -115,7 +115,7 @@ const CommentItem = (props: CommentItemProps) => {
    - + { alt='comment_avatar' /> - +
    @@ -137,13 +137,13 @@ const CommentItem = (props: CommentItemProps) => { alt='comment_avatar' />
    - +
    {user?.nickname}
    - +
    {isMaker && ( OP @@ -166,13 +166,13 @@ const CommentItem = (props: CommentItemProps) => { {t('comment.reply')} - +
    {props.reply_user?.nickname}
    - +
    ) diff --git a/src/components/respository/Info.tsx b/src/components/respository/Info.tsx index 08dc2855..3e34b94a 100644 --- a/src/components/respository/Info.tsx +++ b/src/components/respository/Info.tsx @@ -1,7 +1,6 @@ import classNames from 'classnames'; import copy from 'copy-to-clipboard'; import ReactECharts from 'echarts-for-react'; -import Link from 'next/link'; import { useEffect, useRef, useState } from 'react'; import { AiFillCaretUp, @@ -35,7 +34,7 @@ import Button from '../buttons/Button'; import AddCollection from '../collection/AddCollection'; import BasicDialog from '../dialog/BasicDialog'; import Dropdown, { option } from '../dropdown/Dropdown'; -import CustomLink from '../links/CustomLink'; +import { CustomLink, NoPrefetchLink } from '../links/CustomLink'; import Message from '../message'; import { Repository, RepositoryProps } from '@/types/repository'; @@ -457,23 +456,23 @@ const Info = ({ repo, t, i18n_lang }: RepositoryProps) => {
    {t('info.opensource')} - + {repo.license} - +
    )}
    {!repo.is_claimed && ( - +
    {t('info.unclaim')}
    - +
    )}
    {
    {t('content.volume_label')}
    - +
    {t('content.volume', { volume: repo.volume_name })}
    - +
    )} {repo.tags.length > 0 && ( @@ -54,7 +58,11 @@ const Tabs = ({ repo, t, i18n_lang }: RepositoryProps) => { {t('content.tag_label')}
    {repo.tags.map((item) => ( - +
    {item.name} diff --git a/src/components/side/Ad.tsx b/src/components/side/Ad.tsx index 55a0e79f..3b12d9db 100644 --- a/src/components/side/Ad.tsx +++ b/src/components/side/Ad.tsx @@ -1,8 +1,9 @@ -import Link from 'next/link'; import { MouseEventHandler, useState } from 'react'; import { GoServer } from 'react-icons/go'; import { VscClose } from 'react-icons/vsc'; +import { NoPrefetchLink } from '@/components/links/CustomLink'; + import { redirectRecord } from '@/services/home'; import { AdvertItem } from '@/types/home'; @@ -121,13 +122,13 @@ export default function Ad({ data, className, t, i18n_lang }: Props) { > {data.is_reward ? ( i18n_lang != 'zh' ? ( - + - + ) : ( - + onClickLink(data.aid)} @@ -135,10 +136,10 @@ export default function Ad({ data, className, t, i18n_lang }: Props) { > : - + ) ) : ( - + onClickLink(data.aid)} @@ -146,7 +147,7 @@ export default function Ad({ data, className, t, i18n_lang }: Props) { > - + )}
    ); diff --git a/src/components/side/TagList.tsx b/src/components/side/TagList.tsx index dbb71710..6350c051 100644 --- a/src/components/side/TagList.tsx +++ b/src/components/side/TagList.tsx @@ -39,13 +39,13 @@ export default function TagList() { }); setTags(res.data); } - }, [i18n.language]); + }, []); useEffect(() => { if (!isMobile()) { initTags(); } - }, [initTags]); + }, [i18n.language]); const iconClassName = (iconName: string) => `iconfont icon-${iconName} mr-1`; @@ -74,6 +74,7 @@ export default function TagList() { {!tags.length && } {tags.map((item: Tag) => ( diff --git a/src/components/side/UserStatus.tsx b/src/components/side/UserStatus.tsx index 71219540..a1da2096 100644 --- a/src/components/side/UserStatus.tsx +++ b/src/components/side/UserStatus.tsx @@ -1,10 +1,11 @@ -import Link from 'next/link'; import { useRouter } from 'next/router'; import { useMemo } from 'react'; import { AiOutlineBell, AiOutlineQuestionCircle } from 'react-icons/ai'; import { useLoginContext } from '@/hooks/useLoginContext'; +import { NoPrefetchLink } from '@/components/links/CustomLink'; + import { DEFAULT_AVATAR } from '@/utils/constants'; import SideLoginButton from './SideLoginButton'; @@ -32,7 +33,7 @@ export default function UserStatus({ t }: SideProps) { return (
    - +
    - +
    @@ -81,14 +82,14 @@ export default function UserStatus({ t }: SideProps) {
    {userInfo.contribute} @@ -104,11 +105,11 @@ export default function UserStatus({ t }: SideProps) {
    - + {t('user_side.profile')} - + {userInfo.permission?.code == 'super' ? (
    diff --git a/src/components/user/CollectionList.tsx b/src/components/user/CollectionList.tsx index 90a9f237..a9c9fad6 100644 --- a/src/components/user/CollectionList.tsx +++ b/src/components/user/CollectionList.tsx @@ -1,6 +1,5 @@ import classNames from 'classnames'; import copy from 'copy-to-clipboard'; -import Link from 'next/link'; import { useRouter } from 'next/router'; import { useState } from 'react'; import { @@ -24,6 +23,7 @@ import AddCollection, { EditCollectionMoal, } from '@/components/collection/AddCollection'; import BasicDialog from '@/components/dialog/BasicDialog'; +import { NoPrefetchLink } from '@/components/links/CustomLink'; import Loading from '@/components/loading/Loading'; import Message from '@/components/message'; @@ -88,11 +88,11 @@ const ProjectList = ({ uid, fid, t }: ProjectListProps) => { {/* 面包屑和分享按钮 */}
    - + {t('favorite.text')} - + {fName}
    diff --git a/src/components/user/DynamicRecordList.tsx b/src/components/user/DynamicRecordList.tsx index 1a865acb..21e453ee 100644 --- a/src/components/user/DynamicRecordList.tsx +++ b/src/components/user/DynamicRecordList.tsx @@ -1,6 +1,6 @@ import { fromNow } from '@/utils/day'; -import CustomLink from '../links/CustomLink'; +import { CustomLink } from '../links/CustomLink'; import { DynamicRecord, DynamicRecordItem } from '@/types/user'; import { TranslationFunction } from '@/types/utils'; diff --git a/src/components/user/User.tsx b/src/components/user/User.tsx index d5ab07a7..a526dcac 100644 --- a/src/components/user/User.tsx +++ b/src/components/user/User.tsx @@ -167,7 +167,7 @@ const User = () => { [0, 1].includes(index) || userDetailInfo?.in_person ) .map(({ key, title }) => ( - + {
    diff --git a/src/pages/index.tsx b/src/pages/index.tsx index 8cde20d1..18709251 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -1,4 +1,4 @@ -import { NextPage } from 'next'; +import { GetServerSideProps, NextPage } from 'next'; import { useRouter } from 'next/router'; import { useTranslation } from 'next-i18next'; import { serverSideTranslations } from 'next-i18next/serverSideTranslations'; @@ -60,13 +60,12 @@ const Index: NextPage = () => { ); }; - -export async function getStaticProps({ locale }: { locale: string }) { +export const getServerSideProps: GetServerSideProps = async ({ locale }) => { return { props: { - ...(await serverSideTranslations(locale, ['common', 'home'])), + ...(await serverSideTranslations(locale as string, ['common', 'home'])), }, }; -} +}; export default Index; diff --git a/src/pages/notification/index.tsx b/src/pages/notification/index.tsx index 2e2d9d37..0a8374e9 100644 --- a/src/pages/notification/index.tsx +++ b/src/pages/notification/index.tsx @@ -8,7 +8,7 @@ import useSWRInfinite from 'swr/infinite'; import clsxm from '@/lib/clsxm'; import { useLoginContext } from '@/hooks/useLoginContext'; -import CustomLink from '@/components/links/CustomLink'; +import { CustomLink } from '@/components/links/CustomLink'; import Loading from '@/components/loading/Loading'; import Navbar from '@/components/navbar/Navbar'; import Seo from '@/components/Seo'; diff --git a/src/pages/onefile/code/[oid].tsx b/src/pages/onefile/code/[oid].tsx index 9bf6eab6..ad378b54 100644 --- a/src/pages/onefile/code/[oid].tsx +++ b/src/pages/onefile/code/[oid].tsx @@ -1,10 +1,10 @@ import copy from 'copy-to-clipboard'; import { GetServerSideProps, NextPage } from 'next'; -import Link from 'next/link'; import { useTranslation } from 'next-i18next'; import { serverSideTranslations } from 'next-i18next/serverSideTranslations'; import { GoClippy, GoLink, GoPlay } from 'react-icons/go'; +import { NoPrefetchLink } from '@/components/links/CustomLink'; import { CodeRender } from '@/components/mdRender/MDRender'; import message from '@/components/message'; import Navbar from '@/components/navbar/Navbar'; @@ -88,7 +88,7 @@ const OneFileDetailPage: NextPage = ({ onefile }) => {
    {onefile.demo_url && ( - + = ({ onefile }) => { {t('code.play')} - + )} - + = ({ onefile }) => { {t('code.vite')} - + handleCopy(onefile)} diff --git a/src/pages/onefile/index.tsx b/src/pages/onefile/index.tsx index fc8ada24..68dc8489 100644 --- a/src/pages/onefile/index.tsx +++ b/src/pages/onefile/index.tsx @@ -1,9 +1,9 @@ import { GetServerSideProps, NextPage } from 'next'; -import Link from 'next/link'; import { useRouter } from 'next/router'; import { Trans, useTranslation } from 'next-i18next'; import { serverSideTranslations } from 'next-i18next/serverSideTranslations'; +import { NoPrefetchLink } from '@/components/links/CustomLink'; import Navbar from '@/components/navbar/Navbar'; import Seo from '@/components/Seo'; @@ -110,13 +110,13 @@ const OneFilePage: NextPage = ({ data }) => {

    - + {t('click')} - + {t('p_text3')}

    diff --git a/src/pages/periodical/index.tsx b/src/pages/periodical/index.tsx index c5d10834..d12f1e79 100644 --- a/src/pages/periodical/index.tsx +++ b/src/pages/periodical/index.tsx @@ -6,7 +6,7 @@ import useSWRImmutable from 'swr/immutable'; import Button from '@/components/buttons/Button'; import { RepoModal } from '@/components/dialog/RepoModal'; -import CustomLink from '@/components/links/CustomLink'; +import { CustomLink } from '@/components/links/CustomLink'; import { PeriodicalSkeleton } from '@/components/loading/skeleton'; import Navbar from '@/components/navbar/Navbar'; import Seo from '@/components/Seo';