From b314a9f8016f9e0f652f636c9123454296033a8b Mon Sep 17 00:00:00 2001 From: FatttSnake Date: Tue, 31 Oct 2023 18:44:18 +0800 Subject: [PATCH] Add nickname. Recode route. --- .../common/sidebar/SidebarFooter.tsx | 10 +++--- src/global.d.ts | 11 +++++++ src/pages/Login.tsx | 2 +- src/router/home.tsx | 2 ++ src/router/index.tsx | 13 +++++--- src/router/tools.tsx | 3 ++ src/utils/auth.ts | 33 +++++++++++++++++++ 7 files changed, 64 insertions(+), 10 deletions(-) diff --git a/src/components/common/sidebar/SidebarFooter.tsx b/src/components/common/sidebar/SidebarFooter.tsx index c3b7666..c7fec43 100644 --- a/src/components/common/sidebar/SidebarFooter.tsx +++ b/src/components/common/sidebar/SidebarFooter.tsx @@ -1,6 +1,6 @@ import React from 'react' import Icon from '@ant-design/icons' -import { getLoginStatus, getUsername, logout } from '@/utils/auth' +import { getLoginStatus, getNickName, logout } from '@/utils/auth' import { getRedirectUrl } from '@/utils/common' import { notification } from 'antd' import { COLOR_ERROR } from '@/constants/common.constants.ts' @@ -11,7 +11,7 @@ const SidebarFooter: React.FC = () => { const location = useLocation() const navigate = useNavigate() const [exiting, setExiting] = useState(false) - const [username, setUsername] = useState('') + const [nickName, setNickName] = useState('') const handleClickAvatar = () => { if (getLoginStatus()) { @@ -42,8 +42,8 @@ const SidebarFooter: React.FC = () => { useEffect(() => { if (getLoginStatus()) { - void getUsername().then((username) => { - setUsername(username) + void getNickName().then((nickName) => { + setNickName(nickName) }) } }, [loginStatus]) @@ -60,7 +60,7 @@ const SidebarFooter: React.FC = () => {