沙钢智慧能源系统前端代码
houzhongjian
2024-10-09 314507f8ddadd9c66e98d260c3b2a5dad1a04015
1
import{d as z,Q as F,r as m,ds as P,ad as w,dJ as Q,aO as W,b as j,o as c,c as h,k as t,B as r,C as e,a as s,O as y,D as x,I as b,F as D,i as I,g as q,aD as A,a7 as G,V as H,$ as K,R as L}from"./index-BP6bNRoi.js";import{E as M}from"./el-card-bU92WWV4.js";import{f as X}from"./formatTime-DwR9f7DP.js";import{g as Y}from"./index-vFgEqmZu.js";const Z={class:"flex"},ee=e("div",{class:"card-header"},[e("span",null,"\u8FDE\u63A5")],-1),ae={class:"flex items-center"},le=e("span",{class:"mr-4 text-lg font-medium"}," \u8FDE\u63A5\u72B6\u6001: ",-1),se=e("hr",{class:"my-4"},null,-1),te={class:"flex"},re=e("p",{class:"mt-4 text-lg font-medium"},"\u6D88\u606F\u8F93\u5165\u6846",-1),ue=e("hr",{class:"my-4"},null,-1),oe=e("div",{class:"card-header"},[e("span",null,"\u6D88\u606F\u8BB0\u5F55")],-1),de={class:"max-h-80 overflow-auto"},ne={class:"flex items-center"},ie=e("span",{class:"text-primary mr-2 font-medium"},"\u6536\u5230\u6D88\u606F:",-1),me=z({name:"InfraWebSocket",__name:"index",setup(ce){const g=F(),p=m("http://localhost:48080/infra/ws".replace("http","ws")+"?token="+P()),d=w(()=>k.value==="OPEN"),J=w(()=>d.value?"success":"red"),{status:k,data:n,send:N,close:S,open:R}=Q(p.value,{autoReconnect:!0,heartbeat:!0}),v=m([]),C=w(()=>v.value.slice().reverse());W(()=>{if(n.value)try{if(n.value==="pong")return;const o=JSON.parse(n.value),l=o.type,u=JSON.parse(o.content);if(!l)return void g.error("\u672A\u77E5\u7684\u6D88\u606F\u7C7B\u578B\uFF1A"+n.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()});g.error("\u672A\u5904\u7406\u6D88\u606F\uFF1A"+n.value)}catch(o){g.error("\u5904\u7406\u6D88\u606F\u53D1\u751F\u5F02\u5E38\uFF1A"+n.value),console.error(o)}});const i=m(""),f=m(""),T=()=>{const o=JSON.stringify({text:i.value,toUserId:f.value}),l=JSON.stringify({type:"demo-message-send",content:o});N(l),i.value=""},B=()=>{d.value?S():R()},V=m([]);return j(async()=>{V.value=await Y()}),(o,l)=>{const u=A,_=G,O=H,U=K,E=L,$=M;return c(),h("div",Z,[t($,{gutter:12,class:"w-1/2",shadow:"always"},{header:r(()=>[ee]),default:r(()=>[e("div",ae,[le,t(u,{color:s(J)},{default:r(()=>[y(x(s(k)),1)]),_:1},8,["color"])]),se,e("div",te,[t(_,{modelValue:s(p),"onUpdate:modelValue":l[0]||(l[0]=a=>b(p)?p.value=a:null),disabled:""},{prepend:r(()=>[y("\u670D\u52A1\u5730\u5740")]),_:1},8,["modelValue"]),t(O,{type:s(d)?"danger":"primary",onClick:B},{default:r(()=>[y(x(s(d)?"\u5173\u95ED\u8FDE\u63A5":"\u5F00\u542F\u8FDE\u63A5"),1)]),_:1},8,["type"])]),re,ue,t(_,{modelValue:s(i),"onUpdate:modelValue":l[1]||(l[1]=a=>b(i)?i.value=a:null),autosize:{minRows:2,maxRows:4},disabled:!s(d),clearable:"",placeholder:"\u8BF7\u8F93\u5165\u4F60\u8981\u53D1\u9001\u7684\u6D88\u606F",type:"textarea"},null,8,["modelValue","disabled"]),t(E,{modelValue:s(f),"onUpdate:modelValue":l[2]||(l[2]=a=>b(f)?f.value=a:null),class:"mt-4",placeholder:"\u8BF7\u9009\u62E9\u53D1\u9001\u4EBA"},{default:r(()=>[t(U,{key:"",label:"\u6240\u6709\u4EBA",value:""}),(c(!0),h(D,null,I(s(V),a=>(c(),q(U,{key:a.id,label:a.nickname,value:a.id},null,8,["label","value"]))),128))]),_:1},8,["modelValue"]),t(O,{disabled:!s(d),block:"",class:"ml-2 mt-4",type:"primary",onClick:T},{default:r(()=>[y(" \u53D1\u9001 ")]),_:1},8,["disabled"])]),_:1}),t($,{gutter:12,class:"w-1/2",shadow:"always"},{header:r(()=>[oe]),default:r(()=>[e("div",de,[e("ul",null,[(c(!0),h(D,null,I(s(C),a=>(c(),h("li",{key:a.time,class:"mt-2"},[e("div",ne,[ie,e("span",null,x(s(X)(a.time)),1)]),e("div",null,x(a.text),1)]))),128))])])]),_:1})])}}});export{me as default};