|
|
@@ -1438,33 +1438,7 @@
|
|
|
actionOtherAdd.value = Config.Host80 + '/custom/file/upload/10'
|
|
|
}
|
|
|
|
|
|
- // WebSocket
|
|
|
- function initWebSocket() {
|
|
|
- // 初始化WebSocket
|
|
|
- let token = sessionStorage.getItem("access_token")
|
|
|
- if (typeof WebSocket == 'undefined') {
|
|
|
- uni.showToast({ title: t('Msg.socket'), icon: 'none' })
|
|
|
- } else {
|
|
|
- const wsUrl = HostWs.value + '/webSocket?Access-Token=' + token
|
|
|
- websock.value = new WebSocket(wsUrl)
|
|
|
- websock.value.onMessage = websocketonmessage
|
|
|
- websock.value.onOpen = websocketonopen
|
|
|
- websock.value.onError = websocketonerror
|
|
|
- websock.value.onClose = websocketclose
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- function websocketonopen() {
|
|
|
- }
|
|
|
-
|
|
|
- function websocketonerror() {
|
|
|
- initWebSocket()
|
|
|
- }
|
|
|
-
|
|
|
- function websocketonmessage(e: any) {
|
|
|
- let data = JSON.parse(e.data)
|
|
|
- if (data.newsType == 1) {
|
|
|
- let myData = JSON.parse(e.data)
|
|
|
+ function updateFile(myData) {
|
|
|
if (myData.type == 1) {
|
|
|
fileListID1.value = myData
|
|
|
} else if (myData.type == 2) {
|
|
|
@@ -1490,10 +1464,6 @@
|
|
|
}
|
|
|
}
|
|
|
actionType()
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- function websocketclose() {
|
|
|
}
|
|
|
|
|
|
// 判断是否为PC端
|
|
|
@@ -1555,15 +1525,16 @@
|
|
|
await getMobileInfo()
|
|
|
await getCustomFileList()
|
|
|
// WebSocket
|
|
|
- initWebSocket()
|
|
|
+ // initWebSocket()
|
|
|
isPC.value = IsPC()
|
|
|
+ uni.$on('updateImproveFile',(data)=>{
|
|
|
+ updateFile(data)
|
|
|
+ })
|
|
|
})
|
|
|
|
|
|
// 组件销毁时
|
|
|
onUnmounted(() => {
|
|
|
- if (websock.value) {
|
|
|
- websock.value.close() // 离开路由之后断开WebSocket连接
|
|
|
- }
|
|
|
+ uni.$off('updateImproveFile')
|
|
|
})
|
|
|
</script>
|
|
|
|