|
|
@@ -677,7 +677,7 @@ import { Controls } from '@vue-flow/controls'
|
|
|
import '@vue-flow/controls/dist/style.css'
|
|
|
import '@vue-flow/core/dist/theme-default.css';
|
|
|
import { Plus,Search } from '@element-plus/icons-vue'
|
|
|
-import { toRaw, isReactive, isProxy } from 'vue';
|
|
|
+import { toRaw, isReactive, isProxy,onUnmounted } from 'vue';
|
|
|
import DynamicMap from '@/components/DynamicMap/index.vue'
|
|
|
import {Promotion} from '@element-plus/icons-vue'
|
|
|
import { onMounted, ref,onBeforeUnmount } from 'vue'
|
|
|
@@ -1099,6 +1099,7 @@ function saveNode(){
|
|
|
nodes.value.forEach(item=>{
|
|
|
if(item.id===parNodeid.value){
|
|
|
item.data = par
|
|
|
+ item.data.service = serInfo.value
|
|
|
item.data.service.params = parSerList.value
|
|
|
}
|
|
|
})
|
|
|
@@ -1528,8 +1529,53 @@ function getList() {
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
+const ws = ref(null);
|
|
|
+const connected = ref(false);
|
|
|
+const messages = ref([]);
|
|
|
+const connect = () => {
|
|
|
+ ws.value = new WebSocket('ws://127.0.0.1:8082/websocket/message'); // 替换为你的 WS 地址
|
|
|
+
|
|
|
+ ws.value.onopen = () => {
|
|
|
+ connected.value = true;
|
|
|
+ console.log('WebSocket 连接已建立');
|
|
|
+ };
|
|
|
+
|
|
|
+ ws.value.onmessage = (event) => {
|
|
|
+ console.log('收到消息:', event.data);
|
|
|
|
|
|
+ messages.value.push(event.data); // 存储接收到的消息
|
|
|
+ };
|
|
|
+
|
|
|
+ ws.value.onerror = (error) => {
|
|
|
+ console.error('WebSocket 错误:', error);
|
|
|
+ };
|
|
|
+
|
|
|
+ ws.value.onclose = () => {
|
|
|
+ connected.value = false;
|
|
|
+ console.log('WebSocket 连接已关闭');
|
|
|
+ };
|
|
|
+};
|
|
|
+
|
|
|
+const sendMessage = () => {
|
|
|
+ if (ws.value && ws.value.readyState === WebSocket.OPEN) {
|
|
|
+ const message = 'Hello, Server!'; // 实际发送的消息内容或格式可与后端约定
|
|
|
+ ws.value.send(message);
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+const disconnect = () => {
|
|
|
+ if (ws.value) {
|
|
|
+ ws.value.close();
|
|
|
+ ws.value = null;
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+// 组件卸载时自动断开连接
|
|
|
+onUnmounted(() => {
|
|
|
+ disconnect();
|
|
|
+});
|
|
|
onMounted(() => {
|
|
|
+ connect()
|
|
|
getTreeLeft()
|
|
|
getList();
|
|
|
})
|