video-split-screen 1.0.23 → 1.0.25
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 +165 -155
- package/dist/style.css +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("vue"),k={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}},B={};function N(n){if(B[n])return B[n];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}]}[n]||[];return o.length>0&&(B[n]=o),o}function L(){return Object.keys(k)}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(n){return(p,o)=>(t.openBlock(),t.createElementBlock("div",Y,[n.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)])])):n.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)])])):n.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)])])):n.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)])])):n.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)])])):n.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)])])):n.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)])])):n.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)])])):n.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)])])):n.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)])])):n.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)]))}}),D=(n,p)=>{const o=n.__vccOpts||n;for(const[v,s]of p)o[v]=s;return o},E=D(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(n,{emit:p}){const o=n,v=p,s=t.ref(o.layout);t.watch(()=>o.layout,e=>{s.value=e});const I=t.computed(()=>o.availableLayouts&&o.availableLayouts.length>0?o.availableLayouts:L()),w=t.shallowRef([]);function f(e){const r=Array.isArray(e)?e:o.videos||[],l=b.value,a={};w.value.forEach((i,u)=>{i&&i.id!==void 0&&(a[i.id]=i.__labelNumber??u+1)});const c=Array.from({length:l}).map((i,u)=>{const d=r[u];if(d){const U=a[d.id]??d.__labelNumber??u+1;return{...d,__labelNumber:U}}});w.value=c}t.watch(()=>o.videos,e=>{if(!Array.isArray(e)){console.warn("[VideoGridLayout] Invalid videos prop, expected array");return}f(e)},{flush:"post"});let x=!1;t.watch(w,e=>{!x&&Array.isArray(e)&&v("videosChange",e)});const V=t.computed(()=>{const e=k[s.value];return e||(console.warn(`[VideoGridLayout] Invalid layout type: ${s.value}, fallback to '4'`),k[4])}),m=t.computed(()=>N(s.value)),b=t.computed(()=>{var e;return((e=V.value)==null?void 0:e.count)||4}),C=t.computed(()=>w.value.slice(0,b.value).map(e=>e).filter(Boolean));f(o.videos),t.watch(b,()=>{f(o.videos)}),t.computed(()=>{const e=m.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)});const h=t.ref(-1),y=t.ref(-1),S=t.shallowRef(null),$=t.computed(()=>{const e=V.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=m.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 T(e){const r=m.value[e];return(r==null?void 0:r.isMain)||!1}function O(e){s.value=e,v("layoutChange",s.value)}function g(){if(S.value&&document.body.contains(S.value)){try{document.body.removeChild(S.value)}catch(e){console.warn("[VideoGridLayout] Failed to cleanup drag image:",e)}S.value=null}}function M(e,r){if(r<0||r>=w.value.length){console.warn("[VideoGridLayout] Invalid drag index:",r);return}if(h.value=r,!e.dataTransfer)return;e.dataTransfer.effectAllowed="move";const a=e.target.closest(".video-item");if(a)try{g();const c=a.cloneNode(!0);c.style.width=`${a.offsetWidth}px`,c.style.height=`${a.offsetHeight}px`,c.style.opacity=ut,c.style.position="absolute",c.style.top="-9999px",c.style.pointerEvents="none",document.body.appendChild(c),S.value=c,e.dataTransfer.setDragImage(c,a.offsetWidth/2,a.offsetHeight/2),setTimeout(()=>{g()},100),a.style.opacity=String(ht),a.style.cursor=wt}catch(c){console.error("[VideoGridLayout] Drag start error:",c),g()}}function R(e,r){e.preventDefault(),e.stopPropagation();const l=h.value;if(l===-1||l===r){h.value=-1;return}if(l>=w.value.length){console.warn("[VideoGridLayout] No video at from index:",l),h.value=-1;return}try{const a=e.currentTarget;a&&(a.style.backgroundColor="rgba(66, 184, 131, 0.3)",a.style.borderColor="#42b883",setTimeout(()=>{a.style.backgroundColor="",a.style.borderColor=""},200));const c=[...w.value];if(r>=c.length){const i=c[l];c.splice(l,1),c.push(i)}else{const i=c[l];c[l]=c[r],c[r]=i}x=!0,w.value=c,setTimeout(()=>{x=!1,v("videosChange",w.value.filter(Boolean))},0)}catch(a){console.error("[VideoGridLayout] Drop error:",a)}finally{h.value=-1}}function P(e,r){e.preventDefault(),h.value!==-1&&h.value!==r&&(y.value=r)}function F(e,r){e.preventDefault();const l=e.target,a=e.relatedTarget;l.contains(a)||y.value===r&&(y.value=-1)}function z(e){const l=e.target.closest(".video-item");l&&(l.style.opacity="1",l.style.cursor="move"),g(),h.value=-1,y.value=-1}return t.onBeforeUnmount(()=>{g()}),(e,r)=>(t.openBlock(),t.createElementBlock("div",{class:"video-grid-layout",role:"application","aria-label":"视频分屏布局",style:t.normalizeStyle(A.value)},[n.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,c,i;return t.openBlock(),t.createElementBlock("button",{key:l,class:t.normalizeClass(["layout-btn",{active:s.value===l}]),onClick:u=>O(l),title:((a=t.unref(k)[l])==null?void 0:a.label)||"","aria-label":`切换到${((c=t.unref(k)[l])==null?void 0:c.label)||""}布局`,"aria-pressed":s.value===l,type:"button"},[t.createVNode(E,{type:l},null,8,["type"]),t.createElementVNode("span",ct,t.toDisplayString(((i=t.unref(k)[l])==null?void 0:i.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(m.value,(l,a)=>{var c,i,u;return t.openBlock(),t.createElementBlock("div",{key:((c=C.value[a])==null?void 0:c.id)??a,class:t.normalizeClass(["video-item",{"main-video":T(a),dragging:h.value===a,"drag-over":y.value===a&&h.value!==a}]),style:t.normalizeStyle(G(a)),draggable:!0,"aria-label":`视频 ${a+1}: ${((i=C.value[a])==null?void 0:i.title)||((u=C.value[a])==null?void 0:u.id)||""}`,role:"article",tabindex:"0",onDragstart:d=>M(d,a),onDragover:r[0]||(r[0]=t.withModifiers(()=>{},["prevent"])),onDragenter:d=>P(d,a),onDragleave:d=>F(d,a),onDrop:d=>R(d,a),onDragend:z},[t.renderSlot(e.$slots,"video",{video:C.value[a],index:a},()=>[t.createElementVNode("div",dt,[t.createElementVNode("div",st,t.toDisplayString(a+1),1)])],!0)],46,it)}),128))],4)])],4))}}),_=D(pt,[["__scopeId","data-v-222ef64d"]]),kt={VideoGridLayout:_,VideoLayoutIcon:E},vt={install(n){Object.entries(kt).forEach(([p,o])=>{n.component(p,o)})}};exports.LAYOUT_CONFIGS=k;exports.VideoGridLayout=_;exports.VideoLayoutIcon=E;exports.default=vt;exports.getAllLayoutTypes=L;exports.getLayoutPositions=N;
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("vue"),k={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}},B={};function N(n){if(B[n])return B[n];const a={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}]}[n]||[];return a.length>0&&(B[n]=a),a}function L(){return Object.keys(k)}const j={class:"layout-icon"},H={key:0,viewBox:"0 0 48 48",fill:"none"},W={key:1,viewBox:"0 0 48 48",fill:"none"},q={key:2,viewBox:"0 0 48 48",fill:"none"},J={key:3,viewBox:"0 0 48 48",fill:"none"},K={key:4,viewBox:"0 0 48 48",fill:"none"},Q={key:5,viewBox:"0 0 48 48",fill:"none"},X={key:6,viewBox:"0 0 48 48",fill:"none"},Z={key:7,viewBox:"0 0 48 48",fill:"none"},tt={key:8,viewBox:"0 0 54 48",fill:"none"},et={key:9,viewBox:"0 0 48 48",fill:"none"},ot={key:10,viewBox:"0 0 48 48",fill:"none"},rt=t.defineComponent({__name:"VideoLayoutIcon",props:{type:{}},setup(n){return(p,a)=>(t.openBlock(),t.createElementBlock("div",j,[n.type==="1"?(t.openBlock(),t.createElementBlock("svg",H,[...a[0]||(a[0]=[t.createElementVNode("rect",{x:"4",y:"4",width:"40",height:"40",stroke:"currentColor","stroke-width":"2"},null,-1)])])):n.type==="2"?(t.openBlock(),t.createElementBlock("svg",W,[...a[1]||(a[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)])])):n.type==="3"?(t.openBlock(),t.createElementBlock("svg",q,[...a[2]||(a[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)])])):n.type==="4"?(t.openBlock(),t.createElementBlock("svg",J,[...a[3]||(a[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)])])):n.type==="6"?(t.openBlock(),t.createElementBlock("svg",K,[...a[4]||(a[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)])])):n.type==="7"?(t.openBlock(),t.createElementBlock("svg",Q,[...a[5]||(a[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)])])):n.type==="8"?(t.openBlock(),t.createElementBlock("svg",X,[...a[6]||(a[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)])])):n.type==="9"?(t.openBlock(),t.createElementBlock("svg",Z,[...a[7]||(a[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)])])):n.type==="10"?(t.openBlock(),t.createElementBlock("svg",tt,[...a[8]||(a[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)])])):n.type==="13"?(t.openBlock(),t.createElementBlock("svg",et,[...a[9]||(a[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)])])):n.type==="16"?(t.openBlock(),t.createElementBlock("svg",ot,[...a[10]||(a[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)]))}}),D=(n,p)=>{const a=n.__vccOpts||n;for(const[y,h]of p)a[y]=h;return a},E=D(rt,[["__scopeId","data-v-31e0404d"]]),at={key:0,class:"layout-toolbar",role:"toolbar","aria-label":"布局切换工具栏"},lt={class:"layout-buttons"},ct=["onClick","title","aria-label","aria-pressed"],nt={class:"layout-label"},it={class:"video-grid-container",role:"region","aria-label":"视频网格"},dt=["aria-label","onDragstart","onDragenter","onDragleave","onDrop"],st={class:"video-placeholder"},ht={class:"placeholder-number"},wt=.5,ut="grabbing",pt="0.8",kt=t.defineComponent({__name:"VideoGridLayout",props:{videos:{},layout:{default:"1"},availableLayouts:{},showToolbar:{type:Boolean,default:!0},width:{},height:{},placeholderText:{},placeholders:{}},emits:["layoutChange","videosChange"],setup(n,{emit:p}){const a=n,y=p,h=t.ref(a.layout);t.watch(()=>a.layout,e=>{h.value=e});const _=t.computed(()=>a.availableLayouts&&a.availableLayouts.length>0?a.availableLayouts:L()),s=t.shallowRef([]);function f(e){const r=Array.isArray(e)?e:a.videos||[],l=b.value,o={};s.value.forEach((i,u)=>{i&&i.id!==void 0&&(o[i.id]=i.__labelNumber??u+1)});const c=Array.from({length:l}).map((i,u)=>{const d=r[u];if(d){const Y=o[d.id]??d.__labelNumber??u+1;return{...d,__labelNumber:Y}}});s.value=c}t.watch(()=>a.videos,e=>{if(!Array.isArray(e)){console.warn("[VideoGridLayout] Invalid videos prop, expected array");return}f(e)},{flush:"post"});let x=!1;t.watch(s,e=>{!x&&Array.isArray(e)&&y("videosChange",e)});const V=t.computed(()=>{const e=k[h.value];return e||(console.warn(`[VideoGridLayout] Invalid layout type: ${h.value}, fallback to '4'`),k[4])}),C=t.computed(()=>N(h.value)),b=t.computed(()=>{var e;return((e=V.value)==null?void 0:e.count)||4}),v=t.computed(()=>s.value.slice(0,b.value).map(e=>e).filter(Boolean));t.computed(()=>{const e={};return v.value.forEach((r,l)=>{const o=s.value.findIndex(c=>c&&c.id===r.id);o!==-1&&(e[l]=o)}),e}),f(a.videos),t.watch(b,()=>{f(a.videos)}),t.computed(()=>{const e=C.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)});const w=t.ref(-1),S=t.ref(-1),g=t.shallowRef(null),$=t.computed(()=>{const e=V.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:a.width||"100%",height:a.height||"100%"}}),A=t.computed(()=>({width:a.width||"100%",height:a.height||"100%"}));function G(e){const r=v.value[e];return r?s.value.findIndex(o=>o&&o.id===r.id)+1:e+1}function T(e){const r=C.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=C.value[e];return(r==null?void 0:r.isMain)||!1}function M(e){h.value=e,y("layoutChange",h.value)}function m(){if(g.value&&document.body.contains(g.value)){try{document.body.removeChild(g.value)}catch(e){console.warn("[VideoGridLayout] Failed to cleanup drag image:",e)}g.value=null}}function R(e,r){if(r<0||r>=s.value.length){console.warn("[VideoGridLayout] Invalid drag index:",r);return}if(w.value=r,!e.dataTransfer)return;e.dataTransfer.effectAllowed="move";const o=e.target.closest(".video-item");if(o)try{m();const c=o.cloneNode(!0);c.style.width=`${o.offsetWidth}px`,c.style.height=`${o.offsetHeight}px`,c.style.opacity=pt,c.style.position="absolute",c.style.top="-9999px",c.style.pointerEvents="none",document.body.appendChild(c),g.value=c,e.dataTransfer.setDragImage(c,o.offsetWidth/2,o.offsetHeight/2),setTimeout(()=>{m()},100),o.style.opacity=String(wt),o.style.cursor=ut}catch(c){console.error("[VideoGridLayout] Drag start error:",c),m()}}function P(e,r){e.preventDefault(),e.stopPropagation();const l=w.value;if(l===-1||l===r){w.value=-1;return}if(l>=s.value.length){console.warn("[VideoGridLayout] No video at from index:",l),w.value=-1;return}try{const o=e.currentTarget;o&&(o.style.backgroundColor="rgba(66, 184, 131, 0.3)",o.style.borderColor="#42b883",setTimeout(()=>{o.style.backgroundColor="",o.style.borderColor=""},200));const c=[...s.value];if(r>=c.length){const i=c[l];c.splice(l,1),c.push(i)}else{const i=c[l];c[l]=c[r],c[r]=i}x=!0,s.value=c,setTimeout(()=>{x=!1,y("videosChange",s.value.filter(Boolean))},0)}catch(o){console.error("[VideoGridLayout] Drop error:",o)}finally{w.value=-1}}function F(e,r){e.preventDefault(),w.value!==-1&&w.value!==r&&(S.value=r)}function z(e,r){e.preventDefault();const l=e.target,o=e.relatedTarget;l.contains(o)||S.value===r&&(S.value=-1)}function U(e){const l=e.target.closest(".video-item");l&&(l.style.opacity="1",l.style.cursor="move"),m(),w.value=-1,S.value=-1}return t.onBeforeUnmount(()=>{m()}),(e,r)=>(t.openBlock(),t.createElementBlock("div",{class:"video-grid-layout",role:"application","aria-label":"视频分屏布局",style:t.normalizeStyle(A.value)},[n.showToolbar?(t.openBlock(),t.createElementBlock("div",at,[r[1]||(r[1]=t.createElementVNode("div",{class:"toolbar-title"},"分屏布局",-1)),t.createElementVNode("div",lt,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(_.value,l=>{var o,c,i;return t.openBlock(),t.createElementBlock("button",{key:l,class:t.normalizeClass(["layout-btn",{active:h.value===l}]),onClick:u=>M(l),title:((o=t.unref(k)[l])==null?void 0:o.label)||"","aria-label":`切换到${((c=t.unref(k)[l])==null?void 0:c.label)||""}布局`,"aria-pressed":h.value===l,type:"button"},[t.createVNode(E,{type:l},null,8,["type"]),t.createElementVNode("span",nt,t.toDisplayString(((i=t.unref(k)[l])==null?void 0:i.label)||""),1)],10,ct)}),128))])])):t.createCommentVNode("",!0),t.createElementVNode("div",it,[t.createElementVNode("div",{class:"video-grid",style:t.normalizeStyle($.value)},[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(C.value,(l,o)=>{var c,i,u;return t.openBlock(),t.createElementBlock("div",{key:((c=v.value[o])==null?void 0:c.id)??o,class:t.normalizeClass(["video-item",{"main-video":O(o),dragging:w.value===o,"drag-over":S.value===o&&w.value!==o}]),style:t.normalizeStyle(T(o)),draggable:!0,"aria-label":`视频 ${o+1}: ${((i=v.value[o])==null?void 0:i.title)||((u=v.value[o])==null?void 0:u.id)||""}`,role:"article",tabindex:"0",onDragstart:d=>R(d,o),onDragover:r[0]||(r[0]=t.withModifiers(()=>{},["prevent"])),onDragenter:d=>F(d,o),onDragleave:d=>z(d,o),onDrop:d=>P(d,o),onDragend:U},[t.renderSlot(e.$slots,"video",{video:v.value[o],index:o},()=>[t.createElementVNode("div",st,[t.createElementVNode("div",ht,t.toDisplayString(G(o)),1)])],!0)],46,dt)}),128))],4)])],4))}}),I=D(kt,[["__scopeId","data-v-df2d4d67"]]),vt={VideoGridLayout:I,VideoLayoutIcon:E},yt={install(n){Object.entries(vt).forEach(([p,a])=>{n.component(p,a)})}};exports.LAYOUT_CONFIGS=k;exports.VideoGridLayout=I;exports.VideoLayoutIcon=E;exports.default=yt;exports.getAllLayoutTypes=L;exports.getLayoutPositions=N;
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { defineComponent as P, createElementBlock as c, openBlock as i, createCommentVNode as F, createElementVNode as d, createStaticVNode as g, ref as B, watch as
|
|
2
|
-
const
|
|
1
|
+
import { defineComponent as P, createElementBlock as c, openBlock as i, createCommentVNode as F, createElementVNode as d, createStaticVNode as g, ref as B, watch as I, computed as v, shallowRef as E, onBeforeUnmount as rt, normalizeStyle as V, Fragment as T, renderList as O, unref as A, normalizeClass as M, createVNode as at, toDisplayString as R, withModifiers as lt, renderSlot as nt } from "vue";
|
|
2
|
+
const C = {
|
|
3
3
|
1: {
|
|
4
4
|
type: "1",
|
|
5
5
|
label: "1分屏",
|
|
@@ -78,10 +78,10 @@ const S = {
|
|
|
78
78
|
rows: 4
|
|
79
79
|
}
|
|
80
80
|
}, G = {};
|
|
81
|
-
function
|
|
81
|
+
function ct(n) {
|
|
82
82
|
if (G[n])
|
|
83
83
|
return G[n];
|
|
84
|
-
const
|
|
84
|
+
const r = {
|
|
85
85
|
1: [
|
|
86
86
|
{ col: 1, colSpan: 1, row: 1, rowSpan: 1 }
|
|
87
87
|
],
|
|
@@ -184,63 +184,63 @@ function nt(n) {
|
|
|
184
184
|
{ col: 4, colSpan: 1, row: 4, rowSpan: 1 }
|
|
185
185
|
]
|
|
186
186
|
}[n] || [];
|
|
187
|
-
return
|
|
187
|
+
return r.length > 0 && (G[n] = r), r;
|
|
188
188
|
}
|
|
189
|
-
function
|
|
190
|
-
return Object.keys(
|
|
189
|
+
function it() {
|
|
190
|
+
return Object.keys(C);
|
|
191
191
|
}
|
|
192
|
-
const
|
|
192
|
+
const dt = { class: "layout-icon" }, st = {
|
|
193
193
|
key: 0,
|
|
194
194
|
viewBox: "0 0 48 48",
|
|
195
195
|
fill: "none"
|
|
196
|
-
},
|
|
196
|
+
}, ht = {
|
|
197
197
|
key: 1,
|
|
198
198
|
viewBox: "0 0 48 48",
|
|
199
199
|
fill: "none"
|
|
200
|
-
},
|
|
200
|
+
}, wt = {
|
|
201
201
|
key: 2,
|
|
202
202
|
viewBox: "0 0 48 48",
|
|
203
203
|
fill: "none"
|
|
204
|
-
},
|
|
204
|
+
}, ut = {
|
|
205
205
|
key: 3,
|
|
206
206
|
viewBox: "0 0 48 48",
|
|
207
207
|
fill: "none"
|
|
208
|
-
},
|
|
208
|
+
}, pt = {
|
|
209
209
|
key: 4,
|
|
210
210
|
viewBox: "0 0 48 48",
|
|
211
211
|
fill: "none"
|
|
212
|
-
},
|
|
212
|
+
}, vt = {
|
|
213
213
|
key: 5,
|
|
214
214
|
viewBox: "0 0 48 48",
|
|
215
215
|
fill: "none"
|
|
216
|
-
},
|
|
216
|
+
}, yt = {
|
|
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
|
+
}, gt = {
|
|
225
225
|
key: 8,
|
|
226
226
|
viewBox: "0 0 54 48",
|
|
227
227
|
fill: "none"
|
|
228
|
-
},
|
|
228
|
+
}, St = {
|
|
229
229
|
key: 9,
|
|
230
230
|
viewBox: "0 0 48 48",
|
|
231
231
|
fill: "none"
|
|
232
|
-
},
|
|
232
|
+
}, Ct = {
|
|
233
233
|
key: 10,
|
|
234
234
|
viewBox: "0 0 48 48",
|
|
235
235
|
fill: "none"
|
|
236
|
-
},
|
|
236
|
+
}, ft = /* @__PURE__ */ P({
|
|
237
237
|
__name: "VideoLayoutIcon",
|
|
238
238
|
props: {
|
|
239
239
|
type: {}
|
|
240
240
|
},
|
|
241
241
|
setup(n) {
|
|
242
|
-
return (k,
|
|
243
|
-
n.type === "1" ? (i(), c("svg",
|
|
242
|
+
return (k, r) => (i(), c("div", dt, [
|
|
243
|
+
n.type === "1" ? (i(), c("svg", st, [...r[0] || (r[0] = [
|
|
244
244
|
d("rect", {
|
|
245
245
|
x: "4",
|
|
246
246
|
y: "4",
|
|
@@ -249,7 +249,7 @@ const it = { class: "layout-icon" }, dt = {
|
|
|
249
249
|
stroke: "currentColor",
|
|
250
250
|
"stroke-width": "2"
|
|
251
251
|
}, null, -1)
|
|
252
|
-
])])) : n.type === "2" ? (i(), c("svg",
|
|
252
|
+
])])) : n.type === "2" ? (i(), c("svg", ht, [...r[1] || (r[1] = [
|
|
253
253
|
d("rect", {
|
|
254
254
|
x: "4",
|
|
255
255
|
y: "4",
|
|
@@ -266,7 +266,7 @@ const it = { class: "layout-icon" }, dt = {
|
|
|
266
266
|
stroke: "currentColor",
|
|
267
267
|
"stroke-width": "1.5"
|
|
268
268
|
}, null, -1)
|
|
269
|
-
])])) : n.type === "3" ? (i(), c("svg",
|
|
269
|
+
])])) : n.type === "3" ? (i(), c("svg", wt, [...r[2] || (r[2] = [
|
|
270
270
|
d("rect", {
|
|
271
271
|
x: "4",
|
|
272
272
|
y: "4",
|
|
@@ -291,7 +291,7 @@ const it = { class: "layout-icon" }, dt = {
|
|
|
291
291
|
stroke: "currentColor",
|
|
292
292
|
"stroke-width": "1.5"
|
|
293
293
|
}, null, -1)
|
|
294
|
-
])])) : n.type === "4" ? (i(), c("svg",
|
|
294
|
+
])])) : n.type === "4" ? (i(), c("svg", ut, [...r[3] || (r[3] = [
|
|
295
295
|
d("rect", {
|
|
296
296
|
x: "4",
|
|
297
297
|
y: "4",
|
|
@@ -324,38 +324,38 @@ const it = { class: "layout-icon" }, dt = {
|
|
|
324
324
|
stroke: "currentColor",
|
|
325
325
|
"stroke-width": "1.5"
|
|
326
326
|
}, null, -1)
|
|
327
|
-
])])) : n.type === "6" ? (i(), c("svg",
|
|
327
|
+
])])) : n.type === "6" ? (i(), c("svg", pt, [...r[4] || (r[4] = [
|
|
328
328
|
g('<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
|
-
])])) : n.type === "7" ? (i(), c("svg",
|
|
329
|
+
])])) : n.type === "7" ? (i(), c("svg", vt, [...r[5] || (r[5] = [
|
|
330
330
|
g('<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
|
-
])])) : n.type === "8" ? (i(), c("svg",
|
|
331
|
+
])])) : n.type === "8" ? (i(), c("svg", yt, [...r[6] || (r[6] = [
|
|
332
332
|
g('<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
|
-
])])) : n.type === "9" ? (i(), c("svg",
|
|
333
|
+
])])) : n.type === "9" ? (i(), c("svg", kt, [...r[7] || (r[7] = [
|
|
334
334
|
g('<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
|
-
])])) : n.type === "10" ? (i(), c("svg",
|
|
335
|
+
])])) : n.type === "10" ? (i(), c("svg", gt, [...r[8] || (r[8] = [
|
|
336
336
|
g('<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
|
-
])])) : n.type === "13" ? (i(), c("svg",
|
|
337
|
+
])])) : n.type === "13" ? (i(), c("svg", St, [...r[9] || (r[9] = [
|
|
338
338
|
g('<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
|
-
])])) : n.type === "16" ? (i(), c("svg",
|
|
339
|
+
])])) : n.type === "16" ? (i(), c("svg", Ct, [...r[10] || (r[10] = [
|
|
340
340
|
g('<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
|
])])) : F("", !0)
|
|
342
342
|
]));
|
|
343
343
|
}
|
|
344
344
|
}), U = (n, k) => {
|
|
345
|
-
const
|
|
346
|
-
for (const [
|
|
347
|
-
|
|
348
|
-
return
|
|
349
|
-
}, Y = /* @__PURE__ */ U(
|
|
345
|
+
const r = n.__vccOpts || n;
|
|
346
|
+
for (const [f, u] of k)
|
|
347
|
+
r[f] = u;
|
|
348
|
+
return r;
|
|
349
|
+
}, Y = /* @__PURE__ */ U(ft, [["__scopeId", "data-v-31e0404d"]]), xt = {
|
|
350
350
|
key: 0,
|
|
351
351
|
class: "layout-toolbar",
|
|
352
352
|
role: "toolbar",
|
|
353
353
|
"aria-label": "布局切换工具栏"
|
|
354
|
-
},
|
|
354
|
+
}, mt = { class: "layout-buttons" }, bt = ["onClick", "title", "aria-label", "aria-pressed"], Dt = { class: "layout-label" }, It = {
|
|
355
355
|
class: "video-grid-container",
|
|
356
356
|
role: "region",
|
|
357
357
|
"aria-label": "视频网格"
|
|
358
|
-
}, Lt = ["aria-label", "onDragstart", "onDragenter", "onDragleave", "onDrop"], _t = { class: "video-placeholder" }, $t = { class: "placeholder-number" },
|
|
358
|
+
}, Lt = ["aria-label", "onDragstart", "onDragenter", "onDragleave", "onDrop"], _t = { class: "video-placeholder" }, $t = { class: "placeholder-number" }, Bt = 0.5, Vt = "grabbing", At = "0.8", Gt = /* @__PURE__ */ P({
|
|
359
359
|
__name: "VideoGridLayout",
|
|
360
360
|
props: {
|
|
361
361
|
videos: {},
|
|
@@ -369,123 +369,133 @@ const it = { class: "layout-icon" }, dt = {
|
|
|
369
369
|
},
|
|
370
370
|
emits: ["layoutChange", "videosChange"],
|
|
371
371
|
setup(n, { emit: k }) {
|
|
372
|
-
const
|
|
373
|
-
|
|
374
|
-
|
|
372
|
+
const r = n, f = k, u = B(r.layout);
|
|
373
|
+
I(() => r.layout, (t) => {
|
|
374
|
+
u.value = t;
|
|
375
375
|
});
|
|
376
|
-
const j =
|
|
377
|
-
function
|
|
378
|
-
const e = Array.isArray(t) ? t :
|
|
379
|
-
|
|
380
|
-
s && s.id !== void 0 && (
|
|
376
|
+
const j = v(() => r.availableLayouts && r.availableLayouts.length > 0 ? r.availableLayouts : it()), w = E([]);
|
|
377
|
+
function L(t) {
|
|
378
|
+
const e = Array.isArray(t) ? t : r.videos || [], a = $.value, o = {};
|
|
379
|
+
w.value.forEach((s, y) => {
|
|
380
|
+
s && s.id !== void 0 && (o[s.id] = s.__labelNumber ?? y + 1);
|
|
381
381
|
});
|
|
382
|
-
const l = Array.from({ length: a }).map((s,
|
|
383
|
-
const h = e[
|
|
382
|
+
const l = Array.from({ length: a }).map((s, y) => {
|
|
383
|
+
const h = e[y];
|
|
384
384
|
if (h) {
|
|
385
|
-
const
|
|
386
|
-
return { ...h, __labelNumber:
|
|
385
|
+
const et = o[h.id] ?? h.__labelNumber ?? y + 1;
|
|
386
|
+
return { ...h, __labelNumber: et };
|
|
387
387
|
}
|
|
388
388
|
});
|
|
389
|
-
|
|
389
|
+
w.value = l;
|
|
390
390
|
}
|
|
391
|
-
|
|
391
|
+
I(() => r.videos, (t) => {
|
|
392
392
|
if (!Array.isArray(t)) {
|
|
393
393
|
console.warn("[VideoGridLayout] Invalid videos prop, expected array");
|
|
394
394
|
return;
|
|
395
395
|
}
|
|
396
|
-
|
|
396
|
+
L(t);
|
|
397
397
|
}, { flush: "post" });
|
|
398
|
-
let
|
|
399
|
-
|
|
400
|
-
|
|
398
|
+
let _ = !1;
|
|
399
|
+
I(w, (t) => {
|
|
400
|
+
!_ && Array.isArray(t) && f("videosChange", t);
|
|
401
401
|
});
|
|
402
|
-
const N =
|
|
403
|
-
const t =
|
|
404
|
-
return t || (console.warn(`[VideoGridLayout] Invalid layout type: ${
|
|
405
|
-
}),
|
|
402
|
+
const N = v(() => {
|
|
403
|
+
const t = C[u.value];
|
|
404
|
+
return t || (console.warn(`[VideoGridLayout] Invalid layout type: ${u.value}, fallback to '4'`), C[4]);
|
|
405
|
+
}), D = v(() => ct(u.value)), $ = v(() => {
|
|
406
406
|
var t;
|
|
407
407
|
return ((t = N.value) == null ? void 0 : t.count) || 4;
|
|
408
|
-
}),
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
408
|
+
}), S = v(() => w.value.slice(0, $.value).map((t) => t).filter(Boolean));
|
|
409
|
+
v(() => {
|
|
410
|
+
const t = {};
|
|
411
|
+
return S.value.forEach((e, a) => {
|
|
412
|
+
const o = w.value.findIndex((l) => l && l.id === e.id);
|
|
413
|
+
o !== -1 && (t[a] = o);
|
|
414
|
+
}), t;
|
|
415
|
+
}), L(r.videos), I($, () => {
|
|
416
|
+
L(r.videos);
|
|
417
|
+
}), v(() => {
|
|
418
|
+
const t = D.value.map((e, a) => ({ p: e, idx: a }));
|
|
413
419
|
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);
|
|
414
420
|
});
|
|
415
|
-
const
|
|
421
|
+
const p = B(-1), x = B(-1), m = E(null), z = v(() => {
|
|
416
422
|
const t = N.value;
|
|
417
423
|
return {
|
|
418
424
|
display: "grid",
|
|
419
425
|
gridTemplateColumns: (t == null ? void 0 : t.colTemplate) || `repeat(${(t == null ? void 0 : t.cols) || 2}, 1fr)`,
|
|
420
426
|
gridTemplateRows: (t == null ? void 0 : t.rowTemplate) || `repeat(${(t == null ? void 0 : t.rows) || 2}, 1fr)`,
|
|
421
427
|
gap: "4px",
|
|
422
|
-
width:
|
|
423
|
-
height:
|
|
428
|
+
width: r.width || "100%",
|
|
429
|
+
height: r.height || "100%"
|
|
424
430
|
};
|
|
425
|
-
}), H =
|
|
426
|
-
width:
|
|
427
|
-
height:
|
|
431
|
+
}), H = v(() => ({
|
|
432
|
+
width: r.width || "100%",
|
|
433
|
+
height: r.height || "100%"
|
|
428
434
|
}));
|
|
429
435
|
function W(t) {
|
|
430
|
-
const e =
|
|
436
|
+
const e = S.value[t];
|
|
437
|
+
return e ? w.value.findIndex((o) => o && o.id === e.id) + 1 : t + 1;
|
|
438
|
+
}
|
|
439
|
+
function q(t) {
|
|
440
|
+
const e = D.value[t];
|
|
431
441
|
return !e || typeof e.col != "number" || typeof e.row != "number" ? {} : {
|
|
432
442
|
gridColumn: `${e.col} / span ${e.colSpan}`,
|
|
433
443
|
gridRow: `${e.row} / span ${e.rowSpan}`
|
|
434
444
|
};
|
|
435
445
|
}
|
|
436
|
-
function
|
|
437
|
-
const e =
|
|
446
|
+
function J(t) {
|
|
447
|
+
const e = D.value[t];
|
|
438
448
|
return (e == null ? void 0 : e.isMain) || !1;
|
|
439
449
|
}
|
|
440
|
-
function
|
|
441
|
-
|
|
450
|
+
function K(t) {
|
|
451
|
+
u.value = t, f("layoutChange", u.value);
|
|
442
452
|
}
|
|
443
|
-
function
|
|
444
|
-
if (
|
|
453
|
+
function b() {
|
|
454
|
+
if (m.value && document.body.contains(m.value)) {
|
|
445
455
|
try {
|
|
446
|
-
document.body.removeChild(
|
|
456
|
+
document.body.removeChild(m.value);
|
|
447
457
|
} catch (t) {
|
|
448
458
|
console.warn("[VideoGridLayout] Failed to cleanup drag image:", t);
|
|
449
459
|
}
|
|
450
|
-
|
|
460
|
+
m.value = null;
|
|
451
461
|
}
|
|
452
462
|
}
|
|
453
|
-
function
|
|
454
|
-
if (e < 0 || e >=
|
|
463
|
+
function Q(t, e) {
|
|
464
|
+
if (e < 0 || e >= w.value.length) {
|
|
455
465
|
console.warn("[VideoGridLayout] Invalid drag index:", e);
|
|
456
466
|
return;
|
|
457
467
|
}
|
|
458
|
-
if (
|
|
468
|
+
if (p.value = e, !t.dataTransfer) return;
|
|
459
469
|
t.dataTransfer.effectAllowed = "move";
|
|
460
|
-
const
|
|
461
|
-
if (
|
|
470
|
+
const o = t.target.closest(".video-item");
|
|
471
|
+
if (o)
|
|
462
472
|
try {
|
|
463
|
-
|
|
464
|
-
const l =
|
|
465
|
-
l.style.width = `${
|
|
466
|
-
|
|
467
|
-
}, 100),
|
|
473
|
+
b();
|
|
474
|
+
const l = o.cloneNode(!0);
|
|
475
|
+
l.style.width = `${o.offsetWidth}px`, l.style.height = `${o.offsetHeight}px`, l.style.opacity = At, l.style.position = "absolute", l.style.top = "-9999px", l.style.pointerEvents = "none", document.body.appendChild(l), m.value = l, t.dataTransfer.setDragImage(l, o.offsetWidth / 2, o.offsetHeight / 2), setTimeout(() => {
|
|
476
|
+
b();
|
|
477
|
+
}, 100), o.style.opacity = String(Bt), o.style.cursor = Vt;
|
|
468
478
|
} catch (l) {
|
|
469
|
-
console.error("[VideoGridLayout] Drag start error:", l),
|
|
479
|
+
console.error("[VideoGridLayout] Drag start error:", l), b();
|
|
470
480
|
}
|
|
471
481
|
}
|
|
472
|
-
function
|
|
482
|
+
function X(t, e) {
|
|
473
483
|
t.preventDefault(), t.stopPropagation();
|
|
474
|
-
const a =
|
|
484
|
+
const a = p.value;
|
|
475
485
|
if (a === -1 || a === e) {
|
|
476
|
-
|
|
486
|
+
p.value = -1;
|
|
477
487
|
return;
|
|
478
488
|
}
|
|
479
|
-
if (a >=
|
|
480
|
-
console.warn("[VideoGridLayout] No video at from index:", a),
|
|
489
|
+
if (a >= w.value.length) {
|
|
490
|
+
console.warn("[VideoGridLayout] No video at from index:", a), p.value = -1;
|
|
481
491
|
return;
|
|
482
492
|
}
|
|
483
493
|
try {
|
|
484
|
-
const
|
|
485
|
-
|
|
486
|
-
|
|
494
|
+
const o = t.currentTarget;
|
|
495
|
+
o && (o.style.backgroundColor = "rgba(66, 184, 131, 0.3)", o.style.borderColor = "#42b883", setTimeout(() => {
|
|
496
|
+
o.style.backgroundColor = "", o.style.borderColor = "";
|
|
487
497
|
}, 200));
|
|
488
|
-
const l = [...
|
|
498
|
+
const l = [...w.value];
|
|
489
499
|
if (e >= l.length) {
|
|
490
500
|
const s = l[a];
|
|
491
501
|
l.splice(a, 1), l.push(s);
|
|
@@ -493,88 +503,88 @@ const it = { class: "layout-icon" }, dt = {
|
|
|
493
503
|
const s = l[a];
|
|
494
504
|
l[a] = l[e], l[e] = s;
|
|
495
505
|
}
|
|
496
|
-
|
|
497
|
-
|
|
506
|
+
_ = !0, w.value = l, setTimeout(() => {
|
|
507
|
+
_ = !1, f("videosChange", w.value.filter(Boolean));
|
|
498
508
|
}, 0);
|
|
499
|
-
} catch (
|
|
500
|
-
console.error("[VideoGridLayout] Drop error:",
|
|
509
|
+
} catch (o) {
|
|
510
|
+
console.error("[VideoGridLayout] Drop error:", o);
|
|
501
511
|
} finally {
|
|
502
|
-
|
|
512
|
+
p.value = -1;
|
|
503
513
|
}
|
|
504
514
|
}
|
|
505
|
-
function X(t, e) {
|
|
506
|
-
t.preventDefault(), u.value !== -1 && u.value !== e && (f.value = e);
|
|
507
|
-
}
|
|
508
515
|
function Z(t, e) {
|
|
516
|
+
t.preventDefault(), p.value !== -1 && p.value !== e && (x.value = e);
|
|
517
|
+
}
|
|
518
|
+
function tt(t, e) {
|
|
509
519
|
t.preventDefault();
|
|
510
|
-
const a = t.target,
|
|
511
|
-
a.contains(
|
|
520
|
+
const a = t.target, o = t.relatedTarget;
|
|
521
|
+
a.contains(o) || x.value === e && (x.value = -1);
|
|
512
522
|
}
|
|
513
|
-
function
|
|
523
|
+
function ot(t) {
|
|
514
524
|
const a = t.target.closest(".video-item");
|
|
515
|
-
a && (a.style.opacity = "1", a.style.cursor = "move"),
|
|
525
|
+
a && (a.style.opacity = "1", a.style.cursor = "move"), b(), p.value = -1, x.value = -1;
|
|
516
526
|
}
|
|
517
|
-
return
|
|
518
|
-
|
|
527
|
+
return rt(() => {
|
|
528
|
+
b();
|
|
519
529
|
}), (t, e) => (i(), c("div", {
|
|
520
530
|
class: "video-grid-layout",
|
|
521
531
|
role: "application",
|
|
522
532
|
"aria-label": "视频分屏布局",
|
|
523
533
|
style: V(H.value)
|
|
524
534
|
}, [
|
|
525
|
-
n.showToolbar ? (i(), c("div",
|
|
535
|
+
n.showToolbar ? (i(), c("div", xt, [
|
|
526
536
|
e[1] || (e[1] = d("div", { class: "toolbar-title" }, "分屏布局", -1)),
|
|
527
|
-
d("div",
|
|
528
|
-
(i(!0), c(
|
|
529
|
-
var
|
|
537
|
+
d("div", mt, [
|
|
538
|
+
(i(!0), c(T, null, O(j.value, (a) => {
|
|
539
|
+
var o, l, s;
|
|
530
540
|
return i(), c("button", {
|
|
531
541
|
key: a,
|
|
532
|
-
class: M(["layout-btn", { active:
|
|
533
|
-
onClick: (
|
|
534
|
-
title: ((
|
|
535
|
-
"aria-label": `切换到${((l = A(
|
|
536
|
-
"aria-pressed":
|
|
542
|
+
class: M(["layout-btn", { active: u.value === a }]),
|
|
543
|
+
onClick: (y) => K(a),
|
|
544
|
+
title: ((o = A(C)[a]) == null ? void 0 : o.label) || "",
|
|
545
|
+
"aria-label": `切换到${((l = A(C)[a]) == null ? void 0 : l.label) || ""}布局`,
|
|
546
|
+
"aria-pressed": u.value === a,
|
|
537
547
|
type: "button"
|
|
538
548
|
}, [
|
|
539
|
-
|
|
540
|
-
d("span",
|
|
541
|
-
], 10,
|
|
549
|
+
at(Y, { type: a }, null, 8, ["type"]),
|
|
550
|
+
d("span", Dt, R(((s = A(C)[a]) == null ? void 0 : s.label) || ""), 1)
|
|
551
|
+
], 10, bt);
|
|
542
552
|
}), 128))
|
|
543
553
|
])
|
|
544
554
|
])) : F("", !0),
|
|
545
|
-
d("div",
|
|
555
|
+
d("div", It, [
|
|
546
556
|
d("div", {
|
|
547
557
|
class: "video-grid",
|
|
548
558
|
style: V(z.value)
|
|
549
559
|
}, [
|
|
550
|
-
(i(!0), c(
|
|
551
|
-
var l, s,
|
|
560
|
+
(i(!0), c(T, null, O(D.value, (a, o) => {
|
|
561
|
+
var l, s, y;
|
|
552
562
|
return i(), c("div", {
|
|
553
|
-
key: ((l =
|
|
563
|
+
key: ((l = S.value[o]) == null ? void 0 : l.id) ?? o,
|
|
554
564
|
class: M(["video-item", {
|
|
555
|
-
"main-video":
|
|
556
|
-
dragging:
|
|
557
|
-
"drag-over":
|
|
565
|
+
"main-video": J(o),
|
|
566
|
+
dragging: p.value === o,
|
|
567
|
+
"drag-over": x.value === o && p.value !== o
|
|
558
568
|
}]),
|
|
559
|
-
style: V(
|
|
569
|
+
style: V(q(o)),
|
|
560
570
|
draggable: !0,
|
|
561
|
-
"aria-label": `视频 ${
|
|
571
|
+
"aria-label": `视频 ${o + 1}: ${((s = S.value[o]) == null ? void 0 : s.title) || ((y = S.value[o]) == null ? void 0 : y.id) || ""}`,
|
|
562
572
|
role: "article",
|
|
563
573
|
tabindex: "0",
|
|
564
|
-
onDragstart: (h) =>
|
|
565
|
-
onDragover: e[0] || (e[0] =
|
|
574
|
+
onDragstart: (h) => Q(h, o),
|
|
575
|
+
onDragover: e[0] || (e[0] = lt(() => {
|
|
566
576
|
}, ["prevent"])),
|
|
567
|
-
onDragenter: (h) =>
|
|
568
|
-
onDragleave: (h) =>
|
|
569
|
-
onDrop: (h) =>
|
|
570
|
-
onDragend:
|
|
577
|
+
onDragenter: (h) => Z(h, o),
|
|
578
|
+
onDragleave: (h) => tt(h, o),
|
|
579
|
+
onDrop: (h) => X(h, o),
|
|
580
|
+
onDragend: ot
|
|
571
581
|
}, [
|
|
572
|
-
|
|
573
|
-
video:
|
|
574
|
-
index:
|
|
582
|
+
nt(t.$slots, "video", {
|
|
583
|
+
video: S.value[o],
|
|
584
|
+
index: o
|
|
575
585
|
}, () => [
|
|
576
586
|
d("div", _t, [
|
|
577
|
-
d("div", $t, R(
|
|
587
|
+
d("div", $t, R(W(o)), 1)
|
|
578
588
|
])
|
|
579
589
|
], !0)
|
|
580
590
|
], 46, Lt);
|
|
@@ -583,21 +593,21 @@ const it = { class: "layout-icon" }, dt = {
|
|
|
583
593
|
])
|
|
584
594
|
], 4));
|
|
585
595
|
}
|
|
586
|
-
}),
|
|
587
|
-
VideoGridLayout:
|
|
596
|
+
}), Nt = /* @__PURE__ */ U(Gt, [["__scopeId", "data-v-df2d4d67"]]), Et = {
|
|
597
|
+
VideoGridLayout: Nt,
|
|
588
598
|
VideoLayoutIcon: Y
|
|
589
|
-
},
|
|
599
|
+
}, Ot = {
|
|
590
600
|
install(n) {
|
|
591
|
-
Object.entries(
|
|
592
|
-
n.component(k,
|
|
601
|
+
Object.entries(Et).forEach(([k, r]) => {
|
|
602
|
+
n.component(k, r);
|
|
593
603
|
});
|
|
594
604
|
}
|
|
595
605
|
};
|
|
596
606
|
export {
|
|
597
|
-
|
|
598
|
-
|
|
607
|
+
C as LAYOUT_CONFIGS,
|
|
608
|
+
Nt as VideoGridLayout,
|
|
599
609
|
Y as VideoLayoutIcon,
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
610
|
+
Ot as default,
|
|
611
|
+
it as getAllLayoutTypes,
|
|
612
|
+
ct as getLayoutPositions
|
|
603
613
|
};
|
package/dist/style.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.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
|
+
.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-df2d4d67]{width:100%;height:100%;display:flex;flex-direction:column;background:#0015294d}.layout-toolbar[data-v-df2d4d67]{padding:12px 16px;background:#fff;border-bottom:1px solid #e0e0e0;display:flex;align-items:center;gap:16px;flex-wrap:wrap}.toolbar-title[data-v-df2d4d67]{font-size:14px;font-weight:600;color:#333}.layout-buttons[data-v-df2d4d67]{display:flex;gap:8px;flex-wrap:wrap}.layout-btn[data-v-df2d4d67]{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-df2d4d67]:hover{border-color:#42b883;color:#42b883;background:#f0fdf4}.layout-btn.active[data-v-df2d4d67]{border-color:#42b883;background:#42b883;color:#fff}.layout-label[data-v-df2d4d67]{font-size:12px}.video-grid-container[data-v-df2d4d67]{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-df2d4d67]{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-df2d4d67]{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-df2d4d67]{opacity:.5;cursor:grabbing;transform:scale(.98);box-shadow:0 4px 12px #0000004d}.video-item[data-v-df2d4d67]:hover{border-color:#42b883cc;background:#001529cc}.video-item.drag-over[data-v-df2d4d67]{border:1px solid rgba(66,184,131,1)!important;background:#42b88333!important}.video-item[data-v-df2d4d67]:focus{outline:1px solid rgba(66,184,131,1);outline-offset:1px}.video-item.main-video[data-v-df2d4d67]{border-width:1px}.video-item[data-v-df2d4d67]>*{width:100%;height:100%}.video-placeholder[data-v-df2d4d67]{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-df2d4d67]{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-df2d4d67]{flex-direction:column;align-items:flex-start}.layout-label[data-v-df2d4d67]{display:none}}
|