你好: {nowUsername}
-//token: {nowToken}
-// {error && String(error)} -// {!error && <> -//uid: {data?.data.uid}
-//uuid: {data?.data.uuid}
-// >} -// > -// ) -// } \ No newline at end of file diff --git a/frontend/src/views/profile/Profile.tsx b/frontend/src/views/profile/Profile.tsx index e69de29..431aaac 100644 --- a/frontend/src/views/profile/Profile.tsx +++ b/frontend/src/views/profile/Profile.tsx @@ -0,0 +1,138 @@ +import Card from '@mui/material/Card'; +import CardActions from '@mui/material/CardActions'; +import CardContent from '@mui/material/CardContent'; +import Button from '@mui/material/Button'; +import Typography from '@mui/material/Typography'; +import CardHeader from '@mui/material/CardHeader'; +import { useHover, useRequest } from 'ahooks'; +import { ApiErr } from '@/apis/error'; +import { token } from '@/store/store'; +import { useAtomValue, useSetAtom } from 'jotai'; +import { userInfo, yggProfile } from '@/apis/apis'; +import { AlertErr } from '@/views/Layout'; +import { useNavigate } from 'react-router-dom'; +import Box from '@mui/material/Box'; +import { memo, useEffect, useRef, useState } from 'react'; +import { decodeSkin } from '@/utils/skin'; +import ReactSkinview3d from "react-skinview3d" +import type { ReactSkinview3dOptions } from "react-skinview3d" +import { WalkingAnimation } from "skinview3d" +import type { SkinViewer } from "skinview3d" +import Skeleton from '@mui/material/Skeleton'; +import useTilg from 'tilg'; + +const Profile = () => { + const nowToken = useAtomValue(token) + const navigate = useNavigate(); + const setErr = useSetAtom(AlertErr) + const [textures, setTextures] = useState({ skin: "", cape: "", model: "default" }) + + const userinfo = useRequest(() => userInfo(nowToken), { + refreshDeps: [nowToken], + cacheKey: "/api/v1/user", + cacheTime: 10000, + onError: e => { + if (e instanceof ApiErr && e.code == 5) { + navigate("/login") + } + console.warn(e) + setErr(String(e)) + } + }) + + const SkinInfo = useRequest(() => yggProfile(userinfo.data?.uuid ?? ""), { + onError: e => { + console.warn(e) + setErr(String(e)) + }, + refreshDeps: [userinfo.data?.uuid], + }) + + useEffect(() => { + if (!SkinInfo.data) return + const [skin, cape, model] = decodeSkin(SkinInfo.data) + setTextures({ cape: cape, skin: skin, model: model }) + }, [SkinInfo.data]) + + + + return ( + <> +{import.meta.env.VITE_APIADDR + "/api/yggdrasil"}
+