This commit is contained in:
2026-07-17 19:30:47 +08:00
parent e264214b77
commit 4563b686e0
2 changed files with 22 additions and 20 deletions
+3 -5
View File
@@ -27,11 +27,9 @@
transition: opacity 0.6s ease;
}
/* 视频加载前占位 — 直接显示背景图,避免闪烁 */
.login-bg-poster {
background-image: url(/backimage.png);
background-size: cover;
background-position: center;
/* 视频加载前占位 — 纯色背景,不显示默认图 */
.login-bg-placeholder {
background: #1a1a2e;
}
.login-bg-overlay {
+19 -15
View File
@@ -529,21 +529,25 @@ const BackgroundVideo: React.FC<{ src: string; onReady: () => void }> = ({ src,
}
return (
<video
ref={vidRef}
className="login-bg-video"
style={{ opacity: ready ? 1 : 0 }}
autoPlay
loop
muted
playsInline
preload="auto"
onCanPlayThrough={handleReady}
onCanPlay={handleReady}
onError={handleReady}
>
<source src={src} type={src.endsWith('.webm') ? 'video/webm' : src.endsWith('.mov') ? 'video/quicktime' : 'video/mp4'} />
</video>
<>
{/* 视频加载前显示占位色,不显示默认背景图 */}
{!ready && <div className="login-bg-video login-bg-placeholder" />}
<video
ref={vidRef}
className="login-bg-video"
style={{ opacity: ready ? 1 : 0 }}
autoPlay
loop
muted
playsInline
preload="auto"
onCanPlayThrough={handleReady}
onCanPlay={handleReady}
onError={handleReady}
>
<source src={src} type={src.endsWith('.webm') ? 'video/webm' : src.endsWith('.mov') ? 'video/quicktime' : 'video/mp4'} />
</video>
</>
);
};