11import React , { useEffect , useLayoutEffect , useState } from 'react' ;
22import i18n , { isEn } from '@/i18n' ;
3- import { Outlet , useNavigate } from 'umi' ;
3+ import { Outlet } from 'umi' ;
44import { ConfigProvider , theme , Spin } from 'antd' ;
55import { v4 as uuidv4 } from 'uuid' ;
66import { getAntdThemeConfig , injectThemeVar } from '@/theme' ;
77import { IVersionResponse } from '@/typings' ;
88import miscService from '@/service/misc' ;
9- import { getUser } from '@/service/user' ;
109import antdEnUS from 'antd/locale/en_US' ;
1110import antdZhCN from 'antd/locale/zh_CN' ;
1211import { useTheme } from '@/hooks' ;
@@ -77,13 +76,11 @@ export default function Layout() {
7776const restartCount = 200 ;
7877
7978function AppContainer ( ) {
80- const navigate = useNavigate ( ) ;
8179 const { token } = useToken ( ) ;
8280 const [ initEnd , setInitEnd ] = useState ( false ) ;
8381 const [ appTheme , setAppTheme ] = useTheme ( ) ;
8482 const [ startSchedule , setStartSchedule ] = useState ( 0 ) ; // 0 初始状态 1 服务启动中 2 启动成功
8583 const [ serviceFail , setServiceFail ] = useState ( false ) ;
86- const [ isLogin , setIsLogin ] = useState < boolean | null > ( null ) ;
8784
8885 useLayoutEffect ( ( ) => {
8986 collectInitApp ( ) ;
@@ -93,18 +90,6 @@ function AppContainer() {
9390 injectThemeVar ( token as any , appTheme . backgroundColor , appTheme . primaryColor ) ;
9491 } , [ token ] ) ;
9592
96- function handelGetUserInfo ( ) {
97- getUser ( ) . then ( ( res ) => {
98- if ( ! res ) {
99- navigate ( '/login' ) ;
100- }
101- // 向cookie中写入当前用户id
102- const date = new Date ( '2030-12-30 12:30:00' ) . toUTCString ( ) ;
103- document . cookie = `CHAT2DB.USER_ID=${ res ?. id } ;Expires=${ date } ` ;
104- setIsLogin ( ! ! res ) ;
105- } ) ;
106- }
107-
10893 // 初始化app
10994 function collectInitApp ( ) {
11095 monitorOsTheme ( ) ;
@@ -162,7 +147,6 @@ function AppContainer() {
162147 . then ( ( ) => {
163148 clearInterval ( time ) ;
164149 setStartSchedule ( 2 ) ;
165- handelGetUserInfo ( ) ;
166150 flag ++ ;
167151 } )
168152 . catch ( ( ) => {
@@ -181,7 +165,7 @@ function AppContainer() {
181165 { initEnd && (
182166 < div className = { styles . app } >
183167 { /* 服务启动中 */ }
184- { ( startSchedule < 2 || isLogin === null ) && (
168+ { startSchedule < 2 && (
185169 < div className = { styles . loadingBox } >
186170 < Spin spinning = { ! serviceFail } size = "large" />
187171 { /* 状态等于1时,说明没服务起来需要轮训接口,这时可能服务配置又问题,需要设置来修改 */ }
@@ -211,7 +195,7 @@ function AppContainer() {
211195 </ div >
212196 ) }
213197 { /* 服务启动完成 */ }
214- { startSchedule === 2 && isLogin !== null && < Outlet /> }
198+ { startSchedule === 2 && < Outlet /> }
215199 </ div >
216200 ) }
217201 { /* 全局的弹窗 */ }
0 commit comments