33 <header class =" ss-header" >
44 <h2 class =" ss-title" >{{ t('sponsorUi.goldTitle') }}</h2 >
55 </header >
6- <Swiper v-if =" processedGoldSponsors .length > 0 " :items =" processedGoldSponsors " mode="broadcast" :loop =" false "
7- :height =" 162 " :slides-per-view =" 3 " :space-between =" 10 " mousewheel />
8- <p v-else class =" ss-empty" >{{ t('sponsorUi.seatWaiting') }} <a :href =" sponsorsHref" >{{ t('sponsorUi.beFirst') }}</a ></p >
6+ <ClientOnly v-if =" goldSponsorsList .length > 0 " >
7+ <Swiper class="vp-swiper" :style =" { width: ' 100%' , height: ' 162px' } " :modules =" goldModules " :slides-per-view =" 3 "
8+ :space-between =" 10 " :loop =" false " :navigation =" true " :pagination =" { dynamicBullets: true , clickable: true } "
9+ :mousewheel =" true " :speed =" 300 " >
10+ <SwiperSlide v-for =" (item , index ) in goldSponsorsList " :key =" (item .link || item .alt || ' ' ) + index " >
11+ <a v-if =" item.href" :href =" item.href" target =" _blank" rel =" noopener noreferrer"
12+ class =" swiper-slide-link no-icon" >
13+ <SponsorMedia :src =" item .link " :alt =" item .alt " :ink =" item .ink " fit="cover" />
14+ </a >
15+ <SponsorMedia v-else :src =" item .link " :alt =" item .alt " :ink =" item .ink " fit="cover" />
16+ </SwiperSlide >
17+ </Swiper >
18+ </ClientOnly >
19+ <p v-else class =" ss-empty" >{{ t('sponsorUi.seatWaiting') }} <a :href =" sponsorsHref" >{{ t('sponsorUi.beFirst') }}</a >
20+ </p >
921
1022 <header class =" ss-header" >
1123 <h2 class =" ss-title" >{{ t('sponsorUi.silverTitle') }}</h2 >
1224 </header >
13- <Swiper v-if =" processedGeneralSponsors .length > 0 " :items =" processedGeneralSponsors " mode="carousel" :height =" 168 "
14- :slides-per-view =" 4 " :space-between =" 10 " :speed =" 5000 " />
15- <p v-else class =" ss-empty" >{{ t('sponsorUi.seatWaiting') }} <a :href =" sponsorsHref" >{{ t('sponsorUi.beFirst') }}</a ></p >
25+ <ClientOnly v-if =" generalSponsorsList .length > 0 " >
26+ <Swiper class="vp-swiper swiper-no-swiping" :style =" { width: ' 100%' , height: ' 168px' } " :modules =" silverModules "
27+ :autoplay =" { delay: 0 , disableOnInteraction: false } " :slides-per-view =" 4 " :space-between =" 10 "
28+ :loop =" generalSponsorsList .length > 4 " :speed =" 5000 " @swiper =" onSilverSwiper " >
29+ <SwiperSlide v-for =" (item , index ) in generalSponsorsList " :key =" (item .link || item .alt || ' ' ) + index " >
30+ <a v-if =" item.href" :href =" item.href" target =" _blank" rel =" noopener noreferrer"
31+ class =" swiper-slide-link no-icon" >
32+ <SponsorMedia :src =" item .link " :alt =" item .alt " :ink =" item .ink " />
33+ </a >
34+ <SponsorMedia v-else :src =" item .link " :alt =" item .alt " :ink =" item .ink " />
35+ </SwiperSlide >
36+ </Swiper >
37+ </ClientOnly >
38+ <p v-else class =" ss-empty" >{{ t('sponsorUi.seatWaiting') }} <a :href =" sponsorsHref" >{{ t('sponsorUi.beFirst') }}</a >
39+ </p >
1640 </section >
1741</template >
1842
1943<script setup lang="ts">
20- import { computed } from ' vue'
44+ import { useMutationObserver } from ' @vueuse/core'
45+ import { Autoplay , Mousewheel , Navigation , Pagination } from ' swiper/modules'
46+ import type { Swiper as SwiperType } from ' swiper/types'
47+ import { Swiper , SwiperSlide } from ' swiper/vue'
48+ import { computed , onMounted } from ' vue'
2149import { withBase } from ' vuepress/client'
22- // @ts-ignore
23- import Swiper from ' vuepress-theme-plume/features/Swiper.vue'
2450import { goldSponsors , generalSponsors , shouldShowSponsor } from ' ../data/sponsors'
2551import { useI18n } from ' ../composables/useI18n'
52+ import SponsorMedia from ' ./SponsorMedia.vue'
53+
54+ import ' swiper/css'
55+ import ' swiper/css/navigation'
56+ import ' swiper/css/pagination'
2657
2758const { t, withLocale } = useI18n ()
2859const sponsorsHref = computed (() => withBase (withLocale (' /sponsors.html' )))
2960
30- const processedGoldSponsors = computed (() =>
31- goldSponsors .filter (sponsor => shouldShowSponsor (sponsor ) && sponsor .link )
32- )
61+ const goldSponsorsList = computed (() => goldSponsors .filter (shouldShowSponsor ))
62+ const generalSponsorsList = computed (() => generalSponsors .filter (shouldShowSponsor ))
63+
64+ const goldModules = [Navigation , Pagination , Mousewheel ]
65+ const silverModules = [Autoplay ]
66+
67+ let silverSwiper: SwiperType | undefined
68+
69+ function onSilverSwiper(swiper : SwiperType ) {
70+ silverSwiper = swiper
71+ }
3372
34- const processedGeneralSponsors = computed (() =>
35- generalSponsors .filter (sponsor => shouldShowSponsor (sponsor ) && sponsor .link )
36- )
73+ onMounted (() => {
74+ useMutationObserver (() => document .documentElement , () => {
75+ if (! silverSwiper )
76+ return
77+ silverSwiper .wrapperEl .style .transform = ' translate3d(0px, 0px, 0px)'
78+ setTimeout (() => silverSwiper ?.update (), 350 )
79+ }, { attributeFilter: [' data-theme' ] })
80+ })
3781 </script >
3882
3983<style scoped>
@@ -78,7 +122,26 @@ const processedGeneralSponsors = computed(() =>
78122 text-decoration : underline ;
79123}
80124
125+ .sponsor-swiper :deep(.vp-swiper ) {
126+ margin : 24px 0 ;
127+ }
128+
129+ .sponsor-swiper :deep(.swiper ) {
130+ --swiper-theme-color : var (--vp-c-bg );
131+ --swiper-pagination-bullet-inactive-color : var (--vp-c-bg );
132+ --swiper-pagination-bullet-inactive-opacity : 0.4 ;
133+ }
134+
135+ .sponsor-swiper :deep(.swiper-slide ) {
136+ display : flex ;
137+ height : 100% ;
138+ overflow : hidden ;
139+ background-color : var (--vp-c-bg-soft );
140+ }
141+
81142.sponsor-swiper :deep(.swiper-slide-link ) {
143+ display : flex ;
144+ height : 100% ;
82145 border : 1px solid transparent ;
83146 transition : border-color 0.3s ease ;
84147}
@@ -87,11 +150,7 @@ const processedGeneralSponsors = computed(() =>
87150 border : 1px solid var (--vp-c-brand-1 );
88151}
89152
90- .sponsor-swiper :deep(.swiper-slide ) {
91- background-color : var (--vp-c-bg-soft );
92- }
93-
94- .sponsor-swiper :deep(.swiper-slide-img ) {
95- object-fit : contain !important
153+ .sponsor-swiper :deep(.swiper-wrapper ) {
154+ transition-timing-function : linear ;
96155}
97156 </style >
0 commit comments