fix: 自建情景在聊天面板与系统消息中正确显示图标和名称
This commit is contained in:
@@ -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}
|
||||
|
||||
Reference in New Issue
Block a user