|
@@ -57,8 +57,8 @@
|
|
<img src="../../assets/icon/logout.png" alt=""
|
|
<img src="../../assets/icon/logout.png" alt=""
|
|
style="width: 16px;position: absolute;top: 22px;right: 20px;cursor: pointer;" @click="logout">
|
|
style="width: 16px;position: absolute;top: 22px;right: 20px;cursor: pointer;" @click="logout">
|
|
</div>
|
|
</div>
|
|
- <taskReminder v-for="(r,index) in reminders"
|
|
|
|
- :count="reminders.length" :user="r.user"
|
|
|
|
|
|
+ <taskReminder v-for="(r,index) in client.messages"
|
|
|
|
+ :count="client.messages.length" :user="r.user"
|
|
:businessType="r.businessType" :id="r.id"
|
|
:businessType="r.businessType" :id="r.id"
|
|
:no="r.no" :created="r.created" @doRead="doRead"></taskReminder>
|
|
:no="r.no" :created="r.created" @doRead="doRead"></taskReminder>
|
|
</div>
|
|
</div>
|
|
@@ -101,8 +101,7 @@ export default {
|
|
reminders:[],
|
|
reminders:[],
|
|
client: {
|
|
client: {
|
|
messages: [
|
|
messages: [
|
|
- { data: "*" },
|
|
|
|
- { userSize: 0 }
|
|
|
|
|
|
+
|
|
]
|
|
]
|
|
},
|
|
},
|
|
}
|
|
}
|
|
@@ -114,13 +113,14 @@ export default {
|
|
},
|
|
},
|
|
|
|
|
|
mounted() {
|
|
mounted() {
|
|
- //this.init();
|
|
|
|
|
|
+ this.init();
|
|
},
|
|
},
|
|
|
|
|
|
methods: {
|
|
methods: {
|
|
async logout() {
|
|
async logout() {
|
|
await this.$store.dispatch('user/logout');
|
|
await this.$store.dispatch('user/logout');
|
|
// this.$router.push(`/login?redirect=${this.$route.fullPath}`)
|
|
// this.$router.push(`/login?redirect=${this.$route.fullPath}`)
|
|
|
|
+ this.client.disconnect();
|
|
this.$router.push(`/login`);
|
|
this.$router.push(`/login`);
|
|
},
|
|
},
|
|
setStatus(data) {
|
|
setStatus(data) {
|
|
@@ -194,8 +194,8 @@ export default {
|
|
|
|
|
|
},
|
|
},
|
|
doRead(value){
|
|
doRead(value){
|
|
- this.reminders = this.reminders.filter(item =>item.id != value);
|
|
|
|
- console.log(this.reminders.length)
|
|
|
|
|
|
+ this.client.messages = this.client.messages.filter(item =>item.id != value);
|
|
|
|
+ this.$api.message.updateRead(value);
|
|
},
|
|
},
|
|
|
|
|
|
init() {
|
|
init() {
|
|
@@ -203,20 +203,16 @@ export default {
|
|
console.log("您的浏览器不支持socket")
|
|
console.log("您的浏览器不支持socket")
|
|
} else {
|
|
} else {
|
|
// 创建 WebSocketClient 实例并连接到服务端 API 接口
|
|
// 创建 WebSocketClient 实例并连接到服务端 API 接口
|
|
- // this.client = new WebSocketClient('wss://kps.scdayou.com/ws/apo/ws')
|
|
|
|
- this.client = new WebSocketClient('ws://127.0.0.1:8088/api/ws')
|
|
|
|
|
|
+ console.log("websocket-url",process.env.VUE_APP_WEBSOCKET)
|
|
|
|
+ this.client = new WebSocketClient(process.env.VUE_APP_WEBSOCKET)
|
|
this.client.connect()
|
|
this.client.connect()
|
|
}
|
|
}
|
|
},
|
|
},
|
|
- // destoryed() {
|
|
|
|
- // // 在组件销毁前断开 WebSocket 连接
|
|
|
|
- // this.client.disconnect()
|
|
|
|
- // console.log("websocket 断开")
|
|
|
|
- // },
|
|
|
|
- // beforeDestory() {
|
|
|
|
- // this.client.disconnect()
|
|
|
|
- // console.log("websocket 断开")
|
|
|
|
- // }
|
|
|
|
|
|
+ destoryed() {
|
|
|
|
+ // 在组件销毁前断开 WebSocket 连接
|
|
|
|
+ this.client.disconnect()
|
|
|
|
+ console.log("websocket 断开")
|
|
|
|
+ },
|
|
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|