Skip to content

Commit b28012d

Browse files
committed
update docs
1 parent b9ac216 commit b28012d

8 files changed

Lines changed: 195 additions & 66 deletions

File tree

docs/.vuepress/components/SponsorExclusivePopup.vue

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
</span>
88

99
<span class="sh-pop-body">
10-
<img v-if="hasBrand" :src="homeSponsor.link" :alt="homeSponsor.alt" class="sh-pop-img" />
10+
<SponsorMedia v-if="hasBrand" :src="homeSponsor.link" :alt="homeSponsor.alt" :ink="homeSponsor.ink" fit="cover"
11+
loading="eager" />
1112
<span v-else class="sh-pop-cta">
1213
<GradientText :text="t('sponsorHome.inquireNow')" :colors="['#009485', '#c8abfa']" :animation-speed="3" />
1314
</span>
@@ -23,6 +24,7 @@ import { withBase } from 'vuepress/client'
2324
import { homeSponsor, shouldShowSponsor } from '../data/sponsors'
2425
import { useI18n } from '../composables/useI18n'
2526
import GradientText from './bits/GradientText.vue'
27+
import SponsorMedia from './SponsorMedia.vue'
2628
2729
const { t, withLocale } = useI18n()
2830
const hasBrand = computed(() => shouldShowSponsor(homeSponsor))
@@ -117,17 +119,6 @@ const isExternal = computed(() => hasBrand.value && /^https?:/.test(targetHref.v
117119
overflow: hidden;
118120
}
119121
120-
.sh-pop-img {
121-
width: 100%;
122-
height: 100%;
123-
object-fit: cover;
124-
display: block;
125-
}
126-
127-
[data-theme="dark"] .sh-pop-img {
128-
filter: grayscale(1) invert(1);
129-
}
130-
131122
.sh-pop-cta {
132123
display: inline-flex;
133124
align-items: center;

docs/.vuepress/components/SponsorHome.vue

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<template v-if="hasBrand">
66
<span class="sh-inline-label">{{ t('sponsorHome.exclusive') }}</span>
77
<span class="sh-inline-body">
8-
<img :src="homeSponsor.link" :alt="homeSponsor.alt" class="sh-inline-img" />
8+
<SponsorMedia :src="homeSponsor.link" :alt="homeSponsor.alt" :ink="homeSponsor.ink" fit="cover" />
99
</span>
1010
<span class="sh-inline-label sh-inline-label-right">{{ t('sponsorHome.partner') }}</span>
1111
</template>
@@ -22,6 +22,7 @@ import { homeSponsor, shouldShowSponsor } from '../data/sponsors'
2222
import { useI18n } from '../composables/useI18n'
2323
import GradientText from './bits/GradientText.vue'
2424
import SponsorExclusivePopup from './SponsorExclusivePopup.vue'
25+
import SponsorMedia from './SponsorMedia.vue'
2526
2627
const route = useRoute()
2728
const { t, withLocale } = useI18n()
@@ -114,17 +115,6 @@ watch(() => route.path, () => scheduleCheck())
114115
background: var(--vp-c-bg-soft);
115116
}
116117
117-
.sh-inline-img {
118-
width: 100%;
119-
height: 100%;
120-
object-fit: cover;
121-
display: block;
122-
}
123-
124-
[data-theme="dark"] .sh-inline-img {
125-
filter: grayscale(1) invert(1);
126-
}
127-
128118
.sh-inline-empty {
129119
flex: 1;
130120
display: flex;
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<template>
2+
<span
3+
class="sponsor-media"
4+
:class="{
5+
'is-cover': fit === 'cover',
6+
'is-ink-white': ink === 'white',
7+
'is-ink-black': ink === 'black',
8+
'is-fallback': showFallback,
9+
}"
10+
>
11+
<img
12+
v-if="hasSrc && !failed"
13+
:src="src"
14+
:alt="label"
15+
:loading="loading"
16+
decoding="async"
17+
@error="failed = true"
18+
>
19+
<span v-if="showFallback" class="sponsor-media__name">{{ label }}</span>
20+
</span>
21+
</template>
22+
23+
<script setup lang="ts">
24+
import { computed, ref, watch } from 'vue'
25+
26+
const props = withDefaults(defineProps<{
27+
src?: string
28+
alt?: string
29+
ink?: 'white' | 'black'
30+
fit?: 'contain' | 'cover'
31+
loading?: 'lazy' | 'eager'
32+
}>(), {
33+
fit: 'contain',
34+
loading: 'lazy',
35+
})
36+
37+
const failed = ref(false)
38+
const label = computed(() => props.alt?.trim() || '')
39+
const hasSrc = computed(() => Boolean(props.src))
40+
const showFallback = computed(() => !hasSrc.value || failed.value)
41+
42+
watch(() => props.src, () => {
43+
failed.value = false
44+
})
45+
</script>

docs/.vuepress/components/SponsorPanel.vue

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
<div class="gold-sponsors">
77
<div v-for="brand in goldSponsors" v-show="shouldShowSponsor(brand)" class="brand-item gold"
88
@click="openSponsorLink(brand.href, '_blank')">
9-
<img :alt="brand.alt" :src="brand.link" class="brand-image" />
9+
<SponsorMedia :src="brand.link" :alt="brand.alt" :ink="brand.ink" fit="cover" />
1010
</div>
1111
</div>
1212
<div class="general-sponsors">
1313
<div v-for="brand in generalSponsors" v-show="shouldShowSponsor(brand)" class="brand-item"
1414
@click="openSponsorLink(brand.href, '_blank')">
15-
<img :alt="brand.alt" :src="brand.link" class="brand-image" />
15+
<SponsorMedia :src="brand.link" :alt="brand.alt" :ink="brand.ink" />
1616
</div>
1717
</div>
1818
<div v-if="shouldShowExtraBecomeSponsor" class="brand-item become-brand" @click="openSponsorLink(localeSponsorUrl)">
@@ -31,6 +31,7 @@ import {
3131
shouldShowSponsor,
3232
} from "../data/sponsors";
3333
import { useI18n } from "../composables/useI18n";
34+
import SponsorMedia from "./SponsorMedia.vue";
3435
3536
const { t, withLocale } = useI18n();
3637
const localeSponsorUrl = computed(() => withBase(withLocale('/sponsors.html')));
@@ -77,26 +78,20 @@ const shouldShowExtraBecomeSponsor = computed(() => {
7778
align-items: center;
7879
justify-content: center;
7980
height: 66px;
80-
transition: all 0.3s ease;
81+
overflow: hidden;
82+
transition: outline-color 0.3s ease;
8183
position: relative;
8284
}
8385
8486
.brand-item:hover {
85-
border: 1px solid var(--vp-c-brand);
87+
outline: 1px solid var(--vp-c-brand);
88+
outline-offset: -1px;
8689
}
8790
8891
.brand-item.gold {
8992
height: 96px;
9093
}
9194
92-
.brand-image {
93-
position: absolute;
94-
width: 100%;
95-
height: 100%;
96-
object-fit: contain;
97-
transition: opacity 0.3s ease;
98-
}
99-
10095
.brand-text {
10196
color: var(--vp-c-text-3);
10297
font-size: 10px;
@@ -107,7 +102,8 @@ const shouldShowExtraBecomeSponsor = computed(() => {
107102
padding: 0 8px;
108103
}
109104
110-
.brand-item.gold .brand-text {
105+
.brand-item.gold .brand-text,
106+
.brand-item.gold :deep(.sponsor-media__name) {
111107
font-size: 13px;
112108
}
113109

docs/.vuepress/components/SponsorSidebar.vue

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
<div class="brand-container">
66
<div class="sidebar-brand">
77
<div class="brand" @click="openSponsorLink(homeSponsor.href)">
8-
<img v-if="shouldShowSponsor(homeSponsor)" :alt="homeSponsor.alt" :src="homeSponsor.link" class="brand-image" />
8+
<SponsorMedia v-if="shouldShowSponsor(homeSponsor)" :src="homeSponsor.link" :alt="homeSponsor.alt"
9+
:ink="homeSponsor.ink" fit="cover" />
910
<span v-else class="brand-text">{{ t('sponsorUi.becomeSponsor') }}</span>
1011
</div>
1112
</div>
@@ -15,6 +16,7 @@
1516
<script setup>
1617
import { homeSponsor, openSponsorLink, shouldShowSponsor } from "../data/sponsors";
1718
import { useI18n } from "../composables/useI18n";
19+
import SponsorMedia from "./SponsorMedia.vue";
1820
1921
const { t } = useI18n();
2022
</script>
@@ -45,16 +47,12 @@ const { t } = useI18n();
4547
align-items: center;
4648
justify-content: center;
4749
height: 89px;
50+
overflow: hidden;
4851
}
4952
5053
.brand:hover {
51-
border: 1px solid var(--vp-c-brand);
52-
}
53-
54-
.brand-image {
55-
width: 100%;
56-
height: 100%;
57-
object-fit: fill;
54+
outline: 1px solid var(--vp-c-brand);
55+
outline-offset: -1px;
5856
}
5957
6058
.brand-text {

docs/.vuepress/components/SponsorSwiper.vue

Lines changed: 80 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,37 +3,81 @@
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'
2149
import { withBase } from 'vuepress/client'
22-
// @ts-ignore
23-
import Swiper from 'vuepress-theme-plume/features/Swiper.vue'
2450
import { goldSponsors, generalSponsors, shouldShowSponsor } from '../data/sponsors'
2551
import { 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
2758
const { t, withLocale } = useI18n()
2859
const 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>

docs/.vuepress/data/sponsors.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ export interface Sponsor {
99
href?: string;
1010
alt?: string;
1111
expiryTime: string; // ISO 格式日期:2099-12-31T23:59:59
12+
/** 透明单色 Logo 的墨色:white 浅色主题反色,black 深色主题反色,满版/带背景图不填 */
13+
ink?: 'white' | 'black';
1214
}
1315

1416
export const defaultSponsor: Sponsor = {
@@ -36,6 +38,7 @@ export const generalSponsors: Sponsor[] = [
3638
href: 'https://u.bws.lol/register?aff=SLMYG84W',
3739
alt: 'Bywave',
3840
expiryTime: '2099-12-31T23:59:59',
41+
ink: 'white',
3942
},
4043
{
4144
link: '',

0 commit comments

Comments
 (0)