2 lines
8.8 KiB
JavaScript
2 lines
8.8 KiB
JavaScript
import{s as ue,b3 as Te,b4 as Ae,Q as ie,b5 as Be,a as j,af as ce,r as g,V as $,u as e,M as H,aa as fe,aS as De,aQ as Le,ag as Oe,o as _,h as k,i as L,c as W,k as T,ai as K,Y as b,b6 as F,j as S,G as oe,b7 as Ve,am as Q,an as ne,p as O,b8 as Pe,X as de,B as ve,H as me,b9 as pe,t as ze,Z as he,aJ as He,N as _e,T as Fe,f as je,K as Re,ba as Ue,ap as We,aV as Ke,bb as Qe,w as qe,bc as Je}from"./entry.834fe740.js";import{_ as Xe}from"./card.vue_vue_type_script_setup_true_lang.b114a108.js";import{u as Ye}from"./asyncData.ac40d117.js";import{t as le,E as Ge}from"./empty_news.70229e1b.js";import"./items.vue_vue_type_script_setup_true_lang.8121b615.js";import"./debounce.738623ac.js";const ge=Symbol("carouselContextKey"),Ze=(y,m,f)=>Te(y.subTree).filter(o=>{var c;return Ae(o)&&((c=o.type)==null?void 0:c.name)===m&&!!o.component}).map(o=>o.component.uid).map(o=>f[o]).filter(o=>!!o),xe=(y,m)=>{const f={},a=ue([]);return{children:a,addChild:c=>{f[c.uid]=c,a.value=Ze(y,m,f)},removeChild:c=>{delete f[c],a.value=a.value.filter(C=>C.uid!==c)}}},et=ie({initialIndex:{type:Number,default:0},height:{type:String,default:""},trigger:{type:String,values:["hover","click"],default:"hover"},autoplay:{type:Boolean,default:!0},interval:{type:Number,default:3e3},indicatorPosition:{type:String,values:["","none","outside"],default:""},indicator:{type:Boolean,default:!0},arrow:{type:String,values:["always","hover","never"],default:"hover"},type:{type:String,values:["","card"],default:""},loop:{type:Boolean,default:!0},direction:{type:String,values:["horizontal","vertical"],default:"horizontal"},pauseOnHover:{type:Boolean,default:!0}}),tt={change:(y,m)=>[y,m].every(Be)},at=["onMouseenter","onMouseleave"],st=["onMouseenter","onClick"],ot={key:0},re=300,nt=j({name:"ElCarousel"}),lt=j({...nt,props:et,emits:tt,setup(y,{expose:m,emit:f}){const a=y,l=ce("carousel"),{children:o,addChild:c,removeChild:C}=xe(_e(),"ElCarouselItem"),s=g(-1),p=g(null),h=g(!1),E=g(),M=$(()=>a.arrow!=="never"&&!e(A)),V=$(()=>o.value.some(t=>t.props.label.toString().length>0)),q=$(()=>{const t=[l.b(),l.m(a.direction)];return e(P)&&t.push(l.m("card")),t}),J=$(()=>{const t=[l.e("indicators"),l.em("indicators",a.direction)];return V.value&&t.push(l.em("indicators","labels")),(a.indicatorPosition==="outside"||e(P))&&t.push(l.em("indicators","outside")),t}),P=$(()=>a.type==="card"),A=$(()=>a.direction==="vertical"),R=le(t=>{i(t)},re,{trailing:!0}),X=le(t=>{Ie(t)},re);function n(){p.value&&(clearInterval(p.value),p.value=null)}function r(){a.interval<=0||!a.autoplay||p.value||(p.value=setInterval(()=>d(),a.interval))}const d=()=>{s.value<o.value.length-1?s.value=s.value+1:a.loop&&(s.value=0)};function i(t){if(He(t)){const I=o.value.filter(D=>D.props.name===t);I.length>0&&(t=o.value.indexOf(I[0]))}if(t=Number(t),Number.isNaN(t)||t!==Math.floor(t))return;const u=o.value.length,v=s.value;t<0?s.value=a.loop?u-1:0:t>=u?s.value=a.loop?0:u-1:s.value=t,v===s.value&&w(v),ee()}function w(t){o.value.forEach((u,v)=>{u.translateItem(v,s.value,t)})}function B(t,u){var v,I,D,te;const z=e(o),ae=z.length;if(ae===0||!t.states.inStage)return!1;const ke=u+1,Se=u-1,se=ae-1,Ee=z[se].states.active,Ne=z[0].states.active,$e=(I=(v=z[ke])==null?void 0:v.states)==null?void 0:I.active,Me=(te=(D=z[Se])==null?void 0:D.states)==null?void 0:te.active;return u===se&&Ne||$e?"left":u===0&&Ee||Me?"right":!1}function N(){h.value=!0,a.pauseOnHover&&n()}function Y(){h.value=!1,r()}function Z(t){e(A)||o.value.forEach((u,v)=>{t===B(u,v)&&(u.states.hover=!0)})}function x(){e(A)||o.value.forEach(t=>{t.states.hover=!1})}function Ce(t){s.value=t}function Ie(t){a.trigger==="hover"&&t!==s.value&&(s.value=t)}function we(){i(s.value-1)}function be(){i(s.value+1)}function ee(){n(),r()}H(()=>s.value,(t,u)=>{w(u),u>-1&&f("change",t,u)}),H(()=>a.autoplay,t=>{t?r():n()}),H(()=>a.loop,()=>{i(s.value)}),H(()=>a.interval,()=>{ee()}),H(()=>o.value,()=>{o.value.length>0&&i(a.initialIndex)});const G=ue();return fe(()=>{G.value=De(E.value,()=>{w()}),r()}),Le(()=>{n(),E.value&&G.value&&G.value.stop()}),Oe(ge,{root:E,isCardType:P,isVertical:A,items:o,loop:a.loop,addItem:c,removeItem:C,setActiveItem:i}),m({setActiveItem:i,prev:we,next:be}),(t,u)=>(_(),k("div",{ref_key:"root",ref:E,class:b(e(q)),onMouseenter:F(N,["stop"]),onMouseleave:F(Y,["stop"])},[L("div",{class:b(e(l).e("container")),style:ve({height:t.height})},[e(M)?(_(),W(ne,{key:0,name:"carousel-arrow-left",persisted:""},{default:T(()=>[K(L("button",{type:"button",class:b([e(l).e("arrow"),e(l).em("arrow","left")]),onMouseenter:u[0]||(u[0]=v=>Z("left")),onMouseleave:x,onClick:u[1]||(u[1]=F(v=>e(R)(s.value-1),["stop"]))},[S(e(oe),null,{default:T(()=>[S(e(Ve))]),_:1})],34),[[Q,(t.arrow==="always"||h.value)&&(a.loop||s.value>0)]])]),_:1})):O("v-if",!0),e(M)?(_(),W(ne,{key:1,name:"carousel-arrow-right",persisted:""},{default:T(()=>[K(L("button",{type:"button",class:b([e(l).e("arrow"),e(l).em("arrow","right")]),onMouseenter:u[2]||(u[2]=v=>Z("right")),onMouseleave:x,onClick:u[3]||(u[3]=F(v=>e(R)(s.value+1),["stop"]))},[S(e(oe),null,{default:T(()=>[S(e(Pe))]),_:1})],34),[[Q,(t.arrow==="always"||h.value)&&(a.loop||s.value<e(o).length-1)]])]),_:1})):O("v-if",!0),de(t.$slots,"default")],6),t.indicatorPosition!=="none"?(_(),k("ul",{key:0,class:b(e(J))},[(_(!0),k(me,null,pe(e(o),(v,I)=>(_(),k("li",{key:I,class:b([e(l).e("indicator"),e(l).em("indicator",t.direction),e(l).is("active",I===s.value)]),onMouseenter:D=>e(X)(I),onClick:F(D=>Ce(I),["stop"])},[L("button",{class:b(e(l).e("button"))},[e(V)?(_(),k("span",ot,ze(v.props.label),1)):O("v-if",!0)],2)],42,st))),128))],2)):O("v-if",!0)],42,at))}});var rt=he(lt,[["__file","/home/runner/work/element-plus/element-plus/packages/components/carousel/src/carousel.vue"]]);const ut=ie({name:{type:String,default:""},label:{type:[String,Number],default:""}}),U=.83,it=j({name:"ElCarouselItem"}),ct=j({...it,props:ut,setup(y){const m=y,f=ce("carousel"),a=Fe(ge),l=_e(),o=g(!1),c=g(0),C=g(1),s=g(!1),p=g(!1),h=g(!1),E=g(!1),{isCardType:M,isVertical:V}=a,q=$(()=>{const r=`${`translate${e(V)?"Y":"X"}`}(${e(c)}px)`,d=`scale(${e(C)})`;return{transform:[r,d].join(" ")}});function J(n,r,d){const i=d-1,w=r-1,B=r+1,N=d/2;return r===0&&n===i?-1:r===i&&n===0?d:n<w&&r-n>=N?d+1:n>B&&n-r>=N?-2:n}function P(n,r){var d;const i=((d=a.root.value)==null?void 0:d.offsetWidth)||0;return h.value?i*((2-U)*(n-r)+1)/4:n<r?-(1+U)*i/4:(3+U)*i/4}function A(n,r,d){const i=a.root.value;return i?((d?i.offsetHeight:i.offsetWidth)||0)*(n-r):0}const R=(n,r,d)=>{var i;const w=e(M),B=(i=a.items.value.length)!=null?i:Number.NaN,N=n===r;!w&&!Ue(d)&&(E.value=N||n===d),!N&&B>2&&a.loop&&(n=J(n,r,B));const Y=e(V);s.value=N,w?(h.value=Math.round(Math.abs(n-r))<=1,c.value=P(n,r),C.value=e(s)?1:U):c.value=A(n,r,Y),p.value=!0};function X(){if(a&&e(M)){const n=a.items.value.findIndex(({uid:r})=>r===l.uid);a.setActiveItem(n)}}return fe(()=>{a.addItem({props:m,states:je({hover:o,translate:c,scale:C,active:s,ready:p,inStage:h,animating:E}),uid:l.uid,translateItem:R})}),Re(()=>{a.removeItem(l.uid)}),(n,r)=>K((_(),k("div",{class:b([e(f).e("item"),e(f).is("active",s.value),e(f).is("in-stage",h.value),e(f).is("hover",o.value),e(f).is("animating",E.value),{[e(f).em("item","card")]:e(M)}]),style:ve(e(q)),onClick:X},[e(M)?K((_(),k("div",{key:0,class:b(e(f).e("mask"))},null,2)),[[Q,!s.value]]):O("v-if",!0),de(n.$slots,"default")],6)),[[Q,p.value]])}});var ye=he(ct,[["__file","/home/runner/work/element-plus/element-plus/packages/components/carousel/src/carousel-item.vue"]]);const ft=We(rt,{CarouselItem:ye}),dt=Ke(ye);function vt(){return $request.get({url:"/pc/index"})}const mt={class:"index"},pt={class:"flex"},ht={class:"mt-5 flex"},bt=j({__name:"index",async setup(y){let m,f;const a=Qe(),{data:l}=([m,f]=qe(()=>Ye(()=>vt(),{default:()=>({all:[],hot:[],new:[],page:{}})},"$pqtWcjQkdb")),m=await m,f(),m),o=$(()=>{var c;try{return(c=JSON.parse(l.value.page.data).find(s=>s.name==="banner"))==null?void 0:c.content}catch{return{}}});return(c,C)=>{const s=Je,p=Xe;return _(),k("div",mt,[L("div",pt,[e(o).enabled?(_(),W(e(ft),{key:0,class:"w-[750px] flex-none mr-5",trigger:"click",height:"340px"},{default:T(()=>[(_(!0),k(me,null,pe(e(o).data,h=>(_(),W(e(dt),{key:h},{default:T(()=>[S(s,{to:h.link.path,target:"_blank"},{default:T(()=>[S(e(Ge),{class:"w-full h-full rounded-[8px] bg-white overflow-hidden",src:e(a).getImageUrl(h.image),fit:"contain"},null,8,["src"])]),_:2},1032,["to"])]),_:2},1024))),128))]),_:1})):O("",!0),S(p,{link:"/information/new",class:"flex-1 min-w-0",header:"\u6700\u65B0\u8D44\u8BAF",data:e(l).new,"show-time":!1},null,8,["data"])]),L("div",ht,[S(p,{link:"/information",class:"w-[750px] flex-none mr-5",header:"\u5168\u90E8\u8D44\u8BAF",data:e(l).all,"only-title":!1},null,8,["data"]),S(p,{link:"/information/hot",class:"flex-1",header:"\u70ED\u95E8\u8D44\u8BAF",data:e(l).hot,"only-title":!1,"image-size":"mini","show-author":!1,"show-desc":!1,"show-click":!1,border:!1,"title-line":2},null,8,["data"])])])}}});export{bt as default};
|