重构: AiChat 样式同步到子组件 scoped + 复用抽取(God 拆分遗漏修复)
根因:AiChat God 拆分(抽 ConversationSidebar/ChatInput/MessageList)时样式没移子组件, 留 AiChat <style scoped>。Vue scoped 不匹配子组件内部元素(子元素无父 data-v)→ 对话列表/输入框样式丢失 → 布局塌陷(主导航被覆盖点击无反应 + 样式乱)。 修复(纯样式移动,不改选择器/属性/值): - AiChat <style scoped> 886→151 行(瘦身 83%) - 侧栏 .ai-conv-* 47 选择器 → ConversationSidebar <style scoped>(新建) - 输入框 .ai-input-*/.ai-skill-*/.ai-mention-*/.ai-send-btn 40 → ChatInput <style scoped>(新建) - 复用 .ai-btn-icon* 6 处 → components.css(全局,TopBar+ConversationSidebar 共用) - 容器 .ai-panel/.ai-chat-area/.ai-queue-*/.ai-toast* 32 → AiChat 保留 scoped - 清理 TopBar 重复块(AiChat 漏删死代码,零视觉变更)+ 删 TEMP DEBUG 参考线 自验: vite build ✓ + vue-tsc EXIT 0 + AiChat scoped CLEAN(0 子组件类)
This commit is contained in:
@@ -463,3 +463,311 @@ defineExpose({
|
||||
focusSearch,
|
||||
})
|
||||
</script>
|
||||
|
||||
<!-- ═══ ConversationSidebar scoped 样式(第一批抽离遗漏修复: 从 AiChat.vue <style scoped> 迁移,
|
||||
零视觉变更。原 AiChat scoped 不渗透子组件根,导致侧栏元素失配 → 本组件自持样式。
|
||||
CSS 变量(--df-*)由根级 global.css 提供,共享同一份。.ai-btn-icon 共享按钮抽 components.css 全局。) ═══ -->
|
||||
<style scoped>
|
||||
/* ═══ 对话侧边栏 ═══ */
|
||||
/* 宽度由 CSS 变量驱动(UX-2025-16 拖拽)::style 绑 --sidebar-width,不直接绑 width,
|
||||
这样 sidebar-slide 过渡的 width:0(enter-from/leave-to)能正常覆盖,折叠/展开动画不破 */
|
||||
.ai-conv-sidebar {
|
||||
position: relative;
|
||||
width: var(--sidebar-width, 200px);
|
||||
min-width: var(--sidebar-width, 200px);
|
||||
border-right: 0.5px solid var(--df-border);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
background: var(--df-bg);
|
||||
}
|
||||
/* UX-2025-16:右边缘 2px 拖拽条。hover/active 显高亮;拖拽中 body.ai-sidebar-resizing 全局锁 cursor 防抖 */
|
||||
.ai-sidebar-resize-handle {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: -1px; /* 跨过 0.5px border-right,确保命中区不被 border 遮挡 */
|
||||
width: 4px; /* 命中区 4px(视觉 2px 由 background 控制),易抓取 */
|
||||
height: 100%;
|
||||
cursor: col-resize;
|
||||
z-index: 5;
|
||||
background: transparent;
|
||||
transition: background 0.15s var(--df-ease);
|
||||
}
|
||||
.ai-sidebar-resize-handle:hover {
|
||||
background: var(--df-accent, #4f8cff);
|
||||
opacity: 0.5;
|
||||
}
|
||||
/* 拖拽中全局锁 cursor + 禁选中文本(挂在 body 上,跨元素生效) */
|
||||
body.ai-sidebar-resizing,
|
||||
body.ai-sidebar-resizing * {
|
||||
cursor: col-resize !important;
|
||||
user-select: none !important;
|
||||
}
|
||||
.ai-conv-sidebar-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 10px 10px;
|
||||
border-bottom: 0.5px solid var(--df-border);
|
||||
}
|
||||
.ai-conv-sidebar-title {
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
color: var(--df-text);
|
||||
}
|
||||
|
||||
/* UX-06 §3.1: 对话搜索框(紧贴 header 下,样式跟随周围输入控件) */
|
||||
.ai-conv-search {
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 6px 10px;
|
||||
border-bottom: 0.5px solid var(--df-border);
|
||||
}
|
||||
.ai-conv-search-icon {
|
||||
flex: none;
|
||||
color: var(--df-text-dim);
|
||||
margin-right: 6px;
|
||||
}
|
||||
.ai-conv-search-input {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
border: none;
|
||||
outline: none;
|
||||
background: transparent;
|
||||
font-size: 12px;
|
||||
color: var(--df-text);
|
||||
}
|
||||
.ai-conv-search-input::placeholder {
|
||||
color: var(--df-text-dim);
|
||||
}
|
||||
.ai-conv-search-kbd {
|
||||
flex: none;
|
||||
font-family: inherit;
|
||||
font-size: 10px;
|
||||
color: var(--df-text-dim);
|
||||
border: 0.5px solid var(--df-border);
|
||||
border-radius: 3px;
|
||||
padding: 0 4px;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.ai-conv-list {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
padding: 4px;
|
||||
}
|
||||
.ai-conv-group-title {
|
||||
padding: 8px 8px 3px;
|
||||
font-size: 10px;
|
||||
font-weight: 600;
|
||||
color: var(--df-text-dim);
|
||||
user-select: none;
|
||||
}
|
||||
.ai-conv-group-title--fold {
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 3px;
|
||||
}
|
||||
.ai-conv-group-title--fold:hover {
|
||||
color: var(--df-text);
|
||||
}
|
||||
.ai-conv-group-arrow {
|
||||
display: inline-block;
|
||||
transition: transform 0.15s;
|
||||
font-size: 9px;
|
||||
}
|
||||
.ai-conv-group-arrow.is-folded {
|
||||
transform: rotate(0deg);
|
||||
}
|
||||
.ai-conv-group-arrow:not(.is-folded) {
|
||||
transform: rotate(90deg);
|
||||
}
|
||||
.ai-conv-group-count {
|
||||
margin-left: 2px;
|
||||
font-weight: 400;
|
||||
opacity: 0.7;
|
||||
}
|
||||
.ai-conv-group-empty {
|
||||
padding: 2px 8px 4px 20px;
|
||||
font-size: 10px;
|
||||
color: var(--df-text-dim);
|
||||
font-style: italic;
|
||||
}
|
||||
.ai-conv-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 6px 8px;
|
||||
border-radius: var(--df-radius);
|
||||
cursor: pointer;
|
||||
transition: background 0.15s;
|
||||
gap: 4px;
|
||||
}
|
||||
.ai-conv-item:hover {
|
||||
background: var(--df-sidebar-hover);
|
||||
}
|
||||
.ai-conv-item--active {
|
||||
background: var(--df-sidebar-active);
|
||||
}
|
||||
.ai-conv-item--archived .ai-conv-item-title {
|
||||
opacity: 0.6;
|
||||
}
|
||||
.ai-conv-item-main {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
}
|
||||
.ai-conv-item-title {
|
||||
font-size: 11px;
|
||||
color: var(--df-text);
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
cursor: pointer;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 3px;
|
||||
min-width: 0;
|
||||
}
|
||||
/* UX-2025-20 §7.4: AI 生成标题淡入(0.3s opacity + transform 过渡) */
|
||||
.ai-conv-item-title--flash {
|
||||
animation: ai-title-flash 0.3s var(--df-ease);
|
||||
}
|
||||
.ai-conv-item-title-badge {
|
||||
flex-shrink: 0;
|
||||
color: var(--df-success);
|
||||
}
|
||||
@keyframes ai-title-flash {
|
||||
from { opacity: 0; transform: translateX(-3px); }
|
||||
to { opacity: 1; transform: translateX(0); }
|
||||
}
|
||||
.ai-conv-item-edit {
|
||||
font-size: 11px;
|
||||
color: var(--df-text);
|
||||
width: 100%;
|
||||
height: 18px;
|
||||
padding: 0 4px;
|
||||
border: 1px solid var(--df-primary, #4f8cff);
|
||||
border-radius: var(--df-radius-sm);
|
||||
background: var(--df-bg, #fff);
|
||||
outline: none;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.ai-conv-item-time {
|
||||
font-size: 9px;
|
||||
color: var(--df-text-dim);
|
||||
}
|
||||
/* F-09: 多会话并发生成指示器(会话项标题行内脉冲点,多会话可同时显示) */
|
||||
.ai-conv-gen-dot {
|
||||
display: inline-block;
|
||||
width: 6px;
|
||||
height: 6px;
|
||||
border-radius: 50%;
|
||||
background: var(--df-primary, #4f8cff);
|
||||
flex-shrink: 0;
|
||||
animation: ai-conv-gen-pulse 1.4s ease-in-out infinite;
|
||||
}
|
||||
@keyframes ai-conv-gen-pulse {
|
||||
0%, 100% { opacity: 0.35; transform: scale(0.85); }
|
||||
50% { opacity: 1; transform: scale(1.15); }
|
||||
}
|
||||
.ai-conv-item-actions {
|
||||
display: none;
|
||||
align-items: center;
|
||||
gap: 2px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.ai-conv-item:hover .ai-conv-item-actions {
|
||||
display: flex;
|
||||
}
|
||||
.ai-conv-item-act {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
border: none;
|
||||
border-radius: var(--df-radius-sm);
|
||||
background: transparent;
|
||||
color: var(--df-text-dim);
|
||||
cursor: pointer;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.ai-conv-item-act:hover {
|
||||
background: var(--df-sidebar-hover);
|
||||
color: var(--df-text);
|
||||
}
|
||||
.ai-conv-item-act:last-child:hover {
|
||||
background: var(--df-danger-bg);
|
||||
color: var(--df-danger);
|
||||
}
|
||||
/* UX-17: 置顶按钮高亮态(已置顶时常驻强调色,不依赖 hover) */
|
||||
.ai-conv-item-act--pinned {
|
||||
color: var(--df-accent, var(--df-text));
|
||||
}
|
||||
/* CR-22-1: 已置顶对话视觉强调(左边线,不依赖 hover 图钉一眼识别)。
|
||||
原方案「图钉常驻」与 hover 浮出 actions 矛盾(父 display:none 压制子),
|
||||
改用 :has 给已置顶 item 左 accent 边线,hover 浮出操作不变。 */
|
||||
.ai-conv-item:has(.ai-conv-item-act--pinned) {
|
||||
box-shadow: inset 2px 0 0 var(--df-accent, var(--df-text));
|
||||
}
|
||||
/* ── UX-18: 对话导出按钮 + 格式菜单 ──
|
||||
导出按钮位于归档与删除之间(非 last-child,保持删除按钮 :last-child 红色态不被破坏)。
|
||||
菜单绝对定位浮于 item 下方右侧,窄侧栏优先避免溢出。 */
|
||||
.ai-conv-item-export {
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.ai-conv-export-menu {
|
||||
position: absolute;
|
||||
top: 100%;
|
||||
right: 0;
|
||||
margin-top: 2px;
|
||||
z-index: 20;
|
||||
min-width: 84px;
|
||||
padding: 2px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1px;
|
||||
background: var(--df-bg, #fff);
|
||||
border: 1px solid var(--df-border, #e2e2e2);
|
||||
border-radius: var(--df-radius-sm);
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
|
||||
}
|
||||
.ai-conv-export-opt {
|
||||
border: none;
|
||||
background: transparent;
|
||||
text-align: left;
|
||||
padding: 4px 8px;
|
||||
font-size: 11px;
|
||||
color: var(--df-text);
|
||||
cursor: pointer;
|
||||
border-radius: var(--df-radius-sm);
|
||||
white-space: nowrap;
|
||||
}
|
||||
.ai-conv-export-opt:hover {
|
||||
background: var(--df-sidebar-hover);
|
||||
}
|
||||
.ai-conv-empty {
|
||||
padding: 16px 8px;
|
||||
text-align: center;
|
||||
font-size: 11px;
|
||||
color: var(--df-text-dim);
|
||||
}
|
||||
|
||||
/* 侧边栏滑入动画 */
|
||||
.sidebar-slide-enter-active { transition: width 0.2s var(--df-ease), opacity 0.15s; }
|
||||
.sidebar-slide-leave-active { transition: width 0.15s var(--df-ease), opacity 0.1s; }
|
||||
.sidebar-slide-enter-from, .sidebar-slide-leave-to {
|
||||
width: 0;
|
||||
min-width: 0;
|
||||
opacity: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user