|
|
|
@ -19,15 +19,21 @@ function AuthApp() {
|
|
|
|
|
const loginUser = useAuthStore(state => state.loginUser)
|
|
|
|
|
|
|
|
|
|
const href = useHref()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const [connectWebsocket, fetchInitialData, disconnectWebsocket ] = useConversationStore((state) => [
|
|
|
|
|
state.connectWebsocket,
|
|
|
|
|
state.fetchInitialData,
|
|
|
|
|
state.disconnectWebsocket,
|
|
|
|
|
]);
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
Notification.requestPermission();
|
|
|
|
|
if (loginUser.userId > 0) {
|
|
|
|
|
useConversationStore.getState().connectWebsocket(loginUser.userId)
|
|
|
|
|
useConversationStore.getState().fetchInitialData(loginUser.userId) // userIdStr
|
|
|
|
|
connectWebsocket(loginUser.userId);
|
|
|
|
|
fetchInitialData(loginUser.userId); // userIdStr
|
|
|
|
|
}
|
|
|
|
|
return () => {
|
|
|
|
|
useConversationStore.getState().disconnectWebsocket();
|
|
|
|
|
}
|
|
|
|
|
disconnectWebsocket();
|
|
|
|
|
};
|
|
|
|
|
}, [])
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
@ -37,21 +43,6 @@ function AuthApp() {
|
|
|
|
|
}
|
|
|
|
|
}, [href])
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (loginUser.userId > 0) {
|
|
|
|
|
useConversationStore.getState().connectWebsocket(loginUser.userId)
|
|
|
|
|
useConversationStore.getState().fetchInitialData(loginUser.userId) // userIdStr
|
|
|
|
|
}
|
|
|
|
|
return () => {
|
|
|
|
|
useConversationStore.getState().disconnectWebsocket()
|
|
|
|
|
}
|
|
|
|
|
}, [])
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
Notification.requestPermission()
|
|
|
|
|
return () => {}
|
|
|
|
|
}, [])
|
|
|
|
|
|
|
|
|
|
const {
|
|
|
|
|
token: { colorBgContainer },
|
|
|
|
|
} = theme.useToken()
|
|
|
|
@ -69,7 +60,7 @@ function AuthApp() {
|
|
|
|
|
renderEmpty={() => <Empty description={false} />}
|
|
|
|
|
>
|
|
|
|
|
<AntApp>
|
|
|
|
|
<ErrorBoundary>
|
|
|
|
|
<ErrorBoundary>
|
|
|
|
|
<Outlet />
|
|
|
|
|
</ErrorBoundary>
|
|
|
|
|
</AntApp>
|
|
|
|
|