2 lines
3.9 KiB
JavaScript
2 lines
3.9 KiB
JavaScript
|
import{d as B,N as i,s as T,R,r as A,v as F,D as N,h,c as f,y as c,z as g,u as o,a as r,t as b,e as l,w as m,i as x,F as v,G as $,b as z,W as D,X as W,E as P,Y as j,_ as M}from"./index-4dcc0234.js";/* empty css *//* empty css */import{_ as O}from"./index.vue_vue_type_script_setup_true_lang-a631d3b2.js";import{_ as G}from"./index.vue_vue_type_script_setup_true_lang-9285296e.js";import{_ as L}from"./index-742b412a.js";import"./el-form-item-4ed993c7.js";/* empty css */import{S as X}from"./sortable.esm-be94e56d.js";import{u as Y}from"./diy-06b37a1b.js";import{r as q}from"./range-72f9cbd3.js";const J={class:"content-wrap"},K={class:"edit-attr-item-wrap"},Q={class:"mb-[10px]"},Z={class:"text-sm text-gray-400 mb-[10px]"},ee=["onClick"],te={class:"style-wrap"},oe=B({__name:"edit-image-ads",setup(ne,{expose:y}){const t=Y();t.editComponent.ignore=[],t.editComponent.verify=a=>{const e={code:!0,message:""};return t.value[a].imageHeight==0?(e.code=!1,e.message=i("imageHeightPlaceholder"),e):/^\d+.?\d{0,2}$/.test(t.value[a].imageHeight)?(t.value[a].list.forEach(s=>{if(s.imageUrl==="")return e.code=!1,e.message=i("imageUrlTip"),e}),e):(e.code=!1,e.message=i("imageHeightRegNum"),e)},t.editComponent.list.forEach(a=>{a.id||(a.id=t.generateRandom())}),T(()=>t.editComponent.list,(a,e)=>{_()},{deep:!0});const w=()=>{t.editComponent.list.push({id:t.generateRandom(),imageUrl:"",imgWidth:0,imgHeight:0,link:{name:""}})},H=a=>{_(!0)},_=(a=!1)=>{t.editComponent.list.forEach((e,s)=>{const n=new Image;n.src=R(e.imageUrl),n.onload=async()=>{if(e.imgWidth=n.width,e.imgHeight=n.height,a&&s==0){const u=e.imgHeight/e.imgWidth;e.width=375,e.height=e.width*u,t.editComponent.imageHeight=parseInt(e.height)}}})},V=()=>{t.editComponent.imageHeight=parseInt(t.editComponent.imageHeight)},C=A();return F(()=>{N(()=>{const a=X.create(C.value,{group:"item-wrap",animation:200,onEnd:e=>{const s=t.editComponent.list[e.oldIndex];t.editComponent.list.splice(e.oldIndex,1),t.editComponent.list.splice(e.newIndex,0,s),a.sort(q(t.editComponent.list.length).map(n=>n.toString())),_(!0)}})})}),y({}),(a,e)=>{const s=D,n=W,u=L,I=G,k=O,S=P,U=j;return h(),f(v,null,[c(r("div",J,[r("div",K,[r("h3",Q,b(o(i)("imageSet")),1),l(U,{"label-width":"80px",class:"px-[10px]"},{default:m(()=>[l(n,{label:o(i)("imageHeight"),class:"display-block"},{default:m(()=>[l(s,{modelValue:o(t).editComponent.imageHeight,"onUpdate:modelValue":e[0]||(e[0]=d=>o(t).editComponent.imageHeight=d),placeholder:o(i)("imageHeightPlaceholder"),clearable:"",maxlength:"10",onBlur:V},{append:m(()=>[x("px")]),_:1},8,["modelValue","placeholder"]),r("div",Z,b(o(i)("imageAdsTips")),1)]),_:1},8,["label"]),r("div",{ref_key:"imageBoxRef",ref:C},[(h(!0),f(v,null,$(o(t).editComponent.list,(d,E)=>(h(),f("div",{key:d.id,class:"item-wrap !cursor-move p-[10px] pb-0 relative border border-dashed border-gray-300 mb-[16px]"},[l(n,{label:o(i)("image")},{default:m(()=>[l(u,{modelValue:d.imageUrl,"onUpdate:modelValue":p=>d.imageUrl=p,limit:1,onChange:H},null,8,["modelValue","onUpdate:modelValue"])]),_:2},1032,["label"]),c(r("div",{class:"del absolute cursor-pointer z-[2] top-[-8px] right-[-8px]",onClick:p=>o(t).editComponent.list.splice(E,1)},[l(I,{name:"element-CircleCloseFilled",color:"#bbb",size:"20px"})],8,ee),[[g,o(t).editComponent.list.length>1]]),l(n,{label:o(i)("link")},{default:m(()=>[l(k,{modelValue:d.link,"onUpdate:modelValue":p=>d.link=p},null,8,["modelValue","onUpdate:modelValue"])]),_:2},1032,["label"])]))),128))],512),c(l(S,{class:"w-full",onClick:w},{default:m(()=>[x(b(o(i)("addImageAd")),1)]),_:1},512),[[g,o(t).editComponent.list.length<10]])]),_:1})])],512),[[g,o(t).editTab=="content"]]),c(r("div",te,[z(a.$slots,"style",{},void 0,!0)],512),[[g,o(t).editTab=="style"]])],64)}}});const ae=M(oe,[["__scopeId","data-v-81bcff35"]]),he=Object.freeze(Object.defineProperty({__proto__:null,default:ae},Symbol.toStringTag,{value:"Module"}));export{he as _};
|