2 lines
4.3 KiB
JavaScript
2 lines
4.3 KiB
JavaScript
import{_ as V,C as j,a as A}from"./BtyzBuwr.js";import{d as O,u as T,G as z,r as _,$ as q,o as G,y as i,z as u,A as o,C as p,J as s,B as v,R as b,bR as J,a0 as w,a1 as H,D as f,E as x,P as K}from"./Cbt2tPBc.js";import{_ as Q}from"./CscEAC8U.js";import{m as a,e as l,h as W,r as X,g as Y,d as C}from"./C8NhlFLb.js";import"./CgpbEzJY.js";import{B as Z}from"./_OSaw0MT.js";import{a as ee,_ as te}from"./XRR38INJ.js";import"./B7QhzxXq.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,Ee=O({__name:"index",setup(he){const d=T(),r=z(),h=_(null),m=_(""),y=_(!1),S=_();function P(){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 E(){a.value.length!==0?d.push({name:"add-story-infStory"}):K.warn(r.useString("addAtLeastOneMedia"))}function R(){S.value=l.value,Y.value=a.value.findIndex(e=>e===l.value),y.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)}},F=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="")},I=e=>{e.preventDefault();const t=e.dataTransfer.files;Array.from(t).forEach(c=>{a.value.length<g&&a.value.push(URL.createObjectURL(c))})},$=e=>{a.value.splice(e,1),C.value.splice(e,1)};return G(()=>{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,D=te,L=V;return u(),i(w,null,[o("div",se,[o("div",ae,[o("div",oe,[o("img",{src:Q,alt:s(r).appName.en,class:"w-4",onClick:P},null,8,le),o("div",ne,v(s(r).useString("newStory")),1)]),o("div",{class:"text-primary text-sm",onClick:E},v(s(r).useString("next")),1)]),o("div",re,[s(l)?(u(),i("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?(u(),i("p",ue,v(s(r).useString("tapPlusToAdd")),1)):b("",!0),s(l)?(u(),i("div",ce,[o("div",{onClick:R,class:"flex bg-black/80 items-center rounded gap-2 p-2"},[p(Z,{icon:"vuesax-linear:crop"})])])):b("",!0)]),o("div",de,[o("div",{class:"drop-area",onDragover:t[0]||(t[0]=J(()=>{},["prevent"])),onDrop:I},[o("div",pe,[(u(!0),i(w,null,H(s(a),(n,k)=>(u(),i("div",{key:k,class:"media-container",onClick:M=>N(k)},[U(n)?(u(),i("video",{key:0,src:n,class:"media-preview",controls:""},null,8,me)):(u(),i("img",{key:1,src:n,class:"media-preview"},null,8,_e)),o("button",{onClick:M=>$(k),class:"remove-btn"},"✖",8,fe)],8,ve))),128)),s(a).length<g?(u(),i("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:F},null,544)])]),o("div",ge,[p(D,{value:m.value,"onUpdate:value":t[4]||(t[4]=n=>m.value=n),"button-style":"solid"},{default:f(()=>[p(c,{onClick:t[1]||(t[1]=n=>s(d).push({name:"add-product-excel-inputProductExcel"})),value:"productExcel"},{default:f(()=>[x(v(s(r).useString("productExcel")),1)]),_:1}),p(c,{onClick:t[2]||(t[2]=n=>s(d).push({name:"add-product-inputProduct"})),value:"product"},{default:f(()=>[x(v(s(r).useString("product2")),1)]),_:1}),p(c,{onClick:t[3]||(t[3]=n=>s(d).push({name:"add-story-inputStory"})),value:"story"},{default:f(()=>[x(v(s(r).useString("story2")),1)]),_:1})]),_:1},8,["value"])]),p(L,{visible:y.value,"onUpdate:visible":t[5]||(t[5]=n=>y.value=n),img:s(l),mode:"free",aspectRatio:9/16,resizable:!0,onCropped:s(W)},null,8,["visible","img","onCropped"])],64)}}});export{Ee as _};
|