boyuehasfj-vue3/boyuehasfj-admin/assets/websocket-ClCYpClK.js
2025-06-02 21:34:56 +08:00

2 lines
1.6 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import{_ as e,c as t,e as n,m as l,f as s,j as o,w as a,o as u}from"./index-C-c3zR6K.js";const i=e({data:()=>({url:"ws://127.0.0.1:8080/websocket/message",message:"",text_content:"",ws:null}),methods:{join(){const e=this.url;this.ws=new WebSocket(e);const t=this;this.ws.onopen=function(e){t.text_content=t.text_content+"已经打开连接!\n"},this.ws.onmessage=function(e){t.text_content=e.data+"\n"},this.ws.onclose=function(e){t.text_content=t.text_content+"已经关闭连接!\n"}},exit(){this.ws&&(this.ws.close(),this.ws=null)},send(){this.ws?this.ws.send(this.message):alert("未连接到服务器")}}},[["render",function(e,i,c,d,r,m){const w=o("el-input"),x=o("el-button");return u(),t("div",null,[n(w,{modelValue:r.url,"onUpdate:modelValue":i[0]||(i[0]=e=>r.url=e),type:"text",style:{width:"20%"}},null,8,["modelValue"]),i[6]||(i[6]=l("     ")),n(x,{onClick:m.join,type:"primary"},{default:a((()=>i[3]||(i[3]=[l("连接")]))),_:1},8,["onClick"]),n(x,{onClick:m.exit,type:"danger"},{default:a((()=>i[4]||(i[4]=[l("断开")]))),_:1},8,["onClick"]),i[7]||(i[7]=s("br",null,null,-1)),n(w,{type:"textarea",modelValue:r.message,"onUpdate:modelValue":i[1]||(i[1]=e=>r.message=e),rows:9},null,8,["modelValue"]),n(x,{type:"info",onClick:m.send},{default:a((()=>i[5]||(i[5]=[l("发送消息")]))),_:1},8,["onClick"]),i[8]||(i[8]=s("br",null,null,-1)),i[9]||(i[9]=s("br",null,null,-1)),n(w,{type:"textarea",modelValue:r.text_content,"onUpdate:modelValue":i[2]||(i[2]=e=>r.text_content=e),rows:9},null,8,["modelValue"]),i[10]||(i[10]=l(" 返回内容 ")),i[11]||(i[11]=s("br",null,null,-1)),i[12]||(i[12]=s("br",null,null,-1))])}]]);export{i as default};