video-split-screen 1.0.23 → 1.0.24
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.d.ts +1 -0
- package/dist/index.js +1 -1
- package/dist/index.mjs +382 -199
- package/dist/style.css +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export * from './types';
|
|
|
2
2
|
export * from './layoutConfig';
|
|
3
3
|
export { default as VideoGridLayout } from './components/VideoGridLayout.vue';
|
|
4
4
|
export { default as VideoLayoutIcon } from './components/VideoLayoutIcon.vue';
|
|
5
|
+
export { default as VideoSplitScreenExample } from './components/VideoSplitScreenExample.vue';
|
|
5
6
|
import type { App } from 'vue';
|
|
6
7
|
declare const _default: {
|
|
7
8
|
install(app: App): void;
|
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 e=require("vue"),V={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}},$={};function T(d){if($[d])return $[d];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}]}[d]||[];return o.length>0&&($[d]=o),o}function A(){return Object.keys(V)}const H={class:"layout-icon"},W={key:0,viewBox:"0 0 48 48",fill:"none"},q={key:1,viewBox:"0 0 48 48",fill:"none"},J={key:2,viewBox:"0 0 48 48",fill:"none"},K={key:3,viewBox:"0 0 48 48",fill:"none"},Q={key:4,viewBox:"0 0 48 48",fill:"none"},X={key:5,viewBox:"0 0 48 48",fill:"none"},Z={key:6,viewBox:"0 0 48 48",fill:"none"},ee={key:7,viewBox:"0 0 48 48",fill:"none"},te={key:8,viewBox:"0 0 54 48",fill:"none"},oe={key:9,viewBox:"0 0 48 48",fill:"none"},re={key:10,viewBox:"0 0 48 48",fill:"none"},le=e.defineComponent({__name:"VideoLayoutIcon",props:{type:{}},setup(d){return(u,o)=>(e.openBlock(),e.createElementBlock("div",H,[d.type==="1"?(e.openBlock(),e.createElementBlock("svg",W,[...o[0]||(o[0]=[e.createElementVNode("rect",{x:"4",y:"4",width:"40",height:"40",stroke:"currentColor","stroke-width":"2"},null,-1)])])):d.type==="2"?(e.openBlock(),e.createElementBlock("svg",q,[...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)])])):d.type==="3"?(e.openBlock(),e.createElementBlock("svg",J,[...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)])])):d.type==="4"?(e.openBlock(),e.createElementBlock("svg",K,[...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)])])):d.type==="6"?(e.openBlock(),e.createElementBlock("svg",Q,[...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)])])):d.type==="7"?(e.openBlock(),e.createElementBlock("svg",X,[...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)])])):d.type==="8"?(e.openBlock(),e.createElementBlock("svg",Z,[...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)])])):d.type==="9"?(e.openBlock(),e.createElementBlock("svg",ee,[...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)])])):d.type==="10"?(e.openBlock(),e.createElementBlock("svg",te,[...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)])])):d.type==="13"?(e.openBlock(),e.createElementBlock("svg",oe,[...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)])])):d.type==="16"?(e.openBlock(),e.createElementBlock("svg",re,[...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)]))}}),D=(d,u)=>{const o=d.__vccOpts||d;for(const[p,h]of u)o[p]=h;return o},L=D(le,[["__scopeId","data-v-31e0404d"]]),ae={key:0,class:"layout-toolbar",role:"toolbar","aria-label":"布局切换工具栏"},ne={class:"layout-buttons"},ce=["onClick","title","aria-label","aria-pressed"],ie={class:"layout-label"},de={class:"video-grid-container",role:"region","aria-label":"视频网格"},se=["aria-label","onDragstart","onDragenter","onDragleave","onDrop"],ue={class:"video-placeholder"},he={class:"placeholder-number"},we=.5,pe="grabbing",ve="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(d,{emit:u}){const o=d,p=u,h=e.ref(o.layout);e.watch(()=>o.layout,t=>{h.value=t});const y=e.computed(()=>o.availableLayouts&&o.availableLayouts.length>0?o.availableLayouts:A()),v=e.shallowRef([]);function E(t){const l=Array.isArray(t)?t:o.videos||[],n=b.value,r={};v.value.forEach((w,x)=>{w&&w.id!==void 0&&(r[w.id]=w.__labelNumber??x+1)});const c=Array.from({length:n}).map((w,x)=>{const m=l[x];if(m){const Y=r[m.id]??m.__labelNumber??x+1;return{...m,__labelNumber:Y}}});v.value=c}e.watch(()=>o.videos,t=>{if(!Array.isArray(t)){console.warn("[VideoGridLayout] Invalid videos prop, expected array");return}E(t)},{flush:"post"});let S=!1;e.watch(v,t=>{!S&&Array.isArray(t)&&p("videosChange",t)});const g=e.computed(()=>{const t=V[h.value];return t||(console.warn(`[VideoGridLayout] Invalid layout type: ${h.value}, fallback to '4'`),V[4])}),N=e.computed(()=>T(h.value)),b=e.computed(()=>{var t;return((t=g.value)==null?void 0:t.count)||4}),f=e.computed(()=>v.value.slice(0,b.value).map(t=>t).filter(Boolean));e.computed(()=>{const t={};return f.value.forEach((l,n)=>{const r=v.value.findIndex(c=>c&&c.id===l.id);r!==-1&&(t[n]=r)}),t}),E(o.videos),e.watch(b,()=>{E(o.videos)}),e.computed(()=>{const t=N.value.map((l,n)=>({p:l,idx:n}));return t.sort((l,n)=>l.p.row===n.p.row?(l.p.col||0)-(n.p.col||0):(l.p.row||0)-(n.p.row||0)),t.map(l=>l.idx)});const k=e.ref(-1),C=e.ref(-1),i=e.shallowRef(null),a=e.computed(()=>{const t=g.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%"}}),s=e.computed(()=>({width:o.width||"100%",height:o.height||"100%"}));function B(t){const l=f.value[t];return l?v.value.findIndex(r=>r&&r.id===l.id)+1:t+1}function M(t){const l=N.value[t];return!l||typeof l.col!="number"||typeof l.row!="number"?{}:{gridColumn:`${l.col} / span ${l.colSpan}`,gridRow:`${l.row} / span ${l.rowSpan}`}}function O(t){const l=N.value[t];return(l==null?void 0:l.isMain)||!1}function F(t){h.value=t,p("layoutChange",h.value)}function _(){if(i.value&&document.body.contains(i.value)){try{document.body.removeChild(i.value)}catch(t){console.warn("[VideoGridLayout] Failed to cleanup drag image:",t)}i.value=null}}function R(t,l){if(l<0||l>=v.value.length){console.warn("[VideoGridLayout] Invalid drag index:",l);return}if(k.value=l,!t.dataTransfer)return;t.dataTransfer.effectAllowed="move";const r=t.target.closest(".video-item");if(r)try{_();const c=r.cloneNode(!0);c.style.width=`${r.offsetWidth}px`,c.style.height=`${r.offsetHeight}px`,c.style.opacity=ve,c.style.position="absolute",c.style.top="-9999px",c.style.pointerEvents="none",document.body.appendChild(c),i.value=c,t.dataTransfer.setDragImage(c,r.offsetWidth/2,r.offsetHeight/2),setTimeout(()=>{_()},100),r.style.opacity=String(we),r.style.cursor=pe}catch(c){console.error("[VideoGridLayout] Drag start error:",c),_()}}function U(t,l){t.preventDefault(),t.stopPropagation();const n=k.value;if(n===-1||n===l){k.value=-1;return}if(n>=v.value.length){console.warn("[VideoGridLayout] No video at from index:",n),k.value=-1;return}try{const r=t.currentTarget;r&&(r.style.backgroundColor="rgba(66, 184, 131, 0.3)",r.style.borderColor="#42b883",setTimeout(()=>{r.style.backgroundColor="",r.style.borderColor=""},200));const c=[...v.value];if(l>=c.length){const w=c[n];c.splice(n,1),c.push(w)}else{const w=c[n];c[n]=c[l],c[l]=w}S=!0,v.value=c,setTimeout(()=>{S=!1,p("videosChange",v.value.filter(Boolean))},0)}catch(r){console.error("[VideoGridLayout] Drop error:",r)}finally{k.value=-1}}function P(t,l){t.preventDefault(),k.value!==-1&&k.value!==l&&(C.value=l)}function z(t,l){t.preventDefault();const n=t.target,r=t.relatedTarget;n.contains(r)||C.value===l&&(C.value=-1)}function j(t){const n=t.target.closest(".video-item");n&&(n.style.opacity="1",n.style.cursor="move"),_(),k.value=-1,C.value=-1}return e.onBeforeUnmount(()=>{_()}),(t,l)=>(e.openBlock(),e.createElementBlock("div",{class:"video-grid-layout",role:"application","aria-label":"视频分屏布局",style:e.normalizeStyle(s.value)},[d.showToolbar?(e.openBlock(),e.createElementBlock("div",ae,[l[1]||(l[1]=e.createElementVNode("div",{class:"toolbar-title"},"分屏布局",-1)),e.createElementVNode("div",ne,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(y.value,n=>{var r,c,w;return e.openBlock(),e.createElementBlock("button",{key:n,class:e.normalizeClass(["layout-btn",{active:h.value===n}]),onClick:x=>F(n),title:((r=e.unref(V)[n])==null?void 0:r.label)||"","aria-label":`切换到${((c=e.unref(V)[n])==null?void 0:c.label)||""}布局`,"aria-pressed":h.value===n,type:"button"},[e.createVNode(L,{type:n},null,8,["type"]),e.createElementVNode("span",ie,e.toDisplayString(((w=e.unref(V)[n])==null?void 0:w.label)||""),1)],10,ce)}),128))])])):e.createCommentVNode("",!0),e.createElementVNode("div",de,[e.createElementVNode("div",{class:"video-grid",style:e.normalizeStyle(a.value)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(N.value,(n,r)=>{var c,w,x;return e.openBlock(),e.createElementBlock("div",{key:((c=f.value[r])==null?void 0:c.id)??r,class:e.normalizeClass(["video-item",{"main-video":O(r),dragging:k.value===r,"drag-over":C.value===r&&k.value!==r}]),style:e.normalizeStyle(M(r)),draggable:!0,"aria-label":`视频 ${r+1}: ${((w=f.value[r])==null?void 0:w.title)||((x=f.value[r])==null?void 0:x.id)||""}`,role:"article",tabindex:"0",onDragstart:m=>R(m,r),onDragover:l[0]||(l[0]=e.withModifiers(()=>{},["prevent"])),onDragenter:m=>P(m,r),onDragleave:m=>z(m,r),onDrop:m=>U(m,r),onDragend:j},[e.renderSlot(t.$slots,"video",{video:f.value[r],index:r},()=>[e.createElementVNode("div",ue,[e.createElementVNode("div",he,e.toDisplayString(B(r)),1)])],!0)],46,se)}),128))],4)])],4))}}),I=D(ke,[["__scopeId","data-v-df2d4d67"]]),me={class:"video-split-screen-example"},ge={class:"example-controls"},ye={class:"control-group"},Se={class:"layout-buttons"},fe=["onClick"],xe={class:"control-group"},Ce={class:"video-buttons"},Ve=["disabled"],Ee=["disabled"],Ne={class:"control-group"},be={class:"placeholder-controls"},Be={class:"example-content"},_e={class:"video-grid-container"},$e={class:"custom-video-item"},De={class:"video-content"},Le={class:"video-info"},Ie={class:"video-title"},Te={class:"video-id"},Ae={class:"example-info"},Ge={class:"info-panel"},Me={class:"info-item"},Oe={class:"info-item"},Fe={class:"info-item"},Re={key:0},Ue={key:1},Pe={key:2},ze={class:"info-panel"},je={class:"info-panel"},Ye={class:"log-list"},He=e.defineComponent({__name:"VideoSplitScreenExample",setup(d){const u=e.ref([{id:1,title:"摄像头 1",url:"rtmp://example1.com/live"},{id:2,title:"摄像头 2",url:"rtmp://example2.com/live"},{id:3,title:"摄像头 3",url:"rtmp://example3.com/live"},{id:4,title:"摄像头 4",url:"rtmp://example4.com/live"}]),o=e.ref("4"),p=e.ref(!1),h=e.ref(!1),y=e.ref(""),v=e.computed(()=>{if(h.value)return i=>`位置 ${i+1}`;if(p.value)return y.value||"自定义占位符"}),E=e.ref([]),S=e.ref([]);function g(i){const s=new Date().toLocaleTimeString();S.value.unshift({time:s,message:i}),S.value.length>10&&(S.value=S.value.slice(0,10))}function N(i){o.value=i,g(`切换到 ${i} 分屏布局`)}function b(){const i=Math.max(...u.value.map(a=>a.id))+1;u.value.push({id:i,title:`摄像头 ${i}`,url:`rtmp://example${i}.com/live`}),g(`添加视频: 摄像头 ${i}`)}function f(){if(u.value.length>1){const i=u.value.pop();g(`移除视频: ${i==null?void 0:i.title}`)}}function k(){u.value=[{id:1,title:"摄像头 1",url:"rtmp://example1.com/live"},{id:2,title:"摄像头 2",url:"rtmp://example2.com/live"},{id:3,title:"摄像头 3",url:"rtmp://example3.com/live"},{id:4,title:"摄像头 4",url:"rtmp://example4.com/live"}],o.value="4",p.value=!1,h.value=!1,y.value="",E.value=[],g("重置所有设置")}function C(i){console.log("Videos changed:",i),u.value=i,g(`视频重新排序: ${i.map(a=>a.title).join(" → ")}`)}return e.watch([p,h],()=>{p.value&&h.value&&(h.value=!1),g("更新占位符配置")}),e.watch(y,()=>{g(`设置占位符文本: "${y.value}"`)}),g("示例组件初始化完成"),(i,a)=>(e.openBlock(),e.createElementBlock("div",me,[a[16]||(a[16]=e.createElementVNode("div",{class:"example-header"},[e.createElementVNode("h1",null,"Video Split Screen 示例"),e.createElementVNode("p",null,"演示所有功能:布局切换、拖拽排序、占位符配置")],-1)),e.createElementVNode("div",ge,[e.createElementVNode("div",ye,[a[3]||(a[3]=e.createElementVNode("h3",null,"布局切换",-1)),e.createElementVNode("div",Se,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(["1","2","3","4","6","7","8","9","10","13","16"],s=>e.createElementVNode("button",{key:s,class:e.normalizeClass(["layout-btn",{active:o.value===s}]),onClick:B=>N(s)},e.toDisplayString(s)+"分屏 ",11,fe)),64))])]),e.createElementVNode("div",xe,[a[4]||(a[4]=e.createElementVNode("h3",null,"视频管理",-1)),e.createElementVNode("div",Ce,[e.createElementVNode("button",{onClick:b,disabled:u.value.length>=16},"添加视频",8,Ve),e.createElementVNode("button",{onClick:f,disabled:u.value.length<=1},"移除视频",8,Ee),e.createElementVNode("button",{onClick:k},"重置")])]),e.createElementVNode("div",Ne,[a[7]||(a[7]=e.createElementVNode("h3",null,"占位符配置",-1)),e.createElementVNode("div",be,[e.createElementVNode("label",null,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":a[0]||(a[0]=s=>p.value=s),type:"checkbox"},null,512),[[e.vModelCheckbox,p.value]]),a[5]||(a[5]=e.createTextVNode(" 使用自定义文本 ",-1))]),p.value?e.withDirectives((e.openBlock(),e.createElementBlock("input",{key:0,"onUpdate:modelValue":a[1]||(a[1]=s=>y.value=s),type:"text",placeholder:"输入占位符文本"},null,512)),[[e.vModelText,y.value]]):e.createCommentVNode("",!0),e.createElementVNode("label",null,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":a[2]||(a[2]=s=>h.value=s),type:"checkbox"},null,512),[[e.vModelCheckbox,h.value]]),a[6]||(a[6]=e.createTextVNode(" 使用函数生成 ",-1))])])])]),e.createElementVNode("div",Be,[e.createElementVNode("div",_e,[e.createVNode(I,{videos:u.value,layout:o.value,"placeholder-text":v.value,placeholders:E.value,onVideosChange:C,width:"100%",height:"500px"},{video:e.withCtx(({video:s,index:B})=>[e.createElementVNode("div",$e,[e.createElementVNode("div",De,[a[8]||(a[8]=e.createElementVNode("div",{class:"video-icon"},"📹",-1)),e.createElementVNode("div",Le,[e.createElementVNode("div",Ie,e.toDisplayString(s.title),1),e.createElementVNode("div",Te,"ID: "+e.toDisplayString(s.id),1)])]),a[9]||(a[9]=e.createElementVNode("div",{class:"drag-handle"},"⋮⋮",-1))])]),_:1},8,["videos","layout","placeholder-text","placeholders"])]),e.createElementVNode("div",Ae,[e.createElementVNode("div",Ge,[a[13]||(a[13]=e.createElementVNode("h3",null,"当前状态",-1)),e.createElementVNode("div",Me,[a[10]||(a[10]=e.createElementVNode("strong",null,"布局:",-1)),e.createTextVNode(" "+e.toDisplayString(o.value)+"分屏 ",1)]),e.createElementVNode("div",Oe,[a[11]||(a[11]=e.createElementVNode("strong",null,"视频数量:",-1)),e.createTextVNode(" "+e.toDisplayString(u.value.length),1)]),e.createElementVNode("div",Fe,[a[12]||(a[12]=e.createElementVNode("strong",null,"占位符:",-1)),p.value?(e.openBlock(),e.createElementBlock("span",Re,e.toDisplayString(y.value||"无文本"),1)):h.value?(e.openBlock(),e.createElementBlock("span",Ue,"函数生成")):(e.openBlock(),e.createElementBlock("span",Pe,"默认数字"))])]),e.createElementVNode("div",ze,[a[14]||(a[14]=e.createElementVNode("h3",null,"视频数组 (videos)",-1)),e.createElementVNode("pre",null,e.toDisplayString(JSON.stringify(u.value,null,2)),1)]),e.createElementVNode("div",je,[a[15]||(a[15]=e.createElementVNode("h3",null,"操作日志",-1)),e.createElementVNode("div",Ye,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(S.value,(s,B)=>(e.openBlock(),e.createElementBlock("div",{key:B,class:"log-item"},e.toDisplayString(s.time)+": "+e.toDisplayString(s.message),1))),128))])])])])]))}}),G=D(He,[["__scopeId","data-v-4a52fa65"]]),We={VideoGridLayout:I,VideoLayoutIcon:L,VideoSplitScreenExample:G},qe={install(d){Object.entries(We).forEach(([u,o])=>{d.component(u,o)})}};exports.LAYOUT_CONFIGS=V;exports.VideoGridLayout=I;exports.VideoLayoutIcon=L;exports.VideoSplitScreenExample=G;exports.default=qe;exports.getAllLayoutTypes=A;exports.getLayoutPositions=T;
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
const
|
|
1
|
+
import { defineComponent as z, createElementBlock as c, openBlock as d, createCommentVNode as H, createElementVNode as e, createStaticVNode as I, ref as C, watch as A, computed as f, shallowRef as J, onBeforeUnmount as st, normalizeStyle as U, Fragment as O, renderList as R, unref as F, normalizeClass as Y, createVNode as K, toDisplayString as m, withModifiers as ct, renderSlot as dt, withDirectives as P, createTextVNode as M, vModelCheckbox as q, vModelText as ut, withCtx as ht } from "vue";
|
|
2
|
+
const B = {
|
|
3
3
|
1: {
|
|
4
4
|
type: "1",
|
|
5
5
|
label: "1分屏",
|
|
@@ -77,10 +77,10 @@ const S = {
|
|
|
77
77
|
cols: 4,
|
|
78
78
|
rows: 4
|
|
79
79
|
}
|
|
80
|
-
},
|
|
81
|
-
function
|
|
82
|
-
if (
|
|
83
|
-
return
|
|
80
|
+
}, j = {};
|
|
81
|
+
function wt(u) {
|
|
82
|
+
if (j[u])
|
|
83
|
+
return j[u];
|
|
84
84
|
const o = {
|
|
85
85
|
1: [
|
|
86
86
|
{ col: 1, colSpan: 1, row: 1, rowSpan: 1 }
|
|
@@ -183,65 +183,65 @@ function nt(n) {
|
|
|
183
183
|
{ col: 3, colSpan: 1, row: 4, rowSpan: 1 },
|
|
184
184
|
{ col: 4, colSpan: 1, row: 4, rowSpan: 1 }
|
|
185
185
|
]
|
|
186
|
-
}[
|
|
187
|
-
return o.length > 0 && (
|
|
186
|
+
}[u] || [];
|
|
187
|
+
return o.length > 0 && (j[u] = o), o;
|
|
188
188
|
}
|
|
189
|
-
function
|
|
190
|
-
return Object.keys(
|
|
189
|
+
function pt() {
|
|
190
|
+
return Object.keys(B);
|
|
191
191
|
}
|
|
192
|
-
const
|
|
192
|
+
const vt = { class: "layout-icon" }, gt = {
|
|
193
193
|
key: 0,
|
|
194
194
|
viewBox: "0 0 48 48",
|
|
195
195
|
fill: "none"
|
|
196
|
-
},
|
|
196
|
+
}, yt = {
|
|
197
197
|
key: 1,
|
|
198
198
|
viewBox: "0 0 48 48",
|
|
199
199
|
fill: "none"
|
|
200
|
-
},
|
|
200
|
+
}, kt = {
|
|
201
201
|
key: 2,
|
|
202
202
|
viewBox: "0 0 48 48",
|
|
203
203
|
fill: "none"
|
|
204
|
-
},
|
|
204
|
+
}, St = {
|
|
205
205
|
key: 3,
|
|
206
206
|
viewBox: "0 0 48 48",
|
|
207
207
|
fill: "none"
|
|
208
|
-
},
|
|
208
|
+
}, xt = {
|
|
209
209
|
key: 4,
|
|
210
210
|
viewBox: "0 0 48 48",
|
|
211
211
|
fill: "none"
|
|
212
|
-
},
|
|
212
|
+
}, mt = {
|
|
213
213
|
key: 5,
|
|
214
214
|
viewBox: "0 0 48 48",
|
|
215
215
|
fill: "none"
|
|
216
|
-
},
|
|
216
|
+
}, ft = {
|
|
217
217
|
key: 6,
|
|
218
218
|
viewBox: "0 0 48 48",
|
|
219
219
|
fill: "none"
|
|
220
|
-
},
|
|
220
|
+
}, Ct = {
|
|
221
221
|
key: 7,
|
|
222
222
|
viewBox: "0 0 48 48",
|
|
223
223
|
fill: "none"
|
|
224
|
-
},
|
|
224
|
+
}, bt = {
|
|
225
225
|
key: 8,
|
|
226
226
|
viewBox: "0 0 54 48",
|
|
227
227
|
fill: "none"
|
|
228
|
-
},
|
|
228
|
+
}, _t = {
|
|
229
229
|
key: 9,
|
|
230
230
|
viewBox: "0 0 48 48",
|
|
231
231
|
fill: "none"
|
|
232
|
-
},
|
|
232
|
+
}, $t = {
|
|
233
233
|
key: 10,
|
|
234
234
|
viewBox: "0 0 48 48",
|
|
235
235
|
fill: "none"
|
|
236
|
-
},
|
|
236
|
+
}, Dt = /* @__PURE__ */ z({
|
|
237
237
|
__name: "VideoLayoutIcon",
|
|
238
238
|
props: {
|
|
239
239
|
type: {}
|
|
240
240
|
},
|
|
241
|
-
setup(
|
|
242
|
-
return (
|
|
243
|
-
|
|
244
|
-
|
|
241
|
+
setup(u) {
|
|
242
|
+
return (w, o) => (d(), c("div", vt, [
|
|
243
|
+
u.type === "1" ? (d(), c("svg", gt, [...o[0] || (o[0] = [
|
|
244
|
+
e("rect", {
|
|
245
245
|
x: "4",
|
|
246
246
|
y: "4",
|
|
247
247
|
width: "40",
|
|
@@ -249,8 +249,8 @@ const it = { class: "layout-icon" }, dt = {
|
|
|
249
249
|
stroke: "currentColor",
|
|
250
250
|
"stroke-width": "2"
|
|
251
251
|
}, null, -1)
|
|
252
|
-
])])) :
|
|
253
|
-
|
|
252
|
+
])])) : u.type === "2" ? (d(), c("svg", yt, [...o[1] || (o[1] = [
|
|
253
|
+
e("rect", {
|
|
254
254
|
x: "4",
|
|
255
255
|
y: "4",
|
|
256
256
|
width: "19",
|
|
@@ -258,7 +258,7 @@ const it = { class: "layout-icon" }, dt = {
|
|
|
258
258
|
stroke: "currentColor",
|
|
259
259
|
"stroke-width": "1.5"
|
|
260
260
|
}, null, -1),
|
|
261
|
-
|
|
261
|
+
e("rect", {
|
|
262
262
|
x: "25",
|
|
263
263
|
y: "4",
|
|
264
264
|
width: "19",
|
|
@@ -266,8 +266,8 @@ const it = { class: "layout-icon" }, dt = {
|
|
|
266
266
|
stroke: "currentColor",
|
|
267
267
|
"stroke-width": "1.5"
|
|
268
268
|
}, null, -1)
|
|
269
|
-
])])) :
|
|
270
|
-
|
|
269
|
+
])])) : u.type === "3" ? (d(), c("svg", kt, [...o[2] || (o[2] = [
|
|
270
|
+
e("rect", {
|
|
271
271
|
x: "4",
|
|
272
272
|
y: "4",
|
|
273
273
|
width: "20",
|
|
@@ -275,7 +275,7 @@ const it = { class: "layout-icon" }, dt = {
|
|
|
275
275
|
stroke: "currentColor",
|
|
276
276
|
"stroke-width": "2"
|
|
277
277
|
}, null, -1),
|
|
278
|
-
|
|
278
|
+
e("rect", {
|
|
279
279
|
x: "26",
|
|
280
280
|
y: "4",
|
|
281
281
|
width: "18",
|
|
@@ -283,7 +283,7 @@ const it = { class: "layout-icon" }, dt = {
|
|
|
283
283
|
stroke: "currentColor",
|
|
284
284
|
"stroke-width": "1.5"
|
|
285
285
|
}, null, -1),
|
|
286
|
-
|
|
286
|
+
e("rect", {
|
|
287
287
|
x: "26",
|
|
288
288
|
y: "25",
|
|
289
289
|
width: "18",
|
|
@@ -291,8 +291,8 @@ const it = { class: "layout-icon" }, dt = {
|
|
|
291
291
|
stroke: "currentColor",
|
|
292
292
|
"stroke-width": "1.5"
|
|
293
293
|
}, null, -1)
|
|
294
|
-
])])) :
|
|
295
|
-
|
|
294
|
+
])])) : u.type === "4" ? (d(), c("svg", St, [...o[3] || (o[3] = [
|
|
295
|
+
e("rect", {
|
|
296
296
|
x: "4",
|
|
297
297
|
y: "4",
|
|
298
298
|
width: "19",
|
|
@@ -300,7 +300,7 @@ const it = { class: "layout-icon" }, dt = {
|
|
|
300
300
|
stroke: "currentColor",
|
|
301
301
|
"stroke-width": "1.5"
|
|
302
302
|
}, null, -1),
|
|
303
|
-
|
|
303
|
+
e("rect", {
|
|
304
304
|
x: "25",
|
|
305
305
|
y: "4",
|
|
306
306
|
width: "19",
|
|
@@ -308,7 +308,7 @@ const it = { class: "layout-icon" }, dt = {
|
|
|
308
308
|
stroke: "currentColor",
|
|
309
309
|
"stroke-width": "1.5"
|
|
310
310
|
}, null, -1),
|
|
311
|
-
|
|
311
|
+
e("rect", {
|
|
312
312
|
x: "4",
|
|
313
313
|
y: "25",
|
|
314
314
|
width: "19",
|
|
@@ -316,7 +316,7 @@ const it = { class: "layout-icon" }, dt = {
|
|
|
316
316
|
stroke: "currentColor",
|
|
317
317
|
"stroke-width": "1.5"
|
|
318
318
|
}, null, -1),
|
|
319
|
-
|
|
319
|
+
e("rect", {
|
|
320
320
|
x: "25",
|
|
321
321
|
y: "25",
|
|
322
322
|
width: "19",
|
|
@@ -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
|
-
])])) :
|
|
328
|
-
|
|
329
|
-
])])) :
|
|
330
|
-
|
|
331
|
-
])])) :
|
|
332
|
-
|
|
333
|
-
])])) :
|
|
334
|
-
|
|
335
|
-
])])) :
|
|
336
|
-
|
|
337
|
-
])])) :
|
|
338
|
-
|
|
339
|
-
])])) :
|
|
340
|
-
|
|
341
|
-
])])) :
|
|
327
|
+
])])) : u.type === "6" ? (d(), c("svg", xt, [...o[4] || (o[4] = [
|
|
328
|
+
I('<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
|
+
])])) : u.type === "7" ? (d(), c("svg", mt, [...o[5] || (o[5] = [
|
|
330
|
+
I('<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
|
+
])])) : u.type === "8" ? (d(), c("svg", ft, [...o[6] || (o[6] = [
|
|
332
|
+
I('<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
|
+
])])) : u.type === "9" ? (d(), c("svg", Ct, [...o[7] || (o[7] = [
|
|
334
|
+
I('<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
|
+
])])) : u.type === "10" ? (d(), c("svg", bt, [...o[8] || (o[8] = [
|
|
336
|
+
I('<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
|
+
])])) : u.type === "13" ? (d(), c("svg", _t, [...o[9] || (o[9] = [
|
|
338
|
+
I('<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
|
+
])])) : u.type === "16" ? (d(), c("svg", $t, [...o[10] || (o[10] = [
|
|
340
|
+
I('<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
|
+
])])) : H("", !0)
|
|
342
342
|
]));
|
|
343
343
|
}
|
|
344
|
-
}),
|
|
345
|
-
const o =
|
|
346
|
-
for (const [
|
|
347
|
-
o[
|
|
344
|
+
}), W = (u, w) => {
|
|
345
|
+
const o = u.__vccOpts || u;
|
|
346
|
+
for (const [g, p] of w)
|
|
347
|
+
o[g] = p;
|
|
348
348
|
return o;
|
|
349
|
-
},
|
|
349
|
+
}, Q = /* @__PURE__ */ W(Dt, [["__scopeId", "data-v-31e0404d"]]), Lt = {
|
|
350
350
|
key: 0,
|
|
351
351
|
class: "layout-toolbar",
|
|
352
352
|
role: "toolbar",
|
|
353
353
|
"aria-label": "布局切换工具栏"
|
|
354
|
-
},
|
|
354
|
+
}, It = { class: "layout-buttons" }, Vt = ["onClick", "title", "aria-label", "aria-pressed"], Tt = { class: "layout-label" }, Bt = {
|
|
355
355
|
class: "video-grid-container",
|
|
356
356
|
role: "region",
|
|
357
357
|
"aria-label": "视频网格"
|
|
358
|
-
},
|
|
358
|
+
}, At = ["aria-label", "onDragstart", "onDragenter", "onDragleave", "onDrop"], Gt = { class: "video-placeholder" }, Nt = { class: "placeholder-number" }, Et = 0.5, Mt = "grabbing", Ot = "0.8", Rt = /* @__PURE__ */ z({
|
|
359
359
|
__name: "VideoGridLayout",
|
|
360
360
|
props: {
|
|
361
361
|
videos: {},
|
|
@@ -368,52 +368,58 @@ const it = { class: "layout-icon" }, dt = {
|
|
|
368
368
|
placeholders: {}
|
|
369
369
|
},
|
|
370
370
|
emits: ["layoutChange", "videosChange"],
|
|
371
|
-
setup(
|
|
372
|
-
const o =
|
|
373
|
-
|
|
374
|
-
|
|
371
|
+
setup(u, { emit: w }) {
|
|
372
|
+
const o = u, g = w, p = C(o.layout);
|
|
373
|
+
A(() => o.layout, (t) => {
|
|
374
|
+
p.value = t;
|
|
375
375
|
});
|
|
376
|
-
const
|
|
377
|
-
function
|
|
378
|
-
const
|
|
379
|
-
|
|
380
|
-
|
|
376
|
+
const b = f(() => o.availableLayouts && o.availableLayouts.length > 0 ? o.availableLayouts : pt()), y = J([]);
|
|
377
|
+
function V(t) {
|
|
378
|
+
const l = Array.isArray(t) ? t : o.videos || [], n = G.value, r = {};
|
|
379
|
+
y.value.forEach((v, D) => {
|
|
380
|
+
v && v.id !== void 0 && (r[v.id] = v.__labelNumber ?? D + 1);
|
|
381
381
|
});
|
|
382
|
-
const
|
|
383
|
-
const
|
|
384
|
-
if (
|
|
385
|
-
const
|
|
386
|
-
return { ...
|
|
382
|
+
const i = Array.from({ length: n }).map((v, D) => {
|
|
383
|
+
const S = l[D];
|
|
384
|
+
if (S) {
|
|
385
|
+
const it = r[S.id] ?? S.__labelNumber ?? D + 1;
|
|
386
|
+
return { ...S, __labelNumber: it };
|
|
387
387
|
}
|
|
388
388
|
});
|
|
389
|
-
|
|
389
|
+
y.value = i;
|
|
390
390
|
}
|
|
391
|
-
|
|
391
|
+
A(() => o.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
|
+
V(t);
|
|
397
397
|
}, { flush: "post" });
|
|
398
|
-
let
|
|
399
|
-
|
|
400
|
-
|
|
398
|
+
let _ = !1;
|
|
399
|
+
A(y, (t) => {
|
|
400
|
+
!_ && Array.isArray(t) && g("videosChange", t);
|
|
401
401
|
});
|
|
402
|
-
const
|
|
403
|
-
const t =
|
|
404
|
-
return t || (console.warn(`[VideoGridLayout] Invalid layout type: ${
|
|
405
|
-
}),
|
|
402
|
+
const x = f(() => {
|
|
403
|
+
const t = B[p.value];
|
|
404
|
+
return t || (console.warn(`[VideoGridLayout] Invalid layout type: ${p.value}, fallback to '4'`), B[4]);
|
|
405
|
+
}), T = f(() => wt(p.value)), G = f(() => {
|
|
406
406
|
var t;
|
|
407
|
-
return ((t =
|
|
408
|
-
}),
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
407
|
+
return ((t = x.value) == null ? void 0 : t.count) || 4;
|
|
408
|
+
}), $ = f(() => y.value.slice(0, G.value).map((t) => t).filter(Boolean));
|
|
409
|
+
f(() => {
|
|
410
|
+
const t = {};
|
|
411
|
+
return $.value.forEach((l, n) => {
|
|
412
|
+
const r = y.value.findIndex((i) => i && i.id === l.id);
|
|
413
|
+
r !== -1 && (t[n] = r);
|
|
414
|
+
}), t;
|
|
415
|
+
}), V(o.videos), A(G, () => {
|
|
416
|
+
V(o.videos);
|
|
417
|
+
}), f(() => {
|
|
418
|
+
const t = T.value.map((l, n) => ({ p: l, idx: n }));
|
|
419
|
+
return t.sort((l, n) => l.p.row === n.p.row ? (l.p.col || 0) - (n.p.col || 0) : (l.p.row || 0) - (n.p.row || 0)), t.map((l) => l.idx);
|
|
414
420
|
});
|
|
415
|
-
const
|
|
416
|
-
const t =
|
|
421
|
+
const k = C(-1), L = C(-1), s = J(null), a = f(() => {
|
|
422
|
+
const t = x.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)`,
|
|
@@ -422,62 +428,66 @@ const it = { class: "layout-icon" }, dt = {
|
|
|
422
428
|
width: o.width || "100%",
|
|
423
429
|
height: o.height || "100%"
|
|
424
430
|
};
|
|
425
|
-
}),
|
|
431
|
+
}), h = f(() => ({
|
|
426
432
|
width: o.width || "100%",
|
|
427
433
|
height: o.height || "100%"
|
|
428
434
|
}));
|
|
429
|
-
function
|
|
430
|
-
const
|
|
431
|
-
return
|
|
432
|
-
|
|
433
|
-
|
|
435
|
+
function N(t) {
|
|
436
|
+
const l = $.value[t];
|
|
437
|
+
return l ? y.value.findIndex((r) => r && r.id === l.id) + 1 : t + 1;
|
|
438
|
+
}
|
|
439
|
+
function Z(t) {
|
|
440
|
+
const l = T.value[t];
|
|
441
|
+
return !l || typeof l.col != "number" || typeof l.row != "number" ? {} : {
|
|
442
|
+
gridColumn: `${l.col} / span ${l.colSpan}`,
|
|
443
|
+
gridRow: `${l.row} / span ${l.rowSpan}`
|
|
434
444
|
};
|
|
435
445
|
}
|
|
436
|
-
function
|
|
437
|
-
const
|
|
438
|
-
return (
|
|
446
|
+
function tt(t) {
|
|
447
|
+
const l = T.value[t];
|
|
448
|
+
return (l == null ? void 0 : l.isMain) || !1;
|
|
439
449
|
}
|
|
440
|
-
function
|
|
441
|
-
|
|
450
|
+
function et(t) {
|
|
451
|
+
p.value = t, g("layoutChange", p.value);
|
|
442
452
|
}
|
|
443
|
-
function
|
|
444
|
-
if (
|
|
453
|
+
function E() {
|
|
454
|
+
if (s.value && document.body.contains(s.value)) {
|
|
445
455
|
try {
|
|
446
|
-
document.body.removeChild(
|
|
456
|
+
document.body.removeChild(s.value);
|
|
447
457
|
} catch (t) {
|
|
448
458
|
console.warn("[VideoGridLayout] Failed to cleanup drag image:", t);
|
|
449
459
|
}
|
|
450
|
-
|
|
460
|
+
s.value = null;
|
|
451
461
|
}
|
|
452
462
|
}
|
|
453
|
-
function
|
|
454
|
-
if (
|
|
455
|
-
console.warn("[VideoGridLayout] Invalid drag index:",
|
|
463
|
+
function ot(t, l) {
|
|
464
|
+
if (l < 0 || l >= y.value.length) {
|
|
465
|
+
console.warn("[VideoGridLayout] Invalid drag index:", l);
|
|
456
466
|
return;
|
|
457
467
|
}
|
|
458
|
-
if (
|
|
468
|
+
if (k.value = l, !t.dataTransfer) return;
|
|
459
469
|
t.dataTransfer.effectAllowed = "move";
|
|
460
470
|
const r = t.target.closest(".video-item");
|
|
461
471
|
if (r)
|
|
462
472
|
try {
|
|
463
|
-
|
|
464
|
-
const
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
}, 100), r.style.opacity = String(
|
|
468
|
-
} catch (
|
|
469
|
-
console.error("[VideoGridLayout] Drag start error:",
|
|
473
|
+
E();
|
|
474
|
+
const i = r.cloneNode(!0);
|
|
475
|
+
i.style.width = `${r.offsetWidth}px`, i.style.height = `${r.offsetHeight}px`, i.style.opacity = Ot, i.style.position = "absolute", i.style.top = "-9999px", i.style.pointerEvents = "none", document.body.appendChild(i), s.value = i, t.dataTransfer.setDragImage(i, r.offsetWidth / 2, r.offsetHeight / 2), setTimeout(() => {
|
|
476
|
+
E();
|
|
477
|
+
}, 100), r.style.opacity = String(Et), r.style.cursor = Mt;
|
|
478
|
+
} catch (i) {
|
|
479
|
+
console.error("[VideoGridLayout] Drag start error:", i), E();
|
|
470
480
|
}
|
|
471
481
|
}
|
|
472
|
-
function
|
|
482
|
+
function rt(t, l) {
|
|
473
483
|
t.preventDefault(), t.stopPropagation();
|
|
474
|
-
const
|
|
475
|
-
if (
|
|
476
|
-
|
|
484
|
+
const n = k.value;
|
|
485
|
+
if (n === -1 || n === l) {
|
|
486
|
+
k.value = -1;
|
|
477
487
|
return;
|
|
478
488
|
}
|
|
479
|
-
if (
|
|
480
|
-
console.warn("[VideoGridLayout] No video at from index:",
|
|
489
|
+
if (n >= y.value.length) {
|
|
490
|
+
console.warn("[VideoGridLayout] No video at from index:", n), k.value = -1;
|
|
481
491
|
return;
|
|
482
492
|
}
|
|
483
493
|
try {
|
|
@@ -485,119 +495,292 @@ const it = { class: "layout-icon" }, dt = {
|
|
|
485
495
|
r && (r.style.backgroundColor = "rgba(66, 184, 131, 0.3)", r.style.borderColor = "#42b883", setTimeout(() => {
|
|
486
496
|
r.style.backgroundColor = "", r.style.borderColor = "";
|
|
487
497
|
}, 200));
|
|
488
|
-
const
|
|
489
|
-
if (
|
|
490
|
-
const
|
|
491
|
-
|
|
498
|
+
const i = [...y.value];
|
|
499
|
+
if (l >= i.length) {
|
|
500
|
+
const v = i[n];
|
|
501
|
+
i.splice(n, 1), i.push(v);
|
|
492
502
|
} else {
|
|
493
|
-
const
|
|
494
|
-
|
|
503
|
+
const v = i[n];
|
|
504
|
+
i[n] = i[l], i[l] = v;
|
|
495
505
|
}
|
|
496
|
-
|
|
497
|
-
|
|
506
|
+
_ = !0, y.value = i, setTimeout(() => {
|
|
507
|
+
_ = !1, g("videosChange", y.value.filter(Boolean));
|
|
498
508
|
}, 0);
|
|
499
509
|
} catch (r) {
|
|
500
510
|
console.error("[VideoGridLayout] Drop error:", r);
|
|
501
511
|
} finally {
|
|
502
|
-
|
|
512
|
+
k.value = -1;
|
|
503
513
|
}
|
|
504
514
|
}
|
|
505
|
-
function
|
|
506
|
-
t.preventDefault(),
|
|
515
|
+
function lt(t, l) {
|
|
516
|
+
t.preventDefault(), k.value !== -1 && k.value !== l && (L.value = l);
|
|
507
517
|
}
|
|
508
|
-
function
|
|
518
|
+
function at(t, l) {
|
|
509
519
|
t.preventDefault();
|
|
510
|
-
const
|
|
511
|
-
|
|
520
|
+
const n = t.target, r = t.relatedTarget;
|
|
521
|
+
n.contains(r) || L.value === l && (L.value = -1);
|
|
512
522
|
}
|
|
513
|
-
function
|
|
514
|
-
const
|
|
515
|
-
|
|
523
|
+
function nt(t) {
|
|
524
|
+
const n = t.target.closest(".video-item");
|
|
525
|
+
n && (n.style.opacity = "1", n.style.cursor = "move"), E(), k.value = -1, L.value = -1;
|
|
516
526
|
}
|
|
517
|
-
return
|
|
518
|
-
|
|
519
|
-
}), (t,
|
|
527
|
+
return st(() => {
|
|
528
|
+
E();
|
|
529
|
+
}), (t, l) => (d(), c("div", {
|
|
520
530
|
class: "video-grid-layout",
|
|
521
531
|
role: "application",
|
|
522
532
|
"aria-label": "视频分屏布局",
|
|
523
|
-
style:
|
|
533
|
+
style: U(h.value)
|
|
524
534
|
}, [
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
(
|
|
529
|
-
var r,
|
|
530
|
-
return
|
|
531
|
-
key:
|
|
532
|
-
class:
|
|
533
|
-
onClick: (
|
|
534
|
-
title: ((r =
|
|
535
|
-
"aria-label": `切换到${((
|
|
536
|
-
"aria-pressed":
|
|
535
|
+
u.showToolbar ? (d(), c("div", Lt, [
|
|
536
|
+
l[1] || (l[1] = e("div", { class: "toolbar-title" }, "分屏布局", -1)),
|
|
537
|
+
e("div", It, [
|
|
538
|
+
(d(!0), c(O, null, R(b.value, (n) => {
|
|
539
|
+
var r, i, v;
|
|
540
|
+
return d(), c("button", {
|
|
541
|
+
key: n,
|
|
542
|
+
class: Y(["layout-btn", { active: p.value === n }]),
|
|
543
|
+
onClick: (D) => et(n),
|
|
544
|
+
title: ((r = F(B)[n]) == null ? void 0 : r.label) || "",
|
|
545
|
+
"aria-label": `切换到${((i = F(B)[n]) == null ? void 0 : i.label) || ""}布局`,
|
|
546
|
+
"aria-pressed": p.value === n,
|
|
537
547
|
type: "button"
|
|
538
548
|
}, [
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
], 10,
|
|
549
|
+
K(Q, { type: n }, null, 8, ["type"]),
|
|
550
|
+
e("span", Tt, m(((v = F(B)[n]) == null ? void 0 : v.label) || ""), 1)
|
|
551
|
+
], 10, Vt);
|
|
542
552
|
}), 128))
|
|
543
553
|
])
|
|
544
|
-
])) :
|
|
545
|
-
|
|
546
|
-
|
|
554
|
+
])) : H("", !0),
|
|
555
|
+
e("div", Bt, [
|
|
556
|
+
e("div", {
|
|
547
557
|
class: "video-grid",
|
|
548
|
-
style:
|
|
558
|
+
style: U(a.value)
|
|
549
559
|
}, [
|
|
550
|
-
(
|
|
551
|
-
var
|
|
552
|
-
return
|
|
553
|
-
key: ((
|
|
554
|
-
class:
|
|
555
|
-
"main-video":
|
|
556
|
-
dragging:
|
|
557
|
-
"drag-over":
|
|
560
|
+
(d(!0), c(O, null, R(T.value, (n, r) => {
|
|
561
|
+
var i, v, D;
|
|
562
|
+
return d(), c("div", {
|
|
563
|
+
key: ((i = $.value[r]) == null ? void 0 : i.id) ?? r,
|
|
564
|
+
class: Y(["video-item", {
|
|
565
|
+
"main-video": tt(r),
|
|
566
|
+
dragging: k.value === r,
|
|
567
|
+
"drag-over": L.value === r && k.value !== r
|
|
558
568
|
}]),
|
|
559
|
-
style:
|
|
569
|
+
style: U(Z(r)),
|
|
560
570
|
draggable: !0,
|
|
561
|
-
"aria-label": `视频 ${r + 1}: ${((
|
|
571
|
+
"aria-label": `视频 ${r + 1}: ${((v = $.value[r]) == null ? void 0 : v.title) || ((D = $.value[r]) == null ? void 0 : D.id) || ""}`,
|
|
562
572
|
role: "article",
|
|
563
573
|
tabindex: "0",
|
|
564
|
-
onDragstart: (
|
|
565
|
-
onDragover:
|
|
574
|
+
onDragstart: (S) => ot(S, r),
|
|
575
|
+
onDragover: l[0] || (l[0] = ct(() => {
|
|
566
576
|
}, ["prevent"])),
|
|
567
|
-
onDragenter: (
|
|
568
|
-
onDragleave: (
|
|
569
|
-
onDrop: (
|
|
570
|
-
onDragend:
|
|
577
|
+
onDragenter: (S) => lt(S, r),
|
|
578
|
+
onDragleave: (S) => at(S, r),
|
|
579
|
+
onDrop: (S) => rt(S, r),
|
|
580
|
+
onDragend: nt
|
|
571
581
|
}, [
|
|
572
|
-
|
|
573
|
-
video:
|
|
582
|
+
dt(t.$slots, "video", {
|
|
583
|
+
video: $.value[r],
|
|
574
584
|
index: r
|
|
575
585
|
}, () => [
|
|
576
|
-
|
|
577
|
-
|
|
586
|
+
e("div", Gt, [
|
|
587
|
+
e("div", Nt, m(N(r)), 1)
|
|
578
588
|
])
|
|
579
589
|
], !0)
|
|
580
|
-
], 46,
|
|
590
|
+
], 46, At);
|
|
581
591
|
}), 128))
|
|
582
592
|
], 4)
|
|
583
593
|
])
|
|
584
594
|
], 4));
|
|
585
595
|
}
|
|
586
|
-
}),
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
596
|
+
}), X = /* @__PURE__ */ W(Rt, [["__scopeId", "data-v-df2d4d67"]]), Ut = { class: "video-split-screen-example" }, Ft = { class: "example-controls" }, Pt = { class: "control-group" }, jt = { class: "layout-buttons" }, Yt = ["onClick"], zt = { class: "control-group" }, Ht = { class: "video-buttons" }, Wt = ["disabled"], Jt = ["disabled"], qt = { class: "control-group" }, Kt = { class: "placeholder-controls" }, Qt = { class: "example-content" }, Xt = { class: "video-grid-container" }, Zt = { class: "custom-video-item" }, te = { class: "video-content" }, ee = { class: "video-info" }, oe = { class: "video-title" }, re = { class: "video-id" }, le = { class: "example-info" }, ae = { class: "info-panel" }, ne = { class: "info-item" }, ie = { class: "info-item" }, se = { class: "info-item" }, ce = { key: 0 }, de = { key: 1 }, ue = { key: 2 }, he = { class: "info-panel" }, we = { class: "info-panel" }, pe = { class: "log-list" }, ve = /* @__PURE__ */ z({
|
|
597
|
+
__name: "VideoSplitScreenExample",
|
|
598
|
+
setup(u) {
|
|
599
|
+
const w = C([
|
|
600
|
+
{ id: 1, title: "摄像头 1", url: "rtmp://example1.com/live" },
|
|
601
|
+
{ id: 2, title: "摄像头 2", url: "rtmp://example2.com/live" },
|
|
602
|
+
{ id: 3, title: "摄像头 3", url: "rtmp://example3.com/live" },
|
|
603
|
+
{ id: 4, title: "摄像头 4", url: "rtmp://example4.com/live" }
|
|
604
|
+
]), o = C("4"), g = C(!1), p = C(!1), b = C(""), y = f(() => {
|
|
605
|
+
if (p.value)
|
|
606
|
+
return (s) => `位置 ${s + 1}`;
|
|
607
|
+
if (g.value)
|
|
608
|
+
return b.value || "自定义占位符";
|
|
609
|
+
}), V = C([]), _ = C([]);
|
|
610
|
+
function x(s) {
|
|
611
|
+
const h = (/* @__PURE__ */ new Date()).toLocaleTimeString();
|
|
612
|
+
_.value.unshift({ time: h, message: s }), _.value.length > 10 && (_.value = _.value.slice(0, 10));
|
|
613
|
+
}
|
|
614
|
+
function T(s) {
|
|
615
|
+
o.value = s, x(`切换到 ${s} 分屏布局`);
|
|
616
|
+
}
|
|
617
|
+
function G() {
|
|
618
|
+
const s = Math.max(...w.value.map((a) => a.id)) + 1;
|
|
619
|
+
w.value.push({
|
|
620
|
+
id: s,
|
|
621
|
+
title: `摄像头 ${s}`,
|
|
622
|
+
url: `rtmp://example${s}.com/live`
|
|
623
|
+
}), x(`添加视频: 摄像头 ${s}`);
|
|
624
|
+
}
|
|
625
|
+
function $() {
|
|
626
|
+
if (w.value.length > 1) {
|
|
627
|
+
const s = w.value.pop();
|
|
628
|
+
x(`移除视频: ${s == null ? void 0 : s.title}`);
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
function k() {
|
|
632
|
+
w.value = [
|
|
633
|
+
{ id: 1, title: "摄像头 1", url: "rtmp://example1.com/live" },
|
|
634
|
+
{ id: 2, title: "摄像头 2", url: "rtmp://example2.com/live" },
|
|
635
|
+
{ id: 3, title: "摄像头 3", url: "rtmp://example3.com/live" },
|
|
636
|
+
{ id: 4, title: "摄像头 4", url: "rtmp://example4.com/live" }
|
|
637
|
+
], o.value = "4", g.value = !1, p.value = !1, b.value = "", V.value = [], x("重置所有设置");
|
|
638
|
+
}
|
|
639
|
+
function L(s) {
|
|
640
|
+
console.log("Videos changed:", s), w.value = s, x(`视频重新排序: ${s.map((a) => a.title).join(" → ")}`);
|
|
641
|
+
}
|
|
642
|
+
return A([g, p], () => {
|
|
643
|
+
g.value && p.value && (p.value = !1), x("更新占位符配置");
|
|
644
|
+
}), A(b, () => {
|
|
645
|
+
x(`设置占位符文本: "${b.value}"`);
|
|
646
|
+
}), x("示例组件初始化完成"), (s, a) => (d(), c("div", Ut, [
|
|
647
|
+
a[16] || (a[16] = e("div", { class: "example-header" }, [
|
|
648
|
+
e("h1", null, "Video Split Screen 示例"),
|
|
649
|
+
e("p", null, "演示所有功能:布局切换、拖拽排序、占位符配置")
|
|
650
|
+
], -1)),
|
|
651
|
+
e("div", Ft, [
|
|
652
|
+
e("div", Pt, [
|
|
653
|
+
a[3] || (a[3] = e("h3", null, "布局切换", -1)),
|
|
654
|
+
e("div", jt, [
|
|
655
|
+
(d(), c(O, null, R(["1", "2", "3", "4", "6", "7", "8", "9", "10", "13", "16"], (h) => e("button", {
|
|
656
|
+
key: h,
|
|
657
|
+
class: Y(["layout-btn", { active: o.value === h }]),
|
|
658
|
+
onClick: (N) => T(h)
|
|
659
|
+
}, m(h) + "分屏 ", 11, Yt)), 64))
|
|
660
|
+
])
|
|
661
|
+
]),
|
|
662
|
+
e("div", zt, [
|
|
663
|
+
a[4] || (a[4] = e("h3", null, "视频管理", -1)),
|
|
664
|
+
e("div", Ht, [
|
|
665
|
+
e("button", {
|
|
666
|
+
onClick: G,
|
|
667
|
+
disabled: w.value.length >= 16
|
|
668
|
+
}, "添加视频", 8, Wt),
|
|
669
|
+
e("button", {
|
|
670
|
+
onClick: $,
|
|
671
|
+
disabled: w.value.length <= 1
|
|
672
|
+
}, "移除视频", 8, Jt),
|
|
673
|
+
e("button", { onClick: k }, "重置")
|
|
674
|
+
])
|
|
675
|
+
]),
|
|
676
|
+
e("div", qt, [
|
|
677
|
+
a[7] || (a[7] = e("h3", null, "占位符配置", -1)),
|
|
678
|
+
e("div", Kt, [
|
|
679
|
+
e("label", null, [
|
|
680
|
+
P(e("input", {
|
|
681
|
+
"onUpdate:modelValue": a[0] || (a[0] = (h) => g.value = h),
|
|
682
|
+
type: "checkbox"
|
|
683
|
+
}, null, 512), [
|
|
684
|
+
[q, g.value]
|
|
685
|
+
]),
|
|
686
|
+
a[5] || (a[5] = M(" 使用自定义文本 ", -1))
|
|
687
|
+
]),
|
|
688
|
+
g.value ? P((d(), c("input", {
|
|
689
|
+
key: 0,
|
|
690
|
+
"onUpdate:modelValue": a[1] || (a[1] = (h) => b.value = h),
|
|
691
|
+
type: "text",
|
|
692
|
+
placeholder: "输入占位符文本"
|
|
693
|
+
}, null, 512)), [
|
|
694
|
+
[ut, b.value]
|
|
695
|
+
]) : H("", !0),
|
|
696
|
+
e("label", null, [
|
|
697
|
+
P(e("input", {
|
|
698
|
+
"onUpdate:modelValue": a[2] || (a[2] = (h) => p.value = h),
|
|
699
|
+
type: "checkbox"
|
|
700
|
+
}, null, 512), [
|
|
701
|
+
[q, p.value]
|
|
702
|
+
]),
|
|
703
|
+
a[6] || (a[6] = M(" 使用函数生成 ", -1))
|
|
704
|
+
])
|
|
705
|
+
])
|
|
706
|
+
])
|
|
707
|
+
]),
|
|
708
|
+
e("div", Qt, [
|
|
709
|
+
e("div", Xt, [
|
|
710
|
+
K(X, {
|
|
711
|
+
videos: w.value,
|
|
712
|
+
layout: o.value,
|
|
713
|
+
"placeholder-text": y.value,
|
|
714
|
+
placeholders: V.value,
|
|
715
|
+
onVideosChange: L,
|
|
716
|
+
width: "100%",
|
|
717
|
+
height: "500px"
|
|
718
|
+
}, {
|
|
719
|
+
video: ht(({ video: h, index: N }) => [
|
|
720
|
+
e("div", Zt, [
|
|
721
|
+
e("div", te, [
|
|
722
|
+
a[8] || (a[8] = e("div", { class: "video-icon" }, "📹", -1)),
|
|
723
|
+
e("div", ee, [
|
|
724
|
+
e("div", oe, m(h.title), 1),
|
|
725
|
+
e("div", re, "ID: " + m(h.id), 1)
|
|
726
|
+
])
|
|
727
|
+
]),
|
|
728
|
+
a[9] || (a[9] = e("div", { class: "drag-handle" }, "⋮⋮", -1))
|
|
729
|
+
])
|
|
730
|
+
]),
|
|
731
|
+
_: 1
|
|
732
|
+
}, 8, ["videos", "layout", "placeholder-text", "placeholders"])
|
|
733
|
+
]),
|
|
734
|
+
e("div", le, [
|
|
735
|
+
e("div", ae, [
|
|
736
|
+
a[13] || (a[13] = e("h3", null, "当前状态", -1)),
|
|
737
|
+
e("div", ne, [
|
|
738
|
+
a[10] || (a[10] = e("strong", null, "布局:", -1)),
|
|
739
|
+
M(" " + m(o.value) + "分屏 ", 1)
|
|
740
|
+
]),
|
|
741
|
+
e("div", ie, [
|
|
742
|
+
a[11] || (a[11] = e("strong", null, "视频数量:", -1)),
|
|
743
|
+
M(" " + m(w.value.length), 1)
|
|
744
|
+
]),
|
|
745
|
+
e("div", se, [
|
|
746
|
+
a[12] || (a[12] = e("strong", null, "占位符:", -1)),
|
|
747
|
+
g.value ? (d(), c("span", ce, m(b.value || "无文本"), 1)) : p.value ? (d(), c("span", de, "函数生成")) : (d(), c("span", ue, "默认数字"))
|
|
748
|
+
])
|
|
749
|
+
]),
|
|
750
|
+
e("div", he, [
|
|
751
|
+
a[14] || (a[14] = e("h3", null, "视频数组 (videos)", -1)),
|
|
752
|
+
e("pre", null, m(JSON.stringify(w.value, null, 2)), 1)
|
|
753
|
+
]),
|
|
754
|
+
e("div", we, [
|
|
755
|
+
a[15] || (a[15] = e("h3", null, "操作日志", -1)),
|
|
756
|
+
e("div", pe, [
|
|
757
|
+
(d(!0), c(O, null, R(_.value, (h, N) => (d(), c("div", {
|
|
758
|
+
key: N,
|
|
759
|
+
class: "log-item"
|
|
760
|
+
}, m(h.time) + ": " + m(h.message), 1))), 128))
|
|
761
|
+
])
|
|
762
|
+
])
|
|
763
|
+
])
|
|
764
|
+
])
|
|
765
|
+
]));
|
|
766
|
+
}
|
|
767
|
+
}), ge = /* @__PURE__ */ W(ve, [["__scopeId", "data-v-4a52fa65"]]), ye = {
|
|
768
|
+
VideoGridLayout: X,
|
|
769
|
+
VideoLayoutIcon: Q,
|
|
770
|
+
VideoSplitScreenExample: ge
|
|
771
|
+
}, Se = {
|
|
772
|
+
install(u) {
|
|
773
|
+
Object.entries(ye).forEach(([w, o]) => {
|
|
774
|
+
u.component(w, o);
|
|
593
775
|
});
|
|
594
776
|
}
|
|
595
777
|
};
|
|
596
778
|
export {
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
779
|
+
B as LAYOUT_CONFIGS,
|
|
780
|
+
X as VideoGridLayout,
|
|
781
|
+
Q as VideoLayoutIcon,
|
|
782
|
+
ge as VideoSplitScreenExample,
|
|
783
|
+
Se as default,
|
|
784
|
+
pt as getAllLayoutTypes,
|
|
785
|
+
wt as getLayoutPositions
|
|
603
786
|
};
|
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}}.video-split-screen-example[data-v-4a52fa65]{font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,sans-serif;max-width:1400px;margin:0 auto;padding:20px;background:#f8f9fa;min-height:100vh}.example-header[data-v-4a52fa65]{text-align:center;margin-bottom:30px;padding:20px;background:#fff;border-radius:8px;box-shadow:0 2px 10px #0000001a}.example-header h1[data-v-4a52fa65]{color:#333;margin:0 0 10px;font-size:2rem}.example-header p[data-v-4a52fa65]{color:#666;margin:0;font-size:1.1rem}.example-controls[data-v-4a52fa65]{display:grid;grid-template-columns:repeat(auto-fit,minmax(300px,1fr));gap:20px;margin-bottom:30px}.control-group[data-v-4a52fa65]{background:#fff;padding:20px;border-radius:8px;box-shadow:0 2px 10px #0000001a}.control-group h3[data-v-4a52fa65]{margin:0 0 15px;color:#333;font-size:1.1rem}.layout-buttons[data-v-4a52fa65]{display:flex;flex-wrap:wrap;gap:8px}.layout-btn[data-v-4a52fa65]{padding:6px 12px;border:1px solid #ddd;background:#fff;border-radius:4px;cursor:pointer;transition:all .2s;font-size:.9rem}.layout-btn[data-v-4a52fa65]:hover{border-color:#007bff;color:#007bff}.layout-btn.active[data-v-4a52fa65]{background:#007bff;color:#fff;border-color:#007bff}.video-buttons[data-v-4a52fa65]{display:flex;gap:10px}.video-buttons button[data-v-4a52fa65]{padding:8px 16px;border:none;border-radius:4px;background:#28a745;color:#fff;cursor:pointer;transition:background .2s}.video-buttons button[data-v-4a52fa65]:hover:not(:disabled){background:#218838}.video-buttons button[data-v-4a52fa65]:disabled{background:#6c757d;cursor:not-allowed}.placeholder-controls[data-v-4a52fa65]{display:flex;flex-direction:column;gap:10px}.placeholder-controls label[data-v-4a52fa65]{display:flex;align-items:center;gap:8px;cursor:pointer;font-size:.9rem}.placeholder-controls input[type=text][data-v-4a52fa65]{padding:6px 12px;border:1px solid #ddd;border-radius:4px;font-size:.9rem}.example-content[data-v-4a52fa65]{display:grid;grid-template-columns:1fr 300px;gap:20px;align-items:start}.video-grid-container[data-v-4a52fa65]{background:#fff;padding:20px;border-radius:8px;box-shadow:0 2px 10px #0000001a}.custom-video-item[data-v-4a52fa65]{width:100%;height:100%;display:flex;flex-direction:column;background:linear-gradient(135deg,#667eea,#764ba2);border-radius:8px;overflow:hidden;color:#fff;position:relative}.video-content[data-v-4a52fa65]{flex:1;display:flex;align-items:center;padding:15px;gap:12px}.video-icon[data-v-4a52fa65]{font-size:2rem;opacity:.9}.video-info[data-v-4a52fa65]{flex:1}.video-title[data-v-4a52fa65]{font-size:1.1rem;font-weight:600;margin-bottom:4px}.video-id[data-v-4a52fa65]{font-size:.8rem;opacity:.8}.drag-handle[data-v-4a52fa65]{position:absolute;top:8px;right:8px;font-size:1.2rem;opacity:.7;cursor:grab;transition:opacity .2s}.custom-video-item:hover .drag-handle[data-v-4a52fa65]{opacity:1}.example-info[data-v-4a52fa65]{display:flex;flex-direction:column;gap:20px}.info-panel[data-v-4a52fa65]{background:#fff;padding:15px;border-radius:8px;box-shadow:0 2px 10px #0000001a}.info-panel h3[data-v-4a52fa65]{margin:0 0 15px;color:#333;font-size:1rem}.info-item[data-v-4a52fa65]{margin-bottom:8px;font-size:.9rem}.info-item[data-v-4a52fa65]:last-child{margin-bottom:0}.info-panel pre[data-v-4a52fa65]{background:#f8f9fa;padding:10px;border-radius:4px;font-size:.8rem;overflow-x:auto;margin:0;max-height:200px;overflow-y:auto}.log-list[data-v-4a52fa65]{max-height:200px;overflow-y:auto}.log-item[data-v-4a52fa65]{padding:4px 0;border-bottom:1px solid #eee;font-size:.8rem;color:#666}.log-item[data-v-4a52fa65]:last-child{border-bottom:none}@media (max-width: 768px){.example-content[data-v-4a52fa65],.example-controls[data-v-4a52fa65]{grid-template-columns:1fr}}
|