diff --git a/src/pages/Home.tsx b/src/pages/Home.tsx index cdb8cab..54cf406 100644 --- a/src/pages/Home.tsx +++ b/src/pages/Home.tsx @@ -1,6 +1,6 @@ import classes from "./Home.module.css"; import useUserStore from "@/store/User"; -import { cn, copyText, shortenString } from "@/utils"; +import { cn, copyText, padWithZero, shortenString } from "@/utils"; import { useWeb3Modal } from "@web3modal/wagmi/react"; import { useEffect, useMemo, useRef, useState } from "react"; import { useTranslation } from "react-i18next"; @@ -261,7 +261,7 @@ export default function () { {userData?.nftId ? (
- # {userData?.nftId} + # {padWithZero(userData?.nftId)} { navigate("/mint"); diff --git a/src/utils/index.ts b/src/utils/index.ts index cd3cd9b..0006b2b 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -113,3 +113,8 @@ export function getUrlParameterByName(name: string, url?: string) { console.log("url params:", results); return decodeURIComponent(results[2].replace(/\+/g, " ")); } + +export function padWithZero(num: number) { + // 将数字转换为字符串,并在前面补足零使总长度为5 + return String(num).padStart(5, "0"); +}