index-a0c408d2.js 8.6 KB

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