99 <div class =" brand-container" >
1010 <div class =" gold-sponsors" >
1111 <div
12- v-for =" (brand, index) in goldSponsors "
13- v-show =" !isCollapsed || (isCollapsed && !brand.alt.includes('成为赞助商' ))"
12+ v-for =" (brand, index) in processedGoldSponsors "
13+ v-show =" !isCollapsed || (isCollapsed && shouldShowSponsor(brand ))"
1414 :key =" 'gold-' + index"
1515 :class =" { 'collapsed-mode': isCollapsed }"
1616 class =" brand-item gold"
2727 </div >
2828 <div class =" general-sponsors" >
2929 <div
30- v-for =" (brand, index) in generalSponsors "
31- v-show =" !isCollapsed || (isCollapsed && !brand.alt.includes('成为赞助商' ))"
30+ v-for =" (brand, index) in processedGeneralSponsors "
31+ v-show =" !isCollapsed || (isCollapsed && shouldShowSponsor(brand ))"
3232 :key =" 'general-' + index"
3333 :class =" { 'collapsed-mode': isCollapsed }"
3434 class =" brand-item"
4343 </span >
4444 </div >
4545 </div >
46- <div v-if =" isCollapsed && brandNum() < 9" class =" brand-item become-brand" @click =" openSponsorLink(sponsorUrl)" >
46+ <div
47+ v-if =" isCollapsed && shouldShowExtraBecomeSponsor"
48+ class =" brand-item become-brand"
49+ @click =" openSponsorLink(sponsorUrl)"
50+ >
4751 <span class =" brand-text" >成为赞助商</span >
4852 </div >
4953 </div >
5054</template >
5155
5256<script setup>
5357import { computed , onMounted , ref } from " vue" ;
54- import { generalSponsors , goldSponsors , sponsorUrl } from " ../data/sponsors" ;
58+ import {
59+ defaultSponsor ,
60+ generalSponsors ,
61+ goldSponsors ,
62+ openSponsorLink ,
63+ shouldShowSponsor ,
64+ sponsorUrl
65+ } from " ../data/sponsors" ;
5566
5667const isCollapsed = ref (false );
5768
69+ const processedGoldSponsors = computed (() => {
70+ return goldSponsors .map (brand => {
71+ return shouldShowSponsor (brand) ? brand : defaultSponsor;
72+ });
73+ });
74+
75+ const processedGeneralSponsors = computed (() => {
76+ return generalSponsors .map (brand => {
77+ return shouldShowSponsor (brand) ? brand : defaultSponsor;
78+ });
79+ });
80+
81+ const shouldShowExtraBecomeSponsor = computed (() => {
82+ return (goldSponsors .filter (brand => brand .link && shouldShowSponsor (brand)).length +
83+ generalSponsors .filter (brand => brand .link && shouldShowSponsor (brand)).length ) < 9 ;
84+ });
85+
5886const toggleCollapse = () => {
5987 isCollapsed .value = ! isCollapsed .value ;
6088 if (typeof window !== ' undefined' ) {
6189 localStorage .setItem (" sponsorCollapsed" , isCollapsed .value );
6290 }
6391};
6492
65- const openSponsorLink = (href ) => {
66- if (typeof window !== ' undefined' ) {
67- window .open (href, " _blank" );
68- }
69- };
70-
71- const brandNum = () => {
72- return goldSponsors .value .filter (item => item .link ? .trim () !== ' ' ).length +
73- generalSponsors .value .filter (item => item .link ? .trim () !== ' ' ).length ;
74- }
75-
7693onMounted (() => {
7794 if (typeof window !== ' undefined' ) {
7895 const savedState = localStorage .getItem (" sponsorCollapsed" );
@@ -81,7 +98,6 @@ onMounted(() => {
8198});
8299 </script >
83100
84-
85101<style scoped>
86102.brand-header {
87103 display : flex ;
0 commit comments