|
@@ -105,19 +105,9 @@ export default {
|
|
|
...mapGetters(['userInfo'])
|
|
|
},
|
|
|
created () {
|
|
|
- this.getUnread()
|
|
|
- // if (this.timer) {
|
|
|
- // clearInterval(this.timer)
|
|
|
- // }
|
|
|
- // this.timer = setInterval(() => {
|
|
|
- // this.getUnread()
|
|
|
- // }, 3000)
|
|
|
+ // 初次获取未读消息
|
|
|
+ this.getUnread(false)
|
|
|
},
|
|
|
- // beforeDestroy () {
|
|
|
- // if (this.timer) {
|
|
|
- // clearInterval(this.timer)
|
|
|
- // }
|
|
|
- // },
|
|
|
methods: {
|
|
|
onCommand (index) {
|
|
|
this.menuActive = index
|
|
@@ -137,10 +127,15 @@ export default {
|
|
|
await this.onInit()
|
|
|
this.loading = false
|
|
|
},
|
|
|
- async getUnread () {
|
|
|
+ /**
|
|
|
+ * 获取未读数,后端卡等待时间
|
|
|
+ * @param wait 是否等待
|
|
|
+ */
|
|
|
+ async getUnread (wait = true) {
|
|
|
try {
|
|
|
const { data } = await sendUnreadCount({
|
|
|
- unreadCount: this.unreadTotal
|
|
|
+ unreadCount: this.unreadTotal,
|
|
|
+ wait
|
|
|
})
|
|
|
this.unreadTotal = data
|
|
|
} catch (error) {
|