feat(components): 添加图片骨架屏组件并优化卡片加载体验

实现图片加载时的骨架屏效果,支持暗色模式
在AggregateCard、VideoCard和DemoCard中应用骨架屏
优化图片加载动画和状态管理
This commit is contained in:
SongPro
2025-07-03 22:05:54 +08:00
parent 92323fcb69
commit b30589628a
4 changed files with 96 additions and 16 deletions

View File

@@ -0,0 +1,40 @@
// 图片占位符组件 - 实现骨架屏效果(支持暗色模式)
const ImagePlaceholder = ({ aspectRatio }: { aspectRatio: string }) => (
<div
className={`w-full ${aspectRatio} rounded-md overflow-hidden`}
style={{
background:
'linear-gradient(90deg, var(--skeleton-color) 25%, var(--skeleton-highlight) 50%, var(--skeleton-color) 75%)',
backgroundSize: '200% 100%',
animation: 'shine 1.5s infinite',
}}
>
<style>{`
@keyframes shine {
0% { background-position: -200% 0; }
100% { background-position: 200% 0; }
}
/* 亮色模式变量 */
:root {
--skeleton-color: #f0f0f0;
--skeleton-highlight: #e0e0e0;
}
/* 暗色模式变量 */
@media (prefers-color-scheme: dark) {
:root {
--skeleton-color: #2d2d2d;
--skeleton-highlight: #3d3d3d;
}
}
.dark {
--skeleton-color: #2d2d2d;
--skeleton-highlight: #3d3d3d;
}
`}</style>
</div>
);
export { ImagePlaceholder };