niucloud-admin/niucloud/public/admin/assets/edit-image-ads-0d16c3a9.js
全栈小学生 1c498f5a2a up
2025-01-03 17:59:49 +08:00

2 lines
4.4 KiB
JavaScript

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