|
|
@@ -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;
|
|
|
|