1 |
- import{d as T,k,U as w,V as b,a8 as A,f as m,a0 as x,u as n,W as F,E as W,a4 as P,$ as E,F as J,r as G,o as j,w as z,x as K,a3 as V,af as Q,e as Y,Z as ee,a7 as te,X as ae}from"./vue-18ee037d.js";import"./dayjs-4778c158.js";import{al as M,J as L,x as ne,aw as oe,af as se,N as q,a2 as re,aa as $,a3 as O,ay as le}from"./index-122302b9.js";import{u as ce}from"./device-88d35103.js";import{l as ie}from"./hk-list-level-dc9970c0.js";import{I as de,T as ue}from"./index-60ff9924.js";import{D as pe}from"./index-cc7f4b20.js";import{W as fe,a as me,D as ve,F as he,b as _e,V as ye,A as xe,c as U,d as B,e as H,u as X}from"./audio_decoder_hard-e133cc4e.js";import{R as we}from"./Group-ea2dcc3a.js";import{C as ge}from"./index-977bc6d2.js";import{R as Ce,C as R}from"./Card-58451e7c.js";import{_ as De,a as Se}from"./operate.vue_vue_type_script_setup_true_lang-01dc861c.js";import"./mockjs-890b569b.js";import"./gb28281-53c246af.js";import"./useFlexGapSupport-791d0eca.js";import"./index-8c1b53c2.js";import"./index-7e9674b9.js";import"./index-868fc3c0.js";import"./index-41409ae5.js";import"./index-7af791cb.js";const Ie={class:"p-16px"},ke={class:"m-16px overscroll-contain overflow-y-auto overflow-x-hidden",style:{"max-height":"calc(100% - 64px)"}},be={class:"text-red"},Ne=T({__name:"device-hk",props:{single:{type:Boolean,default:!1}},emits:["select"],setup(l,{emit:p}){const y=l,f=window.allEnv.media+"/hk/api",o=k([]);M.post(f+"/resource/v2/camrea/search",{pageNo:1,pageSize:1e3,regionIndexCodes:[]}).then(d=>{var e,t;o.value=ie((t=(e=d.data)==null?void 0:e.data)==null?void 0:t.list)}),ce().fetchdeviceTree();const C=k([]),S=d=>d.key.includes("-")&&d.hasOwnProperty("LiveStatus"),u=(d,e)=>{const t=_.value.filter(c=>c!==d[0]);t.length<_.value.length?_.value=t:_.value=_.value.concat(d),y.single&&S(e.node)&&(C.value=[e.node.key]),e.node.data&&p("select",e.node)},h=k(""),_=k([]),a=k(!0),s=d=>{_.value=d,a.value=!1},i=(d,e)=>{let t;if(!(e!=null&&e.length))return t;for(let c=0;c<e.length;c++){const r=e[c];r.children&&(r.children.some(g=>g.key===d)?t=r.key:i(d,r.children)&&(t=i(d,r.children)))}return t};let v=[];const I=d=>{v.map(e=>e.title.indexOf(d)>-1?i(e.key,o.value):null).filter((e,t,c)=>e&&c.indexOf(e)===t),h.value=d,a.value=!0},N=ne(d=>I(d.target.value),250);return(d,e)=>(w(),b(J,null,[A("div",Ie,[m(n(de),{placeholder:"模糊搜索设备名称",allowClear:"",onInput:n(N)},{prefix:x(()=>[m(n(L),{icon:"ic:outline-search"})]),_:1},8,["onInput"])]),m(n(pe),{class:"m0"}),A("div",ke,[m(n(ue),{showIcon:"","tree-data":o.value,defaultExpandAll:"","expanded-keys":_.value,"auto-expand-parent":a.value,onExpand:s,selectedKeys:C.value,onSelect:u},{title:x(({title:t,isLeaf:c,disabled:r,DeviceID:g})=>[t.indexOf(h.value)>-1?(w(),b("span",{key:0,class:F({"text-primary":!r&&c&&g})},[W(P(t.substr(0,t.indexOf(h.value)))+" ",1),A("span",be,P(h.value),1),W(" "+P(t.substr(t.indexOf(h.value)+h.value.length)),1)],2)):(w(),b("span",{key:1,onClick:e[0]||(e[0]=Z=>u("test",Z)),class:F({"text-primary":!r&&c&&g})},P(t),3))]),icon:x(({disabled:t,type:c})=>[c!=="group"?(w(),E(n(L),{key:0,icon:"mdi:web-camera",class:F(["v-text-bottom",{"text-primary":!t}])},null,8,["class"])):(w(),E(n(L),{key:1,icon:"icon-park-solid:tree-diagram",class:"v-text-bottom rotate-90"}))]),_:1},8,["tree-data","expanded-keys","auto-expand-parent","selectedKeys"])])],64))}});function Ee(){const l=G([]);if(location.protocol==="http:"||location.protocol==="https:")return{webrtc:!1,streamList:l,changeStreamList:a=>{l.length=0,l.push(...a)},delItem:a=>{l[a].path="",delete l[a].item,delete l[a].stream},closeAll:()=>{l.length=0},updateItem:async(a,s)=>{let i,v;typeof a!="string"?(i=a,v=`${a.ID}`):v=a,l[s].path=v,l[s].item=i}};let p;const y=new Map;let f,o;const D=async()=>{const a=l.filter(s=>s.path);for(const s of a)if(y.has(s.path))s.stream||(s.stream=y.get(s.path));else{const i=new fe(s.path);f||await C(),f.addStream(i),s.stream=i,y.set(s.path,s.stream)}if(a.length){const s=new Set(a.map(v=>v.path)),i=await o.createOffer();await o.setLocalDescription(i),p.send(JSON.stringify({type:"subscribe",offer:i.sdp,streamList:[...s]}))}else f&&(f.close(),f=null,y.clear())},C=async()=>new Promise(a=>{f=new me(oe("webrtc","/batch")),o=f.webrtc,p=o.createDataChannel("signal"),p.onmessage=async s=>{const i=JSON.parse(s.data);switch(i.type){case"answer":o.setRemoteDescription(new RTCSessionDescription(i));break;case"remove":f.deleteStream(i.streamPath),y.delete(i.streamPath);break;case"offer":await o.setRemoteDescription(new RTCSessionDescription(i));const v=await o.createAnswer();await o.setLocalDescription(v),p.send(JSON.stringify(v))}},p.onopen=a,o.ondatachannel=async s=>{const i=s.channel,v=y.get(i.label);if(v){let I,N;const d=new ve(i),e=new he(d,_e.PUSH);e.gotVideo=r=>t.decode(r),e.gotAudio=r=>c.decode(r);const t=new ye,c=new xe;await t.initialize(),await c.initialize(),e.on(U.VIDEO_ENCODER_CONFIG_CHANGED,r=>{t.configure(r)}),e.on(U.AUDIO_ENCODER_CONFIG_CHANGED,r=>{c.configure(r)}),t.on(B.Error,r=>{console.error(r),t.initialize()}),t.on(B.VideoFrame,r=>{if(!I){const g=new MediaStreamTrackGenerator({kind:"video"});v.videoTrack=g,I=g.writable.getWriter()}I.write(r).catch(g=>{console.error(g),t.close(),d.close()})}),c.on(H.Error,r=>{console.error(r),c.initialize()}),c.on(H.AudioFrame,r=>{if(!N){const g=new MediaStreamTrackGenerator({kind:"audio"});v.audioTrack=g,N=g.writable.getWriter()}N.write(r).catch(g=>{console.error(g),c.close(),d.close()})}),d.connect()}},f.connect()});return{webrtc:!0,changeStreamList:a=>{l.length=0,l.push(...a),D()},streamList:l,updateItem:async(a,s)=>{let i,v;typeof a!="string"?(i=a,v=`${a.ID}/${a.DeviceID}`):v=a,l[s].path=v,l[s].item=i,l[s].stream=y.get(v),await D()},delItem:async a=>{l[a].path="",delete l[a].item,delete l[a].stream,await D()},closeAll:()=>{f==null||f.close(),f=null,l.length=0,y.clear()}}}const Le={class:"video-container"},Ae={class:"container-shell"},We=["id"],Te=T({__name:"hk",props:{cameraIndexCode:null,index:null},setup(l){const p=l,y=window.allEnv.media+"/hk/api",f=k(!0);let o=null;const D=()=>{o=new window.JSPlugin({szId:p.cameraIndexCode+p.index,szBasePath:"./hk-plugins/",iMaxSplit:1,iCurrentSplit:document.body.clientWidth<992?1:2,openDebug:!0,oStyle:{}}),o.JS_SetWindowControlCallback({windowEventSelect:function(u){},pluginErrorHandler:function(u,h,_){},windowEventOver:function(u){},windowEventOut:function(u){},windowEventUp:function(u){},windowFullCcreenChange:function(u){},firstFrameDisplay:function(u,h,_){},performanceLack:function(){}}),M.post(y+"/video/v2/cameras/preview",{cameraIndexCode:p.cameraIndexCode,protocol:"ws"}).then(u=>{var _,a;f.value=!1;const h=(a=(_=u.data)==null?void 0:_.data)==null?void 0:a.url;o.JS_Play(h,{playURL:h,mode:0},o.currentWindowIndex).then(()=>{},s=>{console.error(s)})})};j(()=>{p.cameraIndexCode,p.cameraIndexCode&&C()}),z(()=>p.cameraIndexCode,u=>{u&&C()});async function C(){o&&await S(),setTimeout(D,100)}K(S);async function S(){return new Promise((u,h)=>{o?o.JS_Stop(o.currentWindowIndex).then(()=>{o=null,u(!0)},_=>{h(_),o=null}):u(!0)})}return(u,h)=>(w(),b("div",Le,[A("div",Ae,[A("div",{id:l.cameraIndexCode+l.index,class:"player-container"},null,8,We),f.value?(w(),E(n(se),{key:0,class:"loading",size:"large"})):V("",!0),Q(u.$slots,"default",{},void 0,!0)])]))}});const Pe=q(Te,[["__scopeId","data-v-84fe96fb"]]),Re={class:"text-center"},Fe={key:1,class:"video-player-placeholder"},$e=T({__name:"content-hk",setup(l){const p=k(1),y=[{label:"单屏",value:1},{label:"四分屏",value:4},{label:"九分屏",value:9},{label:"十六分屏",value:16}],f=Y(()=>{switch(p.value){case 1:return 24;case 4:return 12;case 9:return 8;case 16:return 6;default:return 24}}),o=()=>document.querySelector(".screen-list"),D=k(null),{toggle:C,isFullscreen:S}=re(D),u=X(),{getActiveInfo:h}=ee(u),{updateItem:_,streamList:a,changeStreamList:s,closeAll:i,webrtc:v}=Ee(),I=G({selectNum:1});z(p,async()=>{I.selectNum=0,u.setActiveInfo({ID:"",DeviceID:"",DeviceName:"",Name:"",LiveStatus:0});const e=new Array(p.value).fill({}).map(()=>({path:""}));s(e)},{immediate:!0}),K(()=>i()),z(()=>n(h),(e,t)=>{e.ID!==(t==null?void 0:t.ID)&&_(h.value,I.selectNum)});const N=({item:e},t)=>{I.selectNum=t,h.value.DeviceID!==(e==null?void 0:e.DeviceID)&&u.setActiveInfo({ID:(e==null?void 0:e.ID)??"",DeviceID:(e==null?void 0:e.DeviceID)??"",DeviceName:(e==null?void 0:e.DeviceName)??"",Name:(e==null?void 0:e.Name)??"",LiveStatus:(e==null?void 0:e.LiveStatus)??0})},d=()=>{le.push("/screen-custom")};return(e,t)=>(w(),b("div",Re,[m(n(we),{value:p.value,"onUpdate:value":t[0]||(t[0]=c=>p.value=c),buttonStyle:"solid",options:y,optionType:"button"},null,8,["value"]),m(n($),{onClick:d},{default:x(()=>[W("自定义分屏")]),_:1}),m(n($),{onClick:n(C)},{default:x(()=>[m(n(L),{icon:"ant-design:fullscreen-outlined",class:"v-text-bottom"}),W("全屏 ")]),_:1},8,["onClick"]),m(n(Ce),{gutter:4,class:"screen-list mt-10px",ref_key:"screenRef",ref:D},{default:x(()=>[n(S)?(w(),E(n($),{key:0,onClick:n(C),type:"link",class:"absolute right-2 top-2 z-10 text-white"},{default:x(()=>[m(n(L),{icon:"ant-design:fullscreen-exit-outlined",class:"v-text-bottom"}),W(" 退出全屏 ")]),_:1},8,["onClick"])):V("",!0),(w(!0),b(J,null,te(n(a),(c,r)=>(w(),E(n(ge),{span:n(f),key:r,class:F(["mt-4px flex-center",{active:p.value>1&&I.selectNum===r&&!n(S),isFullscreen:n(S)}]),onClick:()=>N(c,r)},{default:x(()=>[c.path?(w(),E(Pe,{key:0,cameraIndexCode:c.path,index:r},{default:x(()=>[c.path?(w(),E(n(O),{key:0,class:"position-absolute bottom-0 left-50% cursor-pointer",title:c.path,getPopupContainer:o},{default:x(()=>[m(n(L),{icon:"octicon:ellipsis-16",size:20,color:"#dedede",hoverColor:"#a275d9"})]),_:2},1032,["title"])):V("",!0)]),_:2},1032,["cameraIndexCode","index"])):(w(),b("div",Fe,[m(n(O),{title:"当前无信号,请先选择通道",class:"no-stream-tip cursor-pointer",getPopupContainer:o,placement:"top"},{default:x(()=>[m(n(L),{icon:"pepicons-pop:television-play-off",size:p.value===1?50:24},null,8,["size"])]),_:1})]))]),_:2},1032,["span","class","onClick"]))),128))]),_:1},512)]))}});const ze=q($e,[["__scopeId","data-v-7aa2323e"]]),Ve={class:"w-300px m-l-8px h-full flex-shrink-0"},Oe=T({name:"Screen"}),lt=T({...Oe,setup(l){const p=X(),y=f=>{const{indexCode:o,DeviceID:D,regionName:C,name:S,LiveStatus:u}=f.data;p.setActiveInfo({ID:o,DeviceID:D,DeviceName:C,Name:S,LiveStatus:u})};return(f,o)=>(w(),b("div",{class:"flex",style:ae({height:"calc(100% - 8px)"})},[m(n(R),{class:"w-342px m-r-8px flex-shrink-0",bordered:!1,bodyStyle:{height:"100%",padding:0}},{default:x(()=>[m(Ne,{onSelect:y})]),_:1}),m(n(R),{class:"flex-1",bordered:!1,bodyStyle:{height:"100%",padding:"16px"}},{default:x(()=>[m(ze)]),_:1}),A("div",Ve,[m(n(R),{class:"m-b-8px",bordered:!1,bodyStyle:{height:"230px",padding:0}},{default:x(()=>[m(De)]),_:1}),m(n(R),{style:{height:"calc(100% - 238px)"},bordered:!1,bodyStyle:{height:"100%",padding:0}},{default:x(()=>[m(Se)]),_:1})])],4))}});export{lt as default};
|