zhangyu hace 5 años
padre
commit
fd23fb933c

+ 2 - 12
src/framework/components/messagesever/index.vue

@@ -2,7 +2,7 @@
  * @Author: zhangyu
  * @Date: 2019-08-26 15:22:13
  * @Info: 
- * @LastEditTime: 2019-09-26 17:08:19
+ * @LastEditTime: 2019-09-26 20:16:41
  -->
 <template>
   <div class="notification-box" @click="handleClickRead">
@@ -85,17 +85,7 @@ export default {
     },
     //接收到消息的回调
     onmessage(message) {
-      let json
-      try {
-        json = JSON.parse(message.body)
-      } catch (err) {
-        this.$message.error('数据格式错误!')
-      }
-      this.unreadNum = Msmq.handleMsg(json, this.projects, this.unreadNum);
-      // this.unreadNum++
-      // this.$notify.info({ title: '消息',dangerouslyUseHTMLString: true, message: `项目编号:${json.projectId}<br>消息类型:${json.type}<br>描述信息:${json.description}<br>` });
-      // this.messageList.push(json)
-      
+      this.unreadNum = Msmq.handleMsg(message, this.projects, this.unreadNum);
     },
     // 接收消息失败回调
     onFailed(frame) {

+ 9 - 3
src/framework/components/messagesever/msmq.js

@@ -2,12 +2,18 @@ import { Notification } from 'element-ui';
 import Bus from '@/utils/bus.js'
 
 const MSMQ = {
-  handleMsg (data, projects, unreadNum ) {
+  handleMsg (message, projects, unreadNum ) {
+    let data
+    try {
+      data = JSON.parse(message.body)
+    } catch (err) {}
     // if(projects.some((item) => {return item.id == data.projectId})) { //判断消息是否是当前用户拥有的项目
       unreadNum++
-      Bus.$emit('modelStatusChange', data)
+      if(message.headers.destination == '/topic/model.manage'){ //模型文件的消息触发模型文件列表刷新事件
+        Bus.$emit('modelStatusChange', data)
+      }
       // Notification.info({ title: '消息',dangerouslyUseHTMLString: true, message: `项目编号:${data.projectId}<br>消息类型:${data.type}<br>描述信息:${data.description}<br>` })
-      Notification.info({ title: '消息',dangerouslyUseHTMLString: true, message: `${JSON.stringify(data)}` })
+      Notification.info({ title: '消息', dangerouslyUseHTMLString: true, message: `${JSON.stringify(data)}` })
       return unreadNum
     // }
   }