点击通知后的焦点问题

pull/23/head
taoshihan1991 5 years ago
parent a4230f22f9
commit 866a8aa8a8

@ -308,5 +308,5 @@
</template>
</div>
</body>
<script src="/static/js/chat-main.js?v=0.4.1"></script>
<script src="/static/js/chat-main.js?v=1"></script>
</html>

@ -9,6 +9,7 @@
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script src="https://cdn.jsdelivr.net/npm/element-ui@2.13.1/lib/index.js"></script>
<script src="https://cdn.jsdelivr.net/npm/jquery/dist/jquery.min.js"></script>
<script src="/static/js/functions.js"></script>
<style>
html,
body {
@ -62,12 +63,29 @@
el: '#app',
delimiters:["<{","}>"],
data: {
window:window,
iframeUrl:"",
mailTotal:0,
adminAvator:"",
adminRole:"",
},
methods: {
focusWindow(){
var _this=this;
window.addEventListener('message',function(e){
var redata=e.data;
console.log(redata);
notify(redata.name, {
body: redata.body,
icon: redata.icon
}, function(notification) {
//可直接打开通知notification相关联的tab窗口
window.focus();
notification.close();
_this.openIframeUrl("/chat_main");
});
});
},
openIframeUrl(url){
this.iframeUrl=url;
},
@ -102,61 +120,11 @@
},
created: function () {
this.checkAuth();
this.focusWindow();
}
})
</script>
<script>
new Vue({
delimiters:["<{","}>"],
data: {
websock: null,
},
created() {
//this.initWebSocket();
},
destroyed() {
this.websock.close() //离开路由之后断开websocket连接
},
methods: {
initWebSocket(){ //初始化weosocket
const wsuri = "ws://127.0.0.1:8080/push_mail";
this.websock = new WebSocket(wsuri);
this.websock.onmessage = this.websocketonmessage;
this.websock.onopen = this.websocketonopen;
this.websock.onerror = this.websocketonerror;
this.websock.onclose = this.websocketclose;
},
websocketonopen(){ //连接建立之后执行send方法发送数据
// let actions = "ping";
// let _this=this;
// setInterval(function(){
// _this.websocketsend(JSON.stringify(actions));
// },10000);
},
websocketonerror(){//连接建立失败重连
this.initWebSocket();
},
websocketonmessage(e){ //数据接收
const redata = JSON.parse(e.data);
if (redata.code==200){
this.$notify({
title: redata.result.folder_name,
message: "新邮件:"+redata.result.new_num,
type: 'success',
duration: 0,
});
}
},
websocketsend(Data){//数据发送
this.websock.send(Data);
},
websocketclose(e){ //关闭
console.log('断开连接',e);
},
},
$(window).bind("focus",function(e){
//alert(1);
});
</script>
</html>

@ -98,15 +98,10 @@ var app=new Vue({
this.addOnlineUser(redata.data);
//发送通知
let _this=this;
notify(redata.data.username, {
window.parent.postMessage({
name:redata.data.username,
body: "来了",
icon: redata.data.avator
}, function(notification) {
//可直接打开通知notification相关联的tab窗口
window.focus();
$('#tab-first').trigger('click');
notification.close();
_this.talkTo(redata.data.uid,redata.data.username);
});
_this.alertSound();
@ -116,31 +111,9 @@ var app=new Vue({
//this.sendKefuOnline();
break;
case "notice":
// if(!this.usersMap[redata.data.uid]){
// this.$notify({
// title: "通知",
// message: "新客户访问",
// type: 'success',
// duration: 0,
// });
// }
this.sendKefuOnline();
break;
}
// if (redata.type == "notice") {
// this.$notify({
// title: "通知",
// message: "新客户访问",
// type: 'success',
// duration: 0,
// });
//发送给客户我在线
// let mes = {}
// mes.type = "kfConnect";
// kfConfig.guest_id=redata.data[0].uid;
// mes.data = kfConfig;
// this.socket.send(JSON.stringify(mes));
//}
if (redata.type == "message") {
let msg = redata.data
@ -164,15 +137,10 @@ var app=new Vue({
if(content.is_kefu){
return;
}
//发送通知
notify(msg.name, {
window.parent.postMessage({
name:msg.name,
body: msg.content,
icon: msg.avator
}, function(notification) {
//可直接打开通知notification相关联的tab窗口
window.focus();
notification.close();
_this.talkTo(msg.id,msg.name);
});
_this.alertSound();
_this.chatInputing="";

Loading…
Cancel
Save