diff --git a/components/MainUI/Action/Action.tsx b/components/MainUI/Action/Action.tsx index c83d56f..a7e46f9 100644 --- a/components/MainUI/Action/Action.tsx +++ b/components/MainUI/Action/Action.tsx @@ -1,4 +1,4 @@ -import React from "react"; +import React, { useState, useEffect } from "react"; import Image from "next/image"; import HandIcon from "@/assets/icons/v2/hand.svg"; import MicroIcon from "@/assets/icons/v2/micro.svg"; @@ -15,6 +15,9 @@ export default function Action({ setIsPetting: (isPetting: boolean) => void; petPet: () => void; }) { + const [isMicro, setIsMicro] = useState(true); + const [dots, setDots] = useState("."); + const handlePetTouch = async () => { try { setIsPetting(true); @@ -31,20 +34,58 @@ export default function Action({ const router = useRouter(); + // 处理点击事件 + const handleClick = () => { + setIsMicro(!isMicro); + }; + + // 当 isMicro 为 false 时,处理点的动画 + useEffect(() => { + let interval: NodeJS.Timeout; + + if (!isMicro) { + interval = setInterval(() => { + setDots((prev) => { + if (prev === ".") return ".."; + if (prev === "..") return "..."; + return "."; + }); + }, 500); + } + + return () => { + if (interval) clearInterval(interval); + }; + }, [isMicro]); + return (
- Hand + {isMicro ? ( + Micro + ) : ( + {dots} + )}
-
- Micro +
+ Hand
diff --git a/components/MainUI/Init.tsx b/components/MainUI/Init.tsx index 3413b90..7e2892b 100644 --- a/components/MainUI/Init.tsx +++ b/components/MainUI/Init.tsx @@ -167,6 +167,12 @@ export default function Init({ }; const petPet = async () => { + // TODO:没有连接钱包的时候先把数值记录一下 + if (!walletConnected) { + showTxErrorModal("Connect to wallet in user page first"); + return; + } + try { const { pda } = useGameAccountPDA(); diff --git a/components/MainUI/PetInfo/PetInfo.tsx b/components/MainUI/PetInfo/PetInfo.tsx index e491878..3427896 100644 --- a/components/MainUI/PetInfo/PetInfo.tsx +++ b/components/MainUI/PetInfo/PetInfo.tsx @@ -17,14 +17,14 @@ export default function PetInfo({ gameAccount }: { gameAccount: any }) { console.log("gameAccount", gameAccount); }, [gameAccount]); return ( -
+
- - -
+
Coin -

{balance} coins

+

{balance} $

+ + {/* */}
); } diff --git a/components/MainUI/PetInfo/components/ProgressBar.tsx b/components/MainUI/PetInfo/components/ProgressBar.tsx index 376707c..186032e 100644 --- a/components/MainUI/PetInfo/components/ProgressBar.tsx +++ b/components/MainUI/PetInfo/components/ProgressBar.tsx @@ -2,25 +2,34 @@ import Image from "next/image"; import React from "react"; type ProgressBarProps = { - value: number; // 进度值(0-100) + value: number; Icon: string; }; const ProgressBar: React.FC = ({ value, Icon }) => { + const filledBlocks = Math.round(value / 10); + return ( -
+
-
-
- {/* 外框的高光效果 */} -
- {/* 进度值文字 */} -
- {Math.round(value)} +
+
+ {`${Math.round(value)}%`}
+ {[...Array(10)].map((_, index) => ( +
+ ))}
); diff --git a/components/MainUI/SlideUI/UserPage.tsx b/components/MainUI/SlideUI/UserPage.tsx index 6757c02..ce48b54 100644 --- a/components/MainUI/SlideUI/UserPage.tsx +++ b/components/MainUI/SlideUI/UserPage.tsx @@ -7,6 +7,12 @@ import { useNavHeight } from "@/components/Root/navHeightContext"; import { ConnectButton } from "@ant-design/web3"; import type { Account } from "@ant-design/web3"; import { showInitializeModal } from "@/utils/solana"; +import { Press_Start_2P } from "next/font/google"; + +const pressStart2P = Press_Start_2P({ + weight: "400", + subsets: ["latin"], +}); export default function UserPage({ userInfo, @@ -89,6 +95,7 @@ export default function UserPage({