styles:美化样式 #207
@@ -21,6 +21,15 @@ import { loadConfig, loadTheme, saveTheme } from "./lib/storage";
|
||||
import { I18nContext, parseLocale, t } from "./lib/i18n";
|
||||
import { renderScenarioIconById } from "./lib/scenarioIcons";
|
||||
import type { Locale } from "./lib/i18n";
|
||||
|
||||
/** SVG 图标 ID → emoji 映射(用于纯文本场景,如系统消息) */
|
||||
const ICON_ID_TO_EMOJI: Record<string, string> = {
|
||||
sparkles: "✨", theater: "🎭", palette: "🎨", target: "🎯", film: "🎬",
|
||||
"book-open": "📖", book: "📚", edit: "✏️", clipboard: "📋", "map-pin": "📍",
|
||||
search: "🔍", lightbulb: "💡", briefcase: "💼", code: "💻", "graduation-cap": "🎓",
|
||||
mic: "🎤", music: "🎵", globe: "🌐", heart: "❤️", shield: "🛡️",
|
||||
zap: "⚡", coffee: "☕", tool: "🔧", "message-circle": "💬",
|
||||
};
|
||||
import type { Theme } from "./types";
|
||||
import type { UserScenario } from "./lib/api/scenarios";
|
||||
import "./App.css";
|
||||
@@ -228,10 +237,14 @@ function AppContent() {
|
||||
}
|
||||
}
|
||||
updateConfig(updates);
|
||||
// 插入系统提示消息
|
||||
const scenarioName = sc
|
||||
? `${sc.icon} ${sc.nameKey ? tr(sc.nameKey) : sc.name}`
|
||||
// 插入系统提示消息(自建情景的 icon 是 SVG ID,需转为 emoji)
|
||||
const iconText = sc
|
||||
? (ICON_ID_TO_EMOJI[sc.icon] || sc.icon)
|
||||
: "";
|
||||
const displayName = sc
|
||||
? (sc.nameKey ? tr(sc.nameKey) : sc.name)
|
||||
: scenarioId;
|
||||
const scenarioName = iconText ? `${iconText} ${displayName}` : displayName;
|
||||
setMessages(prev => [...prev, {
|
||||
id: uuidv4(),
|
||||
role: "system",
|
||||
@@ -607,6 +620,7 @@ function AppContent() {
|
||||
currentReply={currentReply}
|
||||
connectionStatus={connectionStatus}
|
||||
currentScenario={config.scenario}
|
||||
allScenarios={allScenarios}
|
||||
isProcessing={isProcessing}
|
||||
isVADReady={isVADReady}
|
||||
vadError={vadError ?? undefined}
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
import { useEffect, useRef, useState, type ReactNode } from "react";
|
||||
import { useI18n } from "../../lib/i18n";
|
||||
import { scenarios } from "../../lib/scenarios";
|
||||
import type { ExtendedScenario } from "../../hooks/useScenarios";
|
||||
import type { ChatMessage } from "../../types";
|
||||
import type { ConnectionStatus } from "../../lib/websocket";
|
||||
|
||||
@@ -15,6 +16,7 @@ interface ChatPanelProps {
|
||||
currentReply?: string;
|
||||
connectionStatus: ConnectionStatus;
|
||||
currentScenario?: string;
|
||||
allScenarios?: ExtendedScenario[];
|
||||
isProcessing?: boolean;
|
||||
isVADReady?: boolean;
|
||||
vadError?: string | null;
|
||||
@@ -43,6 +45,7 @@ export function ChatPanel({
|
||||
currentReply,
|
||||
connectionStatus,
|
||||
currentScenario,
|
||||
allScenarios,
|
||||
isProcessing,
|
||||
isVADReady,
|
||||
vadError,
|
||||
@@ -103,6 +106,10 @@ export function ChatPanel({
|
||||
}
|
||||
};
|
||||
|
||||
// 当前情景对象(优先从 allScenarios 查找,含自建情景;兜底用系统情景)
|
||||
const scenarioList = allScenarios || scenarios;
|
||||
const activeScenarioObj = scenarioList.find(sc => sc.id === activeScenario);
|
||||
|
||||
return (
|
||||
<div className="chat-panel">
|
||||
<div className="chat-panel__messages" ref={containerRef}>
|
||||
@@ -111,11 +118,13 @@ export function ChatPanel({
|
||||
<div className="chat-panel__scenario-hint">
|
||||
<div className="scenario-hint-card">
|
||||
<span className="scenario-hint-card__icon">
|
||||
{scenarios.find(s => s.id === activeScenario)?.icon}
|
||||
{activeScenarioObj?.icon}
|
||||
</span>
|
||||
<div className="scenario-hint-card__text">
|
||||
<strong>{t(scenarios.find(s => s.id === activeScenario)?.nameKey || "")}</strong>
|
||||
<p>{t(`scenario.${activeScenario}.hint`)}</p>
|
||||
<strong>{activeScenarioObj ? (activeScenarioObj.nameKey ? t(activeScenarioObj.nameKey) : activeScenarioObj.name) : ""}</strong>
|
||||
{activeScenarioObj && (activeScenarioObj.descKey || activeScenarioObj.description) && (
|
||||
<p>{activeScenarioObj.descKey ? t(activeScenarioObj.descKey) : activeScenarioObj.description}</p>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -124,7 +133,7 @@ export function ChatPanel({
|
||||
{/* 空状态:欢迎信息 */}
|
||||
{isEmpty && (
|
||||
<div className="chat-panel__welcome">
|
||||
<span className="chat-panel__welcome-icon">{scenarios.find(s => s.id === activeScenario)?.icon || <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.2" strokeLinecap="round" strokeLinejoin="round"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/></svg>}</span>
|
||||
<span className="chat-panel__welcome-icon">{activeScenarioObj?.icon || <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.2" strokeLinecap="round" strokeLinejoin="round"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/></svg>}</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>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user