refactor: 重构视频面板 UI,情景选择改为卡片网格,控制按钮改为 SVG 图标

- 情景选择从 ChatPanel header 下拉菜单迁移至视频面板下方卡片网格
- 摄像头/麦克风按钮改为圆形 SVG 图标按钮
- 识别/中断/停止按钮改为药丸形状 SVG 图标按钮
- 设备选择器改为水平布局,优化空间利用
- 移除 ChatPanel 空状态中重复的情景卡片
- .gitignore 忽略 .claudian/ 和笔记目录
This commit is contained in:
2026-06-21 22:58:02 +08:00
parent 492fb06c08
commit 949a707e0f
4 changed files with 306 additions and 58 deletions

4
.gitignore vendored
View File

@@ -24,4 +24,6 @@ Thumbs.db
# ---- Obsidian ----
.obsidian/
.claudian/sessions/conv-1781943335504-q62bzosye.meta.json
.claudian/
修改过程笔记/
学习复盘/

View File

@@ -495,7 +495,10 @@ body {
display: flex;
flex-direction: column;
padding: 16px 20px;
gap: 10px;
gap: 12px;
overflow-y: auto;
scrollbar-width: thin;
scrollbar-color: var(--color-border) transparent;
}
.video-container {
@@ -652,7 +655,7 @@ body {
flex-direction: column;
align-items: center;
gap: 10px;
padding: 8px 0;
padding: 10px 0 4px;
}
.video-controls__row {
@@ -1387,11 +1390,228 @@ body {
.video-controls__toolbar {
display: flex;
gap: 6px;
gap: 8px;
flex-wrap: wrap;
justify-content: center;
align-items: center;
}
/* ---- Round Control Buttons (Camera / Mic) ---- */
.btn-ctrl-round {
width: 44px;
height: 44px;
border-radius: 50%;
border: 2px solid var(--color-border);
background: var(--color-surface-2);
color: var(--color-text-muted);
cursor: pointer;
display: inline-flex;
align-items: center;
justify-content: center;
transition: all var(--transition-fast);
flex-shrink: 0;
position: relative;
}
.btn-ctrl-round:hover {
background: var(--color-surface-3);
border-color: var(--color-surface-3);
color: var(--color-text);
transform: scale(1.06);
}
.btn-ctrl-round:active {
transform: scale(0.95);
}
.btn-ctrl-round--on {
background: rgba(52, 211, 153, 0.1);
border-color: rgba(52, 211, 153, 0.3);
color: var(--color-success);
}
.btn-ctrl-round--on:hover {
background: rgba(52, 211, 153, 0.18);
border-color: rgba(52, 211, 153, 0.45);
}
.btn-ctrl-round--off {
background: rgba(248, 113, 113, 0.08);
border-color: rgba(248, 113, 113, 0.2);
color: var(--color-error);
}
.btn-ctrl-round--off:hover {
background: rgba(248, 113, 113, 0.15);
border-color: rgba(248, 113, 113, 0.35);
}
.btn-ctrl-round--speaking {
animation: micPulse 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) infinite;
box-shadow: 0 0 14px rgba(52, 211, 153, 0.45);
}
/* ---- Pill Control Buttons (Recognize / Interrupt / Stop) ---- */
.btn-ctrl-pill {
padding: 8px 16px;
border-radius: 22px;
font-size: 0.78rem;
font-weight: 500;
cursor: pointer;
transition: all var(--transition-fast);
display: inline-flex;
align-items: center;
gap: 5px;
border: 1px solid var(--color-border);
background: var(--color-surface-2);
color: var(--color-text-muted);
white-space: nowrap;
}
.btn-ctrl-pill:hover:not(:disabled) {
background: var(--color-surface-3);
color: var(--color-text);
border-color: var(--color-surface-3);
}
.btn-ctrl-pill:active:not(:disabled) {
transform: translateY(1px);
}
.btn-ctrl-pill:disabled {
opacity: 0.5;
cursor: not-allowed;
}
.btn-ctrl-pill--recognize {
background: rgba(59, 130, 246, 0.1);
color: var(--color-primary);
border-color: rgba(59, 130, 246, 0.25);
}
.btn-ctrl-pill--recognize:hover:not(:disabled) {
background: rgba(59, 130, 246, 0.2);
border-color: rgba(59, 130, 246, 0.4);
}
.btn-ctrl-pill--interrupt {
background: rgba(251, 191, 36, 0.1);
color: var(--color-warning);
border-color: rgba(251, 191, 36, 0.25);
}
.btn-ctrl-pill--interrupt:hover:not(:disabled) {
background: rgba(251, 191, 36, 0.2);
border-color: rgba(251, 191, 36, 0.4);
}
.btn-ctrl-pill--stop {
background: rgba(248, 113, 113, 0.1);
color: var(--color-error);
border-color: rgba(248, 113, 113, 0.2);
}
.btn-ctrl-pill--stop:hover:not(:disabled) {
background: rgba(248, 113, 113, 0.18);
border-color: rgba(248, 113, 113, 0.35);
}
/* ---- Scenario Picker Grid (video panel) ---- */
.scenario-picker {
display: flex;
flex-direction: column;
gap: 8px;
}
.scenario-picker__title {
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 2px;
}
.scenario-picker__label {
font-size: 0.65rem;
font-weight: 600;
text-transform: uppercase;
letter-spacing: 0.08em;
color: var(--color-text-muted);
opacity: 0.7;
}
.scenario-picker__active {
font-size: 0.7rem;
color: var(--color-primary);
font-weight: 500;
}
.scenario-picker__grid {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 6px;
}
.scenario-picker__card {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 4px;
padding: 10px 4px;
border-radius: var(--radius-sm);
border: 1px solid var(--color-border);
background: var(--color-surface-2);
color: var(--color-text-muted);
cursor: pointer;
transition: all var(--transition-fast);
text-align: center;
min-width: 0;
}
.scenario-picker__card:hover {
background: var(--color-surface-3);
border-color: var(--color-surface-3);
color: var(--color-text);
transform: translateY(-1px);
box-shadow: 0 2px 8px rgba(10, 10, 15, 0.15);
}
.scenario-picker__card:active {
transform: translateY(0);
}
.scenario-picker__card--active {
background: rgba(59, 130, 246, 0.08);
border-color: rgba(59, 130, 246, 0.35);
color: var(--color-primary);
}
.scenario-picker__card--active:hover {
background: rgba(59, 130, 246, 0.14);
border-color: rgba(59, 130, 246, 0.45);
color: var(--color-primary);
}
.scenario-picker__card-icon {
font-size: 1.3rem;
line-height: 1;
}
.scenario-picker__card-name {
font-size: 0.68rem;
font-weight: 500;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
max-width: 100%;
letter-spacing: 0.01em;
}
/* ---- Legacy button styles kept for backward compat ---- */
.btn--recognize {
background: rgba(59, 130, 246, 0.1);
color: var(--color-primary);
@@ -1416,35 +1636,37 @@ body {
/* Device selectors */
.video-controls__devices {
display: flex;
gap: 12px;
gap: 8px;
justify-content: center;
width: 100%;
}
.device-select-wrapper {
display: flex;
flex-direction: column;
gap: 4px;
align-items: center;
gap: 6px;
flex: 1;
min-width: 0;
}
.device-select-label {
font-size: 0.65rem;
font-size: 0.72rem;
color: var(--color-text-muted);
font-weight: 500;
letter-spacing: 0.01em;
flex-shrink: 0;
}
.device-select {
padding: 5px 10px;
font-size: 0.72rem;
border-radius: var(--radius-sm);
flex: 1;
min-width: 0;
padding: 5px 8px;
font-size: 0.7rem;
border-radius: 6px;
border: 1px solid var(--color-border);
background: var(--color-surface-2);
color: var(--color-text-muted);
cursor: pointer;
transition: all var(--transition-fast);
min-width: 120px;
text-align: center;
text-overflow: ellipsis;
}
.device-select:hover {

View File

@@ -401,6 +401,27 @@ function AppContent() {
)}
</div>
{/* ---- 情景选择卡片网格(视频下方) ---- */}
<div className="scenario-picker">
<div className="scenario-picker__title">
<span className="scenario-picker__label">{tr("settings.scenario")}</span>
<span className="scenario-picker__active">{activeScenario.icon} {activeScenario.nameKey ? tr(activeScenario.nameKey) : activeScenario.name}</span>
</div>
<div className="scenario-picker__grid">
{allScenarios.map((sc) => (
<button
key={sc.id}
className={`scenario-picker__card ${config.scenario === sc.id ? "scenario-picker__card--active" : ""}`}
onClick={() => handleSelectScenario(sc.id)}
title={sc.description ? sc.description : sc.descKey ? tr(sc.descKey) : sc.name}
>
<span className="scenario-picker__card-icon">{sc.icon}</span>
<span className="scenario-picker__card-name">{sc.nameKey ? tr(sc.nameKey) : sc.name}</span>
</button>
))}
</div>
</div>
{/* 视频下方控制区(三层结构) */}
<div className="video-controls">
{!isConnected ? (
@@ -415,33 +436,68 @@ function AppContent() {
{/* 视频通话态:核心控制工具栏 */}
<div className="video-controls__toolbar">
<button
className={`btn btn--ctrl ${isCameraOn ? "btn--ctrl-on" : "btn--ctrl-off"}`}
className={`btn-ctrl-round ${isCameraOn ? "btn-ctrl-round--on" : "btn-ctrl-round--off"}`}
onClick={toggleCamera}
title={isCameraOn ? tr("controls.cameraOff") : tr("controls.cameraOn")}
>
📷
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
{isCameraOn ? (
<>
<path d="M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z" />
<circle cx="12" cy="13" r="4" />
</>
) : (
<>
<path d="M16 16v1a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V7a2 2 0 0 1 2-2h2m5.66 0H14a2 2 0 0 1 2 2v3.34l1 1L23 7v10" />
<line x1="1" y1="1" x2="23" y2="23" />
</>
)}
</svg>
</button>
<button
className={`btn btn--ctrl ${isMicOn ? "btn--ctrl-on" : "btn--ctrl-off"} ${isSpeaking ? "btn--speaking" : ""}`}
className={`btn-ctrl-round ${isMicOn ? "btn-ctrl-round--on" : "btn-ctrl-round--off"} ${isSpeaking ? "btn-ctrl-round--speaking" : ""}`}
onClick={toggleMic}
title={isMicOn ? tr("controls.micOff") : tr("controls.micOn")}
>
🎤
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
{isMicOn ? (
<>
<path d="M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z" />
<path d="M19 10v2a7 7 0 0 1-14 0v-2" />
<line x1="12" y1="19" x2="12" y2="23" />
<line x1="8" y1="23" x2="16" y2="23" />
</>
) : (
<>
<line x1="1" y1="1" x2="23" y2="23" />
<path d="M9 9v3a3 3 0 0 0 5.12 2.12M15 9.34V4a3 3 0 0 0-5.94-.6" />
<path d="M17 16.95A7 7 0 0 1 5 12v-2m14 0v2c0 .76-.12 1.49-.34 2.17" />
<line x1="12" y1="19" x2="12" y2="23" />
<line x1="8" y1="23" x2="16" y2="23" />
</>
)}
</svg>
</button>
{/* 识别画面按钮 */}
<button
className="btn--recognize"
className="btn-ctrl-pill btn-ctrl-pill--recognize"
onClick={handleRecognize}
disabled={isProcessing}
>
🔍 {tr("controls.recognize")}
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
<circle cx="11" cy="11" r="8" />
<line x1="21" y1="21" x2="16.65" y2="16.65" />
</svg>
{tr("controls.recognize")}
</button>
{isProcessing && (
<button className="btn btn--warning" onClick={interrupt}>
<button className="btn-ctrl-pill btn-ctrl-pill--interrupt" onClick={interrupt}>
{tr("controls.interrupt")}
</button>
)}
<button className="btn btn--danger" onClick={stopVideo}>
<button className="btn-ctrl-pill btn-ctrl-pill--stop" onClick={stopVideo}>
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
<rect x="6" y="6" width="12" height="12" rx="2" />
</svg>
{tr("controls.stopVideo")}
</button>
</div>
@@ -502,18 +558,6 @@ function AppContent() {
<div className="chat-panel-header">
<span>{tr("chat.title")}</span>
<div className="chat-panel-header__right">
<select
className="scenario-selector"
value={activeScenario.id}
onChange={(e) => handleSelectScenario(e.target.value)}
title={tr("settings.scenario")}
>
{allScenarios.map((sc) => (
<option key={sc.id} value={sc.id}>
{sc.icon} {sc.nameKey ? tr(sc.nameKey) : sc.name}
</option>
))}
</select>
{isConnected && stats.queryCount > 0 && (
<span className="chat-panel-header__stats">
{stats.queryCount} {tr("statusbar.recognitions")}

View File

@@ -121,34 +121,14 @@ export function ChatPanel({
</div>
)}
{/* 空状态:情景选择 + 场景卡片 */}
{/* 空状态:欢迎信息 */}
{isEmpty && (
<div className="chat-panel__welcome">
<span className="chat-panel__welcome-icon">{scenarios.find(s => s.id === activeScenario)?.icon || "💬"}</span>
<p>{isConnected ? t("chat.welcome.prompt") : t("chat.empty.prompt")}</p>
<span className="chat-panel__welcome-hint">{isConnected ? t("chat.welcome.hint") : t("chat.empty.hint")}</span>
{/* 情景选择卡片( free_chat 时隐藏,因为已通过 header 切换 */}
{isFreeChat && onSelectScenario && (
<div className="scenario-cards">
<div className="scenario-cards__title">{t("scenario.choose")}</div>
{scenarios.filter(s => s.id !== "free_chat").map((sc) => (
<button
key={sc.id}
className="scenario-card"
onClick={() => onSelectScenario(sc.id)}
>
<span className="scenario-card__icon">{sc.icon}</span>
<div className="scenario-card__text">
<span className="scenario-card__title">{t(sc.nameKey)}</span>
<span className="scenario-card__desc">{t(sc.descKey)}</span>
</div>
</button>
))}
</div>
)}
{/* 视觉分析快捷卡片(仅 free_chat 模式) */}
{/* 视觉分析快捷卡片( free_chat 模式 + 已连接 */}
{isFreeChat && isConnected && (
<div className="scene-cards">
{sceneCards.map((card) => (