From 61df3f063aeeca61b00d6462047ad7a14db244d3 Mon Sep 17 00:00:00 2001 From: john Date: Sat, 20 Jul 2024 10:37:59 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9E=20fix:?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/Home.tsx | 4 ++-- src/utils/index.ts | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) 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"); +}