1 |
- import{d as te,w as j,u as L,e as F,k as Z,o as _e,q as le,b as Ye,r as de,X as A,a6 as G,a9 as U,B as $,f as _,Y as ke,Z as ue,aa as Ee,a7 as He}from"./vue-fae2b924.js";import{an as Le,s as Ie,u as Be,e as c,G as ce,bt as Ze,K as Xe,a0 as Q,bd as ze,a8 as $e,V as Fe,ab as he}from"./radical-24ede98f.js";import{G as Ae}from"./gb28181-e318e8a2.js";import{V as Oe}from"./jb4-ws-flv-88e095aa.js";import{j as Ne,k as Ve}from"./global-d3aa2cdf.js";import{o as We}from"./index-bad227d6.js";const je={initTime:{type:Le.Dayjs,default:""},timeRange:{type:Object,default(){return{}}},initZoomIndex:{type:Number,default:5},showCenterLine:{type:Boolean,default:!0},lineHeightRatio:{type:Object,default(){return{date:.3,time:.15,none:.1,hover:.35}}},showHoverTime:{type:Boolean,default:!0},hoverTimeFormat:{type:Function},timeSegments:{type:Array,default:()=>[]},enableZoom:{type:Boolean,default:!0},enableDrag:{type:Boolean,default:!0},maxClickDistance:{type:Number,default:3},roundWidthTimeSegments:{type:Boolean,default:!0},customShowTime:{type:Function},showDateAtZero:{type:Boolean,default:!0},extendZOOM:{type:Array,default(){return[]}},formatTime:{type:Function}},H=60*60*1e3,ee=30*1e3,Ge=te({__name:"index",props:je,emits:["timeChange","mousedown","mouseup","dragTimeChange","click_timeline"],setup(h,{expose:T,emit:R}){const{getDarkMode:P}=Ie(Be());j(()=>L(P),()=>se());const p=F(()=>P.value==="dark"),n=h,w=R,x=Z();_e(()=>{if(X(),k(),n.timeSegments.length>0){let t=1/0,a=-1/0;n.timeSegments.forEach(i=>{t=Math.min(t,i.StartTime.getTime()),a=Math.max(a,i.EndTime.getTime())});const s=(t+a)/2;e.startTimestamp=s-l.value/2}else{const t=n.initTime?oe(n.initTime):Date.now();e.startTimestamp=t-l.value/2}W(),o(),le(()=>{J("初始")}),window.addEventListener("mouseup",ae,!0)}),Ye(()=>{window.removeEventListener("mouseup",ae,!0),document.body.style.userSelect=""});const y=Z(),e=de({ctx:{},width:0,height:0,zoomLevel:50,currentTime:0,startTimestamp:0,mousedown:!1,mousedownX:0,mousedownY:0,mousedownCacheStartTimestamp:0,mousemoveX:-1,watchTimeList:[]}),S=12*H,O=24*H,Y=F(()=>{const t=ee/S,a=O/S,s=e.zoomLevel/100;return Math.exp(Math.log(t)+(Math.log(a)-Math.log(t))*(1-s))}),l=F(()=>S*Y.value),I=()=>{if(n.timeSegments.length===0)return{min:0,max:100};let t=1/0,a=-1/0;n.timeSegments.forEach(v=>{t=Math.min(t,v.StartTime.getTime()),a=Math.max(a,v.EndTime.getTime())});const i=(a-t)/S,m=1-(Math.log(i)-Math.log(ee/S))/(Math.log(O/S)-Math.log(ee/S));return{min:Math.max(0,Math.floor(m*100)),max:100}},q=t=>{if(!n.enableZoom)return;t.preventDefault();const a=1.2,s=t.deltaY*a,{min:i,max:m}=I(),d=e.zoomLevel;let r;if(s>0?r=Math.max(i,d-Math.abs(s)/30):r=Math.min(m,d+Math.abs(s)/30),r===d)return;const v=V(t)[0],D=e.startTimestamp+v/e.width*l.value;e.zoomLevel=r;const C=e.startTimestamp+v/e.width*l.value;e.startTimestamp+=D-C,W(),b(e.width,e.height),o(),e.currentTime=e.startTimestamp+l.value/2,J()},k=()=>{const{min:t}=I(),a=50+15*Math.log(S/(60*1e3));n.timeSegments.length>0?e.zoomLevel=t:e.zoomLevel=a},X=()=>{let{width:t,height:a}=x.value.getBoundingClientRect();e.width=t,e.height=a,y.value.width=t,y.value.height=a,e.ctx=y.value.getContext("2d")},o=()=>{B(),M(),f(),e.currentTime=e.startTimestamp+l.value/2,w("timeChange",e.currentTime),u()},u=()=>{e.watchTimeList.forEach(t=>{if(t.time<e.startTimestamp||t.time>e.startTimestamp+l.value)t.callback(-1,-1);else{let a=(t.time-e.startTimestamp)*(e.width/l.value),s=0,{left:i,top:m}=y.value.getBoundingClientRect();s=m,t.callback(a+i,s)}})},f=()=>{if(!n.showCenterLine)return;e.ctx.beginPath();let t=e.width/2;K({x1:t,y1:0,x2:t,y2:e.height,lineWidth:2,color:p.value?"#fff":"#2c2c2c"})},M=()=>{const t=e.ctx;t.beginPath();const a=l.value,s=60;let i,m;const r=a/e.width*s;r<=5*1e3?(i=5*1e3,m="mm:ss"):r<=10*1e3?(i=10*1e3,m="mm:ss"):r<=30*1e3?(i=30*1e3,m="mm:ss"):r<=60*1e3?(i=60*1e3,m="HH:mm"):r<=5*60*1e3?(i=5*60*1e3,m="HH:mm"):r<=15*60*1e3?(i=15*60*1e3,m="HH:mm"):r<=30*60*1e3?(i=30*60*1e3,m="HH:mm"):r<=H?(i=H,m="HH:mm"):(i=Math.ceil(r/H)*H,m="MM-DD HH:mm");const v=Math.floor(e.startTimestamp/i)*i,D=e.startTimestamp+l.value;for(let C=v;C<=D;C+=i){const z=(C-e.startTimestamp)/l.value*e.width;if(z>=0&&z<=e.width){t.font="12px Arial",t.fillStyle=p.value?"#fff":"#515151",t.strokeStyle=p.value?"#fff":"#515151";const me=e.height*(n.lineHeightRatio.time??.2);K({x1:z,y1:0,x2:z,y2:me,lineWidth:1,color:p.value?"#fff":"#515151"});const re=c(C).format(m),Ce=t.measureText(re).width;t.fillText(re,z-Ce/2,me+15)}}},B=(t=()=>{},a=!1)=>{const s=e.width/l.value;n.timeSegments.forEach(i=>{if(i.StartTime.getTime()<=e.startTimestamp+l.value){let m=i.EndTime.getTime()>=e.startTimestamp;e.ctx.beginPath();let d=(i.StartTime.getTime()-e.startTimestamp)*s,r;d<0?(d=0,r=m?(i.EndTime.getTime()-e.startTimestamp)*s:1):r=m?(i.EndTime.getTime()-i.StartTime.getTime())*s:1;let v=.7,D=.9;n.roundWidthTimeSegments&&(d=Math.round(d),r=Math.round(r)),r=Math.max(1,r),a?e.ctx.rect(d,e.height*v,r,e.height*(D-v)):(e.ctx.fillStyle=p.value?"#BB86FC":"#d0a3ff",e.ctx.fillRect(d,e.height*v,r,e.height*(D-v))),t(i)}})},E=t=>{t.stopPropagation(),t.preventDefault(),document.body.style.userSelect="none",N(t)},N=t=>{let a=V(t);e.mousedownX=a[0],e.mousedownY=a[1],e.mousedown=!0,e.mousedownCacheStartTimestamp=e.startTimestamp,w("mousedown",t)},ae=t=>{t.stopPropagation(),t.preventDefault(),document.body.style.userSelect="",fe(t)},fe=t=>{let a=V(t);const s=()=>{e.mousedown=!1,e.mousedownX=0,e.mousedownY=0,e.mousedownCacheStartTimestamp=0};if(Math.abs(a[0]-e.mousedownX)<=n.maxClickDistance&&Math.abs(a[1]-e.mousedownY)<=n.maxClickDistance){s(),Se(a[0]);return}if(e.mousedown&&n.enableDrag){const i=e.startTimestamp+l.value/2,m=ie(i);m&&m.length>0?(s(),w("dragTimeChange",i,m),ce.info(`跳转至: ${c(i).format("YYYY-MM-DD HH:mm:ss")}`)):(e.startTimestamp=e.mousedownCacheStartTimestamp,b(e.width,e.height),o(),s())}else s();w("mouseup",t)},Te=t=>{ge(t)},ge=t=>{let a=V(t)[0];e.mousemoveX=a,e.mousedown&&n.enableDrag?ve(a):n.showHoverTime&&ne(a)},pe=()=>{e.mousemoveX=-1},ve=t=>{if(!n.enableDrag)return;const a=e.width/l.value;let s=t-e.mousedownX,i=l.value/2,m=e.mousedownCacheStartTimestamp-Math.round(s/a),d=m+i;n.timeSegments.some(v=>{const D=v.StartTime.getTime(),C=v.EndTime.getTime();return d>=D&&d<=C})&&(g.value.start&&d<g.value.start&&(m=g.value.start-i),g.value.end&&d>g.value.end&&(m=g.value.end-i),e.startTimestamp=m,b(e.width,e.height),o())},ne=(t,a=!1)=>{const s=e.width/l.value;let i=e.startTimestamp+t/s;a||(b(e.width,e.height),o());let m=e.height*(n.lineHeightRatio.hover??.3);K({x1:t,y1:0,x2:t,y2:m,lineWidth:1,color:p.value?"#fff":"black"}),e.ctx.fillStyle=p.value?"#fff":"black";let d=n.hoverTimeFormat?n.hoverTimeFormat(i):c(i).format("YYYY-MM-DD HH:mm:ss"),r=e.ctx.measureText(d).width;e.ctx.fillText(d,t-r/2,m+20)},we=()=>{b(e.width,e.height),o()},ie=t=>{const a=[];for(let s of n.timeSegments){const{StartTime:i,EndTime:m}=s;t>=i.getTime()&&t<=m.getTime()&&a.push(s)}return a},Se=t=>{const a=e.width/l.value,s=e.startTimestamp+t/a,i=ie(s);i&&i.length>0&&(Pe(s,i),ce.info(`跳转至: ${c(s).format("YYYY-MM-DD HH:mm:ss")}`))},V=t=>{if(!x.value||!t)return[0,0];let{left:a,top:s}=x.value.getBoundingClientRect();return[t.clientX-a,t.clientY-s]},b=(t,a)=>{e.ctx.clearRect(0,0,t,a)},K=({x1:t,y1:a,x2:s,y2:i,lineWidth:m=1,color:d="#fff"})=>{const r=e.ctx;r.beginPath(),r.strokeStyle=d,r.lineWidth=m,r.moveTo(t,a),r.lineTo(s,i),r.stroke()},se=()=>{le(()=>{if(b(e.width,e.height),ye(),X(),k(),n.timeSegments.length>0){let t=1/0,a=-1/0;n.timeSegments.forEach(i=>{t=Math.min(t,i.StartTime.getTime()),a=Math.max(a,i.EndTime.getTime())});const s=(t+a)/2;e.startTimestamp=s-l.value/2}else{const t=n.initTime?oe(n.initTime):Date.now();e.startTimestamp=t-l.value/2}W(),o(),J("重新渲染")})},xe=()=>{X(),o()};Ze(document.body,()=>{xe()});const ye=()=>{e.width=0,e.height=0,e.ctx=null,e.zoomLevel=50,e.currentTime=0,e.startTimestamp=0,e.mousedown=!1,e.mousedownX=0,e.mousedownCacheStartTimestamp=0},Me=t=>{if(e.mousedown)return;let a=typeof t=="number"?t:new Date(t).getTime();e.startTimestamp=a-l.value/2,W(),b(e.width,e.height),o(),e.mousemoveX!==-1&&ne(e.mousemoveX,!0)},be=t=>{e.zoomLevel=t>=0&&t<ZOOM.length?t:5,b(e.width,e.height),e.startTimestamp=e.currentTime-l.value/2,o()},Re=(t,a,s)=>{!t||!a||e.watchTimeList.push({time:typeof t=="number"?t:new Date(t).getTime(),callback:a,windowTimeLineIndex:typeof s=="number"?s-1:-1})},Pe=(t,a=[])=>{w("click_timeline",t,a)},De=()=>{if(!g.value.start||!g.value.end)return;const t=g.value.end-g.value.start,a=t*.05,s=12*H/(t+2*a);e.zoomLevel=25*Math.log(s*Math.exp(50/25)),e.startTimestamp=g.value.start-a,b(e.width,e.height),o()},oe=t=>new Date(c(t).format("YYYY-MM-DD HH:mm:ss")).getTime(),g=F(()=>{let t={start:0,end:0};const a=n.timeRange.start;a&&(t.start=typeof a=="number"?a:new Date(a).getTime());const s=n.timeRange.end;return s&&(t.end=typeof s=="number"?s:new Date(s).getTime()),t}),W=()=>{let t=l.value/2,a=e.startTimestamp+t;g.value.start&&a<g.value.start&&(e.startTimestamp=g.value.start-t),g.value.end&&a>g.value.end&&(e.startTimestamp=g.value.end-t)},J=(t="当前")=>{e.width&&(`${t}`,c(e.startTimestamp).format("YYYY-MM-DD HH:mm:ss"),c(e.startTimestamp+l.value).format("YYYY-MM-DD HH:mm:ss"),`${(l.value/1e3).toFixed(1)}`,e.zoomLevel.toFixed(1),e.width)};return T({reRender:se,setTime:Me,setZoom:be,watchTime:Re,fitTimeRange:De}),(t,a)=>(A(),G("div",{class:"timeRuleContainer w-full h-full cursor-pointer",ref_key:"timeRuleContainer",ref:x,onMousedown:$(E,["stop","prevent"]),onMouseout:$(we,["stop"]),onMousemove:$(Te,["stop"]),onMouseleave:$(pe,["stop"]),onWheel:$(q,["prevent","stop"])},[U("canvas",{ref_key:"canvasRef",ref:y},null,512)],544))}});const Ue=Xe({id:"record-store",state:()=>({timeRange:[c().subtract(2,"day"),c()],timeRangeMP4:[c().subtract(2,"day"),c()],currentChannel:{parentId:"",deviceId:"",key:""},currentStreamPath:""}),getters:{getCurrentChannel(){return this.currentChannel},getTimeRange(){return this.timeRange},getTimeRangeMP4(){return this.timeRangeMP4},getCurrentStreamPath(){return this.currentStreamPath}},actions:{setTimeRange(h){this.timeRange=h},setCurrentChannel(h){this.currentChannel=h},setTimeRangeMP4(h){this.timeRangeMP4=h},setCurrentStreamPath(h){this.currentStreamPath=h}}}),qe={class:"w-full max-w-1200px m-auto pt-10px"},Ke={key:0,class:"placeholder"},Je={class:"tip"},Qe={key:2,class:"text-center mt-10px flex justify-center items-center gap-4"},et=te({name:"Record"}),tt=te({...et,props:{data:{type:Array,default:[]},vodType:{type:String,default:"mp4"},streamPath:{type:String,default:""},endTime:String,showDatePicker:{type:Boolean,default:!0}},setup(h){const T=h,R=Ue(),P=o=>o&&(o<=c(R.getTimeRange[0]).add(-1,"day")||o>R.getTimeRange[1]),p=Z(),n=de({initTime:c(),currentTime:c(),timeSegments:[],initZoomIndex:0,inTimeSegments:!1}),w=[],x=(o,u)=>{n.currentTime=c(o),u?S(o):n.inTimeSegments=!1},y=o=>{o&&p.value.setTime(o),n.timeSegments.length?S(o.toDate().getTime()):n.inTimeSegments=!1},e=(o,u)=>{n.currentTime=c(o),u?S(o):n.inTimeSegments=!1};function S(o){Y.value=o,n.inTimeSegments=!0,Ve(k.value,o/1e3>>0)}const O=o=>{const u=o.sort((B,E)=>Date.parse(B.startTime)-Date.parse(E.startTime)),f=[];let M;return u.forEach(B=>{const E=new Date(B.startTime),N=new Date(B.endTime);(M==null?void 0:M.EndTime.getTime())==E.getTime()?M.EndTime=N:(M&&w.push({StartTime:M.EndTime,EndTime:E}),M={StartTime:E,EndTime:N},f.push(M))}),f},Y=Z(),l=Z("ws-flv"),I=Z(1),q=[{label:"0.5x",value:.5},{label:"1.0x",value:1},{label:"1.5x",value:1.5},{label:"2.0x",value:2},{label:"2.5x",value:2.5},{label:"3.0x",value:3},{label:"4.0x",value:4},{label:"8.0x",value:8},{label:"16.0x",value:16}],k=F(()=>!T.streamPath||!Y.value?"":`${Ae(!0)}${T.streamPath}?start=${Y.value/1e3>>0}&end=${T.endTime}`);j(()=>T.data,()=>{var o,u;if((o=T.data)!=null&&o.length){n.timeSegments=O(T.data);const f=n.timeSegments[0].StartTime;n.currentTime=c(f),n.initTime=c(f),Y.value=f.getTime()}else n.currentTime=c(),n.initTime=c(),n.timeSegments=[];(u=p.value)==null||u.reRender()},{immediate:!0}),j(()=>L(n.inTimeSegments),o=>{}),j(()=>I.value,o=>{var u;(u=T.data)!=null&&u.length&&k.value&&Ne(k.value,o)});function X(o){let u=o;for(const f of w)if(u>=f.StartTime.getTime())u+=f.EndTime.getTime()-f.StartTime.getTime();else break;return c(u)}return(o,u)=>(A(),G("div",qe,[h.data.length?(A(),ke(Oe,{key:1,streamPath:k.value,format:l.value,videoShadow:!0,startTime:Y.value,endTime:n.timeSegments[n.timeSegments.length-1].EndTime.getTime(),onPostion:u[0]||(u[0]=f=>p.value.setTime(n.currentTime=X(f)))},null,8,["streamPath","format","startTime","endTime"])):(A(),G("div",Ke,[U("div",Je,[_(L(Q),{icon:"pepicons-pop:television-play-off",size:70}),u[3]||(u[3]=U("p",{class:"font-bold font-size-18px"},"当前无可播放的录像资源",-1))])])),h.showDatePicker?(A(),G("div",Qe,[_(L(ze),{value:n.currentTime,"onUpdate:value":u[1]||(u[1]=f=>n.currentTime=f),showTime:"",onChange:y,bordered:!1,allowClear:!1,"disabled-date":P,class:"cursor-pointer"},{suffixIcon:ue(()=>[_(L(Q),{icon:"line-md:edit"})]),_:1},8,["value"]),_(L($e),{value:I.value,"onUpdate:value":u[2]||(u[2]=f=>I.value=f),style:{width:"100px"},options:q,bordered:!1},{suffixIcon:ue(()=>[_(L(Q),{icon:"bi:speedometer2"})]),_:1},8,["value"])])):Ee("",!0),U("div",{class:He(["h-40px w-96% m-auto",{"mt-10px":!h.showDatePicker}])},[_(Ge,{ref_key:"timeRuleRef",ref:p,"init-zoom-index":n.initZoomIndex,initTime:n.initTime,timeSegments:n.timeSegments,enableZoom:!0,onDragTimeChange:x,onClick_timeline:e},null,8,["init-zoom-index","initTime","timeSegments"])],2)]))}});const at=Fe(tt,[["__scopeId","data-v-4ac4b8a1"]]),nt=(h,T="YYYY-MM-DD HH:mm:ss")=>new Date(c(h).format(T)).getTime(),ut=async({channel:h,row:T})=>{const{parentId:R,deviceId:P,key:p}=h,{endTime:n}=T,w=`${R}/${P}`;he({content:()=>_(at,{data:[T],streamPath:w,key:p,showDatePicker:!1,endTime:`${nt(n)}`},null),modalConfig:{width:"100%",wrapClassName:"full-antdv-modal",destroyOnClose:!0,footer:null}})},ct=async({row:h})=>{const{streamPath:T,id:R,startTime:P,endTime:p}=h,n=`${We("mp4","/download")}/${T}.mp4?id=${R}`;he({content:()=>_("video",{style:{width:"100%",height:"100%"},autoplay:!0,controls:!0,onError:w=>{const x=w.target,y=x.currentTime;x.load(),x.currentTime=y+1},src:n},null),modalConfig:{title:`${T} ${c(P).format("YYYY-MM-DD HH:mm:ss")}-${c(p).format("YYYY-MM-DD HH:mm:ss")}`,width:"800px",destroyOnClose:!0,footer:null}})};export{at as V,Ge as _,ut as a,ct as b,nt as d,Ue as u};
|