From 4eec5092ffa53d26bbf522320b3838434b8203a1 Mon Sep 17 00:00:00 2001 From: FatttSnake Date: Wed, 27 Dec 2023 10:06:43 +0800 Subject: [PATCH] Optimize code --- src/AuthRoute.tsx | 2 +- src/components/common/sidebar/SidebarFooter.tsx | 3 ++- src/pages/system/Statistics.tsx | 15 +++++++++++++-- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/AuthRoute.tsx b/src/AuthRoute.tsx index 2019960..ae0e24a 100644 --- a/src/AuthRoute.tsx +++ b/src/AuthRoute.tsx @@ -29,7 +29,7 @@ const AuthRoute = () => { return } } - if (isLogin && lastMatch.pathname === '/login') { + if (isLogin && ['/login', '/forget'].includes(lastMatch.pathname)) { return } diff --git a/src/components/common/sidebar/SidebarFooter.tsx b/src/components/common/sidebar/SidebarFooter.tsx index 454e67d..2afed3e 100644 --- a/src/components/common/sidebar/SidebarFooter.tsx +++ b/src/components/common/sidebar/SidebarFooter.tsx @@ -2,6 +2,7 @@ import React, { useState } from 'react' import Icon from '@ant-design/icons' import { COLOR_ERROR } from '@/constants/common.constants' import { getRedirectUrl } from '@/util/route' +import { useUpdatedEffect } from '@/util/hooks' import { getAvatar, getLoginStatus, getNickname, removeToken } from '@/util/auth' import { r_auth_logout } from '@/services/auth' @@ -42,7 +43,7 @@ const SidebarFooter: React.FC = () => { const loginStatus = getLoginStatus() - useEffect(() => { + useUpdatedEffect(() => { if (getLoginStatus()) { void getNickname().then((nickname) => { setNickname(nickname) diff --git a/src/pages/system/Statistics.tsx b/src/pages/system/Statistics.tsx index 0129228..ddf5a64 100644 --- a/src/pages/system/Statistics.tsx +++ b/src/pages/system/Statistics.tsx @@ -281,7 +281,12 @@ const OnlineInfo: React.FC = () => { loading={isLoading} expand={ <> - + 今天 最近7天 最近30天 @@ -399,6 +404,7 @@ const ActiveInfo: React.FC = () => { activeInfoEChartsRef.current?.setOption({ ...lineEChartsBaseOption, + useUTC: true, tooltip: { ...lineEChartsBaseOption.tooltip, formatter: getTooltipTimeFormatter('yyyy-MM-DD') @@ -457,7 +463,12 @@ const ActiveInfo: React.FC = () => { loading={isLoading} expand={ <> - + 最近7天 最近30天 最近3个月