niucloud-admin/niucloud/public/admin/assets/edit-image-ads-03dda0b8.js
全栈小学生 eff269ab88 up
2025-09-20 09:12:11 +08:00

2 lines
4.4 KiB
JavaScript

import{d as T,k as n,al as A,z as F,r as N,as as R,am as $,h as c,c as b,J as g,ae 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,T as M,b as P,aA as W,G as j,D as O,E as G,H as J,_ as L}from"./index-9f163f98.js";/* empty css *//* empty css */import{_ as q}from"./index.vue_vue_type_style_index_0_lang-81acf0a3.js";import{_ as K}from"./index.vue_vue_type_script_setup_true_lang-b29ac1a4.js";import Q from"./index-b01212c8.js";/* empty css */import"./el-form-item-4ed993c7.js";/* empty css */import{S as X}from"./sortable.esm-be94e56d.js";import{u as Y}from"./diy-700f9c59.js";import{r as Z}from"./range-60f1c18d.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=Y();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=X.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(Z(e.editComponent.list.length).map(i=>i.toString())),h(!0)}})})}),w({}),(a,t)=>{const m=W,i=j,f=O,H=Q,k=K,I=q,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,[P(a.$slots,"style",{},void 0,!0)],512),[[_,o(e).editTab=="style"]])],64)}}});const de=L(se,[["__scopeId","data-v-513b5921"]]),we=Object.freeze(Object.defineProperty({__proto__:null,default:de},Symbol.toStringTag,{value:"Module"}));export{we as _};