v2 抽出独立 CSS 并接入真实后端接口

- 将 v2.html 内联样式抽取为 public/css/v2.css
- v2 前端接入 /api/sessions 列表/搜索/详情、消息发送、SSE 流式、文件上传、会话删除
- 尚未接入或后端无支撑的能力以注释列出(重命名/终止/绑定/清空/下载/模式/深度思考等)
This commit is contained in:
2026-09-03 11:42:05 +08:00
parent 9603a38d05
commit 5b72a0bcf7
2 changed files with 693 additions and 452 deletions
+311
View File
@@ -0,0 +1,311 @@
/* ================= 设计变量 ================= */
:root {
--active: rgb(57, 100, 254); /* 激活状态颜色 */
--ink: rgb(15, 17, 21); /* 默认状态颜色 */
--active-soft: rgba(57, 100, 254, 0.1); /* 激活浅蓝背景 */
--gray: #8a8f99;
--gray-light: #c2c7d0;
--surface: #f2f3f7; /* 浅色面(输入框/胶囊控件/用户气泡) */
--page: #ffffff;
--border: #ececf1;
--radius-lg: 24px;
}
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
color: var(--ink);
background: var(--page);
overscroll-behavior: none;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input, textarea { font: inherit; color: inherit; border: 0; outline: none; background: none; }
.hidden { display: none !important; }
/* svg 图标统一描边风格(与 index.html 一致) */
.ic { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.ic.sm { width: 17px; height: 17px; }
/* ================= 应用骨架 ================= */
#app {
height: 100%;
max-width: 760px;
margin: 0 auto;
display: flex;
flex-direction: column;
position: relative;
background: var(--page);
}
/* ================= 顶部导航栏 ================= */
.header {
flex: none;
display: flex;
align-items: center;
gap: 8px;
padding: 10px 12px;
min-height: 56px;
border-bottom: 1px solid var(--border);
}
.header .icon-btn {
width: 40px; height: 40px; border-radius: 50%;
display: flex; align-items: center; justify-content: center;
color: var(--ink);
}
.header .icon-btn:active { background: var(--surface); }
.header-center {
flex: 1; min-width: 0;
display: flex; flex-direction: column; align-items: center; justify-content: center;
gap: 1px; text-align: center;
}
.header-title {
font-size: 15px; font-weight: 600; line-height: 1.3;
max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.header-sub {
font-size: 11px; color: var(--gray); line-height: 1.3;
max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.header-sub .mode { color: var(--active); }
/* ================= 主内容区 ================= */
main { flex: 1; min-height: 0; display: flex; flex-direction: column; }
/* ---------- 未对话状态:模式选择 ---------- */
#welcome-view {
flex: 1; overflow-y: auto;
display: flex; flex-direction: column; align-items: center;
padding: max(48px, 10vh) 24px 24px;
}
.logo-badge {
width: auto;
height: auto;
background: none;
border-radius: 0;
display: inline-flex;
align-items: center;
justify-content: center;
color: var(--active);
}
.logo-badge .ic { width: 40px; height: 40px; }
.welcome-slogan { margin-top: 0; font-size: 18px; }
.welcome-head {
display: flex;
align-items: center;
justify-content: center;
gap: 12px;
margin-bottom: 18px;
}
/* 胶囊式分段控件 */
.mode-switch {
border: 1px solid var(--gray-light);
margin-top: 28px; width: 100%; max-width: 360px;
display: flex; gap: 4px;
border-radius: 999px;
}
.mode-chip {
flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px;
padding: 10px 0; border-radius: 999px;
font-size: 14px; color: var(--ink);
transition: background .18s, color .18s;
}
.mode-chip:hover {background: var(--surface);}
.mode-chip.on { background: var(--active-soft); color: var(--active); border: 1px solid var(--active); }
.mode-hint { margin-top: 14px; font-size: 13px; color: var(--gray); min-height: 20px; text-align: center; }
/* ---------- 对话状态:对话内容区 ---------- */
#chat-view { flex: 1; min-height: 0; overflow-y: auto; padding: 16px 16px 8px; }
.msg { display: flex; flex-direction: column; margin-bottom: 18px; max-width: 100%; }
.msg.me { align-items: flex-end; }
.msg.other { align-items: flex-start; }
/* 用户气泡:右侧,浅色背景,圆角矩形 */
.bubble-user {
background: var(--surface); color: var(--ink);
padding: 10px 14px; border-radius: 16px 16px 4px 16px;
font-size: 15px; line-height: 1.6;
max-width: 82%; white-space: pre-wrap; word-break: break-word;
}
.attach-line { font-size: 12px; color: var(--active); margin-bottom: 4px; }
/* AI 气泡:左侧,无边框/白色背景,大段文字 */
.bubble-ai {
background: var(--page); color: var(--ink);
padding: 2px 0; font-size: 16px; line-height: 1.75;
max-width: 100%; white-space: pre-wrap; word-break: break-word;
}
/* AI 思考过程折叠模块 */
.think {
align-self: stretch; max-width: 100%;
margin-bottom: 8px; border-radius: 12px;
}
.think-head {
display: inline-flex; align-items: center; gap: 6px;
font-size: 13px; color: var(--gray); padding: 6px 8px; margin-left: -8px;
border-radius: 8px;
}
.think-head:active { background: var(--surface); }
.think-head .chev { transition: transform .18s; }
.think.open .think-head { color: var(--ink); }
.think.open .think-head .chev { transform: rotate(180deg); }
.think-body { display: none; padding: 4px 8px 8px 8px; }
.think.open .think-body { display: block; }
.think-body ul { list-style: none; }
.think-body li {
position: relative; padding: 5px 0 5px 16px;
font-size: 13px; line-height: 1.6; color: var(--gray);
}
.think-body li::before {
content: ""; position: absolute; left: 2px; top: 12px;
width: 5px; height: 5px; border-radius: 50%; background: var(--gray-light);
}
/* 输出中占位(打字点) */
.typing { display: inline-flex; gap: 4px; padding: 8px 2px; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--gray-light); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; }
.typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%,80%,100% { opacity: .25; } 40% { opacity: 1; } }
/* 操作栏:时间 + 复制/删除 */
.msg-actions {
display: flex; align-items: center; gap: 10px;
margin-top: 6px; font-size: 12px; color: var(--gray-light);
}
.msg-actions .act { display: flex; color: var(--gray-light); padding: 3px; border-radius: 6px; }
.msg-actions .act:active, .msg-actions .act:hover { color: var(--ink); }
.msg-actions .act.copied { color: var(--active); }
/* ================= 底部输入区 ================= */
footer { flex: none; padding: 8px 12px calc(10px + env(safe-area-inset-bottom, 0px)); background: var(--page); }
.attach-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.attach-chip {
display: inline-flex; align-items: center; gap: 6px;
background: var(--surface); border-radius: 8px; padding: 5px 8px;
font-size: 12px; color: var(--ink); max-width: 100%;
}
.attach-chip .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 140px; }
.attach-chip .rm { color: var(--gray); display: flex; }
.input-shell {
display: flex;
flex-direction: column;
align-items: stretch;
gap: 6px;
background: var(--surface);
border-radius: var(--radius-lg);
padding: 6px 8px;
}
.input-shell textarea {
width: 100%;
flex: none;
resize: none;
background: none;
font-size: 15px;
line-height: 22px;
height: 44px; /* 初始2行 */
max-height: 120px; /* 限制最大高度 */
padding: 6px 12px;
min-width: 0;
}
.input-shell textarea::placeholder { color: var(--gray-light); }
.input-actions {
display: flex;
align-items: center;
justify-content: space-between;
padding-top: 6px;
}
/* 深度思考开关(左侧功能开关) */
.think-toggle {
flex: none;
display: inline-flex;
align-items: center;
gap: 5px;
height: 36px;
padding: 0 12px;
border-radius: 999px;
border: 1px solid var(--gray-light);
font-size: 13px;
color: var(--ink);
background: transparent;
transition: border-color .18s, background .18s, color .18s;
}
.think-toggle.on {
border-color: var(--active);
background: var(--active-soft);
color: var(--active);
font-weight: 600;
}
.plus-btn {
flex: none; width: 36px; height: 36px; border-radius: 50%;
display: flex; align-items: center; justify-content: center;
color: var(--ink);
}
.plus-btn:active { background: #e4e6ec; }
/* ================= 历史记录抽屉 ================= */
#scrim {
position: fixed; inset: 0; background: rgba(0, 0, 0, .4);
opacity: 0; pointer-events: none; transition: opacity .25s; z-index: 40;
}
#scrim.show { opacity: 1; pointer-events: auto; }
#drawer {
position: fixed; top: 0; bottom: 0; left: 0; z-index: 50;
width: min(78vw, 320px);
background: var(--page);
display: flex; flex-direction: column;
transform: translateX(-102%); transition: transform .25s ease;
box-shadow: 4px 0 24px rgba(0, 0, 0, .08);
}
#drawer.open { transform: translateX(0); }
.drawer-search { flex: none; padding: 14px 14px 10px; }
.search-box {
display: flex; align-items: center; gap: 8px;
background: var(--surface); border-radius: 12px; padding: 9px 12px;
color: var(--gray);
}
.search-box input { flex: 1; min-width: 0; font-size: 14px; background: none; }
.search-box input::placeholder { color: var(--gray-light); }
.drawer-list { flex: 1; min-height: 0; overflow-y: auto; padding: 0 8px 12px; }
.group-label { padding: 14px 10px 6px; font-size: 11px; color: var(--gray); }
.conv-item {
display: block; width: 100%; text-align: left;
padding: 12px 10px; border-radius: 12px;
font-size: 14px; color: var(--ink);
overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.conv-item:active { background: var(--surface); }
.conv-item.active { background: var(--active-soft); color: var(--active); }
.drawer-empty { padding: 24px 10px; font-size: 13px; color: var(--gray-light); text-align: center; }
/* 底部用户区 */
.drawer-user {
flex: none; display: flex; align-items: center; gap: 10px;
padding: 12px 14px calc(12px + env(safe-area-inset-bottom, 0px));
border-top: 1px solid var(--border);
}
.avatar {
width: 36px; height: 36px; border-radius: 50%; flex: none;
background: linear-gradient(135deg, var(--active), #7f9dff);
color: #fff; display: flex; align-items: center; justify-content: center;
font-size: 15px; font-weight: 600;
}
.user-name { flex: 1; font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-more { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: var(--gray); }
.user-more:active { background: var(--surface); }
/* ================= Toast ================= */
#toast {
position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%);
background: rgba(15, 17, 21, .88); color: #fff;
padding: 9px 16px; border-radius: 10px; font-size: 13px;
z-index: 90; pointer-events: none; transition: opacity .2s;
}
/* ================= 工具调用行(v2 轻量展示,替代工具卡片) ================= */
.tool-line { font-size: 12px; color: var(--gray); line-height: 1.6; padding: 2px 0; }
+382 -452
View File
File diff suppressed because it is too large Load Diff