index-8897072a.js 4.2 KB

1
  1. import{d as L,r as c,co as M,b as P,dZ as Q,be as Y,B as ee,o as m,c as f,i as s,w as r,g as e,a as t,j as y,t as h,y as w,F as j,k as B,l as ae,ak as le,U as te,J as se,D as re,G as ne,_ as ue,__tla as oe}from"./index-b2b3c6c4.js";import{E as de,__tla as ie}from"./el-card-bd6e27c9.js";import{f as ce,__tla as me}from"./formatTime-7e07ce72.js";import{g as pe,__tla as ve}from"./index-292d166c.js";import{u as _e,__tla as fe}from"./useMessage-a5edbb0f.js";let G,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,D,J,N,O,$,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"},D=e("p",{class:"mt-4 text-lg font-medium"},"\u6D88\u606F\u8F93\u5165\u6846",-1),J=e("hr",{class:"my-4"},null,-1),N=e("div",{class:"card-header"},[e("span",null,"\u6D88\u606F\u8BB0\u5F55")],-1),O={class:"max-h-80 overflow-auto"},$={class:"flex items-center"},I=e("span",{class:"text-primary mr-2 font-medium"},"\u6536\u5230\u6D88\u606F:",-1),G=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=P(()=>R.value==="OPEN"),H=P(()=>o.value?"success":"red"),{status:R,data:d,send:W,close:X,open:Z}=Q(p.value,{autoReconnect:!1,heartbeat:!0}),v=c([]);Y(()=>{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(""),q=()=>{const u=JSON.stringify({text:i.value,toUserId:_.value}),l=JSON.stringify({type:"demo-message-send",content:u});W(l),i.value=""},A=()=>{o.value?X():Z()},z=c([]);return ee(async()=>{z.value=await pe()}),(u,l)=>{const n=le,T=te,C=se,E=re,K=ne,F=de;return m(),f("div",g,[s(F,{gutter:12,class:"w-1/2",shadow:"always"},{header:r(()=>[b]),default:r(()=>[e("div",k,[V,s(n,{color:t(H)},{default:r(()=>[y(h(t(R)),1)]),_:1},8,["color"])]),U,e("div",S,[s(T,{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(C,{type:t(o)?"danger":"primary",onClick:A},{default:r(()=>[y(h(t(o)?"\u5173\u95ED\u8FDE\u63A5":"\u5F00\u542F\u8FDE\u63A5"),1)]),_:1},8,["type"])]),D,J,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(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(E,{key:"",label:"\u6240\u6709\u4EBA",value:""}),(m(!0),f(j,null,B(t(z),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:q},{default:r(()=>[y(" \u53D1\u9001 ")]),_:1},8,["disabled"])]),_:1}),s(F,{gutter:12,class:"w-1/2",shadow:"always"},{header:r(()=>[N]),default:r(()=>[e("div",O,[e("ul",null,[(m(!0),f(j,null,B(t(v).reverse(),a=>(m(),f("li",{key:a.time,class:"mt-2"},[e("div",$,[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,G as default};