@@ -133,8 +133,29 @@ const componentCards = computed<ShowCard[]>(() => {
133133
134134 <n-image-group show-toolbar-tooltip show-toolbar >
135135 <n-space size =" small" align =" center" >
136- <n-image lazy :preview-src =" resolveImage(img)" width =" 200" v-for =" img in componentCard.images"
137- :src =" resolveImage(img)" />
136+ <div v-for =" img in componentCard.images" class =" theme-image-container" :key =" typeof img === 'string' ? img : img.light" >
137+ <!-- 如果是字符串图片(无主题变化),直接显示 -->
138+ <n-image v-if =" typeof img === 'string'" lazy :preview-src =" img" width =" 200" :src =" img" />
139+ <!-- 如果是主题图片对象,显示带过渡效果的双图片 -->
140+ <div v-else class =" theme-image-wrapper" >
141+ <n-image
142+ lazy
143+ :preview-src =" img.light"
144+ width =" 200"
145+ :src =" img.light"
146+ class =" theme-image light-image"
147+ :class =" { 'active': !themeActive }"
148+ />
149+ <n-image
150+ lazy
151+ :preview-src =" img.dark"
152+ width =" 200"
153+ :src =" img.dark"
154+ class =" theme-image dark-image"
155+ :class =" { 'active': themeActive }"
156+ />
157+ </div >
158+ </div >
138159 </n-space >
139160 </n-image-group >
140161
@@ -346,7 +367,7 @@ const componentCards = computed<ShowCard[]>(() => {
346367
347368:deep(.n-image img ) {
348369 border-radius : var (--border-radius-lg );
349- transition : transform var (--transition-normal );
370+ transition : transform var (--transition-normal ), opacity var ( --transition-normal ) ;
350371}
351372
352373/* ==================== 按钮样式 ==================== */
@@ -594,4 +615,55 @@ const componentCards = computed<ShowCard[]>(() => {
594615 background-position : 200% 0 ;
595616 }
596617}
618+
619+ /* ==================== 主题图片过渡效果 ==================== */
620+
621+ /* *
622+ * 主题图片容器样式
623+ * 支持主题切换的图片容器
624+ */
625+ .theme-image-container {
626+ display : inline-block ;
627+ position : relative ;
628+ }
629+
630+ /* *
631+ * 主题图片包装器样式
632+ * 用于叠加显示明暗主题图片
633+ */
634+ .theme-image-wrapper {
635+ position : relative ;
636+ display : inline-block ;
637+ width : 200px ;
638+ height : auto ;
639+ }
640+
641+ /* *
642+ * 主题图片样式
643+ * 明暗主题图片的基础样式和过渡效果
644+ */
645+ :deep(.theme-image ) {
646+ position : absolute ;
647+ top : 0 ;
648+ left : 0 ;
649+ opacity : 0 ;
650+ transition : opacity 0.6s ease-in-out ;
651+ width : 100% ;
652+ height : 100% ;
653+ }
654+
655+ /* *
656+ * 第一个主题图片(用于确定容器尺寸)
657+ */
658+ :deep(.theme-image :first-child ) {
659+ position : relative ;
660+ }
661+
662+ /* *
663+ * 激活状态的主题图片
664+ * 显示当前主题对应的图片
665+ */
666+ :deep(.theme-image.active ) {
667+ opacity : 1 ;
668+ }
597669 </style >
0 commit comments