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