| 12 |
- import{bg as ft,bh as vt,bi as _t,Q as W,aC as A,d as X,c as h,r as z,f as D,b0 as G,cI as bt,h as yt,b6 as Ct,o as Rt,C as gt,j as Ut,Z as w,a1 as k,a7 as a,n as u,a0 as i,T as s,a6 as l,b4 as T,aI as Lt,aH as K,dW as N,a2 as E,a3 as H,aQ as _,a5 as b,bc as m,at as xt}from"./index-a8341fa1.js";import"./dayjs-919e6097.js";import{i as Ft,a as Pt}from"./stream-type-63b6e1e6.js";import{A as Q}from"./index-5352c15f.js";const C=ft({requestOptions:{apiUrl:()=>vt("test","/api/stress")}});function St(n,e,c){return C.post({url:`/push/${n}/${e}`,data:c})}function wt(n,e,c){return C.post({url:`/pull/${n}/${e}`,data:c})}function kt(){return C.get({url:"/count"})}function Tt(){return C.post({url:"/stop/push"})}function At(){return C.post({url:"/stop/pull"})}const U=_t({id:"app-stress-store",persist:{paths:["remoteURLOptions"]},state:()=>({remoteURLOptions:[]}),actions:{setRemoteURL(n){if(this.remoteURLOptions.some(c=>c.value===n))return;const e=[{value:n},...this.remoteURLOptions].slice(0,10);this.remoteURLOptions=e}}}),{remoteURLOptions:Z}=W(U()),It=n=>{const{t:e}=A();return{type:"object",properties:{layout:{type:"void","x-component":"FormLayout","x-component-props":{layout:"horizontal",labelCol:6,wrapperCol:18},properties:{streamPath:{type:"string",title:e("routes.stress.流路径"),"x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:e("routes.stress.请输入流路径"),allowClear:!0},"x-validator":[{required:!0,message:e("routes.stress.请输入流路径")}],default:n?.streamPath||""},remoteURL:{type:"string",title:e("routes.stress.目标地址"),"x-decorator":"FormItem","x-component":"AutoCompleteInput","x-component-props":{placeholder:e("routes.stress.请输入推流目标地址"),allowClear:!0,style:{width:"100%"}},enum:Z.value,"x-validator":[{required:!0,message:e("routes.stress.请输入推流目标地址")},{pattern:/^(rtmp|rtmps|rtsp|rtsps|srt|http|https):\/\/.+/,message:e("routes.stress.请输入有效的推流地址")}],default:n?.remoteURL||""}}}}}},Mt=n=>{const{t:e}=A();return{type:"object",properties:{layout:{type:"void","x-component":"FormLayout","x-component-props":{layout:"horizontal",labelCol:6,wrapperCol:18},properties:{protocol:{type:"string",title:e("routes.stress.拉流协议"),"x-decorator":"FormItem","x-component":"Radio.Group","x-component-props":{optionType:"button",options:[{label:"RTMP",value:"rtmp",disabled:!0},{label:"RTSP",value:"rtsp",disabled:!0},{label:"SRT",value:"srt",disabled:!0},{label:"FLV",value:"flv"},{label:"MP4",value:"mp4"},{label:"HLS",value:"hls"},{label:"WebRTC",value:"webrtc"},{label:"GB28181",value:"gb28181"}]},"x-validator":[{required:!0,message:e("routes.stress.请选择拉流协议")}],default:n?.protocol||"rtmp"},remoteURL:{type:"string",title:e("routes.stress.源地址"),"x-decorator":"FormItem","x-component":"AutoCompleteInput","x-component-props":{placeholder:e("routes.stress.请输入拉流源地址"),allowClear:!0,style:{width:"100%"}},enum:Z.value,"x-validator":[{required:!0,message:e("routes.stress.请输入拉流源地址")},{pattern:/^(rtmp|rtmps|rtsp|rtsps|srt|http|https|ws|wss):\/\/.+/,message:e("routes.stress.请输入有效的拉流地址")}],default:n?.remoteURL||""},testMode:{type:"number",title:e("routes.stress.测试模式"),"x-decorator":"FormItem","x-component":"Radio.Group","x-component-props":{options:[{label:e("routes.stress.拉流并发布"),value:0},{label:e("routes.stress.仅拉流"),value:1}]},default:n?.testMode||0}}}}}},Vt={class:"stress-page"},$t={class:"status-cards"},jt={class:"status-content"},qt={class:"status-number"},Ot={class:"status-label"},Bt={class:"status-content"},zt={class:"status-number"},Dt={class:"status-label"},Gt={class:"slider-container"},Kt={class:"slider-wrapper"},Nt={class:"slider-value"},Et={class:"quick-buttons"},Ht={class:"button-group-label"},Qt={class:"action-buttons"},Wt={class:"slider-container"},Xt={class:"slider-wrapper"},Zt={class:"slider-value"},Jt={class:"quick-buttons"},Yt={class:"button-group-label"},te={class:"action-buttons"},ee=X({name:"StressDetail"}),se=X({...ee,setup(n){const{t:e}=A(),{remoteURLOptions:c}=W(U()),I=h(0),M=h(0),V=h("push"),L=h(!1),x=h(!1),F=h(!1),P=h(!1),p=z({pushCount:1,streamPath:"",protocol:"rtmp",remoteURL:""}),d=z({pullCount:1,protocol:"rtmp",remoteURL:"",testMode:0}),R=1e3,g=1e4,$={0:"0",100:"100",200:"200",500:"500",1e3:"1000"},j=[1,10,100,1e3,5e3],q=[...j.map(t=>-t).reverse(),...j],O=D({get:()=>Math.min(p.pushCount,R),set:t=>{p.pushCount=t}}),B=D({get:()=>Math.min(d.pullCount,R),set:t=>{d.pullCount=t}}),{FormilyForm:J,submit:Y,form:S}=G({schema:It(p)}),{FormilyForm:tt,submit:et,form:y}=G({schema:Mt(d),formProps:{effects(){bt("remoteURL",t=>{const o=t.value,r=Ft(o);r?y.setFieldState("protocol",v=>{v.hidden=!0,v.value=r}):y.setFieldState("protocol",v=>{v.hidden=!1})})}}});yt(()=>c.value,t=>{y&&y.setFieldState("remoteURL",o=>{o.dataSource=t}),S&&S.setFieldState("remoteURL",o=>{o.dataSource=t})});async function f(){try{const t=await kt();I.value=t.pushCount||0,M.value=t.pullCount||0}catch(t){console.error(e("routes.stress.获取推拉流数量失败"),t)}}const{pause:st,resume:ot}=Ct(f);function rt(){c.value.length>0&&!p.remoteURL.trim()&&(at(c.value[0].value),lt(c.value[0].value))}function at(t){p.remoteURL=t,S.setValues({remoteURL:t})}function lt(t){d.remoteURL=t,y.setValues({remoteURL:t})}function ut(t){const o=p.pushCount+t;o>=0&&o<=g&&(p.pushCount=o)}function nt(t){const o=p.pushCount+t;return o>=0&&o<=g}function it(t){const o=d.pullCount+t;o>=0&&o<=g&&(d.pullCount=o)}function ct(t){const o=d.pullCount+t;return o>=0&&o<=g}async function pt(){try{L.value=!0;const t=await Y();if(!t)return;t.remoteURL?.trim()&&U().setRemoteURL(t.remoteURL.trim()),t.protocol=Pt(t.remoteURL),await St(t.protocol,p.pushCount,{streamPath:t.streamPath,remoteURL:t.remoteURL}),m.success(e("routes.stress.推流测试已开始")),f()}catch(t){m.error(e("routes.stress.启动推流失败")+": "+t.message)}finally{L.value=!1}}async function dt(){try{x.value=!0;const t=await et();if(!t)return;t.remoteURL?.trim()&&U().setRemoteURL(t.remoteURL.trim()),await wt(t.protocol,d.pullCount,{remoteURL:t.remoteURL,testMode:t.testMode}),m.success(e("routes.stress.拉流测试已开始")),f()}catch(t){m.error(e("routes.stress.启动拉流失败")+": "+t.message)}finally{x.value=!1}}async function mt(){try{F.value=!0,await Tt(),m.success(e("routes.stress.推流已停止")),f()}catch(t){m.error(e("routes.stress.停止推流失败")+": "+t.message)}finally{F.value=!1}}async function ht(){try{P.value=!0,await At(),m.success(e("routes.stress.拉流已停止")),f()}catch(t){m.error(e("routes.stress.停止拉流失败")+": "+t.message)}finally{P.value=!1}}return Rt(async()=>{f(),ot(),await gt(),rt()}),Ut(()=>{st()}),(t,o)=>(w(),k("div",Vt,[a("div",$t,[u(s(T),{title:s(e)("routes.stress.推流状态"),class:"status-card push-card"},{default:i(()=>[a("div",jt,[a("div",qt,l(I.value),1),a("div",Ot,l(s(e)("routes.stress.正在推流")),1)])]),_:1},8,["title"]),u(s(T),{title:s(e)("routes.stress.拉流状态"),class:"status-card pull-card"},{default:i(()=>[a("div",Bt,[a("div",zt,l(M.value),1),a("div",Dt,l(s(e)("routes.stress.正在拉流")),1)])]),_:1},8,["title"])]),u(s(T),{title:s(e)("routes.stress.压力测试控制"),class:"control-panel"},{default:i(()=>[u(s(Lt),{activeKey:V.value,"onUpdate:activeKey":o[2]||(o[2]=r=>V.value=r)},{default:i(()=>[u(s(K),{key:"push",tab:s(e)("routes.stress.推流测试")},{default:i(()=>[u(s(J),{ref:"pushFormRef"},null,512),a("div",Gt,[a("label",null,l(s(e)("routes.stress.推流数量"))+":",1),a("div",Kt,[u(s(Q),{value:O.value,"onUpdate:value":o[0]||(o[0]=r=>O.value=r),min:0,max:R,marks:$,"tooltip-formatter":r=>`${r} ${s(e)("routes.stress.路")}`},null,8,["value","tooltip-formatter"])]),a("span",Nt,l(p.pushCount)+" "+l(s(e)("routes.stress.路")),1)]),a("div",Et,[a("span",Ht,l(s(e)("routes.stress.快速调整")),1),u(s(N),null,{default:i(()=>[(w(),k(E,null,H(q,r=>u(s(_),{key:r,onClick:v=>ut(r),disabled:!nt(r)},{default:i(()=>[b(l(r>0?"+":"")+l(r),1)]),_:2},1032,["onClick","disabled"])),64))]),_:1})]),a("div",Qt,[u(s(_),{type:"primary",size:"large",loading:L.value,onClick:pt},{default:i(()=>[b(l(s(e)("routes.stress.开始推流")),1)]),_:1},8,["loading"]),u(s(_),{danger:"",size:"large",loading:F.value,onClick:mt},{default:i(()=>[b(l(s(e)("routes.stress.停止推流")),1)]),_:1},8,["loading"])])]),_:1},8,["tab"]),u(s(K),{key:"pull",tab:s(e)("routes.stress.拉流测试")},{default:i(()=>[u(s(tt),{ref:"pullFormRef"},null,512),a("div",Wt,[a("label",null,l(s(e)("routes.stress.拉流数量"))+":",1),a("div",Xt,[u(s(Q),{value:B.value,"onUpdate:value":o[1]||(o[1]=r=>B.value=r),min:0,max:R,marks:$,"tooltip-formatter":r=>`${r} ${s(e)("routes.stress.路")}`},null,8,["value","tooltip-formatter"])]),a("span",Zt,l(d.pullCount)+" "+l(s(e)("routes.stress.路")),1)]),a("div",Jt,[a("span",Yt,l(s(e)("routes.stress.快速调整")),1),u(s(N),null,{default:i(()=>[(w(),k(E,null,H(q,r=>u(s(_),{key:r,onClick:v=>it(r),disabled:!ct(r)},{default:i(()=>[b(l(r>0?"+":"")+l(r),1)]),_:2},1032,["onClick","disabled"])),64))]),_:1})]),a("div",te,[u(s(_),{type:"primary",size:"large",loading:x.value,onClick:dt},{default:i(()=>[b(l(s(e)("routes.stress.开始拉流")),1)]),_:1},8,["loading"]),u(s(_),{danger:"",size:"large",loading:P.value,onClick:ht},{default:i(()=>[b(l(s(e)("routes.stress.停止拉流")),1)]),_:1},8,["loading"])])]),_:1},8,["tab"])]),_:1},8,["activeKey"])]),_:1},8,["title"])]))}});const ue=xt(se,[["__scopeId","data-v-94a7e41c"]]);export{ue as default};
- //# sourceMappingURL=index-3ccefe8c.js.map
|