|
@@ -5,7 +5,7 @@
|
|
|
|
|
|
<script>
|
|
|
import {parseJsonStr} from '@/utils/common'
|
|
|
- import {routeMsg} from '@/utils/msg'
|
|
|
+ import {routeMsg, readNotices} from '@/utils/msg'
|
|
|
export default {
|
|
|
name: 'msg',
|
|
|
data () {
|
|
@@ -31,15 +31,20 @@
|
|
|
},
|
|
|
watch: {
|
|
|
listenWebsocket: function (data) {
|
|
|
- if (!data || data.indexOf('[') !== 0) {
|
|
|
+ if (!data) return
|
|
|
+ let json = parseJsonStr(data)
|
|
|
+ console.log('json = ' + JSON.stringify(json))
|
|
|
+ if (data.indexOf('{"approved') > -1) {
|
|
|
+ readNotices(this, json['approved'])
|
|
|
return
|
|
|
}
|
|
|
- let newMsgCollections = parseJsonStr(data)
|
|
|
- // console.log('newMsgCollections = ' + JSON.stringify(newMsgCollections))
|
|
|
- if (newMsgCollections) {
|
|
|
- this.updateMsgCollections(newMsgCollections)
|
|
|
- if (newMsgCollections.length <= 5) {
|
|
|
- newMsgCollections.forEach((item) => {
|
|
|
+ if (data.indexOf('[') !== 0) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (json) {
|
|
|
+ this.updateMsgCollections(json)
|
|
|
+ if (json.length <= 5) {
|
|
|
+ json.forEach((item) => {
|
|
|
this.notice(item)
|
|
|
})
|
|
|
}
|