Files
kicer 488734641d feat(渲染): 支持 LaTeX 数学公式,KaTeX 本地化
聊天消息与 md 文件预览都支持 $...$ 行内与 $$...$$ 块级。

实现:占位符往返,不用 marked 扩展
- 解析前把公式抠成 @@MATHn@@(跳过围栏代码与行内代码)
- marked 正常解析后把占位换回 KaTeX 输出
- 这样公式里的 * _ \ { } 不会被 marked 当成强调/转义

行内 $ 的边界判断:前后紧邻字母/数字时不识别,避免「花了 $5 和 $6」被当公式。

KaTeX 0.16.11 本地 vendor(592KB,含 20 个 woff2 字体),不走 CDN。
md 预览的新窗口用根绝对路径引入 CSS,blob 文档的相对路径找不到字体。
2026-11-17 22:42:48 +08:00

681 lines
49 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<!-- viewport-fit=cover:让 env(safe-area-inset-*) 生效(缺了它 iOS 上恒为 0);
interactive-widget=resizes-content:键盘弹起时缩 layout viewport(新 Chromium 认;
不认的浏览器会忽略,由 js/viewport.js 的 --kb 兜底)。 -->
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover, interactive-widget=resizes-content">
<title>Agent 任务台</title>
<script src="/vendor/marked.min.js"></script>
<script src="/vendor/katex/katex.min.js"></script>
<script src="/js/math.js"></script>
<script src="/vendor/prism.min.js"></script>
<meta name="theme-color" content="#3964FE">
<!-- 主题首屏:先落 data-theme,避开刷新时的白屏闪一下。默认浅色,手动切过后存 localStorage -->
<script>
(function () {
try {
var m = localStorage.getItem('agent-theme') === 'dark' ? 'dark' : 'light';
document.documentElement.setAttribute('data-theme', m);
document.documentElement.setAttribute('data-theme-mode', m);
} catch (_) {
document.documentElement.setAttribute('data-theme', 'light');
document.documentElement.setAttribute('data-theme-mode', 'light');
}
})();
</script>
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="apple-mobile-web-app-title" content="Agent">
<link rel="manifest" href="/manifest.json">
<link rel="apple-touch-icon" href="/icons/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="192x192" href="/icons/icon-192.png">
<link rel="stylesheet" href="/vendor/katex/katex.min.css">
<link rel="stylesheet" href="/css/style.css">
<style>
/* 「压缩」摘要卡片:与 .msg-ctx(画像快照/渠道/记忆)同一套视觉——淡蓝底、蓝边蓝字、
三角箭头、虚线分隔。纯色不用渐变/阴影,折叠与展开同一底色。默认收起 */
.msg-summary {
width: 100%; /* .msg.other 是 align-items:flex-start 的列 flex,不写就只撑标题那点宽 */
margin: 0 0 8px; border: 1px solid var(--bd-dbe4fb); border-radius: 12px; overflow: hidden;
background: var(--bg-f7f9ff);
}
.msg-summary > summary {
list-style: none; cursor: pointer; user-select: none;
display: flex; align-items: center; gap: 7px;
padding: 9px 12px; font-size: 13px; font-weight: 600; color: var(--active);
}
.msg-summary > summary::-webkit-details-marker { display: none; }
.msg-summary > summary::before {
content: ''; flex: none; width: 0; height: 0; margin-left: 1px;
border-left: 5px solid var(--active); border-top: 4px solid transparent; border-bottom: 4px solid transparent;
transition: transform .15s ease;
}
.msg-summary[open] > summary::before { transform: rotate(90deg); }
.msg-summary-body {
/* 比标题区深一档(用变量,暗色自动跟随) */
border-top: 1px dashed var(--bd-dbe4fb); background: var(--bg-fbfcff);
padding: 10px 13px 12px;
}
.msg-summary-body .bubble-ai { margin: 0; background: transparent; font-size: 14px; line-height: 1.7; }
/* 「仅摘要」后摘要之前的旧历史:UI 保留但变淡,尾部附存档说明(不再发给 AI) */
.msg-archived { opacity: .55; }
.archived-note {
display: flex; align-items: center; gap: 8px;
margin: 10px 0 12px; font-size: 11px; color: var(--gray);
}
.archived-note::before, .archived-note::after { content: ''; flex: 1; height: 1px; background: var(--border); }
/* schedule 弹窗控件(.modal select/input 的 100% 宽会撑满整行,这里收窄成本行内样式) */
#schedule-modal .sched-row { display: flex; align-items: center; gap: 6px; margin-bottom: 10px; font-size: 14px; color: var(--ink); flex-wrap: wrap; }
#schedule-modal .sched-row select,
#schedule-modal .sched-row input {
width: auto; margin: 0; padding: 7px 8px; font-size: 14px;
border: 1px solid var(--bd-dde1ea); border-radius: 8px; background: var(--bg-fff); color: var(--ink);
}
#schedule-modal .sched-row select { appearance: none; -webkit-appearance: none; }
#schedule-modal .sched-row .sched-num { width: 52px; text-align: center; }
#schedule-modal .sched-row .sched-grow { flex: 1; min-width: 130px; font-family: monospace; }
#schedule-modal .sched-meta { font-size: 12.5px; color: var(--gray); margin-bottom: 10px; white-space: pre-wrap; }
/* schedule 弹窗内的提示词编辑区(.modal input 不覆盖 textarea,单独给样式) */
#schedule-modal textarea {
width: 100%; box-sizing: border-box; display: block;
border: 1px solid var(--bd-dde1ea); border-radius: 10px;
padding: 10px 12px; font-size: 14px; line-height: 1.5;
margin-bottom: 10px; background: var(--bg-fff); color: var(--ink); resize: vertical;
}
#schedule-modal textarea:focus { border-color: var(--active); }
/* welcome 头像兼做「选择模型」入口(与聊天态的「选择模型」同一弹窗) */
.logo-badge { cursor: pointer; }
</style>
<script>
// 注册 Service Worker(PWA / 离线缓存)
if ('serviceWorker' in navigator) {
window.addEventListener('load', () => {
navigator.serviceWorker.register('/sw.js').catch((err) => {
console.warn('[SW] register failed:', err);
});
});
}
</script>
</head>
<body>
<!-- 图标 sprite:全站 99 处 svg 的几何图形都收在这里,引用方式
<svg class="ic" viewBox="0 0 24 24"><use href="#i-xxx"/></svg>
尺寸/描边仍由各处 CSS 控制(.ic、.tree-act svg 等),本文件只存形状。
同形但历史写法不同的(folder/folder-b/folder-c、x-line/x-line-b/x-path、eye/eye-sm 等)
各留一份,保证替换前后逐像素一致;后续要收敛,改引用指向同一个 id 即可。 -->
<svg id="icon-sprite" style="position:absolute;width:0;height:0;overflow:hidden" aria-hidden="true">
<symbol id="i-history" viewBox="0 0 24 24"><path stroke-width="2" stroke-linecap="round" d="M4 5h16M4 15h10"/></symbol>
<symbol id="i-clock" viewBox="0 0 24 24"><circle cx="12" cy="12" r="8.5"></circle><polyline points="12 7.5 12 12 15.5 14"></polyline></symbol>
<symbol id="i-database" viewBox="0 0 24 24"><ellipse cx="12" cy="5" rx="8" ry="2.5" fill="none" stroke="currentColor" stroke-width="1.6"></ellipse><path fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" d="M4 5v6c0 1.4 3.6 2.5 8 2.5s8-1.1 8-2.5V5"></path><path fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" d="M4 11v6c0 1.4 3.6 2.5 8 2.5s8-1.1 8-2.5v-6"></path></symbol>
<symbol id="i-plus" viewBox="0 0 24 24"><line x1="12" y1="5" x2="12" y2="19"></line><line x1="5" y1="12" x2="19" y2="12"></line></symbol>
<symbol id="i-more" viewBox="0 0 24 24"><circle cx="5" cy="12" r="1.4" fill="currentColor" stroke="none"></circle><circle cx="12" cy="12" r="1.4" fill="currentColor" stroke="none"></circle><circle cx="19" cy="12" r="1.4" fill="currentColor" stroke="none"></circle></symbol>
<symbol id="i-sliders" viewBox="0 0 24 24"><line x1="3" y1="7" x2="21" y2="7"></line><circle cx="9" cy="7" r="2.6"></circle><line x1="3" y1="17" x2="21" y2="17"></line><circle cx="15" cy="17" r="2.6"></circle></symbol>
<symbol id="i-robot" viewBox="0 0 24 24"><rect x="4" y="8" width="16" height="12" rx="3"></rect><line x1="12" y1="4" x2="12" y2="8"></line><circle cx="12" cy="3" r="1.4"></circle><circle cx="9" cy="13.5" r="1" fill="currentColor" stroke="none"></circle><circle cx="15" cy="13.5" r="1" fill="currentColor" stroke="none"></circle><line x1="9.5" y1="17" x2="14.5" y2="17"></line></symbol>
<symbol id="i-folder" viewBox="0 0 24 24"><path d="M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"></path></symbol>
<symbol id="i-x-line" viewBox="0 0 24 24"><line x1="6" y1="6" x2="18" y2="18"></line><line x1="18" y1="6" x2="6" y2="18"></line></symbol>
<symbol id="i-bulb" viewBox="0 0 24 24"><path d="M12 10.2a1.8 1.8 0 1 0 0.001 3.6A1.8 1.8 0 0 0 12 10.2z"></path><path stroke-width="1.5" d="M15.76 15.76 C10.955 20.565 5.373 22.779 3.297 20.703 C1.22 18.627 3.434 13.045 8.24 8.24 C13.045 3.435 18.627 1.22 20.703 3.297 C22.779 5.374 20.565 10.955 15.76 15.76z"></path><path stroke-width="1.5" d="M16.096 7.904 C20.905 12.713 22.965 18.298 20.703 20.703 C18.44 23.108 13.003 20.755 8.24 15.76 C3.477 10.76 1.22 5.373 3.297 3.297 C5.374 1.22 10.955 3.434 16.096 7.904z"></path></symbol>
<symbol id="i-folder-b" viewBox="0 0 24 24"><path fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" d="M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"></path></symbol>
<symbol id="i-paperclip" viewBox="0 0 24 24"><path fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" d="M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48"></path></symbol>
<symbol id="i-send" viewBox="0 0 24 24"><line x1="12" y1="19" x2="12" y2="5"></line><polyline points="5 12 12 5 19 12"></polyline></symbol>
<symbol id="i-mic" viewBox="0 0 24 24"><rect x="9" y="2" width="6" height="12" rx="3"></rect><path d="M5 10a7 7 0 0 0 14 0"></path><line x1="12" y1="19" x2="12" y2="22"></line></symbol>
<symbol id="i-keyboard" viewBox="0 0 24 24"><rect x="3" y="5" width="18" height="14" rx="2.5"></rect><circle cx="7" cy="9" r="1.1" fill="currentColor" stroke="none"></circle><circle cx="12" cy="9" r="1.1" fill="currentColor" stroke="none"></circle><circle cx="17" cy="9" r="1.1" fill="currentColor" stroke="none"></circle><circle cx="7" cy="12.5" r="1.1" fill="currentColor" stroke="none"></circle><circle cx="12" cy="12.5" r="1.1" fill="currentColor" stroke="none"></circle><circle cx="17" cy="12.5" r="1.1" fill="currentColor" stroke="none"></circle><line x1="8" y1="16" x2="16" y2="16"></line></symbol>
<symbol id="i-chevron-down" viewBox="0 0 24 24"><polyline points="6 9 12 15 18 9"></polyline></symbol>
<symbol id="i-spinner" viewBox="0 0 24 24"><circle cx="12" cy="12" r="10" style="fill:none;stroke:var(--sb-ring,#dde);stroke-width:2.5"></circle><path d="M22 12a10 10 0 0 1-10 10" style="fill:none;stroke:var(--sb-arc,#3964FE);stroke-width:2.5;stroke-linecap:round"></path></symbol>
<symbol id="i-search" viewBox="0 0 24 24"><circle cx="11" cy="11" r="8"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line></symbol>
<symbol id="i-gear" viewBox="0 0 24 24"><circle cx="12" cy="12" r="3"></circle><path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"></path></symbol>
<symbol id="i-upload-cloud" viewBox="0 0 24 24"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"></path><polyline points="17 8 12 3 7 8"></polyline><line x1="12" y1="3" x2="12" y2="15"></line></symbol>
<symbol id="i-download" viewBox="0 0 24 24"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"></path><polyline points="7 10 12 15 17 10"></polyline><line x1="12" y1="15" x2="12" y2="3"></line></symbol>
<symbol id="i-trash" viewBox="0 0 24 24"><path d="M3 6h18"/><path d="M8 6V4a1 1 0 0 1 1-1h6a1 1 0 0 1 1 1v2"/><path d="M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"/><path d="M10 11v6"/><path d="M14 11v6"/></symbol>
<symbol id="i-chevron-left" viewBox="0 0 24 24"><polyline points="15 18 9 12 15 6"></polyline></symbol>
<symbol id="i-x-line-b" viewBox="0 0 24 24"><line x1="18" y1="6" x2="6" y2="18"></line><line x1="6" y1="6" x2="18" y2="18"></line></symbol>
<symbol id="i-refresh" viewBox="0 0 24 24"><polyline points="23 4 23 10 17 10"></polyline><path d="M20.49 15a9 9 0 1 1-2.12-9.36L23 10"></path></symbol>
<symbol id="i-external" viewBox="0 0 24 24"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"></path><polyline points="15 3 21 3 21 9"></polyline><line x1="10" y1="14" x2="21" y2="3"></line></symbol>
<symbol id="i-eye" viewBox="0 0 24 24"><path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"></path><circle cx="12" cy="12" r="3"></circle></symbol>
<symbol id="i-maximize" viewBox="0 0 24 24"><path d="M8 3H5a2 2 0 0 0-2 2v3"></path><path d="M21 8V5a2 2 0 0 0-2-2h-3"></path><path d="M16 21h3a2 2 0 0 0 2-2v-3"></path><path d="M3 16v3a2 2 0 0 0 2 2h3"></path></symbol>
<symbol id="i-minimize" viewBox="0 0 24 24"><path d="M8 3v3a2 2 0 0 1-2 2H3"></path><path d="M21 8h-3a2 2 0 0 1-2-2V3"></path><path d="M3 16h3a2 2 0 0 1 2 2v3"></path><path d="M16 21v-3a2 2 0 0 1 2-2h3"></path></symbol>
<symbol id="i-copy" viewBox="0 0 24 24"><rect x="9" y="9" width="13" height="13" rx="2"></rect><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path></symbol>
<symbol id="i-x-path" viewBox="0 0 24 24"><path d="M18 6 6 18"></path><path d="m6 6 12 12"></path></symbol>
<symbol id="i-pencil" viewBox="0 0 24 24"><path d="M12 20h9"></path><path d="M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4z"></path></symbol>
<symbol id="i-gem" viewBox="0 0 24 24"><path d="M6 3h12l4 6-10 13L2 9z"></path><polyline points="2 9 22 9"></polyline><polyline points="10 3 8 9 12 22"></polyline><polyline points="14 3 16 9 12 22"></polyline></symbol>
<symbol id="i-image" viewBox="0 0 24 24"><rect x="3" y="3" width="18" height="18" rx="2"></rect><circle cx="8.5" cy="8.5" r="1.5"></circle><polyline points="21 15 16 10 5 21"></polyline></symbol>
<symbol id="i-file" viewBox="0 0 24 24"><path d="M6 3h8l4 4v14H6z"/><path d="M14 3v4h4"/></symbol>
<symbol id="i-link" viewBox="0 0 24 24"><path d="M10 13a5 5 0 0 0 7 0l2-2a5 5 0 0 0-7-7l-1 1"/><path d="M14 11a5 5 0 0 0-7 0l-2 2a5 5 0 0 0 7 7l1-1"/></symbol>
<symbol id="i-external-b" viewBox="0 0 24 24"><path d="M14 4h6v6"/><path d="M20 4l-9 9"/><path d="M19 14v5a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1h5"/></symbol>
<symbol id="i-reload" viewBox="0 0 24 24"><path d="M20 12a8 8 0 1 1-2.3-5.7"/><path d="M20 4v5h-5"/></symbol>
<symbol id="i-terminal" viewBox="0 0 24 24"><rect x="3" y="4" width="18" height="16" rx="2"/><path d="M7 9l3 3-3 3"/><path d="M13 15h4"/></symbol>
<symbol id="i-git" viewBox="0 0 24 24"><circle cx="6" cy="5" r="2"/><circle cx="6" cy="19" r="2"/><circle cx="18" cy="7" r="2"/><path d="M6 7v10"/><path d="M18 9v1a4 4 0 0 1-4 4H9"/></symbol>
<symbol id="i-eye-sm" viewBox="0 0 24 24"><path d="M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7S2 12 2 12z"/><circle cx="12" cy="12" r="2.6"/></symbol>
<symbol id="i-theme-auto" viewBox="0 0 24 24"><rect x="2" y="3" width="20" height="14" rx="2"/><path d="M8 21h8"/><path d="M12 17v4"/></symbol>
<symbol id="i-theme-light" viewBox="0 0 24 24"><circle cx="12" cy="12" r="4.5"/><path d="M12 1.5v2M12 20.5v2M3.4 3.4l1.4 1.4M19.2 19.2l1.4 1.4M1.5 12h2M20.5 12h2M3.4 20.6l1.4-1.4M19.2 4.8l1.4-1.4"/></symbol>
<symbol id="i-theme-dark" viewBox="0 0 24 24"><path d="M21 13.2A9 9 0 1 1 10.8 3a7.2 7.2 0 0 0 10.2 10.2z"/></symbol>
<symbol id="i-file-doc" viewBox="0 0 24 24"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path><polyline points="14 2 14 8 20 8"></polyline></symbol>
<symbol id="i-folder-c" viewBox="0 0 24 24"><path d="M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"></path></symbol>
<symbol id="i-chevron-right" viewBox="0 0 24 24"><polyline points="9 18 15 12 9 6"></polyline></symbol>
<symbol id="i-home" viewBox="0 0 24 24"><path d="M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"></path><polyline points="9 22 9 12 15 12 15 22"></polyline></symbol>
<symbol id="i-image-b" viewBox="0 0 24 24"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect><circle cx="8.5" cy="8.5" r="1.5"></circle><polyline points="21 15 16 10 5 21"></polyline></symbol>
<symbol id="i-user" viewBox="0 0 24 24"><circle cx="12" cy="8" r="4"></circle><path d="M4 21c0-4 4-6 8-6s8 2 8 6"></path></symbol>
<symbol id="i-users" viewBox="0 0 24 24"><circle cx="9" cy="8" r="3.5"></circle><path d="M2 21c0-3.6 3.1-5.5 7-5.5s7 1.9 7 5.5"></path><path d="M16 8.5a3 3 0 0 1 0 6"></path><path d="M18 21c0-2.8-1.4-4.5-4-5.2"></path></symbol>
<symbol id="i-sliders-v" viewBox="0 0 24 24"><line x1="4" y1="21" x2="4" y2="14"></line><line x1="4" y1="10" x2="4" y2="3"></line><line x1="12" y1="21" x2="12" y2="12"></line><line x1="12" y1="8" x2="12" y2="3"></line><line x1="20" y1="21" x2="20" y2="16"></line><line x1="20" y1="12" x2="20" y2="3"></line><line x1="1" y1="14" x2="7" y2="14"></line><line x1="9" y1="8" x2="15" y2="8"></line><line x1="17" y1="16" x2="23" y2="16"></line></symbol>
<symbol id="i-zap" viewBox="0 0 24 24"><polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2"></polygon></symbol>
<symbol id="i-cpu" viewBox="0 0 24 24"><rect x="4" y="4" width="16" height="16" rx="2"></rect><rect x="9" y="9" width="6" height="6"></rect><line x1="9" y1="1" x2="9" y2="4"></line><line x1="15" y1="1" x2="15" y2="4"></line><line x1="9" y1="20" x2="9" y2="23"></line><line x1="15" y1="20" x2="15" y2="23"></line><line x1="20" y1="9" x2="23" y2="9"></line><line x1="20" y1="14" x2="23" y2="14"></line><line x1="1" y1="9" x2="4" y2="9"></line><line x1="1" y1="14" x2="4" y2="14"></line></symbol>
<symbol id="i-layout" viewBox="0 0 24 24"><rect x="3" y="4" width="18" height="16" rx="2"></rect><line x1="3" y1="10" x2="21" y2="10"></line><circle cx="7" cy="15" r="1.2" fill="currentColor" stroke="none"></circle><circle cx="12" cy="15" r="1.2" fill="currentColor" stroke="none"></circle><circle cx="17" cy="15" r="1.2" fill="currentColor" stroke="none"></circle></symbol>
<symbol id="i-chevron-right-b" viewBox="0 0 24 24"><polyline points="9 6 15 12 9 18"></polyline></symbol>
<symbol id="i-edit" viewBox="0 0 24 24"><path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"></path><path d="M18.5 2.5a2.12 2.12 0 0 1 3 3L12 15l-4 1 1-4z"></path></symbol>
<symbol id="i-check" viewBox="0 0 24 24"><polyline points="20 6 9 17 4 12"></polyline></symbol>
<symbol id="i-pencil-b" viewBox="0 0 24 24"><path d="M12 20h9"/><path d="M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z"/></symbol>
</svg>
<div id="app">
<!-- ================= 顶部导航栏 ================= -->
<header class="header" id="chat-header">
<button class="icon-btn" id="menu-btn" title="历史记录" aria-label="打开历史记录">
<svg viewBox="0 0 24 24" class="ic sm"><use href="#i-history"/></svg>
</button>
<div class="header-center" id="header-center"><!-- 未对话状态为空白,JS 注入对话信息 --></div>
<!-- 标题右侧的会话属性区(仅桌面端):模型名(文字)/ 定时任务(无任务=灰色入口·有任务=紫色频次)/ 压缩。
无会话时只留模型占位(选模型),定时与压缩隐藏。 -->
<div class="header-meta" id="header-meta">
<button class="hdr-chip hdr-model" id="hdr-model" data-act="model" data-tip="切换模型" aria-label="切换模型">
<span class="hdr-label" id="hdr-model-text">选择模型</span>
</button>
<button class="hdr-chip hdr-sched hidden" id="hdr-sched" data-act="schedule" data-tip="定时任务" aria-label="定时任务">
<svg class="ic" viewBox="0 0 24 24"><use href="#i-clock"/></svg>
<span class="hdr-label" id="hdr-sched-text">定时任务</span>
</button>
<button class="icon-btn ha-btn hdr-compact hidden" id="hdr-compact" data-act="compact" data-tip="压缩上下文" aria-label="压缩上下文">
<svg class="ic" viewBox="0 0 24 24"><use href="#i-database"/></svg>
</button>
</div>
<!-- 右侧动作区:桌面端只留「新建会话」;移动端整组收进「更多」下拉菜单。
桌面属性区与菜单项共用 data-act,事件统一在 sessions.js 分发。 -->
<div class="header-actions" id="header-actions">
<div class="ha-icons">
<button class="icon-btn ha-btn" data-act="theme" id="theme-toggle" data-tip="主题:浅色" aria-label="切换主题">
<svg class="ic sm" viewBox="0 0 24 24"><use href="#i-theme-light"/></svg>
<svg class="ic sm hidden" viewBox="0 0 24 24"><use href="#i-theme-dark"/></svg>
</button>
<button class="icon-btn ha-btn" data-act="new" data-tip="新建会话" aria-label="新建会话">
<svg class="ic sm" viewBox="0 0 24 24"><use href="#i-plus"/></svg>
</button>
</div>
<button class="icon-btn ha-more" id="ha-more" title="更多" aria-label="更多操作" aria-haspopup="menu" aria-expanded="false" aria-controls="ha-menu">
<svg class="ic sm" viewBox="0 0 24 24"><use href="#i-more"/></svg>
</button>
<div class="ha-menu hidden" id="ha-menu" role="menu">
<button class="ha-item" role="menuitem" data-act="model">
<svg class="ic sm" viewBox="0 0 24 24"><use href="#i-sliders"/></svg>
<span class="ha-item-main">切换模型</span><span class="ha-item-sub hidden" id="ha-model-sub"></span>
</button>
<button class="ha-item" role="menuitem" data-act="schedule">
<svg class="ic sm" viewBox="0 0 24 24"><use href="#i-clock"/></svg>
<span class="ha-item-main">定时任务</span><span class="ha-item-sub hidden" id="ha-sched-sub"></span>
</button>
<button class="ha-item" role="menuitem" data-act="compact">
<svg class="ic sm" viewBox="0 0 24 24"><use href="#i-database"/></svg>
<span class="ha-item-main">压缩上下文</span>
</button>
<button class="ha-item" role="menuitem" data-act="theme" id="theme-toggle-mobile">
<svg class="ic sm" viewBox="0 0 24 24"><use href="#i-theme-light"/></svg>
<svg class="ic sm hidden" viewBox="0 0 24 24"><use href="#i-theme-dark"/></svg>
<span class="ha-item-main">切换主题</span><span class="ha-item-sub" id="theme-label-mobile">浅色</span>
</button>
<button class="ha-item" role="menuitem" data-act="new">
<svg class="ic sm" viewBox="0 0 24 24"><use href="#i-plus"/></svg>
<span class="ha-item-main">新建会话</span>
</button>
</div>
</div>
</header>
<main>
<!-- ================= 未对话状态:欢迎页 ================= -->
<section id="welcome-view">
<div class="welcome-head">
<div class="logo-badge" onclick="openModelSwitch()" title="选择模型" role="button" aria-label="选择模型">
<svg class="ic" viewBox="0 0 24 24"><use href="#i-robot"/></svg>
</div>
<div class="welcome-slogan">随时开始吧</div>
</div>
<!-- 本地端:新建会话时手选工作目录(服务器形态由 JS 整块隐藏)。
只暂存在前端,真正建档时随 POST /api/sessions 提交一次;不选 = 老行为。 -->
<div class="welcome-dir hidden" id="welcome-dir">
<span class="welcome-dir-cap">工作目录</span>
<button type="button" class="welcome-dir-pick" id="welcome-dir-pick" title="选择本会话的工作目录">
<svg class="ic sm" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><use href="#i-folder"/></svg>
<span class="welcome-dir-path" id="welcome-dir-path">默认</span>
</button>
<button type="button" class="welcome-dir-clear hidden" id="welcome-dir-clear" title="恢复默认目录" aria-label="恢复默认目录">
<svg class="ic sm" viewBox="0 0 24 24"><use href="#i-x-line"/></svg>
</button>
</div>
</section>
<!-- ================= 对话状态:对话内容区 ================= -->
<section id="chat-view" class="hidden"></section>
</main>
<!-- ================= 底部输入区 ================= -->
<footer>
<div class="attach-chips hidden" id="attach-chips"></div>
<!-- 待发送条幅:运行中发出的消息先排在这里(不立即入库),逐条一行。
默认等本轮结束自动发出;队首可「干预」(跑完当前这步就插话)或「立即发送」(中断本轮)。 -->
<div class="send-queue hidden" id="send-queue" aria-live="polite"></div>
<div class="input-shell">
<!-- 编辑已发送消息:覆盖式重发提示条(发送后丢弃该条及其后的历史) -->
<div class="edit-bar hidden" id="edit-bar">
<span>编辑已发送消息:发送后将丢弃原历史信息</span>
<button id="edit-cancel" type="button">取消</button>
</div>
<div class="up-cards hidden" id="up-cards" aria-label="已上传文件"></div>
<textarea id="msg-input" placeholder="传送信息" rows="2" enterkeyhint="enter"></textarea>
<!-- 语音模式:输入框位置变成「按住 说话」(只有居中文字,无按钮外观) -->
<div id="voice-hold" class="hidden" role="button" tabindex="0" aria-label="按住说话">按住 说话</div>
<div class="input-actions">
<div class="ia-side ia-left">
<button class="think-toggle" id="deep-think-btn" title="深度思考">
<svg viewBox="0 0 24 24" class="ic sm"><use href="#i-bulb"/></svg>
深度思考
</button>
</div>
<div class="ia-side ia-right">
<button class="plus-btn" id="files-btn" title="任务文件" aria-label="任务文件">
<svg viewBox="0 0 24 24" class="ic sm"><use href="#i-folder-b"/></svg>
</button>
<button class="plus-btn" id="attach-btn" title="上传文件" aria-label="上传文件">
<svg viewBox="0 0 24 24" class="ic sm"><use href="#i-paperclip"/></svg>
</button>
<!-- 同一按钮四态:发送(↑)/ 停止(方块)/ 语音(麦克风)/ 键盘。
data-state 由 JS 切换,尺寸不变避免输入区跳动 -->
<button class="send-btn" id="send-btn" data-state="send" title="发送" aria-label="发送">
<svg class="ic sm ic-send" viewBox="0 0 24 24"><use href="#i-send"/></svg>
<svg class="ic sm ic-voice" viewBox="0 0 24 24"><use href="#i-mic"/></svg>
<svg class="ic sm ic-kb" viewBox="0 0 24 24"><use href="#i-keyboard"/></svg>
<span class="stop-sq" aria-hidden="true"></span>
</button>
</div>
</div>
<!-- 按住说话的遮罩:盖满输入卡并扩到屏幕两边(footer 有 12px 内边距 + shell 1px 边框)。
声波由 JS 生成 25 根柱子;上滑到文案区域进入取消态(整体变红)。 -->
<div id="voice-overlay" class="hidden" aria-hidden="true">
<div class="vo-hint" id="voice-hint">松手传送,上滑取消</div>
<div class="vo-wave" id="voice-wave"></div>
<!-- 桌面点击模式的操作行:手机端按住说话用不到,CSS 里默认隐藏 -->
<div class="vo-actions" id="voice-actions">
<button type="button" class="vo-btn ghost" id="voice-cancel">取消</button>
<button type="button" class="vo-btn primary" id="voice-send">发送</button>
</div>
</div>
</div>
<!-- 回到底部浮动按钮(搬自 index;上翻历史时出现、AI 输出中常驻转圈)。
放在 footer 内、相对 footer 顶边停靠:输入框长高/编辑条出现时不会被盖住 -->
<button class="scroll-bottom-btn hidden" id="scroll-bottom-btn" onclick="clickScrollBottom()" title="回到底部" aria-label="回到底部">
<svg class="sb-arrow" viewBox="0 0 24 24"><use href="#i-chevron-down"/></svg>
<svg class="sb-spinner hidden" viewBox="0 0 24 24"><use href="#i-spinner"/></svg>
</button>
</footer>
<!-- ================= 历史记录抽屉 ================= -->
<div id="scrim"></div>
<aside id="drawer" aria-label="对话历史">
<div class="drawer-search">
<div class="search-box">
<svg class="ic sm" viewBox="0 0 24 24"><use href="#i-search"/></svg>
<input type="search" id="search-input" placeholder="搜寻对话内容..." enterkeyhint="search">
</div>
</div>
<div class="drawer-list" id="drawer-list"></div>
<div class="files-tree" id="files-tree"></div>
<!-- 底部图标操作栏:文件树 / 设置(文件树按钮是「会话 ↔ 文件」的切换开关)。
预览不占按钮:桌面端在文件树里点文件即开预览栏,关窗走预览栏自己的关闭钮。
窄屏两个都隐藏:文件只保留输入行右侧的旧面板(不做两套)。选中项高亮。 -->
<div class="drawer-actions" id="drawer-actions">
<button class="drawer-act" id="da-files" type="button" title="文件树" aria-label="文件树">
<svg viewBox="0 0 24 24"><use href="#i-folder"/></svg>
</button>
<button class="drawer-act" id="da-settings" type="button" title="设置" aria-label="设置">
<svg viewBox="0 0 24 24"><use href="#i-gear"/></svg>
</button>
</div>
</aside>
<!-- ================= 任务文件面板(浮层:点输入行右侧文件夹按钮展开;盖住输入区+遮罩) ================= -->
<div id="files-mask" aria-hidden="true"></div>
<div class="files-panel" id="files-panel" aria-label="任务文件">
<div class="files-panel-header">
<div class="files-drag-handle" id="files-drag-handle" aria-label="拖拽调整高度"></div>
<span class="files-panel-title">任务文件<span class="files-panel-size" id="files-panel-size" title="当前目录下全部文件总大小"></span></span>
<label class="file-upload" title="上传文件" aria-label="上传文件">
<input type="file" id="file-input" multiple hidden>
<svg viewBox="0 0 24 24"><use href="#i-upload-cloud"/></svg>
</label>
</div>
<div class="files-crumbs hidden" id="files-crumbs" aria-label="目录路径"></div>
<div class="files-list" id="files-list"></div>
<div class="files-panel-progress hidden" id="fp-progress" aria-live="polite">
<div class="fp-track"><div class="bar" id="fp-progress-bar"></div></div>
<span class="pct" id="fp-progress-pct">0%</span>
</div>
<div class="files-panel-footer">
<div class="files-panel-footer-left">
<span class="file-check files-panel-check" id="files-toggle-all" role="checkbox" aria-checked="false" aria-label="全选" title="全选" tabindex="0"></span>
<span class="files-panel-count" id="files-count">未选择文件</span>
</div>
<div class="files-panel-actions">
<button class="files-fab" id="files-bulk-download" title="批量下载" aria-label="批量下载" disabled>
<svg viewBox="0 0 24 24"><use href="#i-download"/></svg>
</button>
<button class="files-fab del" id="files-bulk-delete" title="批量删除" aria-label="批量删除" disabled>
<svg viewBox="0 0 24 24"><use href="#i-trash"/></svg>
</button>
</div>
</div>
</div>
<!-- ================= 设置区(覆盖层;入口:侧边栏用户区) ================= -->
<section id="settings-page" class="hidden" aria-label="设置">
<!-- 垫底静态快照层:子页右滑返回时,父页快照垫在这里(仅动画背景,pointer-events:none;滑完重渲染真页) -->
<div id="set-under" aria-hidden="true"></div>
<!-- 当前页层:返回滑动只平移这一层,底下露出垫底的父页 -->
<div id="set-top">
<!-- 顶栏:左侧返回 + 中间标题 + 右侧操作按钮,风格与对话页 header 一致 -->
<header class="header">
<button class="icon-btn" id="set-back-btn" title="返回" aria-label="返回">
<svg class="ic" viewBox="0 0 24 24"><use href="#i-chevron-left"/></svg>
</button>
<div class="header-center"><div class="header-title" id="set-title">设置</div></div>
<div class="header-right" id="set-actions"><!-- JS 按页注入操作按钮 --></div>
</header>
<div id="set-body"><!-- JS 按页渲染 --></div>
</div>
</section>
<!-- 新建技能弹窗(搬自 index) -->
<div id="skill-create-modal" class="modal-overlay hidden" onclick="if(event.target===this)sUI.closeCreate()">
<div class="modal">
<button class="modal-close-btn" onclick="sUI.closeCreate()">
<svg viewBox="0 0 24 24"><use href="#i-x-line-b"/></svg>
</button>
<h3>新建技能</h3>
<input type="text" id="skill-new-name" placeholder="技能名(字母/数字/-/_)">
<input type="text" id="skill-new-desc" placeholder="一句话描述(何时使用该技能)">
<button class="primary-btn" onclick="sUI.createSkill()">创建</button>
</div>
</div>
<!-- 平台编辑/新增弹窗(模型池共用:点卡片内任一模型=编辑整个平台;右上+模型=新增整个平台) -->
<div id="model-edit-modal" class="modal-overlay hidden" onclick="if(event.target===this)sUI.mClose()">
<div class="modal modal-wide">
<button class="modal-close-btn" onclick="sUI.mClose()">
<svg viewBox="0 0 24 24"><use href="#i-x-line-b"/></svg>
</button>
<h3 id="mpe-title">编辑平台</h3>
<!-- 平台预设:仅新增平台时展示,点选即填好 url/类型并给模型卡带上该平台的参数缺省 -->
<div class="mpe-chips hidden" id="mpe-presets"></div>
<input type="text" id="mpe-name" placeholder="平台名(留空取 url 主机名首段)">
<input type="text" id="mpe-url" placeholder="平台上游地址(OpenAI 兼容 /v1)">
<div class="mpe-sec">
<div class="mpe-sec-head"><span>Key列表</span><button class="ghost-btn sm" onclick="sUI.mAddKey()">添加Key</button></div>
<div id="mpe-keys"></div>
</div>
<div class="mpe-sec">
<div class="mpe-sec-head"><span>模型</span><button class="ghost-btn sm" onclick="sUI.mAddModel()">添加模型</button></div>
<div id="mpe-models"></div>
</div>
<div class="btn-row mpe-foot">
<button class="ghost-btn danger hidden" id="mpe-del-btn" onclick="sUI.mDelPlat()">删除平台</button>
<button class="primary-btn" onclick="sUI.mSave()">保存</button>
</div>
</div>
</div>
<!-- 用户编辑弹窗(设置→用户;仅管理员):用户名 / 密码 / 角色 / 默认模型;保存后即时生效无需重启 -->
<div id="user-edit-modal" class="modal-overlay hidden" onclick="if(event.target===this)sUI.closeUserModal()">
<div class="modal">
<button class="modal-close-btn" onclick="sUI.closeUserModal()">
<svg viewBox="0 0 24 24"><use href="#i-x-line-b"/></svg>
</button>
<h3 id="ue-title">添加用户</h3>
<input type="text" id="ue-user" placeholder="用户名(字母/数字/下划线)" autocomplete="off">
<input type="password" id="ue-pass" placeholder="初始密码(至少 6 位)" autocomplete="new-password">
<select id="ue-role">
<option value="user">普通用户(仅账户页)</option>
<option value="admin">管理员(全部设置)</option>
</select>
<select id="ue-model"></select>
<div class="btn-row mpe-foot">
<button class="ghost-btn danger hidden" id="ue-del-btn" onclick="sUI.userDelFromModal()">删除用户</button>
<button class="primary-btn" onclick="sUI.saveUser()">保存</button>
</div>
<div class="cfg-note">默认模型 = 该用户新建会话时自动选择的模型;选「不锁定」则按原逻辑。</div>
</div>
</div>
<!-- MCP 服务编辑/新增弹窗:配置 name / url / 多条 headers / 单次调用超时 / 启用开关;保存后写入 config.yml,重启生效 -->
<div id="mcp-edit-modal" class="modal-overlay hidden" onclick="if(event.target===this)mcpUI.close()">
<div class="modal modal-wide">
<button class="modal-close-btn" onclick="mcpUI.close()">
<svg viewBox="0 0 24 24"><use href="#i-x-line-b"/></svg>
</button>
<h3 id="mce-title">编辑 MCP 服务</h3>
<input type="text" id="mce-name" placeholder="服务名">
<input type="text" id="mce-url" placeholder="MCP 服务 JSON-RPC URL">
<!-- 内置服务预设字段(name 只读、url 可改,表单由预设生成) -->
<div class="mpe-sec hidden" id="mce-preset-sec">
<div class="mpe-sec-head"><span>配置参数</span><span class="cfg-note" id="mce-preset-desc"></span></div>
<div id="mce-preset-fields"></div>
</div>
<div class="mpe-sec" id="mce-headers-sec">
<div class="mpe-sec-head"><span>请求头(headers)</span><button class="ghost-btn sm" onclick="mcpUI.addHeader()">添加 header</button></div>
<div id="mce-headers"></div>
</div>
<div class="mpe-sec">
<label class="mpe-line"><span>单次调用超时</span>
<span class="mpe-unit"><input type="number" id="mce-timeout" min="1000" max="600000" step="1000" placeholder="60000"><i>ms</i></span>
</label>
<label class="mpe-line"><span>工具暴露</span>
<select id="mce-mode">
<option value="advertise">advertise(下发给模型)</option>
<option value="skill">skill(以技能形式暴露)</option>
<option value="disable">disable(不加载)</option>
</select>
</label>
</div>
<div class="btn-row mpe-foot">
<button class="ghost-btn danger hidden" id="mce-del-btn" onclick="mcpUI.del()">删除服务</button>
<button class="primary-btn" onclick="mcpUI.save()">保存</button>
</div>
</div>
</div>
<!-- 定时任务详情弹窗:频次(预设控件组合 cron,无法识别的既有表达式落入自定义)+ 提示词(可改),动作:更新/删除。
必须在 confirm-modal 之前:同为 z-index:100,DOM 靠后者叠在上,删除二次确认要盖住本窗 -->
<div id="schedule-modal" class="modal-overlay hidden" onclick="if(event.target===this)closeScheduleModal()">
<div class="modal">
<button class="modal-close-btn" onclick="closeScheduleModal()">
<svg viewBox="0 0 24 24"><use href="#i-x-line-b"/></svg>
</button>
<h3 id="schedule-modal-title">定时任务</h3>
<div class="sched-row">
<select id="sched-freq" onchange="schedFreqUi()">
<option value="daily">每天</option>
<option value="weekly">每周</option>
<option value="everyN">每隔</option>
<option value="custom">自定义</option>
</select>
<select id="sched-dow" class="hidden">
<option value="1">周一</option><option value="2">周二</option><option value="3">周三</option><option value="4">周四</option><option value="5">周五</option><option value="6">周六</option><option value="0">周日</option>
</select>
<input id="sched-hh" class="sched-num hidden" type="number" min="0" max="23" placeholder="时">
<span id="sched-colon" class="hidden">:</span>
<input id="sched-mm" class="sched-num hidden" type="number" min="0" max="59" placeholder="分">
<input id="sched-nh" class="sched-num hidden" type="number" min="1" max="23">
<span id="sched-nh-unit" class="hidden">小时</span>
<input id="sched-cron" class="sched-grow hidden" type="text" placeholder="分 时 日 月 周(5 段 cron)">
</div>
<div class="sched-meta" id="sched-modal-meta"></div>
<textarea id="sched-modal-prompt" rows="6" placeholder="每次触发时投递给本会话的提示词"></textarea>
<div class="btn-row">
<button class="ghost-btn danger" id="sched-del-btn" onclick="deleteSchedule()">删除</button>
<button class="primary-btn" id="sched-save-btn" onclick="saveSchedule()">更新</button>
</div>
</div>
</div>
<!-- 全局确认弹窗(替代原生 confirm;搬自 index)。resolve: true=确定 / false=取消 / null=右上 X 或点遮罩关闭 -->
<div id="confirm-modal" class="modal-overlay hidden" onclick="if(event.target===this)confirmClose(null)">
<div class="modal">
<button class="modal-close-btn" onclick="confirmClose(null)" aria-label="关闭">
<svg viewBox="0 0 24 24"><use href="#i-x-line-b"/></svg>
</button>
<h3 id="confirm-title">请确认</h3>
<div class="modal-text" id="confirm-text"></div>
<label class="del-dir hidden" id="confirm-check-wrap"><input type="checkbox" id="confirm-check"> <span id="confirm-check-label"></span></label>
<div class="btn-row">
<button class="ghost-btn" id="confirm-cancel-btn" onclick="confirmClose(false)">取消</button>
<button class="primary-btn" id="confirm-ok-btn" onclick="confirmClose(true)">确定</button>
</div>
</div>
</div>
<!-- 全局输入弹窗(替代原生 prompt;搬自 index) -->
<div id="prompt-modal" class="modal-overlay hidden" onclick="if(event.target===this)promptCancel()">
<div class="modal">
<button class="modal-close-btn" onclick="promptCancel()">
<svg viewBox="0 0 24 24"><use href="#i-x-line-b"/></svg>
</button>
<h3 id="prompt-title">请输入</h3>
<input type="text" id="prompt-input">
<div class="btn-row">
<button class="ghost-btn" onclick="promptCancel()">取消</button>
<button class="primary-btn" onclick="promptOk()">确定</button>
</div>
</div>
</div>
<!-- 已完成/已终止会话:选择模型继续(搬自 index;顶部动作区「切换模型」入口) -->
<div id="bind-model-modal" class="modal-overlay hidden" onclick="if(event.target===this)closeModelSwitch()">
<div class="modal">
<div class="msw-header">
<div class="msw-titles">
<h3>切换模型</h3>
<p class="msw-sub" id="bind-model-sub">选择一个模型继续当前会话</p>
</div>
<button class="modal-close-btn" onclick="closeModelSwitch()">
<svg viewBox="0 0 24 24"><use href="#i-x-line-b"/></svg>
</button>
</div>
<div class="msw-list" id="bind-model-list"></div>
</div>
</div>
<div id="toast" class="hidden"></div>
</div>
<!-- 图片全屏查看器(点击消息/工具卡中图片打开;双指缩放、放大后可拖动;同组多图可左右滑动切换) -->
<div id="img-viewer" class="hidden">
<button class="fs-close" onclick="closeImageViewer()">✕</button>
<img id="img-viewer-img" alt="">
<!-- 组内页码(如 2 / 5):仅同组多图时显示 -->
<span id="img-count" class="hidden"></span>
</div>
<!-- ================= 文档预览分栏(桌面端≥960px;紧贴左侧文件树:文件树 | 预览 | 会话;office/全部文档类型统一承载;移动端走全屏 #fs-viewer,本栏隐藏) -->
<aside id="pv-pane" aria-label="文档预览">
<header class="pv-head">
<!-- 地址条胶囊:路径 input(点击全选可复制) + 内嵌 刷新/新窗口,模拟浏览器地址栏 -->
<span class="pv-addr">
<input class="pv-title" id="pv-title" aria-label="文件路径或网址">
<button class="icon-btn hidden" id="pv-refresh" title="重新载入" aria-label="重新载入">
<svg class="ic sm" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><use href="#i-refresh"/></svg>
</button>
<button class="icon-btn hidden" id="pv-popup" title="新窗口打开" aria-label="新窗口打开">
<svg class="ic sm" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><use href="#i-external"/></svg>
</button>
</span>
<span class="pv-actions">
<!-- 源码钮:只在当前内容有源文本时出现(md/文本/代码/html/svg),点了在预览与原文间切换 -->
<button class="icon-btn hidden" id="pv-src" title="查看源码" aria-label="查看源码">
<svg class="ic sm" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><use href="#i-eye"/></svg>
</button>
<button class="icon-btn hidden" id="pv-download" title="下载文件" aria-label="下载文件">
<svg class="ic sm" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><use href="#i-download"/></svg>
</button>
<button class="icon-btn" id="pv-max" title="放大" aria-label="放大">
<svg class="ic sm" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><use href="#i-maximize"/></svg>
<svg class="ic sm hidden" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><use href="#i-minimize"/></svg>
</button>
<button class="icon-btn" id="pv-close" title="关闭预览" aria-label="关闭预览">✕</button>
</span>
<div class="pv-suggest hidden" id="pv-suggest"></div>
</header>
<div class="pv-body" id="pv-body"></div>
</aside>
<!-- 消息全屏查看器(双击气泡/工具卡打开;支持双指缩放) -->
<div id="fs-viewer" class="hidden" onclick="if(event.target===this)closeFullscreen()">
<!-- 顶部操作区:文件预览(fs-bar 模式)时独立成一行,内容从行下开始,不遮挡页面自己的顶部按钮;
消息全屏时退化为右上角悬浮按钮簇。文件名仅栏模式显示。 -->
<div class="fs-actions">
<span class="fs-name" id="fs-file-name"></span>
<!-- 源码切换钮:仅当当前内容有源文本时显隐(toggleFsSrc 在渲染视图/源码面板间互切) -->
<button class="fs-btn hidden" id="fs-src-btn" title="显示源码" aria-label="显示源码">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><use href="#i-eye"/></svg>
</button>
<!-- 复制源码:显隐与 eye 一致(有源文本才出现);HTML/SVG/MD/代码通用 -->
<button class="fs-btn hidden" id="fs-copy-btn" title="复制源码" aria-label="复制源码">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><use href="#i-copy"/></svg>
</button>
<button class="fs-btn" onclick="closeFullscreen()" title="关闭" aria-label="关闭">✕</button>
</div>
<div class="fs-panel" id="fs-body"></div>
<div class="fs-panel fs-src-panel hidden" id="fs-src-pane"><pre id="fs-src-code"></pre></div>
</div>
<!-- 拖拽上传提示层:window 级 dragenter 时显示;pointer-events:none,不参与命中测试(逻辑见 js/files.js) -->
<div id="drop-overlay" class="hidden" aria-hidden="true">
<div class="drop-hint">
<svg viewBox="0 0 24 24" class="ic"><use href="#i-upload-cloud"/></svg>
<span>松开即可上传</span>
</div>
</div>
<script src="/js/viewport.js"></script>
<script src="/js/core.js"></script>
<script src="/js/chat.js"></script>
<script src="/js/sessions.js"></script>
<script src="/js/stream.js"></script>
<script src="/js/files.js"></script>
<script src="/js/voice.js"></script>
<script src="/js/preview.js"></script>
<script src="/js/vcs.js"></script>
<script src="/js/files-tree.js"></script>
<script src="/js/settings.js"></script>
<script>
// 启动自愈:外部工具改前端文件是非原子写入,极端时机下浏览器可能拿到半截或重复拼接的 HTML
// (脚本缺半 → 白屏裸首页;重复注入 → 每个文件报 duplicate variable 后 JS 全挂)。
// 这里检测关键脚本数量与入口全局,不对就自动整页重载一次(sessionStorage 防循环)。
// 注意:js/ 脚本增减时需同步改这里的期望数 10。
(function () {
var ok = false;
try {
var n = document.querySelectorAll('script[src^="/js/"]').length;
ok = n === 10 && typeof state !== 'undefined' &&
typeof openFilePreview === 'function' && typeof restartNow === 'function';
} catch (_) {}
if (ok) { try { sessionStorage.removeItem('boot-heal'); } catch (_) {} return; }
try {
if (sessionStorage.getItem('boot-heal')) { sessionStorage.removeItem('boot-heal'); return; }
sessionStorage.setItem('boot-heal', '1');
} catch (_) { return; }
location.reload();
})();
</script>
</body>
</html>