index-2793fdc8.js 4.2 KB

1
  1. import{d as L,r as c,bB as M,Y as C,d_ as Q,bP as Z,q as ee,o as m,c as f,f as s,w as r,g as e,a as t,y,t as h,l as w,F as E,v as A,x as ae,ah as le,R as te,G as se,A as re,B as ne,_ as ue,__tla as oe}from"./index-8dc1e40a.js";import{E as de,__tla as ie}from"./el-card-18df90f0.js";import{f as ce,__tla as me}from"./formatTime-8a155b2e.js";import{g as pe,__tla as ve}from"./index-6f284c9a.js";import{u as _e,__tla as fe}from"./useMessage-7a27dd80.js";let F,ye=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,k,V,U,S,N,O,R,$,D,I;g={class:"flex"},b=e("div",{class:"card-header"},[e("span",null,"\u8FDE\u63A5")],-1),k={class:"flex items-center"},V=e("span",{class:"mr-4 text-lg font-medium"}," \u8FDE\u63A5\u72B6\u6001: ",-1),U=e("hr",{class:"my-4"},null,-1),S={class:"flex"},N=e("p",{class:"mt-4 text-lg font-medium"},"\u6D88\u606F\u8F93\u5165\u6846",-1),O=e("hr",{class:"my-4"},null,-1),R=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(L({name:"InfraWebSocket",__name:"index",setup(he){const x=_e(),p=c("https://zxpt.newfeifan.cn/infra/ws".replace("http","ws")+"?token="+M()),o=C(()=>J.value==="OPEN"),G=C(()=>o.value?"success":"red"),{status:J,data:d,send:H,close:W,open:X}=Q(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(""),_=c(""),Y=()=>{const u=JSON.stringify({text:i.value,toUserId:_.value}),l=JSON.stringify({type:"demo-message-send",content:u});H(l),i.value=""},j=()=>{o.value?W():X()},z=c([]);return ee(async()=>{z.value=await pe()}),(u,l)=>{const n=le,P=te,T=se,q=re,K=ne,B=de;return m(),f("div",g,[s(B,{gutter:12,class:"w-1/2",shadow:"always"},{header:r(()=>[b]),default:r(()=>[e("div",k,[V,s(n,{color:t(G)},{default:r(()=>[y(h(t(J)),1)]),_:1},8,["color"])]),U,e("div",S,[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(T,{type:t(o)?"danger":"primary",onClick:j},{default:r(()=>[y(h(t(o)?"\u5173\u95ED\u8FDE\u63A5":"\u5F00\u542F\u8FDE\u63A5"),1)]),_:1},8,["type"])]),N,O,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(K,{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(q,{key:"",label:"\u6240\u6709\u4EBA",value:""}),(m(!0),f(E,null,A(t(z),a=>(m(),ae(q,{key:a.id,label:a.nickname,value:a.id},null,8,["label","value"]))),128))]),_:1},8,["modelValue"]),s(T,{disabled:!t(o),block:"",class:"ml-2 mt-4",type:"primary",onClick:Y},{default:r(()=>[y(" \u53D1\u9001 ")]),_:1},8,["disabled"])]),_:1}),s(B,{gutter:12,class:"w-1/2",shadow:"always"},{header:r(()=>[R]),default:r(()=>[e("div",$,[e("ul",null,[(m(!0),f(E,null,A(t(v).reverse(),a=>(m(),f("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","/Users/RuHu.Xu/Desktop/mall-newfeifan-zx-admin/src/views/infra/webSocket/index.vue"]])});export{ye as __tla,F as default};