From 8fe76c3c286fd431b3fdf190e4594a27d5cda59a Mon Sep 17 00:00:00 2001
From: guoshilong <123456>
Date: Sat, 18 Mar 2023 15:34:33 +0800
Subject: [PATCH] socketio连接调整
---
src/views/funcView.vue | 74 +++++++++++++++++++++++-------------
1 files changed, 47 insertions(+), 27 deletions(-)
diff --git a/src/views/funcView.vue b/src/views/funcView.vue
index 5f5b177..0a8d1a1 100644
--- a/src/views/funcView.vue
+++ b/src/views/funcView.vue
@@ -3,7 +3,7 @@
<el-row>
<el-col :span="4">
<div class="search">
- <avue-form :option="option" v-model="form" @submit="connect">
+ <avue-form :option="option" v-model="form" @submit="getMenuList">
<template slot-scope="{}" slot="modulesIdLabel">
<span></span>
</template>
@@ -87,6 +87,7 @@
import PlusIcon from 'vue-material-design-icons/PlusCircle'
import MinusIcon from 'vue-material-design-icons/MinusCircle'
import io from "socket.io-client";
+import {getDetail} from "@/api/modules/modules";
export default {
name: "funcView",
@@ -131,18 +132,12 @@
socketIoClient: null,
}
},
+ created() {
+ this.connect()
+ },
mounted() {
},
methods: {
- handleSubmit(form, done) {
- getAll(form).then(res => {
- if (res.data.code == 200) {
- let data = res.data.data
- this.menuList = data
- done()
- }
- })
- },
handleSelect(index) {
let selectData = this.menuList.filter(e => {
return e.id == index
@@ -159,38 +154,49 @@
if (data.type == 2) {
let fileArray = data.fileUrl
this.flipConfig.pages = []
- fileArray.forEach(e => {
- this.flipConfig.pages.push(e.value)
- })
+ if (fileArray.length>0 && fileArray){
+ fileArray.forEach(e => {
+ this.flipConfig.pages.push(e.value)
+ })
+ }
} else if (data.type == 3) {
- url = data.fileUrl[0].value
- this.path = 'http://192.168.0.200:8012/onlinePreview?url=' + encodeURIComponent(Base64.encode(url))
+ if (data.fileUrl&&data.fileUrl.length>0){
+ url = data.fileUrl[0].value
+ this.path = 'http://192.168.0.200:8012/onlinePreview?url=' + encodeURIComponent(Base64.encode(url))
+ }
} else if (data.type == 1) {
- url = data.fileUrl[0].value
- this.path = 'http://192.168.0.200:8012/onlinePreview?url=' + encodeURIComponent(Base64.encode(url))
+ if (data.fileUrl&&data.fileUrl.length>0){
+ url = data.fileUrl[0].value
+ this.path = 'http://192.168.0.200:8012/onlinePreview?url=' + encodeURIComponent(Base64.encode(url))
+ }
}
} else if (data.property == 3) {
}
-
-
},
- connect(form, done) {
+ connect() {
+
+ // if (this.socketIoClient != null){
+ // this.socketIoClient.disconnect()
+ // this.socketIoClient = null
+ // }
+
+
let serveUri = 'http://192.168.0.200:10246'
- let params = {
- modulesId: form.modulesId,
- isView: true
- }
+ // let params = {
+ // modulesId: form.modulesId,
+ // isView: true
+ // }
this.socketIoClient = io.connect(serveUri, {
- 'force new connection': true,
- 'query': 'connectInfo=' + JSON.stringify(params)
+ // 'force new connection': true,
+ // 'query': 'connectInfo=' + JSON.stringify(params)
});
//监听与服务器的连接状态
this.socketIoClient.on("connect", () => {
- done()
+ // done()
})
//监听服务器发回的消息
@@ -210,20 +216,34 @@
});
this.socketIoClient.on("menuChange", (res) => {
+ console.log(res)
this.handleSelect(res)
});
//上一页
this.socketIoClient.on("previousPage", (res) => {
+ console.log(res)
this.left()
});
//下一页
this.socketIoClient.on("nextPage", (res) => {
+ console.log(res)
this.right()
});
},
+ getMenuList(form,done){
+ this.sendMsg("putInClientMap",null)
+ done()
+ },
+ sendMsg(msgName,data){
+ let msg = {
+ current:this.form.modulesId,
+ msg :data
+ }
+ this.socketIoClient.emit(msgName,JSON.stringify(msg))
+ },
left() {
this.$refs.flipbook.flipLeft()
},
--
Gitblit v1.9.3