2 lines
4.3 KiB
JavaScript
2 lines
4.3 KiB
JavaScript
import{_ as $,C as j,a as A}from"./C4m4KSuD.js";import{d as T,u as O,H as z,r as _,a0 as q,o as H,z as i,A as u,B as o,K as s,C as p,T as b,D as v,bT as K,a1 as w,a2 as Q,E as f,F as x,Q as G}from"./8BTqhy_r.js";import{_ as J}from"./CscEAC8U.js";import{m as a,e as l,h as W,r as X,g as Y,d as C}from"./DgApfi7S.js";import"./TE2v2ou9.js";import{B as Z}from"./DoxGZixE.js";import{a as ee,_ as te}from"./Bx_WKW0L.js";import"./CX0PKsg3.js";const se={class:"w-full h-screen bg-black text-white"},ae={class:"flex w-full p-4 gap-8 justify-between items-center"},oe={class:"flex gap-8 items-center"},le=["alt"],ne={class:"font-semibold text-lg"},re={class:"w-full flex items-center justify-center relative"},ie=["src","alt"],ue={key:1,class:"empty-state"},ce={key:2,class:"flex absolute gap-2 right-5 bottom-5"},de={class:"media-picker"},pe={class:"media-grid"},ve=["onClick"],me=["src"],_e=["src"],fe=["onClick"],ge={class:"absolute bottom-5 right-5 addStyle"},g=10,Pe=T({__name:"index",setup(he){const d=O(),r=z(),h=_(null),m=_(""),k=_(!1),S=_();function E(){d.push({name:"home"}),X()}q(a,e=>{a.value.length===0?l.value="":a.value.length===1?l.value=a.value[0]:l.value=e[e.length-1]});function P(){a.value.length!==0?d.push({name:"add-story-infStory"}):G.warn(r.useString("addAtLeastOneMedia"))}function F(){S.value=l.value,Y.value=a.value.findIndex(e=>e===l.value),k.value=!0}function N(e){l.value=a.value[e]}const U=e=>e.includes(".mp4")||e.includes(".mov")||e.includes("video"),B=async()=>{try{j.isNativePlatform()?(await A.pickImages({limit:g-a.value.length})).photos.forEach(t=>{a.value.push(t.webPath),C.value.push(t)}):h.value.click()}catch(e){console.error("Error selecting media:",e)}},I=e=>{const t=e.target.files;t.length&&(Array.from(t).forEach(c=>{a.value.length<g&&(a.value.push(URL.createObjectURL(c)),C.value.push(c),l.value=a.value[a.value.length-1])}),h.value.value="")},R=e=>{e.preventDefault();const t=e.dataTransfer.files;Array.from(t).forEach(c=>{a.value.length<g&&a.value.push(URL.createObjectURL(c))})},D=e=>{a.value.splice(e,1),C.value.splice(e,1)};return H(()=>{switch(d.currentRoute.value.name){case"add-product-inputProduct":m.value="product";break;case"add-story-inputStory":m.value="story";break;case"add-product-excel-inputProductExcel":m.value="productExcel";break}}),(e,t)=>{const c=ee,L=te,M=$;return i(),u(w,null,[o("div",se,[o("div",ae,[o("div",oe,[o("img",{src:J,alt:s(r).appName.en,class:"w-4",onClick:E},null,8,le),o("div",ne,p(s(r).useString("newStory")),1)]),o("div",{class:"text-primary text-sm",onClick:P},p(s(r).useString("next")),1)]),o("div",re,[s(l)?(i(),u("img",{key:0,src:s(l),alt:s(r).appName.en,class:"w-full aspect-square object-contain"},null,8,ie)):s(a).length===0?(i(),u("p",ue,p(s(r).useString("tapPlusToAdd")),1)):b("",!0),s(l)?(i(),u("div",ce,[o("div",{onClick:F,class:"flex bg-black/80 items-center rounded gap-2 p-2"},[v(Z,{icon:"vuesax-linear:crop"})])])):b("",!0)]),o("div",de,[o("div",{class:"drop-area",onDragover:t[0]||(t[0]=K(()=>{},["prevent"])),onDrop:R},[o("div",pe,[(i(!0),u(w,null,Q(s(a),(n,y)=>(i(),u("div",{key:y,class:"media-container",onClick:V=>N(y)},[U(n)?(i(),u("video",{key:0,src:n,class:"media-preview",controls:""},null,8,me)):(i(),u("img",{key:1,src:n,class:"media-preview"},null,8,_e)),o("button",{onClick:V=>D(y),class:"remove-btn"},"✖",8,fe)],8,ve))),128)),s(a).length<g?(i(),u("div",{key:0,class:"add-media text-black",onClick:B},t[6]||(t[6]=[o("span",null,"+",-1)]))):b("",!0)])],32),o("input",{ref_key:"fileInput",ref:h,type:"file",accept:"image/*,video/*",multiple:"",hidden:"",onChange:I},null,544)])]),o("div",ge,[v(L,{value:m.value,"onUpdate:value":t[4]||(t[4]=n=>m.value=n),"button-style":"solid"},{default:f(()=>[v(c,{onClick:t[1]||(t[1]=n=>s(d).push({name:"add-product-excel-inputProductExcel"})),value:"productExcel"},{default:f(()=>[x(p(s(r).useString("productExcel")),1)]),_:1}),v(c,{onClick:t[2]||(t[2]=n=>s(d).push({name:"add-product-inputProduct"})),value:"product"},{default:f(()=>[x(p(s(r).useString("product2")),1)]),_:1}),v(c,{onClick:t[3]||(t[3]=n=>s(d).push({name:"add-story-inputStory"})),value:"story"},{default:f(()=>[x(p(s(r).useString("story2")),1)]),_:1})]),_:1},8,["value"])]),v(M,{visible:k.value,"onUpdate:visible":t[5]||(t[5]=n=>k.value=n),img:s(l),mode:"free",aspectRatio:9/16,resizable:!0,onCropped:s(W)},null,8,["visible","img","onCropped"])],64)}}});export{Pe as _};
|