import{d as Q,r as c,bj as X,K as E,e0 as Y,by as Z,l as ee,o as m,c as _,f as s,w as r,g as e,a as t,n as y,t as h,P as w,F as W,q as j,v as ae,al as le,W as te,C as se,y as re,z as ne,_ as ue,__tla as oe}from"./index-04f8d540.js";import{E as de,__tla as ie}from"./el-card-3a265a8d.js";import{f as ce,__tla as me}from"./formatTime-81f0c591.js";import{g as pe,__tla as ve}from"./index-6e48cf5a.js";import{u as fe,__tla as _e}from"./useMessage-9c37e840.js";let F,ye=Promise.all([(()=>{try{return oe}catch{}})(),(()=>{try{return ie}catch{}})(),(()=>{try{return me}catch{}})(),(()=>{try{return ve}catch{}})(),(()=>{try{return _e}catch{}})()]).then(async()=>{let b,g,V,k,S,U,z,N,O,$,D,I;b={class:"flex"},g=e("div",{class:"card-header"},[e("span",null,"\u8FDE\u63A5")],-1),V={class:"flex items-center"},k=e("span",{class:"mr-4 text-lg font-medium"}," \u8FDE\u63A5\u72B6\u6001: ",-1),S=e("hr",{class:"my-4"},null,-1),U={class:"flex"},z=e("p",{class:"mt-4 text-lg font-medium"},"\u6D88\u606F\u8F93\u5165\u6846",-1),N=e("hr",{class:"my-4"},null,-1),O=e("div",{class:"card-header"},[e("span",null,"\u6D88\u606F\u8BB0\u5F55")],-1),$={class:"max-h-80 overflow-auto"},D={class:"flex items-center"},I=e("span",{class:"text-primary mr-2 font-medium"},"\u6536\u5230\u6D88\u606F:",-1),F=ue(Q({name:"InfraWebSocket",__name:"index",setup(he){const x=fe(),p=c("https://zxsh.newfeifan.cn/infra/ws".replace("http","ws")+"?token="+X()),o=E(()=>J.value==="OPEN"),K=E(()=>o.value?"success":"red"),{status:J,data:d,send:A,close:B,open:G}=Y(p.value,{autoReconnect:!1,heartbeat:!0}),v=c([]);Z(()=>{if(d.value)try{if(d.value==="pong")return;const u=JSON.parse(d.value),l=u.type,n=JSON.parse(u.content);if(!l)return void x.error("\u672A\u77E5\u7684\u6D88\u606F\u7C7B\u578B\uFF1A"+d.value);if(l==="demo-message-receive")return void(n.single?v.value.push({text:`\u3010\u5355\u53D1\u3011\u7528\u6237\u7F16\u53F7(${n.fromUserId})\uFF1A${n.text}`,time:new Date().getTime()}):v.value.push({text:`\u3010\u7FA4\u53D1\u3011\u7528\u6237\u7F16\u53F7(${n.fromUserId})\uFF1A${n.text}`,time:new Date().getTime()}));if(l==="notice-push")return void v.value.push({text:`\u3010\u7CFB\u7EDF\u901A\u77E5\u3011\uFF1A${n.title}`,time:new Date().getTime()});x.error("\u672A\u5904\u7406\u6D88\u606F\uFF1A"+d.value)}catch(u){x.error("\u5904\u7406\u6D88\u606F\u53D1\u751F\u5F02\u5E38\uFF1A"+d.value),console.error(u)}});const i=c(""),f=c(""),H=()=>{const u=JSON.stringify({text:i.value,toUserId:f.value}),l=JSON.stringify({type:"demo-message-send",content:u});A(l),i.value=""},L=()=>{o.value?B():G()},C=c([]);return ee(async()=>{C.value=await pe()}),(u,l)=>{const n=le,P=te,R=se,T=re,M=ne,q=de;return m(),_("div",b,[s(q,{gutter:12,class:"w-1/2",shadow:"always"},{header:r(()=>[g]),default:r(()=>[e("div",V,[k,s(n,{color:t(K)},{default:r(()=>[y(h(t(J)),1)]),_:1},8,["color"])]),S,e("div",U,[s(P,{modelValue:t(p),"onUpdate:modelValue":l[0]||(l[0]=a=>w(p)?p.value=a:null),disabled:""},{prepend:r(()=>[y("\u670D\u52A1\u5730\u5740")]),_:1},8,["modelValue"]),s(R,{type:t(o)?"danger":"primary",onClick:L},{default:r(()=>[y(h(t(o)?"\u5173\u95ED\u8FDE\u63A5":"\u5F00\u542F\u8FDE\u63A5"),1)]),_:1},8,["type"])]),z,N,s(P,{modelValue:t(i),"onUpdate:modelValue":l[1]||(l[1]=a=>w(i)?i.value=a:null),autosize:{minRows:2,maxRows:4},disabled:!t(o),clearable:"",type:"textarea",placeholder:"\u8BF7\u8F93\u5165\u4F60\u8981\u53D1\u9001\u7684\u6D88\u606F"},null,8,["modelValue","disabled"]),s(M,{modelValue:t(f),"onUpdate:modelValue":l[2]||(l[2]=a=>w(f)?f.value=a:null),class:"mt-4",placeholder:"\u8BF7\u9009\u62E9\u53D1\u9001\u4EBA"},{default:r(()=>[s(T,{key:"",label:"\u6240\u6709\u4EBA",value:""}),(m(!0),_(W,null,j(t(C),a=>(m(),ae(T,{key:a.id,label:a.nickname,value:a.id},null,8,["label","value"]))),128))]),_:1},8,["modelValue"]),s(R,{disabled:!t(o),block:"",class:"ml-2 mt-4",type:"primary",onClick:H},{default:r(()=>[y(" \u53D1\u9001 ")]),_:1},8,["disabled"])]),_:1}),s(q,{gutter:12,class:"w-1/2",shadow:"always"},{header:r(()=>[O]),default:r(()=>[e("div",$,[e("ul",null,[(m(!0),_(W,null,j(t(v).reverse(),a=>(m(),_("li",{key:a.time,class:"mt-2"},[e("div",D,[I,e("span",null,h(t(ce)(a.time)),1)]),e("div",null,h(a.text),1)]))),128))])])]),_:1})])}}}),[["__file","D:/zx/mall-newfeifan-zx-business/src/views/infra/webSocket/index.vue"]])});export{ye as __tla,F as default};
