消息提醒
This commit is contained in:
@ -231,7 +231,7 @@ const conversation = (props) => {
|
|||||||
setMsgPage(msgPage+1)
|
setMsgPage(msgPage+1)
|
||||||
}
|
}
|
||||||
let count = earlierMsg.length
|
let count = earlierMsg.length
|
||||||
let arr = [...msgList]
|
let arr = pageNum==1?[] : [...msgList]
|
||||||
while(count>0){
|
while(count>0){
|
||||||
arr.unshift(earlierMsg.pop())
|
arr.unshift(earlierMsg.pop())
|
||||||
count--
|
count--
|
||||||
@ -266,14 +266,18 @@ const disconnectedAlert = () =>{
|
|||||||
const checkDisconnected = ()=>{
|
const checkDisconnected = ()=>{
|
||||||
if(window.isCloseChatUIModal!=undefined){ //弹窗没有关闭(弹窗开着或者隐藏,ws不应该断)
|
if(window.isCloseChatUIModal!=undefined){ //弹窗没有关闭(弹窗开着或者隐藏,ws不应该断)
|
||||||
console.log('websocket断开,重新连接')
|
console.log('websocket断开,重新连接')
|
||||||
if(isModalVisible){ //断连后,用户打开弹窗再发提醒
|
console.log(window.isModalVisibleForCustomerService)
|
||||||
setConversationId('')
|
setConversationId('')
|
||||||
|
if(window.isModalVisibleForCustomerService){ //断连后,用户打开弹窗再发提醒
|
||||||
disconnectedAlert()
|
disconnectedAlert()
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
setConversationId('')
|
setConversationId('')
|
||||||
setMsgPage(0)
|
setMsgPage(0)
|
||||||
delete window.webSocketForCustomerService //释放websocket对象
|
if(window.webSocketForCustomerService!=undefined) delete window.webSocketForCustomerService //释放websocket对象
|
||||||
|
if(window.isModalVisibleForCustomerService!=undefined) delete window.isModalVisibleForCustomerService
|
||||||
|
if(window.isConversationURLChanged!=undefined) delete window.isConversationURLChanged
|
||||||
|
if(window.msgAlertForCustomerService!=undefined) delete window.msgAlertForCustomerService
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -288,6 +292,7 @@ const getToken = ()=>{
|
|||||||
setLoading(true)
|
setLoading(true)
|
||||||
getMoreMessage(1)
|
getMoreMessage(1)
|
||||||
}else{
|
}else{
|
||||||
|
console.log(window.webSocketForCustomerService)
|
||||||
if(window.webSocketForCustomerService!=undefined){
|
if(window.webSocketForCustomerService!=undefined){
|
||||||
//别的路由切过来,ws没断,重新监听
|
//别的路由切过来,ws没断,重新监听
|
||||||
console.log('ws没断,重新监听')
|
console.log('ws没断,重新监听')
|
||||||
@ -316,11 +321,16 @@ const monitorWebSocket = (ws)=>{
|
|||||||
ws.onmessage = function (res) {
|
ws.onmessage = function (res) {
|
||||||
if(res.data){
|
if(res.data){
|
||||||
let data = JSON.parse(res.data)
|
let data = JSON.parse(res.data)
|
||||||
if(window.isConversationURLChanged!= true){
|
if(window.isConversationURLChanged){//路由变化
|
||||||
setWsMsg(data)
|
|
||||||
}
|
|
||||||
window.msgAlertForCustomerService = true
|
window.msgAlertForCustomerService = true
|
||||||
showMsg()
|
showMsg()
|
||||||
|
}else {
|
||||||
|
if(window.isBlurForCustomerService){//失焦
|
||||||
|
window.msgAlertForCustomerService = true
|
||||||
|
showMsg()
|
||||||
|
}
|
||||||
|
setWsMsg(data)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -359,6 +369,9 @@ useEffect(()=>{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
if(window.msgAlertForCustomerService){
|
||||||
|
msgAlert && msgAlert() //侧边栏提醒
|
||||||
|
}
|
||||||
},[])
|
},[])
|
||||||
useEffect(()=>{
|
useEffect(()=>{
|
||||||
if(!isCloseWs){
|
if(!isCloseWs){
|
||||||
@ -368,6 +381,7 @@ useEffect(()=>{
|
|||||||
}
|
}
|
||||||
},[isCloseWs])
|
},[isCloseWs])
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
window.isModalVisibleForCustomerService = isModalVisible
|
||||||
if(isModalVisible){
|
if(isModalVisible){
|
||||||
stopMsg()
|
stopMsg()
|
||||||
//登录人的信息的关键字 顺序是固定的。
|
//登录人的信息的关键字 顺序是固定的。
|
||||||
@ -392,9 +406,6 @@ useEffect(() => {
|
|||||||
//校验登录
|
//校验登录
|
||||||
getToken()
|
getToken()
|
||||||
}else{
|
}else{
|
||||||
if(window.msgAlertForCustomerService){
|
|
||||||
msgAlert && msgAlert() //侧边栏提醒
|
|
||||||
}
|
|
||||||
setMsgList([])
|
setMsgList([])
|
||||||
}
|
}
|
||||||
}, [isModalVisible])
|
}, [isModalVisible])
|
||||||
|
Reference in New Issue
Block a user