Ver código fonte

feat(global): the warning pop-up window is changed to push by person

Casper Dai 2 anos atrás
pai
commit
83444e38ad
1 arquivos alterados com 9 adições e 4 exclusões
  1. 9 4
      src/layout/components/Notify.vue

+ 9 - 4
src/layout/components/Notify.vue

@@ -41,6 +41,7 @@
 </template>
 
 <script>
+import { mapGetters } from 'vuex'
 import {
   subscribe,
   unsubscribe
@@ -56,6 +57,10 @@ export default {
     }
   },
   computed: {
+    ...mapGetters(['userId']),
+    topic () {
+      return `${this.userId}/user/event`
+    },
     title () {
       if (this.msgData.length > 5) {
         return `预警消息 (${this.msgData.length})`
@@ -82,14 +87,14 @@ export default {
   methods: {
     startMonitor () {
       console.log('start dashboard monitor')
-      subscribe(['dashboard/event'], this.onMessage)
+      subscribe([this.topic], this.onMessage)
     },
     stopMonitor () {
       console.log('stop dashboard monitor')
-      unsubscribe(['dashboard/event'], this.onMessage)
+      unsubscribe([this.topic], this.onMessage)
     },
     onMessage (topic, message) {
-      if (topic === 'dashboard/event') {
+      if (topic === this.topic) {
         this.msgData.unshift(JSON.parse(message))
       }
     },
@@ -110,7 +115,7 @@ export default {
   width: 300px;
   right: $spacing;
   bottom: $spacing;
-  z-index: 99;
+  z-index: 2000;
   overflow: hidden;
   text-overflow: ellipsis;