fix: 第三轮修复 — 前端Session切换、DevTools UI刷新保持、头像背景替换

1. 修复前端清空对话无反应 (clearMainSessionMessages 链路)
2. 修复清除所有对话后侧边栏残留 + 重复新增按钮
3. 修复侧边栏点击无法切换会话 (Zustand 竞态 + URL hash)
4. 修复 URL 不显示 session ID (hash 同步链)
5. DevTools 会话监看刷新保持展开/折叠状态
6. 首页性能仪表盘去重 + 资源使用卡片 60s sparkline
7. DevTools 全局刷新改为 DOM 局部增量更新
8. 替换前端昔涟头像、聊天背景、用户头像为实际图片
9. 修复图片文件名 (双.png + 目录拼写)
This commit is contained in:
2026-05-17 20:32:42 +08:00
parent e7b7eff0d8
commit d00a8313ad
18 changed files with 799 additions and 343 deletions
@@ -1,12 +1,39 @@
import { useState } from 'react';
import { usePersonaStore } from '@/store/personaStore';
import type { CyreneForm } from '@/types/persona';
import type { CyreneForm, Mood } from '@/types/persona';
interface CyreneAvatarProps {
size?: 'sm' | 'md' | 'lg';
className?: string;
}
const FORM_AVATAR: Record<CyreneForm, string> = {
/**
* 根据昔涟形态和心情获取对应的头像图片路径。
*
* 图片目录结构:
* - 1st_Form/ (空 — 尚未收集,回退到 2nd_Form)
* - 2nd_Form/: Cyrene-2F-N-Happy-1.png, Cyrene-2F-N-Tangle-1.png
* - 3rd_Form/: Cyrene-3F-Q-Happy-1.png, Cyrene-3F-Q-Happy-2.png
*/
function getAvatarPath(form: CyreneForm, _mood: Mood): string {
const base = '/images/Cyrene_Avatar';
// de_moi_ge 形态使用 3rd_Form,其余形态(mimi/default)使用 2nd_Form
// 注意:1st_Form 目录为空,mimi 也回退到 2nd_Form
if (form === 'de_moi_ge') {
return `${base}/3rd_Form/Cyrene-3F-Q-Happy-1.png`;
}
// mimi / default 形态:happy 用 Happy 图,thoughtful/worried 用 Tangle 图
if (_mood === 'thoughtful' || _mood === 'worried') {
return `${base}/2nd_Form/Cyrene-2F-N-Tangle-1.png`;
}
return `${base}/2nd_Form/Cyrene-2F-N-Happy-1.png`;
}
/** 图片加载失败时的回退 emoji */
const FORM_FALLBACK_EMOJI: Record<CyreneForm, string> = {
mimi: '🌸',
default: '🌺',
de_moi_ge: '🌌',
@@ -18,18 +45,35 @@ const SIZE_CLASS = {
lg: 'w-20 h-20 text-4xl',
};
const FORM_LABEL: Record<CyreneForm, string> = {
mimi: '迷迷',
default: '小昔涟',
de_moi_ge: '德谬歌',
};
export function CyreneAvatar({ size = 'md', className = '' }: CyreneAvatarProps) {
const { currentForm } = usePersonaStore();
const emoji = FORM_AVATAR[currentForm] || '🌸';
const { currentForm, mood } = usePersonaStore();
const [imgError, setImgError] = useState(false);
const avatarSrc = getAvatarPath(currentForm, mood);
const fallbackEmoji = FORM_FALLBACK_EMOJI[currentForm] || '🌸';
return (
<div
className={`${SIZE_CLASS[size]} rounded-full bg-gradient-to-br from-pink-200 to-pink-400 dark:from-pink-800 dark:to-pink-600 flex items-center justify-center shadow-md ${className}`}
title={`昔涟 · ${currentForm === 'mimi' ? '迷迷' : currentForm === 'de_moi_ge' ? '德谬歌' : '小昔涟'}`}
className={`${SIZE_CLASS[size]} rounded-full bg-gradient-to-br from-pink-200 to-pink-400 dark:from-pink-800 dark:to-pink-600 flex items-center justify-center shadow-md overflow-hidden ${className}`}
title={`昔涟 · ${FORM_LABEL[currentForm]}`}
>
<span role="img" aria-label="昔涟">
{emoji}
</span>
{imgError ? (
<span role="img" aria-label="昔涟">
{fallbackEmoji}
</span>
) : (
<img
src={avatarSrc}
alt={`昔涟 · ${FORM_LABEL[currentForm]}`}
className="w-full h-full object-cover"
onError={() => setImgError(true)}
/>
)}
</div>
);
}