From af1fd4e98a36d1fff1d8c4b5a1282707aea09c27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=B2=81=E8=AA=89=E7=A8=8B?= <2659568239@qq.com> Date: Wed, 11 Sep 2024 16:31:32 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/lib/components/Notifications.jsx | 141 ++++++++++++--------------- server/config.js | 2 +- 2 files changed, 61 insertions(+), 82 deletions(-) diff --git a/app/lib/components/Notifications.jsx b/app/lib/components/Notifications.jsx index d38db4d..c79a1be 100644 --- a/app/lib/components/Notifications.jsx +++ b/app/lib/components/Notifications.jsx @@ -1,104 +1,83 @@ -import React from 'react'; +import React, { useRef, useEffect } from 'react'; import { connect } from 'react-redux'; -import classnames from 'classnames'; import PropTypes from 'prop-types'; import * as appPropTypes from './appPropTypes'; import * as stateActions from '../redux/stateActions'; -import { Appear } from './transitions'; const Notifications = ({ notifications, onClick }) => { - console.log("notifications", notifications); + const chatwarpRef = useRef(null); - return ( -
-
聊天
+ useEffect(() => { + if (chatwarpRef.current) { + chatwarpRef.current.scrollTop = chatwarpRef.current.scrollHeight; + } + }, [notifications]); -
- { - notifications.map((notification) => { - return ( -
- { - // 类型是否是用户发送的消息 - notification.type == 'userMessage' ? -
- { - notification.isMe ? -
-
-
- {notification.text} -
-
: - <> -
用户-{notification.id}
-
- {notification.text} -
- - } -
: -
- {notification.text} -
- } + return ( +
+
聊天
-
- - - // 信息提示动画 - // - //
onClick(notification.id)} - // > - //
- - //
- // - //

{notification.title}

- //
- - //

{notification.text}

- //
- //
- // - ); - }) - } -
-
- ); +
+ { + notifications.map((notification) => ( +
+ { + notification.type === 'userMessage' ? +
+ { + notification.isMe ? +
+
+
+ {notification.text} +
+
: + <> +
用户-{notification.id}
+
+ {notification.text} +
+ + } +
: +
+ {notification.text} +
+ } +
+ )) + } +
+
+ ); }; -Notifications.propTypes = -{ - notifications: PropTypes.arrayOf(appPropTypes.Notification).isRequired, - onClick: PropTypes.func.isRequired +Notifications.propTypes = { + notifications: PropTypes.arrayOf(appPropTypes.Notification).isRequired, + onClick: PropTypes.func.isRequired }; const mapStateToProps = (state) => { - const { notifications } = state; - - return { notifications }; + const { notifications } = state; + return { notifications }; }; const mapDispatchToProps = (dispatch) => { - return { - onClick: (notificationId) => { - dispatch(stateActions.removeNotification(notificationId)); - } - }; + return { + onClick: (notificationId) => { + dispatch(stateActions.removeNotification(notificationId)); + } + }; }; const NotificationsContainer = connect( - mapStateToProps, - mapDispatchToProps + mapStateToProps, + mapDispatchToProps )(Notifications); export default NotificationsContainer; diff --git a/server/config.js b/server/config.js index d4b0f94..f2243b5 100644 --- a/server/config.js +++ b/server/config.js @@ -17,7 +17,7 @@ module.exports = // Signaling settings (protoo WebSocket server and HTTP API server). https : { - listenIp : '0.0.0.0', // 换成你的IP地址 + listenIp : '192.168.0.167', // 换成你的IP地址 // NOTE: Don't change listenPort (client app assumes 4443). listenPort : process.env.PROTOO_LISTEN_PORT || 4443, // NOTE: Set your own valid certificate files.