Improve camera drawer UX: layout, device switching, default selection

- Grid layout for source controls: camera + switch on top row (equal
  width), upload full-width below; preview area uses aspect-ratio 4/3
- "使用摄像头" no longer changes label text; uses is-active highlight only
- "切换摄像头" now actually cycles through real video devices via
  enumerateDevices(); falls back to facingMode flip on mobile/single-cam;
  button disabled until camera is active and ≥2 devices are detected
- Default-selects first sample image when drawer opens so "拍摄完成"
  is immediately pressable without requiring a capture/upload first
- Fix: camera prompt text is now locked to CAMERA_STATE_PROMPTS[state]
  and no longer overwritten by assistant replies

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Xin Wang
2026-06-02 10:43:18 +08:00
parent 6cf31c7062
commit 85baf5698e
3 changed files with 70 additions and 15 deletions

View File

@@ -136,7 +136,8 @@ body {
.camera-drawer__preview {
position: relative;
min-height: 210px;
aspect-ratio: 4 / 3;
min-height: 200px;
overflow: hidden;
border: 1px solid rgba(149, 160, 187, 0.28);
border-radius: 14px;
@@ -270,13 +271,12 @@ body {
}
.camera-drawer__sources {
display: flex;
flex-wrap: wrap;
display: grid;
grid-template-columns: 1fr 1fr;
gap: 8px;
}
.camera-drawer__source {
flex: 1 1 auto;
display: inline-flex;
align-items: center;
justify-content: center;
@@ -287,11 +287,21 @@ body {
cursor: pointer;
}
/* Upload spans the full width on its own row below camera + switch. */
.camera-drawer__source--upload {
grid-column: 1 / -1;
}
.camera-drawer__source.is-active {
border-color: var(--success);
color: var(--success);
}
.camera-drawer__source:disabled {
opacity: 0.5;
cursor: not-allowed;
}
.camera-drawer__samples {
display: grid;
grid-template-columns: repeat(4, 1fr);