From 1c2c7bd06aa29478660c637b2f3d51adf34a733e Mon Sep 17 00:00:00 2001 From: sp mac bookpro 2605 Date: Sat, 6 Jun 2026 14:46:07 +0800 Subject: [PATCH] ui: refactor session sidebar styles and widen history drawer --- src/components/SessionSidebar.tsx | 112 +++++--------- src/pages/chat/components/ChatDrawers.tsx | 2 +- src/styles.css | 170 ++++++++++++++++++++++ 3 files changed, 208 insertions(+), 76 deletions(-) diff --git a/src/components/SessionSidebar.tsx b/src/components/SessionSidebar.tsx index 10f436d..f6fe302 100644 --- a/src/components/SessionSidebar.tsx +++ b/src/components/SessionSidebar.tsx @@ -67,6 +67,19 @@ export default function SessionSidebar({ agentId, activeSessionId, onChange, ref }; const list = tab === 'active' ? active : archived; + const styleVars = { + ['--ss-text' as any]: c.text, + ['--ss-text-dim' as any]: c.textDim, + ['--ss-text-active' as any]: c.textActive, + ['--ss-bg-active' as any]: c.bgActive, + ['--ss-border-active' as any]: c.borderActive, + ['--ss-bg-hover' as any]: c.bgHover, + ['--ss-bg-search' as any]: c.bgSearch, + ['--ss-input-bg' as any]: c.inputBg, + ['--ss-border' as any]: c.border, + ['--ss-danger' as any]: c.dangerText, + ['--ss-primary' as any]: c.primaryBtn ?? 'var(--color-brand)' + } as any; // 防抖搜索 useEffect(() => { @@ -165,16 +178,9 @@ export default function SessionSidebar({ agentId, activeSessionId, onChange, ref (editing ? null : onChange(s.id))} - style={{ - cursor: 'pointer', - padding: '8px 10px', - background: isActive ? c.bgActive : c.bgTransparent, - borderRadius: 6, - border: isActive ? `1px solid ${c.borderActive}` : '1px solid transparent', - marginBottom: 4 - }} + className={`session-sidebar-item${isActive ? ' active' : ''}`} > -
+
{editing ? ( ) : ( <> -
- 💬 {s.title} +
+ {s.title}
-
+
{s.lastPreview || '无消息'} · {dayjs(s.lastAt || s.updatedAt).format('MM-DD HH:mm')}
)}
{!editing && ( -
e.stopPropagation()}> +
e.stopPropagation()}> )} @@ -278,14 +266,13 @@ export default function SessionSidebar({ agentId, activeSessionId, onChange, ref allowClear value={searchQ} onChange={(e) => setSearchQ(e.target.value)} - style={{ marginBottom: 8 }} - styles={isDark ? { input: { background: c.inputBg, borderColor: c.border, color: c.text } } : undefined} + className="session-sidebar-search" /> {inSearchMode ? ( -
+
{searching ? ( -
+
) : searchHits.length === 0 && searchSessionTitles.length === 0 ? ( @@ -293,25 +280,17 @@ export default function SessionSidebar({ agentId, activeSessionId, onChange, ref ) : ( <> {searchSessionTitles.length > 0 && ( -
-
+
+
📁 会话标题命中 ({searchSessionTitles.length})
{searchSessionTitles.map((s) => (
onChange(s.id)} - style={{ - cursor: 'pointer', - padding: '6px 10px', - borderRadius: 6, - marginBottom: 2, - background: activeSessionId === s.id ? c.bgActive : c.bgSearch, - fontSize: 12, - color: c.text - }} + className={`session-sidebar-search-hit${activeSessionId === s.id ? ' active' : ''}`} > - 💬 {s.title} + {s.title} {s.archived && 归档}
))} @@ -319,7 +298,7 @@ export default function SessionSidebar({ agentId, activeSessionId, onChange, ref )} {searchHits.length > 0 && (
-
+
🔎 消息内容命中 ({searchHits.length})
{searchHits.map((h) => ( @@ -328,22 +307,15 @@ export default function SessionSidebar({ agentId, activeSessionId, onChange, ref onClick={() => onChange(h.sessionId, { highlightMessageId: h.id }) } - style={{ - cursor: 'pointer', - padding: 8, - borderRadius: 6, - marginBottom: 4, - background: c.bgSearch, - borderLeft: `3px solid ${h.role === 'user' ? '#6366f1' : '#10b981'}` - }} + className={`session-sidebar-search-msg-hit ${h.role === 'user' ? 'role-user' : 'role-assistant'}`} > -
+
{h.role === 'user' ? '我' : 'AI'} · {h.sessionTitle} {h.sessionArchived && 归档} {dayjs(h.createdAt).format('MM-DD HH:mm')}
@@ -364,7 +336,7 @@ export default function SessionSidebar({ agentId, activeSessionId, onChange, ref { value: 'active', label: ( - + 活跃 ({active.length}) ) @@ -372,13 +344,13 @@ export default function SessionSidebar({ agentId, activeSessionId, onChange, ref { value: 'archived', label: ( - + 归档 ({archived.length}) ) } ]} - style={{ marginBottom: 8 }} + className="session-sidebar-seg" /> {list.length === 0 ? ( @@ -386,22 +358,12 @@ export default function SessionSidebar({ agentId, activeSessionId, onChange, ref )} )} - - {/* 顶部全局样式 mark 标签高亮 */} -
); } diff --git a/src/pages/chat/components/ChatDrawers.tsx b/src/pages/chat/components/ChatDrawers.tsx index 1d5c2bc..05e8491 100644 --- a/src/pages/chat/components/ChatDrawers.tsx +++ b/src/pages/chat/components/ChatDrawers.tsx @@ -144,7 +144,7 @@ export default function ChatDrawers(props: { setHistoryDrawerOpen(false)} open={historyDrawerOpen} styles={{ body: { padding: 0 } }} diff --git a/src/styles.css b/src/styles.css index 1af5ae2..598e4b8 100644 --- a/src/styles.css +++ b/src/styles.css @@ -870,6 +870,176 @@ body { border-radius: 2px; } +.session-sidebar { + width: 420px; + height: 100%; + display: flex; + flex-direction: column; + padding: 0 4px; + box-sizing: border-box; +} + +.session-sidebar-new { + margin-bottom: 8px; + background: var(--ss-primary); + border: none; +} + +.session-sidebar-search { + margin-bottom: 8px; +} + +.session-sidebar .ant-input-affix-wrapper, +.session-sidebar .ant-input-affix-wrapper:hover, +.session-sidebar .ant-input-affix-wrapper-focused { + background: var(--ss-input-bg); + border-color: var(--ss-border); +} + +.session-sidebar .ant-input { + color: var(--ss-text); +} + +.session-sidebar-scroll { + flex: 1; + overflow: auto; +} + +.session-sidebar-loading { + padding: 16px; + text-align: center; +} + +.session-sidebar-search-section { + margin-bottom: 8px; +} + +.session-sidebar-search-section-title { + font-size: 11px; + color: var(--ss-text-dim); + padding: 4px 8px; +} + +.session-sidebar-search-hit { + cursor: pointer; + padding: 6px 10px; + border-radius: 6px; + margin-bottom: 2px; + background: var(--ss-bg-search); + font-size: 12px; + color: var(--ss-text); +} + +.session-sidebar-search-hit.active { + background: var(--ss-bg-active); +} + +.session-sidebar-search-msg-hit { + cursor: pointer; + padding: 8px; + border-radius: 6px; + margin-bottom: 4px; + background: var(--ss-bg-search); + border-left: 3px solid transparent; +} + +.session-sidebar-search-msg-hit.role-user { + border-left-color: #6366f1; +} + +.session-sidebar-search-msg-hit.role-assistant { + border-left-color: #10b981; +} + +.session-sidebar-search-msg-meta { + font-size: 11px; + color: var(--ss-text-dim); + margin-bottom: 2px; +} + +.session-sidebar-search-msg-snippet { + font-size: 12px; + color: var(--ss-text); + line-height: 1.4; +} + +.session-sidebar-seg { + margin-bottom: 8px; +} + +.session-sidebar-seg-label { + display: inline-flex; + align-items: center; + gap: 6px; +} + +.session-sidebar-list { + flex: 1; + overflow: auto; +} + +.session-sidebar-item { + cursor: pointer; + padding: 8px 10px; + background: transparent; + border-radius: 6px; + border: 1px solid transparent; + margin-bottom: 4px; +} + +.session-sidebar-item:hover { + background: var(--ss-bg-hover); +} + +.session-sidebar-item.active { + background: var(--ss-bg-active); + border-color: var(--ss-border-active); +} + +.session-sidebar-item-main { + flex: 1; + min-width: 0; +} + +.session-sidebar-item-title { + font-size: 13px; + font-weight: 500; + color: var(--ss-text); + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + display: inline-flex; + align-items: center; + gap: 6px; +} + +.session-sidebar-item-title.active { + font-weight: 600; + color: var(--ss-text-active); +} + +.session-sidebar-item-subtitle { + font-size: 11px; + color: var(--ss-text-dim); + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + margin-top: 2px; +} + +.session-sidebar-item-actions { + display: flex; + gap: 2px; + margin-left: 6px; +} + +.session-sidebar mark { + background: #fef3c7; + color: #b45309; + padding: 0 2px; + border-radius: 2px; +} + .chat-disclaimer { text-align: center; font-size: 11px;