index-e88ee381.js 4.1 KB

1
  1. import{d as Q,r as c,bi as X,J as P,e1 as Y,bw as Z,k as ee,o as m,c as f,f as s,w as r,g as e,a as t,m as y,t as h,N as w,F as q,n as F,q as ae,ak as le,U as te,B as se,x as re,y as ue,__tla as ne}from"./index-2eab2d23.js";import{E as oe,__tla as de}from"./el-card-c558f0ec.js";import{f as ie,__tla as ce}from"./formatTime-41155543.js";import{g as me,__tla as pe}from"./index-e191a423.js";import{u as ve,__tla as _e}from"./useMessage-171aa63e.js";let W,fe=Promise.all([(()=>{try{return ne}catch{}})(),(()=>{try{return de}catch{}})(),(()=>{try{return ce}catch{}})(),(()=>{try{return pe}catch{}})(),(()=>{try{return _e}catch{}})()]).then(async()=>{let g,b,k,V,N,U,J,O,S,$,I,D;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),N=e("hr",{class:"my-4"},null,-1),U={class:"flex"},J=e("p",{class:"mt-4 text-lg font-medium"},"\u6D88\u606F\u8F93\u5165\u6846",-1),O=e("hr",{class:"my-4"},null,-1),S=e("div",{class:"card-header"},[e("span",null,"\u6D88\u606F\u8BB0\u5F55")],-1),$={class:"max-h-80 overflow-auto"},I={class:"flex items-center"},D=e("span",{class:"text-primary mr-2 font-medium"},"\u6536\u5230\u6D88\u606F:",-1),W=Q({name:"InfraWebSocket",__name:"index",setup(ye){const x=ve(),p=c("https://zxpt.newfeifan.cn/infra/ws".replace("http","ws")+"?token="+X()),n=P(()=>R.value==="OPEN"),j=P(()=>n.value?"success":"red"),{status:R,data:o,send:A,close:G,open:H}=Y(p.value,{autoReconnect:!1,heartbeat:!0}),v=c([]);Z(()=>{if(o.value)try{if(o.value==="pong")return;const d=JSON.parse(o.value),l=d.type,u=JSON.parse(d.content);if(!l)return void x.error("\u672A\u77E5\u7684\u6D88\u606F\u7C7B\u578B\uFF1A"+o.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"+o.value)}catch{x.error("\u5904\u7406\u6D88\u606F\u53D1\u751F\u5F02\u5E38\uFF1A"+o.value)}});const i=c(""),_=c(""),K=()=>{const d=JSON.stringify({text:i.value,toUserId:_.value}),l=JSON.stringify({type:"demo-message-send",content:d});A(l),i.value=""},L=()=>{n.value?G():H()},T=c([]);return ee(async()=>{T.value=await me()}),(d,l)=>{const u=le,z=te,B=se,C=re,M=ue,E=oe;return m(),f("div",g,[s(E,{gutter:12,class:"w-1/2",shadow:"always"},{header:r(()=>[b]),default:r(()=>[e("div",k,[V,s(u,{color:t(j)},{default:r(()=>[y(h(t(R)),1)]),_:1},8,["color"])]),N,e("div",U,[s(z,{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(B,{type:t(n)?"danger":"primary",onClick:L},{default:r(()=>[y(h(t(n)?"\u5173\u95ED\u8FDE\u63A5":"\u5F00\u542F\u8FDE\u63A5"),1)]),_:1},8,["type"])]),J,O,s(z,{modelValue:t(i),"onUpdate:modelValue":l[1]||(l[1]=a=>w(i)?i.value=a:null),autosize:{minRows:2,maxRows:4},disabled:!t(n),clearable:"",type:"textarea",placeholder:"\u8BF7\u8F93\u5165\u4F60\u8981\u53D1\u9001\u7684\u6D88\u606F"},null,8,["modelValue","disabled"]),s(M,{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(C,{key:"",label:"\u6240\u6709\u4EBA",value:""}),(m(!0),f(q,null,F(t(T),a=>(m(),ae(C,{key:a.id,label:a.nickname,value:a.id},null,8,["label","value"]))),128))]),_:1},8,["modelValue"]),s(B,{disabled:!t(n),block:"",class:"ml-2 mt-4",type:"primary",onClick:K},{default:r(()=>[y(" \u53D1\u9001 ")]),_:1},8,["disabled"])]),_:1}),s(E,{gutter:12,class:"w-1/2",shadow:"always"},{header:r(()=>[S]),default:r(()=>[e("div",$,[e("ul",null,[(m(!0),f(q,null,F(t(v).reverse(),a=>(m(),f("li",{key:a.time,class:"mt-2"},[e("div",I,[D,e("span",null,h(t(ie)(a.time)),1)]),e("div",null,h(a.text),1)]))),128))])])]),_:1})])}}})});export{fe as __tla,W as default};