feat: 登陆超时刷新要重新登陆

perf/export-docx
Jimmy Liow 1 year ago
parent 37c3b5aa45
commit 6f446d852a

@ -130,7 +130,7 @@ const useAuthStore = create(obervseLifecycle((set, get) => ({
const now = new Date()
const diffTime = now.getTime() - lastReqDate.getTime()
const diffHours = diffTime/1000/60/60
if (diffHours > 4) {
if (diffHours > 1) {
loginTimeout()
}
}
@ -143,7 +143,8 @@ const useAuthStore = create(obervseLifecycle((set, get) => ({
loginTimeout: () => {
const { tokenInterval } = get()
// TODO: 这里没有清理 token刷新后可以正常使用系统
const { clearStorage } = usingStorage()
clearStorage()
clearInterval(tokenInterval)
set(() => ({
tokenTimeout: true

@ -4,7 +4,7 @@ import { Layout, Menu, ConfigProvider, theme, Dropdown, Space, Row, Col, Badge,
import { DownOutlined } from '@ant-design/icons';
import 'antd/dist/reset.css';
import AppLogo from '@/assets/logo-gh.png';
import { isEmpty } from '@/utils/commons';
import { isEmpty, isNotEmpty } from '@/utils/commons';
import Language from '../i18n/LanguageSwitcher';
import { useTranslation } from 'react-i18next';
import zhLocale from 'antd/locale/zh_CN';
@ -43,6 +43,7 @@ function App() {
const needToLogin = href !== '/login' && isEmpty(loginToken)
useEffect(() => {
if (isNotEmpty(loginToken)) {
fetchUserDetail(loginToken)
.then(u => {
setUserDetail({
@ -50,6 +51,7 @@ function App() {
travelAgencyName: u.VName,
})
})
}
}, [loginToken])
useEffect(() => {

Loading…
Cancel
Save