video-split-screen 1.0.1 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -1
- package/dist/index.mjs +69 -76
- package/dist/style.css +1 -1
- package/package.json +1 -3
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),p={1:{type:"1",label:"1分屏",count:1,cols:1,rows:1},2:{type:"2",label:"2分屏",count:2,cols:2,rows:1},3:{type:"3",label:"3分屏",count:3,cols:2,rows:2},4:{type:"4",label:"4分屏",count:4,cols:2,rows:2},6:{type:"6",label:"6分屏",count:6,cols:3,rows:2},7:{type:"7",label:"7分屏",count:7,cols:4,rows:4},8:{type:"8",label:"8分屏",count:8,cols:4,rows:4},9:{type:"9",label:"9分屏",count:9,cols:3,rows:3},10:{type:"10",label:"10分屏",count:10,cols:6,rows:4},13:{type:"13",label:"13分屏",count:13,cols:4,rows:4},16:{type:"16",label:"16分屏",count:16,cols:4,rows:4}},x={};function V(c){if(x[c])return x[c];const o={1:[{col:1,colSpan:1,row:1,rowSpan:1}],2:[{col:1,colSpan:1,row:1,rowSpan:1},{col:2,colSpan:1,row:1,rowSpan:1}],3:[{col:1,colSpan:1,row:1,rowSpan:2,isMain:!0},{col:2,colSpan:1,row:1,rowSpan:1},{col:2,colSpan:1,row:2,rowSpan:1}],4:[{col:1,colSpan:1,row:1,rowSpan:1},{col:2,colSpan:1,row:1,rowSpan:1},{col:1,colSpan:1,row:2,rowSpan:1},{col:2,colSpan:1,row:2,rowSpan:1}],6:[{col:1,colSpan:1,row:1,rowSpan:1},{col:2,colSpan:1,row:1,rowSpan:1},{col:3,colSpan:1,row:1,rowSpan:1},{col:1,colSpan:1,row:2,rowSpan:1},{col:2,colSpan:1,row:2,rowSpan:1},{col:3,colSpan:1,row:2,rowSpan:1}],7:[{col:1,colSpan:2,row:1,rowSpan:2},{col:3,colSpan:2,row:1,rowSpan:2},{col:1,colSpan:2,row:3,rowSpan:2},{col:3,colSpan:1,row:3,rowSpan:1},{col:4,colSpan:1,row:3,rowSpan:1},{col:3,colSpan:1,row:4,rowSpan:1},{col:4,colSpan:1,row:4,rowSpan:1}],8:[{col:1,colSpan:3,row:1,rowSpan:3,isMain:!0},{col:4,colSpan:1,row:1,rowSpan:1},{col:4,colSpan:1,row:2,rowSpan:1},{col:4,colSpan:1,row:3,rowSpan:1},{col:1,colSpan:1,row:4,rowSpan:1},{col:2,colSpan:1,row:4,rowSpan:1},{col:3,colSpan:1,row:4,rowSpan:1},{col:4,colSpan:1,row:4,rowSpan:1}],9:[{col:1,colSpan:1,row:1,rowSpan:1},{col:2,colSpan:1,row:1,rowSpan:1},{col:3,colSpan:1,row:1,rowSpan:1},{col:1,colSpan:1,row:2,rowSpan:1},{col:2,colSpan:1,row:2,rowSpan:1},{col:3,colSpan:1,row:2,rowSpan:1},{col:1,colSpan:1,row:3,rowSpan:1},{col:2,colSpan:1,row:3,rowSpan:1},{col:3,colSpan:1,row:3,rowSpan:1}],10:[{col:1,colSpan:5,row:1,rowSpan:3,isMain:!0},{col:6,colSpan:1,row:1,rowSpan:1},{col:6,colSpan:1,row:2,rowSpan:1},{col:6,colSpan:1,row:3,rowSpan:1},{col:1,colSpan:1,row:4,rowSpan:1},{col:2,colSpan:1,row:4,rowSpan:1},{col:3,colSpan:1,row:4,rowSpan:1},{col:4,colSpan:1,row:4,rowSpan:1},{col:5,colSpan:1,row:4,rowSpan:1},{col:6,colSpan:1,row:4,rowSpan:1}],13:[{col:1,colSpan:2,row:1,rowSpan:2,isMain:!0},{col:3,colSpan:1,row:1,rowSpan:1},{col:4,colSpan:1,row:1,rowSpan:1},{col:3,colSpan:1,row:2,rowSpan:1},{col:4,colSpan:1,row:2,rowSpan:1},{col:1,colSpan:1,row:3,rowSpan:1},{col:2,colSpan:1,row:3,rowSpan:1},{col:3,colSpan:1,row:3,rowSpan:1},{col:4,colSpan:1,row:3,rowSpan:1},{col:1,colSpan:1,row:4,rowSpan:1},{col:2,colSpan:1,row:4,rowSpan:1},{col:3,colSpan:1,row:4,rowSpan:1},{col:4,colSpan:1,row:4,rowSpan:1}],16:[{col:1,colSpan:1,row:1,rowSpan:1},{col:2,colSpan:1,row:1,rowSpan:1},{col:3,colSpan:1,row:1,rowSpan:1},{col:4,colSpan:1,row:1,rowSpan:1},{col:1,colSpan:1,row:2,rowSpan:1},{col:2,colSpan:1,row:2,rowSpan:1},{col:3,colSpan:1,row:2,rowSpan:1},{col:4,colSpan:1,row:2,rowSpan:1},{col:1,colSpan:1,row:3,rowSpan:1},{col:2,colSpan:1,row:3,rowSpan:1},{col:3,colSpan:1,row:3,rowSpan:1},{col:4,colSpan:1,row:3,rowSpan:1},{col:1,colSpan:1,row:4,rowSpan:1},{col:2,colSpan:1,row:4,rowSpan:1},{col:3,colSpan:1,row:4,rowSpan:1},{col:4,colSpan:1,row:4,rowSpan:1}]}[c]||[];return o.length>0&&(x[c]=o),o}function L(){return Object.keys(p)}const Y={class:"layout-icon"},j={key:0,viewBox:"0 0 48 48",fill:"none"},H={key:1,viewBox:"0 0 48 48",fill:"none"},W={key:2,viewBox:"0 0 48 48",fill:"none"},q={key:3,viewBox:"0 0 48 48",fill:"none"},J={key:4,viewBox:"0 0 48 48",fill:"none"},K={key:5,viewBox:"0 0 48 48",fill:"none"},Q={key:6,viewBox:"0 0 48 48",fill:"none"},X={key:7,viewBox:"0 0 48 48",fill:"none"},Z={key:8,viewBox:"0 0 54 48",fill:"none"},ee={key:9,viewBox:"0 0 48 48",fill:"none"},te={key:10,viewBox:"0 0 48 48",fill:"none"},oe=e.defineComponent({__name:"VideoLayoutIcon",props:{type:{}},setup(c){return(w,o)=>(e.openBlock(),e.createElementBlock("div",Y,[c.type==="1"?(e.openBlock(),e.createElementBlock("svg",j,[...o[0]||(o[0]=[e.createElementVNode("rect",{x:"4",y:"4",width:"40",height:"40",stroke:"currentColor","stroke-width":"2"},null,-1)])])):c.type==="2"?(e.openBlock(),e.createElementBlock("svg",H,[...o[1]||(o[1]=[e.createElementVNode("rect",{x:"4",y:"4",width:"19",height:"40",stroke:"currentColor","stroke-width":"1.5"},null,-1),e.createElementVNode("rect",{x:"25",y:"4",width:"19",height:"40",stroke:"currentColor","stroke-width":"1.5"},null,-1)])])):c.type==="3"?(e.openBlock(),e.createElementBlock("svg",W,[...o[2]||(o[2]=[e.createElementVNode("rect",{x:"4",y:"4",width:"20",height:"40",stroke:"currentColor","stroke-width":"2"},null,-1),e.createElementVNode("rect",{x:"26",y:"4",width:"18",height:"19",stroke:"currentColor","stroke-width":"1.5"},null,-1),e.createElementVNode("rect",{x:"26",y:"25",width:"18",height:"19",stroke:"currentColor","stroke-width":"1.5"},null,-1)])])):c.type==="4"?(e.openBlock(),e.createElementBlock("svg",q,[...o[3]||(o[3]=[e.createElementVNode("rect",{x:"4",y:"4",width:"19",height:"19",stroke:"currentColor","stroke-width":"1.5"},null,-1),e.createElementVNode("rect",{x:"25",y:"4",width:"19",height:"19",stroke:"currentColor","stroke-width":"1.5"},null,-1),e.createElementVNode("rect",{x:"4",y:"25",width:"19",height:"19",stroke:"currentColor","stroke-width":"1.5"},null,-1),e.createElementVNode("rect",{x:"25",y:"25",width:"19",height:"19",stroke:"currentColor","stroke-width":"1.5"},null,-1)])])):c.type==="6"?(e.openBlock(),e.createElementBlock("svg",J,[...o[4]||(o[4]=[e.createStaticVNode('<rect x="3" y="4" width="13" height="18" stroke="currentColor" stroke-width="1.5" data-v-31e0404d></rect><rect x="18" y="4" width="12" height="18" stroke="currentColor" stroke-width="1.5" data-v-31e0404d></rect><rect x="32" y="4" width="13" height="18" stroke="currentColor" stroke-width="1.5" data-v-31e0404d></rect><rect x="3" y="24" width="13" height="18" stroke="currentColor" stroke-width="1.5" data-v-31e0404d></rect><rect x="18" y="24" width="12" height="18" stroke="currentColor" stroke-width="1.5" data-v-31e0404d></rect><rect x="32" y="24" width="13" height="18" stroke="currentColor" stroke-width="1.5" data-v-31e0404d></rect>',6)])])):c.type==="7"?(e.openBlock(),e.createElementBlock("svg",K,[...o[5]||(o[5]=[e.createStaticVNode('<rect x="4" y="4" width="19" height="19" stroke="currentColor" stroke-width="2" data-v-31e0404d></rect><rect x="25" y="4" width="19" height="19" stroke="currentColor" stroke-width="2" data-v-31e0404d></rect><rect x="4" y="25" width="19" height="19" stroke="currentColor" stroke-width="2" data-v-31e0404d></rect><rect x="25" y="25" width="9" height="9" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="35" y="25" width="9" height="9" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="25" y="35" width="9" height="9" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="35" y="35" width="9" height="9" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect>',7)])])):c.type==="8"?(e.openBlock(),e.createElementBlock("svg",Q,[...o[6]||(o[6]=[e.createStaticVNode('<rect x="4" y="4" width="28" height="29" stroke="currentColor" stroke-width="2" data-v-31e0404d></rect><rect x="34" y="4" width="10" height="9" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="34" y="14.5" width="10" height="9" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="34" y="24.5" width="10" height="8.5" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="4" y="35" width="9" height="9" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="14" y="35" width="9" height="9" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="24" y="35" width="9" height="9" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="34" y="35" width="10" height="9" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect>',8)])])):c.type==="9"?(e.openBlock(),e.createElementBlock("svg",X,[...o[7]||(o[7]=[e.createStaticVNode('<rect x="4" y="4" width="12" height="12" stroke="currentColor" stroke-width="1.5" data-v-31e0404d></rect><rect x="18" y="4" width="12" height="12" stroke="currentColor" stroke-width="1.5" data-v-31e0404d></rect><rect x="32" y="4" width="12" height="12" stroke="currentColor" stroke-width="1.5" data-v-31e0404d></rect><rect x="4" y="18" width="12" height="12" stroke="currentColor" stroke-width="1.5" data-v-31e0404d></rect><rect x="18" y="18" width="12" height="12" stroke="currentColor" stroke-width="1.5" data-v-31e0404d></rect><rect x="32" y="18" width="12" height="12" stroke="currentColor" stroke-width="1.5" data-v-31e0404d></rect><rect x="4" y="32" width="12" height="12" stroke="currentColor" stroke-width="1.5" data-v-31e0404d></rect><rect x="18" y="32" width="12" height="12" stroke="currentColor" stroke-width="1.5" data-v-31e0404d></rect><rect x="32" y="32" width="12" height="12" stroke="currentColor" stroke-width="1.5" data-v-31e0404d></rect>',9)])])):c.type==="10"?(e.openBlock(),e.createElementBlock("svg",Z,[...o[8]||(o[8]=[e.createStaticVNode('<rect x="3" y="4" width="36" height="29" stroke="currentColor" stroke-width="2" data-v-31e0404d></rect><rect x="41" y="4" width="10" height="9" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="41" y="14.5" width="10" height="9" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="41" y="24.5" width="10" height="8.5" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="3" y="35" width="7" height="9" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="11" y="35" width="7" height="9" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="19" y="35" width="7" height="9" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="27" y="35" width="7" height="9" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="35" y="35" width="6" height="9" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="42" y="35" width="9" height="9" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect>',10)])])):c.type==="13"?(e.openBlock(),e.createElementBlock("svg",ee,[...o[9]||(o[9]=[e.createStaticVNode('<rect x="4" y="4" width="18" height="18" stroke="currentColor" stroke-width="2" data-v-31e0404d></rect><rect x="24" y="4" width="8" height="8" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="34" y="4" width="10" height="8" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="24" y="14" width="8" height="8" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="34" y="14" width="10" height="8" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="4" y="24" width="8" height="8" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="14" y="24" width="8" height="8" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="24" y="24" width="8" height="8" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="34" y="24" width="10" height="8" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="4" y="34" width="8" height="10" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="14" y="34" width="8" height="10" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="24" y="34" width="8" height="10" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="34" y="34" width="10" height="10" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect>',13)])])):c.type==="16"?(e.openBlock(),e.createElementBlock("svg",te,[...o[10]||(o[10]=[e.createStaticVNode('<rect x="4" y="4" width="9" height="9" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="15" y="4" width="9" height="9" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="26" y="4" width="9" height="9" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="37" y="4" width="7" height="9" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="4" y="15" width="9" height="9" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="15" y="15" width="9" height="9" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="26" y="15" width="9" height="9" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="37" y="15" width="7" height="9" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="4" y="26" width="9" height="9" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="15" y="26" width="9" height="9" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="26" y="26" width="9" height="9" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="37" y="26" width="7" height="9" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="4" y="37" width="9" height="7" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="15" y="37" width="9" height="7" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="26" y="37" width="9" height="7" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="37" y="37" width="7" height="7" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect>',16)])])):e.createCommentVNode("",!0)]))}}),N=(c,w)=>{const o=c.__vccOpts||c;for(const[v,d]of w)o[v]=d;return o},B=N(oe,[["__scopeId","data-v-31e0404d"]]),re={key:0,class:"layout-toolbar",role:"toolbar","aria-label":"布局切换工具栏"},ae={class:"layout-buttons"},le=["onClick","title","aria-label","aria-pressed"],ce={class:"layout-label"},ne={class:"video-grid-container",role:"region","aria-label":"视频网格"},ie=["aria-label","onDragstart","onDragenter","onDragleave","onDrop"],de={key:0,class:"video-placeholder"},se={class:"placeholder-number"},he={key:1,style:{width:"100%",height:"100%"}},we=.5,ue="grabbing",pe="0.8",ke=e.defineComponent({__name:"VideoGridLayout",props:{videos:{},layout:{default:"1"},availableLayouts:{},showToolbar:{type:Boolean,default:!0},width:{},height:{},placeholderText:{},placeholders:{}},emits:["layoutChange","videosChange"],setup(c,{emit:w}){const o=c,v=w,d=e.ref(o.layout);e.watch(()=>o.layout,t=>{d.value=t});const I=e.computed(()=>o.availableLayouts&&o.availableLayouts.length>0?o.availableLayouts:L()),i=e.shallowRef([...o.videos]);e.watch(()=>o.videos,t=>{if(!Array.isArray(t)){console.warn("[VideoGridLayout] Invalid videos prop, expected array");return}(i.value.length!==t.length||i.value.some((r,l)=>{var a;return r.id!==((a=t[l])==null?void 0:a.id)}))&&(i.value=[...t])},{flush:"post"});let C=!1;e.watch(i,t=>{!C&&Array.isArray(t)&&v("videosChange",t)});const b=e.computed(()=>{const t=p[d.value];return t||(console.warn(`[VideoGridLayout] Invalid layout type: ${d.value}, fallback to '4'`),p[4])}),m=e.computed(()=>V(d.value)),$=e.computed(()=>{var t;return((t=b.value)==null?void 0:t.count)||4}),k=e.computed(()=>i.value.slice(0,$.value)),E=e.computed(()=>{const t=m.value.map((r,l)=>({p:r,idx:l}));return t.sort((r,l)=>r.p.row===l.p.row?(r.p.col||0)-(l.p.col||0):(r.p.row||0)-(l.p.row||0)),t.map(r=>r.idx)}),s=e.ref(-1),y=e.ref(-1),S=e.shallowRef(null),_=e.computed(()=>{const t=b.value;return{display:"grid",gridTemplateColumns:(t==null?void 0:t.colTemplate)||`repeat(${(t==null?void 0:t.cols)||2}, 1fr)`,gridTemplateRows:(t==null?void 0:t.rowTemplate)||`repeat(${(t==null?void 0:t.rows)||2}, 1fr)`,gap:"4px",width:o.width||"100%",height:o.height||"100%"}}),A=e.computed(()=>({width:o.width||"100%",height:o.height||"100%"}));function G(t){const r=t,l=E.value[r];if(k.value[l])return"";if(Array.isArray(o.placeholders)&&o.placeholders[l]!==void 0)return String(o.placeholders[l]);if(typeof o.placeholderText=="function")try{return o.placeholderText(r)}catch{return String(r+1)}return o.placeholderText?String(o.placeholderText):String(r+1)}function T(t){const r=m.value[t];return!r||typeof r.col!="number"||typeof r.row!="number"?{}:{gridColumn:`${r.col} / span ${r.colSpan}`,gridRow:`${r.row} / span ${r.rowSpan}`}}function O(t){const r=m.value[t];return(r==null?void 0:r.isMain)||!1}function M(t){d.value=t,v("layoutChange",d.value)}function g(){if(S.value&&document.body.contains(S.value)){try{document.body.removeChild(S.value)}catch(t){console.warn("[VideoGridLayout] Failed to cleanup drag image:",t)}S.value=null}}function R(t,r){if(r<0||r>=i.value.length){console.warn("[VideoGridLayout] Invalid drag index:",r);return}if(s.value=r,!t.dataTransfer)return;t.dataTransfer.effectAllowed="move";const a=t.target.closest(".video-item");if(a)try{g();const n=a.cloneNode(!0);n.style.width=`${a.offsetWidth}px`,n.style.height=`${a.offsetHeight}px`,n.style.opacity=pe,n.style.position="absolute",n.style.top="-9999px",n.style.pointerEvents="none",document.body.appendChild(n),S.value=n,t.dataTransfer.setDragImage(n,a.offsetWidth/2,a.offsetHeight/2),setTimeout(()=>{g()},100),a.style.opacity=String(we),a.style.cursor=ue}catch(n){console.error("[VideoGridLayout] Drag start error:",n),g()}}function P(t,r){t.preventDefault(),t.stopPropagation();const l=s.value;if(l===-1||l===r){s.value=-1;return}if(r<0||r>=i.value.length){console.warn("[VideoGridLayout] Invalid drop index:",r),s.value=-1;return}try{const a=i.value[l],n=i.value[r];if(a&&n){C=!0;const h=[...i.value];h[l]=n,h[r]=a,i.value=h,setTimeout(()=>{C=!1,v("videosChange",i.value)},0)}}catch(a){console.error("[VideoGridLayout] Drop error:",a)}finally{s.value=-1}}function F(t,r){t.preventDefault(),s.value!==-1&&s.value!==r&&(y.value=r)}function z(t,r){t.preventDefault();const l=t.target,a=t.relatedTarget;l.contains(a)||y.value===r&&(y.value=-1)}function U(t){const l=t.target.closest(".video-item");l&&(l.style.opacity="1",l.style.cursor="move"),g(),s.value=-1,y.value=-1}return e.onBeforeUnmount(()=>{g()}),(t,r)=>(e.openBlock(),e.createElementBlock("div",{class:"video-grid-layout",role:"application","aria-label":"视频分屏布局",style:e.normalizeStyle(A.value)},[c.showToolbar?(e.openBlock(),e.createElementBlock("div",re,[r[1]||(r[1]=e.createElementVNode("div",{class:"toolbar-title"},"分屏布局",-1)),e.createElementVNode("div",ae,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(I.value,l=>{var a,n,h;return e.openBlock(),e.createElementBlock("button",{key:l,class:e.normalizeClass(["layout-btn",{active:d.value===l}]),onClick:f=>M(l),title:((a=e.unref(p)[l])==null?void 0:a.label)||"","aria-label":`切换到${((n=e.unref(p)[l])==null?void 0:n.label)||""}布局`,"aria-pressed":d.value===l,type:"button"},[e.createVNode(B,{type:l},null,8,["type"]),e.createElementVNode("span",ce,e.toDisplayString(((h=e.unref(p)[l])==null?void 0:h.label)||""),1)],10,le)}),128))])])):e.createCommentVNode("",!0),e.createElementVNode("div",ne,[e.createElementVNode("div",{class:"video-grid",style:e.normalizeStyle(_.value)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(m.value,(l,a)=>{var n,h,f;return e.openBlock(),e.createElementBlock("div",{key:((n=k.value[a])==null?void 0:n.id)??a,class:e.normalizeClass(["video-item",{"main-video":O(a),dragging:s.value===a,"drag-over":y.value===a&&s.value!==a}]),style:e.normalizeStyle(T(a)),draggable:!0,"aria-label":`视频 ${a+1}: ${((h=k.value[a])==null?void 0:h.title)||((f=k.value[a])==null?void 0:f.id)||""}`,role:"article",tabindex:"0",onDragstart:u=>R(u,a),onDragover:r[0]||(r[0]=e.withModifiers(()=>{},["prevent"])),onDragenter:u=>F(u,a),onDragleave:u=>z(u,a),onDrop:u=>P(u,a),onDragend:U},[e.renderSlot(t.$slots,"video",{video:k.value[a],index:a},()=>[k.value[a]?(e.openBlock(),e.createElementBlock("div",he)):(e.openBlock(),e.createElementBlock("div",de,[e.createElementVNode("div",se,e.toDisplayString(G(E.value.indexOf(a))),1)]))],!0)],46,ie)}),128))],4)])],4))}}),D=N(ke,[["__scopeId","data-v-473a71fa"]]),ve={VideoGridLayout:D,VideoLayoutIcon:B},ye={install(c){Object.entries(ve).forEach(([w,o])=>{c.component(w,o)})}};exports.LAYOUT_CONFIGS=p;exports.VideoGridLayout=D;exports.VideoLayoutIcon=B;exports.default=ye;exports.getAllLayoutTypes=L;exports.getLayoutPositions=V;
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("vue"),p={1:{type:"1",label:"1分屏",count:1,cols:1,rows:1},2:{type:"2",label:"2分屏",count:2,cols:2,rows:1},3:{type:"3",label:"3分屏",count:3,cols:2,rows:2},4:{type:"4",label:"4分屏",count:4,cols:2,rows:2},6:{type:"6",label:"6分屏",count:6,cols:3,rows:2},7:{type:"7",label:"7分屏",count:7,cols:4,rows:4},8:{type:"8",label:"8分屏",count:8,cols:4,rows:4},9:{type:"9",label:"9分屏",count:9,cols:3,rows:3},10:{type:"10",label:"10分屏",count:10,cols:6,rows:4},13:{type:"13",label:"13分屏",count:13,cols:4,rows:4},16:{type:"16",label:"16分屏",count:16,cols:4,rows:4}},x={};function V(c){if(x[c])return x[c];const o={1:[{col:1,colSpan:1,row:1,rowSpan:1}],2:[{col:1,colSpan:1,row:1,rowSpan:1},{col:2,colSpan:1,row:1,rowSpan:1}],3:[{col:1,colSpan:1,row:1,rowSpan:2,isMain:!0},{col:2,colSpan:1,row:1,rowSpan:1},{col:2,colSpan:1,row:2,rowSpan:1}],4:[{col:1,colSpan:1,row:1,rowSpan:1},{col:2,colSpan:1,row:1,rowSpan:1},{col:1,colSpan:1,row:2,rowSpan:1},{col:2,colSpan:1,row:2,rowSpan:1}],6:[{col:1,colSpan:1,row:1,rowSpan:1},{col:2,colSpan:1,row:1,rowSpan:1},{col:3,colSpan:1,row:1,rowSpan:1},{col:1,colSpan:1,row:2,rowSpan:1},{col:2,colSpan:1,row:2,rowSpan:1},{col:3,colSpan:1,row:2,rowSpan:1}],7:[{col:1,colSpan:2,row:1,rowSpan:2},{col:3,colSpan:2,row:1,rowSpan:2},{col:1,colSpan:2,row:3,rowSpan:2},{col:3,colSpan:1,row:3,rowSpan:1},{col:4,colSpan:1,row:3,rowSpan:1},{col:3,colSpan:1,row:4,rowSpan:1},{col:4,colSpan:1,row:4,rowSpan:1}],8:[{col:1,colSpan:3,row:1,rowSpan:3,isMain:!0},{col:4,colSpan:1,row:1,rowSpan:1},{col:4,colSpan:1,row:2,rowSpan:1},{col:4,colSpan:1,row:3,rowSpan:1},{col:1,colSpan:1,row:4,rowSpan:1},{col:2,colSpan:1,row:4,rowSpan:1},{col:3,colSpan:1,row:4,rowSpan:1},{col:4,colSpan:1,row:4,rowSpan:1}],9:[{col:1,colSpan:1,row:1,rowSpan:1},{col:2,colSpan:1,row:1,rowSpan:1},{col:3,colSpan:1,row:1,rowSpan:1},{col:1,colSpan:1,row:2,rowSpan:1},{col:2,colSpan:1,row:2,rowSpan:1},{col:3,colSpan:1,row:2,rowSpan:1},{col:1,colSpan:1,row:3,rowSpan:1},{col:2,colSpan:1,row:3,rowSpan:1},{col:3,colSpan:1,row:3,rowSpan:1}],10:[{col:1,colSpan:5,row:1,rowSpan:3,isMain:!0},{col:6,colSpan:1,row:1,rowSpan:1},{col:6,colSpan:1,row:2,rowSpan:1},{col:6,colSpan:1,row:3,rowSpan:1},{col:1,colSpan:1,row:4,rowSpan:1},{col:2,colSpan:1,row:4,rowSpan:1},{col:3,colSpan:1,row:4,rowSpan:1},{col:4,colSpan:1,row:4,rowSpan:1},{col:5,colSpan:1,row:4,rowSpan:1},{col:6,colSpan:1,row:4,rowSpan:1}],13:[{col:1,colSpan:2,row:1,rowSpan:2,isMain:!0},{col:3,colSpan:1,row:1,rowSpan:1},{col:4,colSpan:1,row:1,rowSpan:1},{col:3,colSpan:1,row:2,rowSpan:1},{col:4,colSpan:1,row:2,rowSpan:1},{col:1,colSpan:1,row:3,rowSpan:1},{col:2,colSpan:1,row:3,rowSpan:1},{col:3,colSpan:1,row:3,rowSpan:1},{col:4,colSpan:1,row:3,rowSpan:1},{col:1,colSpan:1,row:4,rowSpan:1},{col:2,colSpan:1,row:4,rowSpan:1},{col:3,colSpan:1,row:4,rowSpan:1},{col:4,colSpan:1,row:4,rowSpan:1}],16:[{col:1,colSpan:1,row:1,rowSpan:1},{col:2,colSpan:1,row:1,rowSpan:1},{col:3,colSpan:1,row:1,rowSpan:1},{col:4,colSpan:1,row:1,rowSpan:1},{col:1,colSpan:1,row:2,rowSpan:1},{col:2,colSpan:1,row:2,rowSpan:1},{col:3,colSpan:1,row:2,rowSpan:1},{col:4,colSpan:1,row:2,rowSpan:1},{col:1,colSpan:1,row:3,rowSpan:1},{col:2,colSpan:1,row:3,rowSpan:1},{col:3,colSpan:1,row:3,rowSpan:1},{col:4,colSpan:1,row:3,rowSpan:1},{col:1,colSpan:1,row:4,rowSpan:1},{col:2,colSpan:1,row:4,rowSpan:1},{col:3,colSpan:1,row:4,rowSpan:1},{col:4,colSpan:1,row:4,rowSpan:1}]}[c]||[];return o.length>0&&(x[c]=o),o}function L(){return Object.keys(p)}const Y={class:"layout-icon"},j={key:0,viewBox:"0 0 48 48",fill:"none"},H={key:1,viewBox:"0 0 48 48",fill:"none"},W={key:2,viewBox:"0 0 48 48",fill:"none"},q={key:3,viewBox:"0 0 48 48",fill:"none"},J={key:4,viewBox:"0 0 48 48",fill:"none"},K={key:5,viewBox:"0 0 48 48",fill:"none"},Q={key:6,viewBox:"0 0 48 48",fill:"none"},X={key:7,viewBox:"0 0 48 48",fill:"none"},Z={key:8,viewBox:"0 0 54 48",fill:"none"},tt={key:9,viewBox:"0 0 48 48",fill:"none"},et={key:10,viewBox:"0 0 48 48",fill:"none"},ot=t.defineComponent({__name:"VideoLayoutIcon",props:{type:{}},setup(c){return(w,o)=>(t.openBlock(),t.createElementBlock("div",Y,[c.type==="1"?(t.openBlock(),t.createElementBlock("svg",j,[...o[0]||(o[0]=[t.createElementVNode("rect",{x:"4",y:"4",width:"40",height:"40",stroke:"currentColor","stroke-width":"2"},null,-1)])])):c.type==="2"?(t.openBlock(),t.createElementBlock("svg",H,[...o[1]||(o[1]=[t.createElementVNode("rect",{x:"4",y:"4",width:"19",height:"40",stroke:"currentColor","stroke-width":"1.5"},null,-1),t.createElementVNode("rect",{x:"25",y:"4",width:"19",height:"40",stroke:"currentColor","stroke-width":"1.5"},null,-1)])])):c.type==="3"?(t.openBlock(),t.createElementBlock("svg",W,[...o[2]||(o[2]=[t.createElementVNode("rect",{x:"4",y:"4",width:"20",height:"40",stroke:"currentColor","stroke-width":"2"},null,-1),t.createElementVNode("rect",{x:"26",y:"4",width:"18",height:"19",stroke:"currentColor","stroke-width":"1.5"},null,-1),t.createElementVNode("rect",{x:"26",y:"25",width:"18",height:"19",stroke:"currentColor","stroke-width":"1.5"},null,-1)])])):c.type==="4"?(t.openBlock(),t.createElementBlock("svg",q,[...o[3]||(o[3]=[t.createElementVNode("rect",{x:"4",y:"4",width:"19",height:"19",stroke:"currentColor","stroke-width":"1.5"},null,-1),t.createElementVNode("rect",{x:"25",y:"4",width:"19",height:"19",stroke:"currentColor","stroke-width":"1.5"},null,-1),t.createElementVNode("rect",{x:"4",y:"25",width:"19",height:"19",stroke:"currentColor","stroke-width":"1.5"},null,-1),t.createElementVNode("rect",{x:"25",y:"25",width:"19",height:"19",stroke:"currentColor","stroke-width":"1.5"},null,-1)])])):c.type==="6"?(t.openBlock(),t.createElementBlock("svg",J,[...o[4]||(o[4]=[t.createStaticVNode('<rect x="3" y="4" width="13" height="18" stroke="currentColor" stroke-width="1.5" data-v-31e0404d></rect><rect x="18" y="4" width="12" height="18" stroke="currentColor" stroke-width="1.5" data-v-31e0404d></rect><rect x="32" y="4" width="13" height="18" stroke="currentColor" stroke-width="1.5" data-v-31e0404d></rect><rect x="3" y="24" width="13" height="18" stroke="currentColor" stroke-width="1.5" data-v-31e0404d></rect><rect x="18" y="24" width="12" height="18" stroke="currentColor" stroke-width="1.5" data-v-31e0404d></rect><rect x="32" y="24" width="13" height="18" stroke="currentColor" stroke-width="1.5" data-v-31e0404d></rect>',6)])])):c.type==="7"?(t.openBlock(),t.createElementBlock("svg",K,[...o[5]||(o[5]=[t.createStaticVNode('<rect x="4" y="4" width="19" height="19" stroke="currentColor" stroke-width="2" data-v-31e0404d></rect><rect x="25" y="4" width="19" height="19" stroke="currentColor" stroke-width="2" data-v-31e0404d></rect><rect x="4" y="25" width="19" height="19" stroke="currentColor" stroke-width="2" data-v-31e0404d></rect><rect x="25" y="25" width="9" height="9" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="35" y="25" width="9" height="9" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="25" y="35" width="9" height="9" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="35" y="35" width="9" height="9" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect>',7)])])):c.type==="8"?(t.openBlock(),t.createElementBlock("svg",Q,[...o[6]||(o[6]=[t.createStaticVNode('<rect x="4" y="4" width="28" height="29" stroke="currentColor" stroke-width="2" data-v-31e0404d></rect><rect x="34" y="4" width="10" height="9" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="34" y="14.5" width="10" height="9" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="34" y="24.5" width="10" height="8.5" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="4" y="35" width="9" height="9" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="14" y="35" width="9" height="9" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="24" y="35" width="9" height="9" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="34" y="35" width="10" height="9" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect>',8)])])):c.type==="9"?(t.openBlock(),t.createElementBlock("svg",X,[...o[7]||(o[7]=[t.createStaticVNode('<rect x="4" y="4" width="12" height="12" stroke="currentColor" stroke-width="1.5" data-v-31e0404d></rect><rect x="18" y="4" width="12" height="12" stroke="currentColor" stroke-width="1.5" data-v-31e0404d></rect><rect x="32" y="4" width="12" height="12" stroke="currentColor" stroke-width="1.5" data-v-31e0404d></rect><rect x="4" y="18" width="12" height="12" stroke="currentColor" stroke-width="1.5" data-v-31e0404d></rect><rect x="18" y="18" width="12" height="12" stroke="currentColor" stroke-width="1.5" data-v-31e0404d></rect><rect x="32" y="18" width="12" height="12" stroke="currentColor" stroke-width="1.5" data-v-31e0404d></rect><rect x="4" y="32" width="12" height="12" stroke="currentColor" stroke-width="1.5" data-v-31e0404d></rect><rect x="18" y="32" width="12" height="12" stroke="currentColor" stroke-width="1.5" data-v-31e0404d></rect><rect x="32" y="32" width="12" height="12" stroke="currentColor" stroke-width="1.5" data-v-31e0404d></rect>',9)])])):c.type==="10"?(t.openBlock(),t.createElementBlock("svg",Z,[...o[8]||(o[8]=[t.createStaticVNode('<rect x="3" y="4" width="36" height="29" stroke="currentColor" stroke-width="2" data-v-31e0404d></rect><rect x="41" y="4" width="10" height="9" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="41" y="14.5" width="10" height="9" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="41" y="24.5" width="10" height="8.5" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="3" y="35" width="7" height="9" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="11" y="35" width="7" height="9" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="19" y="35" width="7" height="9" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="27" y="35" width="7" height="9" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="35" y="35" width="6" height="9" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="42" y="35" width="9" height="9" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect>',10)])])):c.type==="13"?(t.openBlock(),t.createElementBlock("svg",tt,[...o[9]||(o[9]=[t.createStaticVNode('<rect x="4" y="4" width="18" height="18" stroke="currentColor" stroke-width="2" data-v-31e0404d></rect><rect x="24" y="4" width="8" height="8" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="34" y="4" width="10" height="8" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="24" y="14" width="8" height="8" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="34" y="14" width="10" height="8" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="4" y="24" width="8" height="8" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="14" y="24" width="8" height="8" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="24" y="24" width="8" height="8" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="34" y="24" width="10" height="8" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="4" y="34" width="8" height="10" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="14" y="34" width="8" height="10" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="24" y="34" width="8" height="10" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="34" y="34" width="10" height="10" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect>',13)])])):c.type==="16"?(t.openBlock(),t.createElementBlock("svg",et,[...o[10]||(o[10]=[t.createStaticVNode('<rect x="4" y="4" width="9" height="9" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="15" y="4" width="9" height="9" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="26" y="4" width="9" height="9" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="37" y="4" width="7" height="9" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="4" y="15" width="9" height="9" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="15" y="15" width="9" height="9" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="26" y="15" width="9" height="9" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="37" y="15" width="7" height="9" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="4" y="26" width="9" height="9" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="15" y="26" width="9" height="9" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="26" y="26" width="9" height="9" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="37" y="26" width="7" height="9" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="4" y="37" width="9" height="7" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="15" y="37" width="9" height="7" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="26" y="37" width="9" height="7" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="37" y="37" width="7" height="7" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect>',16)])])):t.createCommentVNode("",!0)]))}}),N=(c,w)=>{const o=c.__vccOpts||c;for(const[k,d]of w)o[k]=d;return o},b=N(ot,[["__scopeId","data-v-31e0404d"]]),rt={key:0,class:"layout-toolbar",role:"toolbar","aria-label":"布局切换工具栏"},at={class:"layout-buttons"},lt=["onClick","title","aria-label","aria-pressed"],ct={class:"layout-label"},nt={class:"video-grid-container",role:"region","aria-label":"视频网格"},it=["aria-label","onDragstart","onDragenter","onDragleave","onDrop"],dt={class:"video-placeholder"},st={class:"placeholder-number"},ht=.5,wt="grabbing",ut="0.8",pt=t.defineComponent({__name:"VideoGridLayout",props:{videos:{},layout:{default:"1"},availableLayouts:{},showToolbar:{type:Boolean,default:!0},width:{},height:{},placeholderText:{},placeholders:{}},emits:["layoutChange","videosChange"],setup(c,{emit:w}){const o=c,k=w,d=t.ref(o.layout);t.watch(()=>o.layout,e=>{d.value=e});const I=t.computed(()=>o.availableLayouts&&o.availableLayouts.length>0?o.availableLayouts:L()),i=t.shallowRef([...o.videos]);t.watch(()=>o.videos,e=>{if(!Array.isArray(e)){console.warn("[VideoGridLayout] Invalid videos prop, expected array");return}(i.value.length!==e.length||i.value.some((r,l)=>{var a;return r.id!==((a=e[l])==null?void 0:a.id)}))&&(i.value=[...e])},{flush:"post"});let C=!1;t.watch(i,e=>{!C&&Array.isArray(e)&&k("videosChange",e)});const B=t.computed(()=>{const e=p[d.value];return e||(console.warn(`[VideoGridLayout] Invalid layout type: ${d.value}, fallback to '4'`),p[4])}),g=t.computed(()=>V(d.value)),$=t.computed(()=>{var e;return((e=B.value)==null?void 0:e.count)||4}),m=t.computed(()=>i.value.slice(0,$.value)),E=t.computed(()=>{const e=g.value.map((r,l)=>({p:r,idx:l}));return e.sort((r,l)=>r.p.row===l.p.row?(r.p.col||0)-(l.p.col||0):(r.p.row||0)-(l.p.row||0)),e.map(r=>r.idx)}),s=t.ref(-1),v=t.ref(-1),y=t.shallowRef(null),_=t.computed(()=>{const e=B.value;return{display:"grid",gridTemplateColumns:(e==null?void 0:e.colTemplate)||`repeat(${(e==null?void 0:e.cols)||2}, 1fr)`,gridTemplateRows:(e==null?void 0:e.rowTemplate)||`repeat(${(e==null?void 0:e.rows)||2}, 1fr)`,gap:"4px",width:o.width||"100%",height:o.height||"100%"}}),A=t.computed(()=>({width:o.width||"100%",height:o.height||"100%"}));function G(e){const r=e,l=E.value[r];if(Array.isArray(o.placeholders)&&o.placeholders[l]!==void 0)return String(o.placeholders[l]);if(typeof o.placeholderText=="function")try{return o.placeholderText(r)}catch{return String(r+1)}return o.placeholderText?String(o.placeholderText):String(r+1)}function T(e){const r=g.value[e];return!r||typeof r.col!="number"||typeof r.row!="number"?{}:{gridColumn:`${r.col} / span ${r.colSpan}`,gridRow:`${r.row} / span ${r.rowSpan}`}}function O(e){const r=g.value[e];return(r==null?void 0:r.isMain)||!1}function M(e){d.value=e,k("layoutChange",d.value)}function S(){if(y.value&&document.body.contains(y.value)){try{document.body.removeChild(y.value)}catch(e){console.warn("[VideoGridLayout] Failed to cleanup drag image:",e)}y.value=null}}function R(e,r){if(r<0||r>=i.value.length){console.warn("[VideoGridLayout] Invalid drag index:",r);return}if(s.value=r,!e.dataTransfer)return;e.dataTransfer.effectAllowed="move";const a=e.target.closest(".video-item");if(a)try{S();const n=a.cloneNode(!0);n.style.width=`${a.offsetWidth}px`,n.style.height=`${a.offsetHeight}px`,n.style.opacity=ut,n.style.position="absolute",n.style.top="-9999px",n.style.pointerEvents="none",document.body.appendChild(n),y.value=n,e.dataTransfer.setDragImage(n,a.offsetWidth/2,a.offsetHeight/2),setTimeout(()=>{S()},100),a.style.opacity=String(ht),a.style.cursor=wt}catch(n){console.error("[VideoGridLayout] Drag start error:",n),S()}}function P(e,r){e.preventDefault(),e.stopPropagation();const l=s.value;if(l===-1||l===r){s.value=-1;return}if(r<0||r>=i.value.length){console.warn("[VideoGridLayout] Invalid drop index:",r),s.value=-1;return}try{const a=i.value[l],n=i.value[r];if(a&&n){C=!0;const h=[...i.value];h[l]=n,h[r]=a,i.value=h,setTimeout(()=>{C=!1,k("videosChange",i.value)},0)}}catch(a){console.error("[VideoGridLayout] Drop error:",a)}finally{s.value=-1}}function F(e,r){e.preventDefault(),s.value!==-1&&s.value!==r&&(v.value=r)}function z(e,r){e.preventDefault();const l=e.target,a=e.relatedTarget;l.contains(a)||v.value===r&&(v.value=-1)}function U(e){const l=e.target.closest(".video-item");l&&(l.style.opacity="1",l.style.cursor="move"),S(),s.value=-1,v.value=-1}return t.onBeforeUnmount(()=>{S()}),(e,r)=>(t.openBlock(),t.createElementBlock("div",{class:"video-grid-layout",role:"application","aria-label":"视频分屏布局",style:t.normalizeStyle(A.value)},[c.showToolbar?(t.openBlock(),t.createElementBlock("div",rt,[r[1]||(r[1]=t.createElementVNode("div",{class:"toolbar-title"},"分屏布局",-1)),t.createElementVNode("div",at,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(I.value,l=>{var a,n,h;return t.openBlock(),t.createElementBlock("button",{key:l,class:t.normalizeClass(["layout-btn",{active:d.value===l}]),onClick:f=>M(l),title:((a=t.unref(p)[l])==null?void 0:a.label)||"","aria-label":`切换到${((n=t.unref(p)[l])==null?void 0:n.label)||""}布局`,"aria-pressed":d.value===l,type:"button"},[t.createVNode(b,{type:l},null,8,["type"]),t.createElementVNode("span",ct,t.toDisplayString(((h=t.unref(p)[l])==null?void 0:h.label)||""),1)],10,lt)}),128))])])):t.createCommentVNode("",!0),t.createElementVNode("div",nt,[t.createElementVNode("div",{class:"video-grid",style:t.normalizeStyle(_.value)},[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(g.value,(l,a)=>{var n,h,f;return t.openBlock(),t.createElementBlock("div",{key:((n=m.value[a])==null?void 0:n.id)??a,class:t.normalizeClass(["video-item",{"main-video":O(a),dragging:s.value===a,"drag-over":v.value===a&&s.value!==a}]),style:t.normalizeStyle(T(a)),draggable:!0,"aria-label":`视频 ${a+1}: ${((h=m.value[a])==null?void 0:h.title)||((f=m.value[a])==null?void 0:f.id)||""}`,role:"article",tabindex:"0",onDragstart:u=>R(u,a),onDragover:r[0]||(r[0]=t.withModifiers(()=>{},["prevent"])),onDragenter:u=>F(u,a),onDragleave:u=>z(u,a),onDrop:u=>P(u,a),onDragend:U},[t.renderSlot(e.$slots,"video",{video:m.value[a],index:a},()=>[t.createElementVNode("div",dt,[t.createElementVNode("div",st,t.toDisplayString(G(E.value.indexOf(a))),1)])],!0)],46,it)}),128))],4)])],4))}}),D=N(pt,[["__scopeId","data-v-fe8c1045"]]),kt={VideoGridLayout:D,VideoLayoutIcon:b},vt={install(c){Object.entries(kt).forEach(([w,o])=>{c.component(w,o)})}};exports.LAYOUT_CONFIGS=p;exports.VideoGridLayout=D;exports.VideoLayoutIcon=b;exports.default=vt;exports.getAllLayoutTypes=L;exports.getLayoutPositions=V;
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { defineComponent as N, createElementBlock as c, openBlock as i, createCommentVNode as P, createElementVNode as d, createStaticVNode as
|
|
2
|
-
const
|
|
1
|
+
import { defineComponent as N, createElementBlock as c, openBlock as i, createCommentVNode as P, createElementVNode as d, createStaticVNode as y, ref as $, watch as I, computed as p, shallowRef as T, onBeforeUnmount as et, normalizeStyle as A, Fragment as O, renderList as E, unref as B, normalizeClass as M, createVNode as rt, toDisplayString as R, withModifiers as at, renderSlot as lt } from "vue";
|
|
2
|
+
const S = {
|
|
3
3
|
1: {
|
|
4
4
|
type: "1",
|
|
5
5
|
label: "1分屏",
|
|
@@ -77,10 +77,10 @@ const g = {
|
|
|
77
77
|
cols: 4,
|
|
78
78
|
rows: 4
|
|
79
79
|
}
|
|
80
|
-
},
|
|
80
|
+
}, _ = {};
|
|
81
81
|
function nt(l) {
|
|
82
|
-
if (
|
|
83
|
-
return
|
|
82
|
+
if (_[l])
|
|
83
|
+
return _[l];
|
|
84
84
|
const o = {
|
|
85
85
|
1: [
|
|
86
86
|
{ col: 1, colSpan: 1, row: 1, rowSpan: 1 }
|
|
@@ -184,10 +184,10 @@ function nt(l) {
|
|
|
184
184
|
{ col: 4, colSpan: 1, row: 4, rowSpan: 1 }
|
|
185
185
|
]
|
|
186
186
|
}[l] || [];
|
|
187
|
-
return o.length > 0 && (
|
|
187
|
+
return o.length > 0 && (_[l] = o), o;
|
|
188
188
|
}
|
|
189
189
|
function ct() {
|
|
190
|
-
return Object.keys(
|
|
190
|
+
return Object.keys(S);
|
|
191
191
|
}
|
|
192
192
|
const it = { class: "layout-icon" }, dt = {
|
|
193
193
|
key: 0,
|
|
@@ -217,11 +217,11 @@ const it = { class: "layout-icon" }, dt = {
|
|
|
217
217
|
key: 6,
|
|
218
218
|
viewBox: "0 0 48 48",
|
|
219
219
|
fill: "none"
|
|
220
|
-
},
|
|
220
|
+
}, kt = {
|
|
221
221
|
key: 7,
|
|
222
222
|
viewBox: "0 0 48 48",
|
|
223
223
|
fill: "none"
|
|
224
|
-
},
|
|
224
|
+
}, yt = {
|
|
225
225
|
key: 8,
|
|
226
226
|
viewBox: "0 0 54 48",
|
|
227
227
|
fill: "none"
|
|
@@ -325,26 +325,26 @@ const it = { class: "layout-icon" }, dt = {
|
|
|
325
325
|
"stroke-width": "1.5"
|
|
326
326
|
}, null, -1)
|
|
327
327
|
])])) : l.type === "6" ? (i(), c("svg", ut, [...o[4] || (o[4] = [
|
|
328
|
-
|
|
328
|
+
y('<rect x="3" y="4" width="13" height="18" stroke="currentColor" stroke-width="1.5" data-v-31e0404d></rect><rect x="18" y="4" width="12" height="18" stroke="currentColor" stroke-width="1.5" data-v-31e0404d></rect><rect x="32" y="4" width="13" height="18" stroke="currentColor" stroke-width="1.5" data-v-31e0404d></rect><rect x="3" y="24" width="13" height="18" stroke="currentColor" stroke-width="1.5" data-v-31e0404d></rect><rect x="18" y="24" width="12" height="18" stroke="currentColor" stroke-width="1.5" data-v-31e0404d></rect><rect x="32" y="24" width="13" height="18" stroke="currentColor" stroke-width="1.5" data-v-31e0404d></rect>', 6)
|
|
329
329
|
])])) : l.type === "7" ? (i(), c("svg", pt, [...o[5] || (o[5] = [
|
|
330
|
-
|
|
330
|
+
y('<rect x="4" y="4" width="19" height="19" stroke="currentColor" stroke-width="2" data-v-31e0404d></rect><rect x="25" y="4" width="19" height="19" stroke="currentColor" stroke-width="2" data-v-31e0404d></rect><rect x="4" y="25" width="19" height="19" stroke="currentColor" stroke-width="2" data-v-31e0404d></rect><rect x="25" y="25" width="9" height="9" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="35" y="25" width="9" height="9" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="25" y="35" width="9" height="9" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="35" y="35" width="9" height="9" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect>', 7)
|
|
331
331
|
])])) : l.type === "8" ? (i(), c("svg", vt, [...o[6] || (o[6] = [
|
|
332
|
-
|
|
333
|
-
])])) : l.type === "9" ? (i(), c("svg",
|
|
334
|
-
|
|
335
|
-
])])) : l.type === "10" ? (i(), c("svg",
|
|
336
|
-
|
|
332
|
+
y('<rect x="4" y="4" width="28" height="29" stroke="currentColor" stroke-width="2" data-v-31e0404d></rect><rect x="34" y="4" width="10" height="9" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="34" y="14.5" width="10" height="9" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="34" y="24.5" width="10" height="8.5" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="4" y="35" width="9" height="9" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="14" y="35" width="9" height="9" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="24" y="35" width="9" height="9" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="34" y="35" width="10" height="9" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect>', 8)
|
|
333
|
+
])])) : l.type === "9" ? (i(), c("svg", kt, [...o[7] || (o[7] = [
|
|
334
|
+
y('<rect x="4" y="4" width="12" height="12" stroke="currentColor" stroke-width="1.5" data-v-31e0404d></rect><rect x="18" y="4" width="12" height="12" stroke="currentColor" stroke-width="1.5" data-v-31e0404d></rect><rect x="32" y="4" width="12" height="12" stroke="currentColor" stroke-width="1.5" data-v-31e0404d></rect><rect x="4" y="18" width="12" height="12" stroke="currentColor" stroke-width="1.5" data-v-31e0404d></rect><rect x="18" y="18" width="12" height="12" stroke="currentColor" stroke-width="1.5" data-v-31e0404d></rect><rect x="32" y="18" width="12" height="12" stroke="currentColor" stroke-width="1.5" data-v-31e0404d></rect><rect x="4" y="32" width="12" height="12" stroke="currentColor" stroke-width="1.5" data-v-31e0404d></rect><rect x="18" y="32" width="12" height="12" stroke="currentColor" stroke-width="1.5" data-v-31e0404d></rect><rect x="32" y="32" width="12" height="12" stroke="currentColor" stroke-width="1.5" data-v-31e0404d></rect>', 9)
|
|
335
|
+
])])) : l.type === "10" ? (i(), c("svg", yt, [...o[8] || (o[8] = [
|
|
336
|
+
y('<rect x="3" y="4" width="36" height="29" stroke="currentColor" stroke-width="2" data-v-31e0404d></rect><rect x="41" y="4" width="10" height="9" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="41" y="14.5" width="10" height="9" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="41" y="24.5" width="10" height="8.5" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="3" y="35" width="7" height="9" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="11" y="35" width="7" height="9" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="19" y="35" width="7" height="9" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="27" y="35" width="7" height="9" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="35" y="35" width="6" height="9" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="42" y="35" width="9" height="9" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect>', 10)
|
|
337
337
|
])])) : l.type === "13" ? (i(), c("svg", St, [...o[9] || (o[9] = [
|
|
338
|
-
|
|
338
|
+
y('<rect x="4" y="4" width="18" height="18" stroke="currentColor" stroke-width="2" data-v-31e0404d></rect><rect x="24" y="4" width="8" height="8" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="34" y="4" width="10" height="8" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="24" y="14" width="8" height="8" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="34" y="14" width="10" height="8" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="4" y="24" width="8" height="8" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="14" y="24" width="8" height="8" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="24" y="24" width="8" height="8" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="34" y="24" width="10" height="8" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="4" y="34" width="8" height="10" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="14" y="34" width="8" height="10" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="24" y="34" width="8" height="10" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="34" y="34" width="10" height="10" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect>', 13)
|
|
339
339
|
])])) : l.type === "16" ? (i(), c("svg", gt, [...o[10] || (o[10] = [
|
|
340
|
-
|
|
340
|
+
y('<rect x="4" y="4" width="9" height="9" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="15" y="4" width="9" height="9" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="26" y="4" width="9" height="9" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="37" y="4" width="7" height="9" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="4" y="15" width="9" height="9" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="15" y="15" width="9" height="9" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="26" y="15" width="9" height="9" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="37" y="15" width="7" height="9" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="4" y="26" width="9" height="9" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="15" y="26" width="9" height="9" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="26" y="26" width="9" height="9" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="37" y="26" width="7" height="9" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="4" y="37" width="9" height="7" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="15" y="37" width="9" height="7" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="26" y="37" width="9" height="7" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect><rect x="37" y="37" width="7" height="7" stroke="currentColor" stroke-width="1.2" data-v-31e0404d></rect>', 16)
|
|
341
341
|
])])) : P("", !0)
|
|
342
342
|
]));
|
|
343
343
|
}
|
|
344
344
|
}), F = (l, v) => {
|
|
345
345
|
const o = l.__vccOpts || l;
|
|
346
|
-
for (const [
|
|
347
|
-
o[
|
|
346
|
+
for (const [g, h] of v)
|
|
347
|
+
o[g] = h;
|
|
348
348
|
return o;
|
|
349
349
|
}, U = /* @__PURE__ */ F(Ct, [["__scopeId", "data-v-31e0404d"]]), xt = {
|
|
350
350
|
key: 0,
|
|
@@ -355,13 +355,7 @@ const it = { class: "layout-icon" }, dt = {
|
|
|
355
355
|
class: "video-grid-container",
|
|
356
356
|
role: "region",
|
|
357
357
|
"aria-label": "视频网格"
|
|
358
|
-
}, Lt = ["aria-label", "onDragstart", "onDragenter", "onDragleave", "onDrop"], $t = {
|
|
359
|
-
key: 0,
|
|
360
|
-
class: "video-placeholder"
|
|
361
|
-
}, It = { class: "placeholder-number" }, _t = {
|
|
362
|
-
key: 1,
|
|
363
|
-
style: { width: "100%", height: "100%" }
|
|
364
|
-
}, At = 0.5, Bt = "grabbing", Vt = "0.8", Gt = /* @__PURE__ */ N({
|
|
358
|
+
}, Lt = ["aria-label", "onDragstart", "onDragenter", "onDragleave", "onDrop"], $t = { class: "video-placeholder" }, It = { class: "placeholder-number" }, At = 0.5, Bt = "grabbing", _t = "0.8", Vt = /* @__PURE__ */ N({
|
|
365
359
|
__name: "VideoGridLayout",
|
|
366
360
|
props: {
|
|
367
361
|
videos: {},
|
|
@@ -375,7 +369,7 @@ const it = { class: "layout-icon" }, dt = {
|
|
|
375
369
|
},
|
|
376
370
|
emits: ["layoutChange", "videosChange"],
|
|
377
371
|
setup(l, { emit: v }) {
|
|
378
|
-
const o = l,
|
|
372
|
+
const o = l, g = v, h = $(o.layout);
|
|
379
373
|
I(() => o.layout, (t) => {
|
|
380
374
|
h.value = t;
|
|
381
375
|
});
|
|
@@ -392,18 +386,18 @@ const it = { class: "layout-icon" }, dt = {
|
|
|
392
386
|
}, { flush: "post" });
|
|
393
387
|
let D = !1;
|
|
394
388
|
I(s, (t) => {
|
|
395
|
-
!D && Array.isArray(t) &&
|
|
389
|
+
!D && Array.isArray(t) && g("videosChange", t);
|
|
396
390
|
});
|
|
397
391
|
const V = p(() => {
|
|
398
|
-
const t =
|
|
399
|
-
return t || (console.warn(`[VideoGridLayout] Invalid layout type: ${h.value}, fallback to '4'`),
|
|
400
|
-
}),
|
|
392
|
+
const t = S[h.value];
|
|
393
|
+
return t || (console.warn(`[VideoGridLayout] Invalid layout type: ${h.value}, fallback to '4'`), S[4]);
|
|
394
|
+
}), m = p(() => nt(h.value)), j = p(() => {
|
|
401
395
|
var t;
|
|
402
396
|
return ((t = V.value) == null ? void 0 : t.count) || 4;
|
|
403
|
-
}),
|
|
404
|
-
const t =
|
|
397
|
+
}), b = p(() => s.value.slice(0, j.value)), G = p(() => {
|
|
398
|
+
const t = m.value.map((e, a) => ({ p: e, idx: a }));
|
|
405
399
|
return t.sort((e, a) => e.p.row === a.p.row ? (e.p.col || 0) - (a.p.col || 0) : (e.p.row || 0) - (a.p.row || 0)), t.map((e) => e.idx);
|
|
406
|
-
}), w = $(-1),
|
|
400
|
+
}), w = $(-1), C = $(-1), x = T(null), z = p(() => {
|
|
407
401
|
const t = V.value;
|
|
408
402
|
return {
|
|
409
403
|
display: "grid",
|
|
@@ -419,7 +413,6 @@ const it = { class: "layout-icon" }, dt = {
|
|
|
419
413
|
}));
|
|
420
414
|
function W(t) {
|
|
421
415
|
const e = t, a = G.value[e];
|
|
422
|
-
if (S.value[a]) return "";
|
|
423
416
|
if (Array.isArray(o.placeholders) && o.placeholders[a] !== void 0)
|
|
424
417
|
return String(o.placeholders[a]);
|
|
425
418
|
if (typeof o.placeholderText == "function")
|
|
@@ -431,27 +424,27 @@ const it = { class: "layout-icon" }, dt = {
|
|
|
431
424
|
return o.placeholderText ? String(o.placeholderText) : String(e + 1);
|
|
432
425
|
}
|
|
433
426
|
function q(t) {
|
|
434
|
-
const e =
|
|
427
|
+
const e = m.value[t];
|
|
435
428
|
return !e || typeof e.col != "number" || typeof e.row != "number" ? {} : {
|
|
436
429
|
gridColumn: `${e.col} / span ${e.colSpan}`,
|
|
437
430
|
gridRow: `${e.row} / span ${e.rowSpan}`
|
|
438
431
|
};
|
|
439
432
|
}
|
|
440
433
|
function J(t) {
|
|
441
|
-
const e =
|
|
434
|
+
const e = m.value[t];
|
|
442
435
|
return (e == null ? void 0 : e.isMain) || !1;
|
|
443
436
|
}
|
|
444
437
|
function K(t) {
|
|
445
|
-
h.value = t,
|
|
438
|
+
h.value = t, g("layoutChange", h.value);
|
|
446
439
|
}
|
|
447
|
-
function
|
|
448
|
-
if (
|
|
440
|
+
function f() {
|
|
441
|
+
if (x.value && document.body.contains(x.value)) {
|
|
449
442
|
try {
|
|
450
|
-
document.body.removeChild(
|
|
443
|
+
document.body.removeChild(x.value);
|
|
451
444
|
} catch (t) {
|
|
452
445
|
console.warn("[VideoGridLayout] Failed to cleanup drag image:", t);
|
|
453
446
|
}
|
|
454
|
-
|
|
447
|
+
x.value = null;
|
|
455
448
|
}
|
|
456
449
|
}
|
|
457
450
|
function Q(t, e) {
|
|
@@ -464,13 +457,13 @@ const it = { class: "layout-icon" }, dt = {
|
|
|
464
457
|
const r = t.target.closest(".video-item");
|
|
465
458
|
if (r)
|
|
466
459
|
try {
|
|
467
|
-
|
|
460
|
+
f();
|
|
468
461
|
const n = r.cloneNode(!0);
|
|
469
|
-
n.style.width = `${r.offsetWidth}px`, n.style.height = `${r.offsetHeight}px`, n.style.opacity =
|
|
470
|
-
|
|
462
|
+
n.style.width = `${r.offsetWidth}px`, n.style.height = `${r.offsetHeight}px`, n.style.opacity = _t, n.style.position = "absolute", n.style.top = "-9999px", n.style.pointerEvents = "none", document.body.appendChild(n), x.value = n, t.dataTransfer.setDragImage(n, r.offsetWidth / 2, r.offsetHeight / 2), setTimeout(() => {
|
|
463
|
+
f();
|
|
471
464
|
}, 100), r.style.opacity = String(At), r.style.cursor = Bt;
|
|
472
465
|
} catch (n) {
|
|
473
|
-
console.error("[VideoGridLayout] Drag start error:", n),
|
|
466
|
+
console.error("[VideoGridLayout] Drag start error:", n), f();
|
|
474
467
|
}
|
|
475
468
|
}
|
|
476
469
|
function X(t, e) {
|
|
@@ -490,7 +483,7 @@ const it = { class: "layout-icon" }, dt = {
|
|
|
490
483
|
D = !0;
|
|
491
484
|
const u = [...s.value];
|
|
492
485
|
u[a] = n, u[e] = r, s.value = u, setTimeout(() => {
|
|
493
|
-
D = !1,
|
|
486
|
+
D = !1, g("videosChange", s.value);
|
|
494
487
|
}, 0);
|
|
495
488
|
}
|
|
496
489
|
} catch (r) {
|
|
@@ -500,24 +493,24 @@ const it = { class: "layout-icon" }, dt = {
|
|
|
500
493
|
}
|
|
501
494
|
}
|
|
502
495
|
function Z(t, e) {
|
|
503
|
-
t.preventDefault(), w.value !== -1 && w.value !== e && (
|
|
496
|
+
t.preventDefault(), w.value !== -1 && w.value !== e && (C.value = e);
|
|
504
497
|
}
|
|
505
498
|
function tt(t, e) {
|
|
506
499
|
t.preventDefault();
|
|
507
500
|
const a = t.target, r = t.relatedTarget;
|
|
508
|
-
a.contains(r) ||
|
|
501
|
+
a.contains(r) || C.value === e && (C.value = -1);
|
|
509
502
|
}
|
|
510
503
|
function ot(t) {
|
|
511
504
|
const a = t.target.closest(".video-item");
|
|
512
|
-
a && (a.style.opacity = "1", a.style.cursor = "move"),
|
|
505
|
+
a && (a.style.opacity = "1", a.style.cursor = "move"), f(), w.value = -1, C.value = -1;
|
|
513
506
|
}
|
|
514
507
|
return et(() => {
|
|
515
|
-
|
|
508
|
+
f();
|
|
516
509
|
}), (t, e) => (i(), c("div", {
|
|
517
510
|
class: "video-grid-layout",
|
|
518
511
|
role: "application",
|
|
519
512
|
"aria-label": "视频分屏布局",
|
|
520
|
-
style:
|
|
513
|
+
style: A(H.value)
|
|
521
514
|
}, [
|
|
522
515
|
l.showToolbar ? (i(), c("div", xt, [
|
|
523
516
|
e[1] || (e[1] = d("div", { class: "toolbar-title" }, "分屏布局", -1)),
|
|
@@ -528,13 +521,13 @@ const it = { class: "layout-icon" }, dt = {
|
|
|
528
521
|
key: a,
|
|
529
522
|
class: M(["layout-btn", { active: h.value === a }]),
|
|
530
523
|
onClick: (L) => K(a),
|
|
531
|
-
title: ((r =
|
|
532
|
-
"aria-label": `切换到${((n =
|
|
524
|
+
title: ((r = B(S)[a]) == null ? void 0 : r.label) || "",
|
|
525
|
+
"aria-label": `切换到${((n = B(S)[a]) == null ? void 0 : n.label) || ""}布局`,
|
|
533
526
|
"aria-pressed": h.value === a,
|
|
534
527
|
type: "button"
|
|
535
528
|
}, [
|
|
536
529
|
rt(U, { type: a }, null, 8, ["type"]),
|
|
537
|
-
d("span", bt, R(((u =
|
|
530
|
+
d("span", bt, R(((u = B(S)[a]) == null ? void 0 : u.label) || ""), 1)
|
|
538
531
|
], 10, mt);
|
|
539
532
|
}), 128))
|
|
540
533
|
])
|
|
@@ -542,37 +535,37 @@ const it = { class: "layout-icon" }, dt = {
|
|
|
542
535
|
d("div", Dt, [
|
|
543
536
|
d("div", {
|
|
544
537
|
class: "video-grid",
|
|
545
|
-
style:
|
|
538
|
+
style: A(z.value)
|
|
546
539
|
}, [
|
|
547
|
-
(i(!0), c(O, null, E(
|
|
540
|
+
(i(!0), c(O, null, E(m.value, (a, r) => {
|
|
548
541
|
var n, u, L;
|
|
549
542
|
return i(), c("div", {
|
|
550
|
-
key: ((n =
|
|
543
|
+
key: ((n = b.value[r]) == null ? void 0 : n.id) ?? r,
|
|
551
544
|
class: M(["video-item", {
|
|
552
545
|
"main-video": J(r),
|
|
553
546
|
dragging: w.value === r,
|
|
554
|
-
"drag-over":
|
|
547
|
+
"drag-over": C.value === r && w.value !== r
|
|
555
548
|
}]),
|
|
556
|
-
style:
|
|
549
|
+
style: A(q(r)),
|
|
557
550
|
draggable: !0,
|
|
558
|
-
"aria-label": `视频 ${r + 1}: ${((u =
|
|
551
|
+
"aria-label": `视频 ${r + 1}: ${((u = b.value[r]) == null ? void 0 : u.title) || ((L = b.value[r]) == null ? void 0 : L.id) || ""}`,
|
|
559
552
|
role: "article",
|
|
560
553
|
tabindex: "0",
|
|
561
|
-
onDragstart: (
|
|
554
|
+
onDragstart: (k) => Q(k, r),
|
|
562
555
|
onDragover: e[0] || (e[0] = at(() => {
|
|
563
556
|
}, ["prevent"])),
|
|
564
|
-
onDragenter: (
|
|
565
|
-
onDragleave: (
|
|
566
|
-
onDrop: (
|
|
557
|
+
onDragenter: (k) => Z(k, r),
|
|
558
|
+
onDragleave: (k) => tt(k, r),
|
|
559
|
+
onDrop: (k) => X(k, r),
|
|
567
560
|
onDragend: ot
|
|
568
561
|
}, [
|
|
569
562
|
lt(t.$slots, "video", {
|
|
570
|
-
video:
|
|
563
|
+
video: b.value[r],
|
|
571
564
|
index: r
|
|
572
565
|
}, () => [
|
|
573
|
-
|
|
566
|
+
d("div", $t, [
|
|
574
567
|
d("div", It, R(W(G.value.indexOf(r))), 1)
|
|
575
|
-
])
|
|
568
|
+
])
|
|
576
569
|
], !0)
|
|
577
570
|
], 46, Lt);
|
|
578
571
|
}), 128))
|
|
@@ -580,21 +573,21 @@ const it = { class: "layout-icon" }, dt = {
|
|
|
580
573
|
])
|
|
581
574
|
], 4));
|
|
582
575
|
}
|
|
583
|
-
}),
|
|
584
|
-
VideoGridLayout:
|
|
576
|
+
}), Gt = /* @__PURE__ */ F(Vt, [["__scopeId", "data-v-fe8c1045"]]), Tt = {
|
|
577
|
+
VideoGridLayout: Gt,
|
|
585
578
|
VideoLayoutIcon: U
|
|
586
|
-
},
|
|
579
|
+
}, Et = {
|
|
587
580
|
install(l) {
|
|
588
|
-
Object.entries(
|
|
581
|
+
Object.entries(Tt).forEach(([v, o]) => {
|
|
589
582
|
l.component(v, o);
|
|
590
583
|
});
|
|
591
584
|
}
|
|
592
585
|
};
|
|
593
586
|
export {
|
|
594
|
-
|
|
595
|
-
|
|
587
|
+
S as LAYOUT_CONFIGS,
|
|
588
|
+
Gt as VideoGridLayout,
|
|
596
589
|
U as VideoLayoutIcon,
|
|
597
|
-
|
|
590
|
+
Et as default,
|
|
598
591
|
ct as getAllLayoutTypes,
|
|
599
592
|
nt as getLayoutPositions
|
|
600
593
|
};
|
package/dist/style.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.video-grid-layout{width:100%;height:100%;display:flex;flex-direction:column;background:#0015294d}.layout-toolbar{padding:12px 16px;background:#fff;border-bottom:1px solid #e0e0e0;display:flex;align-items:center;gap:16px;flex-wrap:wrap}.toolbar-title{font-size:14px;font-weight:600;color:#333}.layout-buttons{display:flex;gap:8px;flex-wrap:wrap}.layout-btn{display:flex;align-items:center;gap:6px;padding:6px 12px;border:1px solid #d0d0d0;background:#fff;border-radius:4px;cursor:pointer;transition:all .2s;font-size:12px;color:#666}.layout-btn:hover{border-color:#42b883;color:#42b883;background:#f0fdf4}.layout-btn.active{border-color:#42b883;background:#42b883;color:#fff}.layout-label{font-size:12px}.video-grid-container{flex:1;padding:8px;display:flex;align-items:center;justify-content:center;min-height:0;overflow:hidden;box-sizing:border-box}.video-grid{width:100%;height:100%;max-width:100%;max-height:100%;background:#00409f33;padding:4px;border-radius:4px;box-sizing:border-box}.video-item{position:relative;background:#00152999;border:2px solid rgba(0,64,159,.49);border-radius:4px;overflow:hidden;cursor:move;transition:border-color .2s ease,background .2s ease,box-shadow .2s ease,transform .2s ease;min-height:0;min-width:0;-webkit-user-select:none;user-select:none;-webkit-user-drag:element;will-change:transform}.video-item.dragging{opacity:.5;cursor:grabbing;transform:scale(.98);box-shadow:0 4px 12px #0000004d}.video-item:hover{border-color:#42b883cc;background:#001529cc}.video-item.drag-over{border:1px solid rgba(66,184,131,1)!important;background:#42b88333!important}.video-item:focus{outline:1px solid rgba(66,184,131,1);outline-offset:1px}.video-item.main-video{border-width:1px}.video-item>*{width:100%;height:100%}.video-placeholder{display:flex;align-items:center;justify-content:center;height:100%;color:#3de6ff80;-webkit-user-select:none;user-select:none;background:#00409f4d}.placeholder-number{font-size:48px;font-weight:700;color:#3de6ff99;text-shadow:0 0 10px rgba(61,230,255,.3)}@media (max-width: 768px){.layout-toolbar{flex-direction:column;align-items:flex-start}.layout-label{display:none}}.layout-icon[data-v-31e0404d]{width:16px;height:16px;display:inline-flex;align-items:center;justify-content:center}.layout-icon svg[data-v-31e0404d]{width:100%;height:100%}.video-grid-layout[data-v-
|
|
1
|
+
.video-grid-layout{width:100%;height:100%;display:flex;flex-direction:column;background:#0015294d}.layout-toolbar{padding:12px 16px;background:#fff;border-bottom:1px solid #e0e0e0;display:flex;align-items:center;gap:16px;flex-wrap:wrap}.toolbar-title{font-size:14px;font-weight:600;color:#333}.layout-buttons{display:flex;gap:8px;flex-wrap:wrap}.layout-btn{display:flex;align-items:center;gap:6px;padding:6px 12px;border:1px solid #d0d0d0;background:#fff;border-radius:4px;cursor:pointer;transition:all .2s;font-size:12px;color:#666}.layout-btn:hover{border-color:#42b883;color:#42b883;background:#f0fdf4}.layout-btn.active{border-color:#42b883;background:#42b883;color:#fff}.layout-label{font-size:12px}.video-grid-container{flex:1;padding:8px;display:flex;align-items:center;justify-content:center;min-height:0;overflow:hidden;box-sizing:border-box}.video-grid{width:100%;height:100%;max-width:100%;max-height:100%;background:#00409f33;padding:4px;border-radius:4px;box-sizing:border-box}.video-item{position:relative;background:#00152999;border:2px solid rgba(0,64,159,.49);border-radius:4px;overflow:hidden;cursor:move;transition:border-color .2s ease,background .2s ease,box-shadow .2s ease,transform .2s ease;min-height:0;min-width:0;-webkit-user-select:none;user-select:none;-webkit-user-drag:element;will-change:transform}.video-item.dragging{opacity:.5;cursor:grabbing;transform:scale(.98);box-shadow:0 4px 12px #0000004d}.video-item:hover{border-color:#42b883cc;background:#001529cc}.video-item.drag-over{border:1px solid rgba(66,184,131,1)!important;background:#42b88333!important}.video-item:focus{outline:1px solid rgba(66,184,131,1);outline-offset:1px}.video-item.main-video{border-width:1px}.video-item>*{width:100%;height:100%}.video-placeholder{display:flex;align-items:center;justify-content:center;height:100%;color:#3de6ff80;-webkit-user-select:none;user-select:none;background:#00409f4d}.placeholder-number{font-size:48px;font-weight:700;color:#3de6ff99;text-shadow:0 0 10px rgba(61,230,255,.3)}@media (max-width: 768px){.layout-toolbar{flex-direction:column;align-items:flex-start}.layout-label{display:none}}.layout-icon[data-v-31e0404d]{width:16px;height:16px;display:inline-flex;align-items:center;justify-content:center}.layout-icon svg[data-v-31e0404d]{width:100%;height:100%}.video-grid-layout[data-v-fe8c1045]{width:100%;height:100%;display:flex;flex-direction:column;background:#0015294d}.layout-toolbar[data-v-fe8c1045]{padding:12px 16px;background:#fff;border-bottom:1px solid #e0e0e0;display:flex;align-items:center;gap:16px;flex-wrap:wrap}.toolbar-title[data-v-fe8c1045]{font-size:14px;font-weight:600;color:#333}.layout-buttons[data-v-fe8c1045]{display:flex;gap:8px;flex-wrap:wrap}.layout-btn[data-v-fe8c1045]{display:flex;align-items:center;gap:6px;padding:6px 12px;border:1px solid #d0d0d0;background:#fff;border-radius:4px;cursor:pointer;transition:all .2s;font-size:12px;color:#666}.layout-btn[data-v-fe8c1045]:hover{border-color:#42b883;color:#42b883;background:#f0fdf4}.layout-btn.active[data-v-fe8c1045]{border-color:#42b883;background:#42b883;color:#fff}.layout-label[data-v-fe8c1045]{font-size:12px}.video-grid-container[data-v-fe8c1045]{flex:1;padding:8px;display:flex;align-items:center;justify-content:center;min-height:0;overflow:hidden;box-sizing:border-box}.video-grid[data-v-fe8c1045]{width:100%;height:100%;max-width:100%;max-height:100%;background:#00409f33;padding:4px;border-radius:4px;box-sizing:border-box}.video-item[data-v-fe8c1045]{position:relative;background:#00152999;border:2px solid rgba(0,64,159,.49);border-radius:4px;overflow:hidden;cursor:move;transition:border-color .2s ease,background .2s ease,box-shadow .2s ease,transform .2s ease;min-height:0;min-width:0;-webkit-user-select:none;user-select:none;-webkit-user-drag:element;will-change:transform}.video-item.dragging[data-v-fe8c1045]{opacity:.5;cursor:grabbing;transform:scale(.98);box-shadow:0 4px 12px #0000004d}.video-item[data-v-fe8c1045]:hover{border-color:#42b883cc;background:#001529cc}.video-item.drag-over[data-v-fe8c1045]{border:1px solid rgba(66,184,131,1)!important;background:#42b88333!important}.video-item[data-v-fe8c1045]:focus{outline:1px solid rgba(66,184,131,1);outline-offset:1px}.video-item.main-video[data-v-fe8c1045]{border-width:1px}.video-item[data-v-fe8c1045]>*{width:100%;height:100%}.video-placeholder[data-v-fe8c1045]{display:flex;align-items:center;justify-content:center;height:100%;color:#3de6ff80;-webkit-user-select:none;user-select:none;background:#00409f4d}.placeholder-number[data-v-fe8c1045]{font-size:48px;font-weight:700;color:#3de6ff99;text-shadow:0 0 10px rgba(61,230,255,.3)}@media (max-width: 768px){.layout-toolbar[data-v-fe8c1045]{flex-direction:column;align-items:flex-start}.layout-label[data-v-fe8c1045]{display:none}}
|