Optimize code
This commit is contained in:
@@ -29,7 +29,7 @@ const AuthRoute = () => {
|
||||
return <Navigate to={'/verify'} />
|
||||
}
|
||||
}
|
||||
if (isLogin && lastMatch.pathname === '/login') {
|
||||
if (isLogin && ['/login', '/forget'].includes(lastMatch.pathname)) {
|
||||
return <Navigate to={'/'} />
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -281,7 +281,12 @@ const OnlineInfo: React.FC = () => {
|
||||
loading={isLoading}
|
||||
expand={
|
||||
<>
|
||||
<AntdSelect value={scope} onChange={handleOnScopeChange} disabled={isLoading}>
|
||||
<AntdSelect
|
||||
value={scope}
|
||||
onChange={handleOnScopeChange}
|
||||
disabled={isLoading}
|
||||
style={{ width: '8em' }}
|
||||
>
|
||||
<AntdSelect.Option key={'DAY'}>今天</AntdSelect.Option>
|
||||
<AntdSelect.Option key={'WEAK'}>最近7天</AntdSelect.Option>
|
||||
<AntdSelect.Option key={'MONTH'}>最近30天</AntdSelect.Option>
|
||||
@@ -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={
|
||||
<>
|
||||
<AntdSelect value={scope} onChange={handleOnScopeChange} disabled={isLoading}>
|
||||
<AntdSelect
|
||||
value={scope}
|
||||
onChange={handleOnScopeChange}
|
||||
disabled={isLoading}
|
||||
style={{ width: '8em' }}
|
||||
>
|
||||
<AntdSelect.Option key={'WEAK'}>最近7天</AntdSelect.Option>
|
||||
<AntdSelect.Option key={'MONTH'}>最近30天</AntdSelect.Option>
|
||||
<AntdSelect.Option key={'QUARTER'}>最近3个月</AntdSelect.Option>
|
||||
|
||||
Reference in New Issue
Block a user