|
|
|
@ -1,5 +1,5 @@
|
|
|
|
|
import { useEffect } from 'react';
|
|
|
|
|
import { Outlet, Link, useHref, NavLink } from 'react-router-dom'
|
|
|
|
|
import { Outlet, Link, useHref, useNavigate, NavLink } from 'react-router-dom'
|
|
|
|
|
import { Layout, Menu, ConfigProvider, theme, Empty, Row, Col, Avatar, Dropdown, Space, Typography, App as AntApp } from 'antd'
|
|
|
|
|
import { DownOutlined } from '@ant-design/icons'
|
|
|
|
|
import ErrorBoundary from '@/components/ErrorBoundary'
|
|
|
|
@ -19,38 +19,45 @@ const { Title } = Typography
|
|
|
|
|
|
|
|
|
|
function AuthApp() {
|
|
|
|
|
|
|
|
|
|
const navigate = useNavigate()
|
|
|
|
|
|
|
|
|
|
const { colorPrimary, borderRadius } = useThemeContext()
|
|
|
|
|
// const { loginUser, permissionList } = useAuthContext()
|
|
|
|
|
const { loadUser
|
|
|
|
|
} = useAuthStore()
|
|
|
|
|
|
|
|
|
|
const loginUser = loadUser()
|
|
|
|
|
console.info(loginUser)
|
|
|
|
|
|
|
|
|
|
const href = useHref()
|
|
|
|
|
// 除了路由 /p...以外都需要登陆系统
|
|
|
|
|
// const shouldBeLogin = isEmpty(loginUser) && (href.indexOf('/p/') == -1)
|
|
|
|
|
let defaultPath = 'follow'
|
|
|
|
|
|
|
|
|
|
if (href !== '/') {
|
|
|
|
|
const splitPath = href.split('/')
|
|
|
|
|
defaultPath = href
|
|
|
|
|
}
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
// 除了路由 /p...以外都需要登陆系统
|
|
|
|
|
if ((loginUser.userId === 0) && (href.indexOf('/p/') == -1)) {
|
|
|
|
|
navigate('/p/dingding/qrcode');
|
|
|
|
|
}
|
|
|
|
|
}, [href])
|
|
|
|
|
|
|
|
|
|
const {
|
|
|
|
|
token: { colorBgContainer },
|
|
|
|
|
} = theme.useToken()
|
|
|
|
|
const userId = loginUser.userId
|
|
|
|
|
|
|
|
|
|
const { userId } = loginUser;
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (userId) {
|
|
|
|
|
useConversationStore.getState().connectWebsocket(userId);
|
|
|
|
|
useConversationStore.getState().fetchInitialData(userId);
|
|
|
|
|
}
|
|
|
|
|
return () => {
|
|
|
|
|
useConversationStore.getState().disconnectWebsocket();
|
|
|
|
|
//useConversationStore.getState().disconnectWebsocket();
|
|
|
|
|
}
|
|
|
|
|
}, [userId]);
|
|
|
|
|
}, [userId])
|
|
|
|
|
|
|
|
|
|
let defaultPath = 'follow'
|
|
|
|
|
|
|
|
|
|
if (href !== '/') {
|
|
|
|
|
const splitPath = href.split('/')
|
|
|
|
|
defaultPath = href
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const {
|
|
|
|
|
token: { colorBgContainer },
|
|
|
|
|
} = theme.useToken()
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<ConfigProvider
|
|
|
|
|