1 |
- import{d as M,r as c,b6 as Q,e as P,e0 as X,ba as Z,z as ee,o as m,c as f,i as s,w as r,j as e,a as t,l as h,t as y,R as w,F as j,C as F,k as ae,am as le,Y as te,s as se,G as re,H as ne,_ as ue,__tla as oe}from"./index-2f799233.js";import{E as ie,__tla as de}from"./el-card-c64c83d1.js";import{f as ce,__tla as me}from"./formatTime-2157894c.js";import{g as pe,__tla as ve}from"./index-dd9c509d.js";import{u as _e,__tla as fe}from"./useMessage-e567ad40.js";let G,he=Promise.all([(()=>{try{return oe}catch{}})(),(()=>{try{return de}catch{}})(),(()=>{try{return me}catch{}})(),(()=>{try{return ve}catch{}})(),(()=>{try{return fe}catch{}})()]).then(async()=>{let b,g,k,V,S,U,z,N,O,$,D,I;b={class:"flex"},g=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),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),G=ue(M({name:"InfraWebSocket",__name:"index",setup(ye){const x=_e(),p=c("https://zxsh.newfeifan.cn/infra/ws".replace("http","ws")+"?token="+Q()),o=P(()=>J.value==="OPEN"),W=P(()=>o.value?"success":"red"),{status:J,data:i,send:Y,close:q,open:A}=X(p.value,{autoReconnect:!1,heartbeat:!0}),v=c([]);Z(()=>{if(i.value)try{if(i.value==="pong")return;const u=JSON.parse(i.value),l=u.type,n=JSON.parse(u.content);if(!l)return void x.error("\u672A\u77E5\u7684\u6D88\u606F\u7C7B\u578B\uFF1A"+i.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"+i.value)}catch(u){x.error("\u5904\u7406\u6D88\u606F\u53D1\u751F\u5F02\u5E38\uFF1A"+i.value),console.error(u)}});const d=c(""),_=c(""),B=()=>{const u=JSON.stringify({text:d.value,toUserId:_.value}),l=JSON.stringify({type:"demo-message-send",content:u});Y(l),d.value=""},K=()=>{o.value?q():A()},R=c([]);return ee(async()=>{R.value=await pe()}),(u,l)=>{const n=le,C=te,T=se,E=re,L=ne,H=ie;return m(),f("div",b,[s(H,{gutter:12,class:"w-1/2",shadow:"always"},{header:r(()=>[g]),default:r(()=>[e("div",k,[V,s(n,{color:t(W)},{default:r(()=>[h(y(t(J)),1)]),_:1},8,["color"])]),S,e("div",U,[s(C,{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(T,{type:t(o)?"danger":"primary",onClick:K},{default:r(()=>[h(y(t(o)?"\u5173\u95ED\u8FDE\u63A5":"\u5F00\u542F\u8FDE\u63A5"),1)]),_:1},8,["type"])]),z,N,s(C,{modelValue:t(d),"onUpdate:modelValue":l[1]||(l[1]=a=>w(d)?d.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(L,{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,F(t(R),a=>(m(),ae(E,{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:B},{default:r(()=>[h(" \u53D1\u9001 ")]),_:1},8,["disabled"])]),_:1}),s(H,{gutter:12,class:"w-1/2",shadow:"always"},{header:r(()=>[O]),default:r(()=>[e("div",$,[e("ul",null,[(m(!0),f(j,null,F(t(v).reverse(),a=>(m(),f("li",{key:a.time,class:"mt-2"},[e("div",D,[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,G as default};
|