Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions src/pages/scanner/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -304,9 +304,16 @@ export function ScannerPage({ onScan, className }: ScannerPageProps) {

{/* Camera viewfinder */}
<div className="relative flex-1">
{(state === 'scanning' || state === 'success') && (
<video ref={videoRef} className="absolute inset-0 size-full object-cover" playsInline muted />
)}
{/* Video 始终渲染,避免 srcObject 设置时元素不存在的 race condition */}
<video
ref={videoRef}
className={cn(
'absolute inset-0 size-full object-cover',
state !== 'scanning' && state !== 'success' && 'invisible'
)}
playsInline
muted
/>

{/* Scan overlay */}
<div className="absolute inset-0 flex items-center justify-center">
Expand Down