refactor(ui): 全站 svg 图标收进 index.html 的 symbol sprite

前端 99 处 svg、56 个唯一图形(× 号 11 次、+ 号 6 次、复制与文档各 5 次),
43 处是纯冗余路径:改一个图标得在两三个文件里同步,加个新图标又要复制一份 path。
现在几何图形统一定义在 index.html 里的一份 sprite,引用写成
<svg 原属性><use href="#i-xxx"/></svg>——外层 class、尺寸、fill/stroke 原样保留,
所以大小和描边仍归各处 CSS 管(.ic / .tree-act svg / .files-fab svg),形状逐像素照搬。

脚本按几何指纹建映射,99 处全部命中,零未匹配;校验结果 symbol 56 个、
引用 99 处、无缺失、无未被引用、sprite 外无残留几何标签,JS 全部 node --check 通过。
同形但历史写法不同的(folder/folder-b/folder-c、x-line/x-line-b/x-path、eye/eye-sm 等)
各留一份 symbol,保证替换前后完全一致,后续要收敛只改引用指向即可。

sprite 容器用 position:absolute + 零尺寸,不用 display:none:后者在部分旧浏览器上
会让被引用的 symbol 也一并不渲染。

体积:index.html +6KB(sprite 定义),js 合计 -5.3KB,总量基本持平。
This commit is contained in:
2026-11-13 15:20:10 +08:00
parent 0433e61941
commit 2e2e47171f
9 changed files with 163 additions and 100 deletions
+108 -44
View File
@@ -84,12 +84,76 @@
</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"></circle><path d="M22 12a10 10 0 0 1-10 10"></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-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"><path stroke-width="2" stroke-linecap="round" d="M4 5h16M4 15h10"/></svg>
<svg viewBox="0 0 24 24" class="ic sm"><use href="#i-history"/></svg>
</button>
<div class="header-center" id="header-center"><!-- 未对话状态为空白,JS 注入对话信息 --></div>
@@ -100,11 +164,11 @@
<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"><circle cx="12" cy="12" r="8.5"></circle><polyline points="12 7.5 12 12 15.5 14"></polyline></svg>
<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"><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></svg>
<svg class="ic" viewBox="0 0 24 24"><use href="#i-database"/></svg>
</button>
</div>
@@ -113,27 +177,27 @@
<div class="header-actions" id="header-actions">
<div class="ha-icons">
<button class="icon-btn ha-btn" data-act="new" data-tip="新建会话" aria-label="新建会话">
<svg class="ic sm" 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></svg>
<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"><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></svg>
<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"><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></svg>
<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"><circle cx="12" cy="12" r="8.5"></circle><polyline points="12 7.5 12 12 15.5 14"></polyline></svg>
<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"><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></svg>
<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="new">
<svg class="ic sm" 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></svg>
<svg class="ic sm" viewBox="0 0 24 24"><use href="#i-plus"/></svg>
<span class="ha-item-main">新建会话</span>
</button>
</div>
@@ -145,7 +209,7 @@
<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"><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></svg>
<svg class="ic" viewBox="0 0 24 24"><use href="#i-robot"/></svg>
</div>
<div class="welcome-slogan">随时开始吧</div>
</div>
@@ -154,11 +218,11 @@
<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"><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></svg>
<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"><line x1="6" y1="6" x2="18" y2="18"></line><line x1="18" y1="6" x2="6" y2="18"></line></svg>
<svg class="ic sm" viewBox="0 0 24 24"><use href="#i-x-line"/></svg>
</button>
</div>
</section>
@@ -186,23 +250,23 @@
<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"><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></svg>
<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"><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></svg>
<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"><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></svg>
<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"><line x1="12" y1="19" x2="12" y2="5"></line><polyline points="5 12 12 5 19 12"></polyline></svg>
<svg class="ic sm ic-voice" 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></svg>
<svg class="ic sm ic-kb" 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></svg>
<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>
@@ -217,8 +281,8 @@
<!-- 回到底部浮动按钮(搬自 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"><polyline points="6 9 12 15 18 9"></polyline></svg>
<svg class="sb-spinner hidden" viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"></circle><path d="M22 12a10 10 0 0 1-10 10"></path></svg>
<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>
@@ -227,7 +291,7 @@
<aside id="drawer" aria-label="对话历史">
<div class="drawer-search">
<div class="search-box">
<svg class="ic sm" 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></svg>
<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>
@@ -238,10 +302,10 @@
窄屏两个都隐藏:文件只保留输入行右侧的旧面板(不做两套)。选中项高亮。 -->
<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"><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></svg>
<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"><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></svg>
<svg viewBox="0 0 24 24"><use href="#i-gear"/></svg>
</button>
</div>
</aside>
@@ -254,7 +318,7 @@
<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"><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></svg>
<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>
@@ -270,10 +334,10 @@
</div>
<div class="files-panel-actions">
<button class="files-fab" id="files-bulk-download" title="批量下载" aria-label="批量下载" disabled>
<svg 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></svg>
<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"><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"/></svg>
<svg viewBox="0 0 24 24"><use href="#i-trash"/></svg>
</button>
</div>
</div>
@@ -288,7 +352,7 @@
<!-- 顶栏:左侧返回 + 中间标题 + 右侧操作按钮,风格与对话页 header 一致 -->
<header class="header">
<button class="icon-btn" id="set-back-btn" title="返回" aria-label="返回">
<svg class="ic" viewBox="0 0 24 24"><polyline points="15 18 9 12 15 6"></polyline></svg>
<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>
@@ -301,7 +365,7 @@
<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"><line x1="18" y1="6" x2="6" y2="18"></line><line x1="6" y1="6" x2="18" y2="18"></line></svg>
<svg viewBox="0 0 24 24"><use href="#i-x-line-b"/></svg>
</button>
<h3>新建技能</h3>
<input type="text" id="skill-new-name" placeholder="技能名(字母/数字/-/_)">
@@ -314,7 +378,7 @@
<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"><line x1="18" y1="6" x2="6" y2="18"></line><line x1="6" y1="6" x2="18" y2="18"></line></svg>
<svg viewBox="0 0 24 24"><use href="#i-x-line-b"/></svg>
</button>
<h3 id="mpe-title">编辑平台</h3>
<!-- 平台预设:仅新增平台时展示,点选即填好 url/类型并给模型卡带上该平台的参数缺省 -->
@@ -340,7 +404,7 @@
<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"><line x1="18" y1="6" x2="6" y2="18"></line><line x1="6" y1="6" x2="18" y2="18"></line></svg>
<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">
@@ -362,7 +426,7 @@
<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"><line x1="18" y1="6" x2="6" y2="18"></line><line x1="6" y1="6" x2="18" y2="18"></line></svg>
<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="服务名">
@@ -400,7 +464,7 @@
<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"><line x1="18" y1="6" x2="6" y2="18"></line><line x1="6" y1="6" x2="18" y2="18"></line></svg>
<svg viewBox="0 0 24 24"><use href="#i-x-line-b"/></svg>
</button>
<h3 id="schedule-modal-title">定时任务</h3>
<div class="sched-row">
@@ -433,7 +497,7 @@
<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"><line x1="18" y1="6" x2="6" y2="18"></line><line x1="6" y1="6" x2="18" y2="18"></line></svg>
<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>
@@ -449,7 +513,7 @@
<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"><line x1="18" y1="6" x2="6" y2="18"></line><line x1="6" y1="6" x2="18" y2="18"></line></svg>
<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">
@@ -469,7 +533,7 @@
<p class="msw-sub" id="bind-model-sub">选择一个模型继续当前会话</p>
</div>
<button class="modal-close-btn" onclick="closeModelSwitch()">
<svg 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></svg>
<svg viewBox="0 0 24 24"><use href="#i-x-line-b"/></svg>
</button>
</div>
<div class="msw-list" id="bind-model-list"></div>
@@ -494,23 +558,23 @@
<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"><polyline points="23 4 23 10 17 10"></polyline><path d="M20.49 15a9 9 0 1 1-2.12-9.36L23 10"></path></svg>
<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"><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></svg>
<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"><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></svg>
<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"><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></svg>
<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"><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></svg>
<svg class="ic sm hidden" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><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></svg>
<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>
@@ -527,11 +591,11 @@
<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"><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></svg>
<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"><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></svg>
<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>
@@ -542,7 +606,7 @@
<!-- 拖拽上传提示层: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"><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></svg>
<svg viewBox="0 0 24 24" class="ic"><use href="#i-upload-cloud"/></svg>
<span>松开即可上传</span>
</div>
</div>
+7 -7
View File
@@ -32,13 +32,13 @@
// 删除本条:仅已落库消息可删(传 m.id);流式未落库时无 id,不渲染
const del = msgId
? '<button class="act act-del" title="删除本条" data-msg-id="' + msgId + '">' +
'<svg class="ic sm" viewBox="0 0 24 24"><path d="M18 6 6 18"></path><path d="m6 6 12 12"></path></svg>' +
'<svg class="ic sm" viewBox="0 0 24 24"><use href="#i-x-path"/></svg>' +
'</button>'
: '';
// 编辑并重发:只给未压缩的用户消息(调用方传 canEdit);带 b64 回填输入框,避免从 DOM 反推
const edit = canEdit && msgId
? '<button class="act act-edit" title="编辑并重发" data-msg-id="' + msgId + '" data-b64="' + b64 + '">' +
'<svg class="ic sm" 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></svg>' +
'<svg class="ic sm" viewBox="0 0 24 24"><use href="#i-pencil"/></svg>' +
'</button>'
: '';
const u = normUsage(usage);
@@ -49,7 +49,7 @@
'<span>' + fmtTime(ts) + '</span>' +
usageHtml +
'<button class="act act-copy" title="复制" data-b64="' + b64 + '">' +
'<svg class="ic sm" 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></svg>' +
'<svg class="ic sm" viewBox="0 0 24 24"><use href="#i-copy"/></svg>' +
'</button>' +
edit +
del +
@@ -100,7 +100,7 @@
// 历史重渲染默认收起(与原设计一致),流式阶段的展开行为由 ensureStreamThinkPanel 显式控制。
// 复制按钮走 onCopyClick 统一代理:点击时从 DOM 取思考全文(不依赖 b64,流式增量也能复制)
const THINK_COPY_BTN = '<button class="act act-copy" title="复制思考内容">' +
'<svg class="ic sm" 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></svg>' +
'<svg class="ic sm" viewBox="0 0 24 24"><use href="#i-copy"/></svg>' +
'</button>';
function thinkPanelHtml(text) {
return '<details class="msg-think"><summary>思考过程' + THINK_COPY_BTN + '</summary><div class="msg-think-body">' + esc(text) + '</div></details>';
@@ -112,7 +112,7 @@
// 复制文本在点击时从 pre.textContent 现取(onCopyClick 的 .code-wrap 分支),不嵌 b64、不怕内容后续变化。
// 只碰 .md 里的 pre:工具卡 / 思考区已有自己的复制按钮,行内 code 不加。
const CODE_COPY_BTN = '<button class="act act-copy" type="button" title="复制代码">' +
'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><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></svg>' +
'<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>';
function decorateCodePre(root) {
if (!root || !root.querySelectorAll) return;
@@ -172,14 +172,14 @@
if (!text) return '';
const b64 = btoa(unescape(encodeURIComponent(text)));
return '<button class="act act-copy" title="复制参数与结果" data-b64="' + b64 + '">' +
'<svg class="ic sm" 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></svg></button>';
'<svg class="ic sm" viewBox="0 0 24 24"><use href="#i-copy"/></svg></button>';
}
// 工具卡「删除本条」:删的是 tool 消息行;后端会把它在父 assistant 里的调用同步摘除。
// msgId = tool 消息的库行 id(历史渲染传 m.id;实时由 tool_result 事件的 msg_id 携带)
function toolDelBtnHtml(msgId) {
if (!msgId) return '';
return '<button class="act act-del" title="删除本条" data-msg-id="' + msgId + '">' +
'<svg class="ic sm" viewBox="0 0 24 24"><path d="M18 6 6 18"></path><path d="m6 6 12 12"></path></svg></button>';
'<svg class="ic sm" viewBox="0 0 24 24"><use href="#i-x-path"/></svg></button>';
}
function renderToolCard(id, name, argsStr, createdAt, opts) {
const div = document.createElement('div');
+2 -2
View File
@@ -148,11 +148,11 @@
const MODES = {
secretary: {
label: '文秘助理', hint: '支持文字输入,可起草、润色、整理文书',
icon: '<svg class="header-mode-icon" 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></svg>',
icon: '<svg class="header-mode-icon" viewBox="0 0 24 24"><use href="#i-gem"/></svg>',
},
vision: {
label: '识图专家', hint: '支持图片识别输入',
icon: '<svg class="header-mode-icon" 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></svg>',
icon: '<svg class="header-mode-icon" viewBox="0 0 24 24"><use href="#i-image"/></svg>',
},
};
+11 -11
View File
@@ -8,17 +8,17 @@
// 依赖(全局):state $ req toast downloadFile confirmModal openFilePreview
'use strict';
(function () {
const SVG_FOLDER = '<svg class="ic sm" 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"/></svg>';
const SVG_FILE = '<svg class="ic sm" viewBox="0 0 24 24"><path d="M6 3h8l4 4v14H6z"/><path d="M14 3v4h4"/></svg>';
const SVG_LINK = '<svg class="ic sm" 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"/></svg>';
const SVG_REVEAL = '<svg class="ic sm" 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"/></svg>';
const SVG_REFRESH = '<svg class="ic sm" viewBox="0 0 24 24"><path d="M20 12a8 8 0 1 1-2.3-5.7"/><path d="M20 4v5h-5"/></svg>';
const SVG_TERM = '<svg class="ic sm" 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"/></svg>';
const SVG_VCS = '<svg class="ic sm" 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"/></svg>';
const SVG_EYE = '<svg class="ic 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"/></svg>';
const SVG_DL = '<svg viewBox="0 0 24 24"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>';
const SVG_DEL = '<svg 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"/></svg>';
const SVG_REVEAL_SM = '<svg 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"/></svg>';
const SVG_FOLDER = '<svg class="ic sm" viewBox="0 0 24 24"><use href="#i-folder"/></svg>';
const SVG_FILE = '<svg class="ic sm" viewBox="0 0 24 24"><use href="#i-file"/></svg>';
const SVG_LINK = '<svg class="ic sm" viewBox="0 0 24 24"><use href="#i-link"/></svg>';
const SVG_REVEAL = '<svg class="ic sm" viewBox="0 0 24 24"><use href="#i-external-b"/></svg>';
const SVG_REFRESH = '<svg class="ic sm" viewBox="0 0 24 24"><use href="#i-reload"/></svg>';
const SVG_TERM = '<svg class="ic sm" viewBox="0 0 24 24"><use href="#i-terminal"/></svg>';
const SVG_VCS = '<svg class="ic sm" viewBox="0 0 24 24"><use href="#i-git"/></svg>';
const SVG_EYE = '<svg class="ic sm" viewBox="0 0 24 24"><use href="#i-eye-sm"/></svg>';
const SVG_DL = '<svg viewBox="0 0 24 24"><use href="#i-download"/></svg>';
const SVG_DEL = '<svg viewBox="0 0 24 24"><use href="#i-trash"/></svg>';
const SVG_REVEAL_SM = '<svg viewBox="0 0 24 24"><use href="#i-external-b"/></svg>';
let localCapable = false; // local 启动器:才显示「在 Finder/终端中打开」
let showHidden = false;
+9 -9
View File
@@ -329,8 +329,8 @@
const low = f.filename.toLowerCase();
const fsPv = /\.(md|txt|html?|pdf|png|jpe?g|gif|webp|svg|docx|xlsx|pptx|csv|tsv|json|jsonl|xml|yml|yaml|toml|ini|conf|cfg|properties|env|log|py|pyw|js|mjs|cjs|ts|tsx|jsx|java|kt|c|h|cpp|hpp|cc|cs|go|rs|rb|php|swift|sh|bash|zsh|bat|ps1|sql|lua|r|dart|vue|css|less|scss|srt|vtt)$/.test(low);
const ico = fsPv
? '<svg class="file-ico eye" viewBox="0 0 24 24" aria-label="可预览"><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></svg>'
: '<svg class="file-ico doc" viewBox="0 0 24 24" aria-label="可下载"><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></svg>';
? '<svg class="file-ico eye" viewBox="0 0 24 24" aria-label="可预览"><use href="#i-eye"/></svg>'
: '<svg class="file-ico doc" viewBox="0 0 24 24" aria-label="可下载"><use href="#i-file-doc"/></svg>';
const name = esc(String(f.filename).split('/').pop() || f.filename);
const ftime = fmtTime(f.mtime || f.ctime);
const sel = isFileEffectivelySelected(f.filename);
@@ -352,10 +352,10 @@
(under.length > 0 && under.every(isFileEffectivelySelected));
return '<div class="file-dir-head' + (checked ? ' selected' : '') + '" data-dir="' + esc(node.path) + '" role="button">' +
'<span class="file-check" role="checkbox" aria-checked="' + (checked ? 'true' : 'false') + '" aria-label="选择文件夹"></span>' +
'<svg class="file-dir-ico" 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></svg>' +
'<svg class="file-dir-ico" viewBox="0 0 24 24"><use href="#i-folder-c"/></svg>' +
'<span class="file-dir-name">' + esc(node.name) + '</span>' +
'<span class="file-dir-count">' + countDirFiles(node) + ' 个文件</span>' +
'<svg class="file-dir-go" viewBox="0 0 24 24"><polyline points="9 18 15 12 9 6"></polyline></svg>' +
'<svg class="file-dir-go" viewBox="0 0 24 24"><use href="#i-chevron-right"/></svg>' +
'</div>';
}
@@ -386,7 +386,7 @@
sizeEl.textContent = total > 0 ? fmtSize(total) : '';
}
// 根节点:home 图标 + 「根目录」,比一个孤悬的「/」醒目得多;在根时它是当前层,纯文本不可点
const homeIc = '<svg class="crumb-ic" 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></svg>';
const homeIc = '<svg class="crumb-ic" viewBox="0 0 24 24"><use href="#i-home"/></svg>';
let html = filesCurDir
? '<span class="crumb" data-path="">' + homeIc + '根目录</span>'
: '<span class="crumb cur">' + homeIc + '根目录</span>';
@@ -773,8 +773,8 @@
function uploadIconSvg(name) {
// 与文件面板同款图标语言:图片用图、其余用文档
return /\.(png|jpe?g|gif|webp|bmp|svg)$/i.test(name || '')
? '<svg class="ic" 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></svg>'
: '<svg class="ic" 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></svg>';
? '<svg class="ic" viewBox="0 0 24 24"><use href="#i-image-b"/></svg>'
: '<svg class="ic" viewBox="0 0 24 24"><use href="#i-file-doc"/></svg>';
}
function addUploadCard(file) {
const row = $('up-cards');
@@ -789,7 +789,7 @@
'<div class="up-meta">' + uploadTypeLabel(file.name) + ' · ' + fmtSize(file.size) + '</div>' +
'</div>' +
'<button class="up-x hidden" title="不再随消息告知该文件" aria-label="移除卡片">' +
'<svg class="ic" 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></svg>' +
'<svg class="ic" viewBox="0 0 24 24"><use href="#i-x-line-b"/></svg>' +
'</button>' +
'<div class="up-mask"><span class="up-pct">0%</span></div>';
const mask = card.querySelector('.up-mask');
@@ -1058,7 +1058,7 @@
row.innerHTML = state.attachments.map((f, i) =>
'<span class="attach-chip"><span class="name">' + esc(f.name) + '</span>' +
'<button class="rm" data-i="' + i + '" aria-label="移除附件">' +
'<svg class="ic sm" 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></svg>' +
'<svg class="ic sm" viewBox="0 0 24 24"><use href="#i-x-line-b"/></svg>' +
'</button></span>').join('');
}
$('attach-chips').addEventListener('click', e => {
+2 -3
View File
@@ -145,8 +145,7 @@ function pvInfoNode(name, sizeText, hint) {
const box = document.createElement('div');
box.className = 'pv-none';
box.innerHTML =
'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round">' +
'<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></svg>' +
'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"><use href="#i-file-doc"/></svg>' +
'<div class="nm"></div><div class="meta"></div><div class="hint"></div>';
box.querySelector('.nm').textContent = String(name || '');
box.querySelector('.meta').textContent = sizeText ? sizeText : '';
@@ -728,7 +727,7 @@ window.matchMedia('(min-width: 960px)').addEventListener('change', () => { if (!
// —— 通用 UI 卡片(stream.js 转发 SSE ui_card;任何 MCP 服务/工具回包附 type:"ui_card" 块即可产出)——
// 产生方契约 {action, arg, title?, note?};新交互在动作注册表加一条即可,未知 action 忽略(向前兼容)。
// 图标由前端统一持有(与 pv-none 同一枚文档 SVG),产生方不提供图形,只给数据。
const UI_CARD_ICON_DOC = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"><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></svg>';
const UI_CARD_ICON_DOC = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"><use href="#i-file-doc"/></svg>';
const UI_CARD_ACTIONS = {
// arg = 相对会话目录的文件路径,点击 = openFilePreview(office 走预览网关,其余类型走文本/图片渲染)
open_preview: { go: '预览 ›', hint: '点击打开预览', icon: UI_CARD_ICON_DOC, run: (d) => openFilePreview(d.arg) },
+3 -3
View File
@@ -32,10 +32,10 @@
'<span class="conv-title">' + esc(s.title || s.id) + '</span>' + drawerStatusDot(s) +
'</button>' +
'<button class="conv-pop" data-pop="' + esc(s.id) + '" title="在新窗口打开" aria-label="在新窗口打开">' +
'<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/><polyline points="15 3 21 3 21 9"/><line x1="10" y1="14" x2="21" y2="3"/></svg>' +
'<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><use href="#i-external"/></svg>' +
'</button>' +
'<button class="conv-del" data-del="' + esc(s.id) + '" title="删除会话" aria-label="删除会话">' +
'<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round"><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"/></svg>' +
'<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round"><use href="#i-trash"/></svg>' +
'</button>' +
'</div>';
}
@@ -814,7 +814,7 @@
wrap.innerHTML =
'<div class="modal">' +
'<button class="modal-close-btn" data-act="cancel" aria-label="关闭">' +
'<svg 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></svg>' +
'<svg viewBox="0 0 24 24"><use href="#i-x-line-b"/></svg>' +
'</button>' +
'<h3 id="compress-modal-title">压缩上下文</h3>' +
'<div class="modal-body" style="font-size:14px;line-height:1.55;color:#555;padding:4px 0 12px;">' +
+19 -19
View File
@@ -146,7 +146,7 @@
// 快照里的 id 全部剥除,防止重复 id 干扰 $('…') 查找;仅作动画背景,滑完由 renderSetPage 重渲染真页。
function snapSetPage() {
const box = document.createElement('div');
box.innerHTML = '<header class="header"><button class="icon-btn" tabindex="-1"><svg class="ic" viewBox="0 0 24 24"><polyline points="15 18 9 12 15 6"></polyline></svg></button>' +
box.innerHTML = '<header class="header"><button class="icon-btn" tabindex="-1"><svg class="ic" viewBox="0 0 24 24"><use href="#i-chevron-left"/></svg></button>' +
'<div class="header-center"><div class="header-title">' + esc($('set-title').textContent) + '</div></div>' +
'<div class="header-right">' + $('set-actions').innerHTML + '</div></header>' +
'<div class="set-under-body">' + $('set-body').innerHTML + '</div>';
@@ -281,17 +281,17 @@
// ---------- 页:设置主页(卡片入口) ----------
const SET_CARDS = [
{ go: 'account', name: '账户', desc: '修改密码 · 用户画像 · 退出登录',
icon: '<svg class="ic" 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></svg>' },
icon: '<svg class="ic" viewBox="0 0 24 24"><use href="#i-user"/></svg>' },
{ go: 'users', name: '用户', desc: '账号 · 角色 · 默认模型', adminOnly: true, needAuth: true,
icon: '<svg class="ic" 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></svg>' },
icon: '<svg class="ic" viewBox="0 0 24 24"><use href="#i-users"/></svg>' },
{ go: 'service', name: '服务', desc: '服务状态 · 系统配置', adminOnly: true,
icon: '<svg class="ic" 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></svg>' },
icon: '<svg class="ic" viewBox="0 0 24 24"><use href="#i-sliders-v"/></svg>' },
{ go: 'skills', name: '技能', desc: '技能管理 · 技能文件编辑', adminOnly: true,
icon: '<svg class="ic" viewBox="0 0 24 24"><polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2"></polygon></svg>' },
icon: '<svg class="ic" viewBox="0 0 24 24"><use href="#i-zap"/></svg>' },
{ go: 'models', name: '模型', desc: '模型池状态 · 增删改', adminOnly: true,
icon: '<svg class="ic" 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></svg>' },
icon: '<svg class="ic" viewBox="0 0 24 24"><use href="#i-cpu"/></svg>' },
{ go: 'mcp', name: 'MCP', desc: 'MCP 服务 · 增删改', adminOnly: true,
icon: '<svg class="ic" 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></svg>' },
icon: '<svg class="ic" viewBox="0 0 24 24"><use href="#i-layout"/></svg>' },
];
function setPageHome(ctx) {
setTitle('设置');
@@ -303,7 +303,7 @@
'<span class="set-ico">' + c.icon + '</span>' +
'<span class="set-tt"><span class="set-name">' + c.name + '</span>' +
'<span class="set-desc">' + c.desc + '</span></span>' +
'<svg class="ic sm set-arrow" viewBox="0 0 24 24"><polyline points="9 6 15 12 9 18"></polyline></svg>' +
'<svg class="ic sm set-arrow" viewBox="0 0 24 24"><use href="#i-chevron-right-b"/></svg>' +
'</button>').join('') + '</div>');
}
@@ -395,7 +395,7 @@
async function setPageUsers(ctx) {
setTitle('用户');
setActions('<button class="icon-btn" title="添加用户" onclick="sUI.openUserAdd()">' +
'<svg class="ic" 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></svg></button>');
'<svg class="ic" viewBox="0 0 24 24"><use href="#i-plus"/></svg></button>');
setBody('<div class="set-scroll" id="user-list"><div class="empty-tip">加载中…</div></div>');
try {
const r = await req('GET', '/api/users');
@@ -689,7 +689,7 @@
async function setPageService(ctx) {
setTitle('服务');
setActions('<button class="icon-btn" title="编辑配置文件" onclick="sUI.openCfg()">' +
'<svg class="ic" 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></svg></button>');
'<svg class="ic" viewBox="0 0 24 24"><use href="#i-edit"/></svg></button>');
setBody('<div class="set-scroll" id="svc-body"><div class="empty-tip">加载中…</div></div>');
try {
const [st, cg] = await Promise.all([
@@ -769,7 +769,7 @@
async function setPageCfgEditor(ctx) {
setTitle('config.yml 原文');
setActions('<button class="icon-btn" title="校验并保存" onclick="sUI.saveCfg()">' +
'<svg class="ic" viewBox="0 0 24 24"><polyline points="20 6 9 17 4 12"></polyline></svg></button>');
'<svg class="ic" viewBox="0 0 24 24"><use href="#i-check"/></svg></button>');
setBody('<div class="set-editor"><div class="cfg-err hidden" id="cfg-editor-err"></div>' +
'<textarea id="set-editor-area" spellcheck="false" autocomplete="off" autocapitalize="off"></textarea></div>');
try {
@@ -812,7 +812,7 @@
SET.curSkill = null;
setTitle('技能管理');
setActions('<button class="icon-btn" title="新建技能" onclick="sUI.openCreate()">' +
'<svg class="ic" 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></svg></button>');
'<svg class="ic" viewBox="0 0 24 24"><use href="#i-plus"/></svg></button>');
setBody('<div class="set-scroll" id="skills-list"><div class="empty-tip">加载中…</div></div>');
try {
const rows = await req('GET', '/api/skills');
@@ -855,7 +855,7 @@
setTitle(SET.curSkill);
setActions('<label class="icon-btn" title="上传文件">' +
'<input type="file" style="display:none;" onchange="sUI.onUpload(event)">' +
'<svg class="ic" 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></svg></label>');
'<svg class="ic" viewBox="0 0 24 24"><use href="#i-upload-cloud"/></svg></label>');
setBody('<div class="set-scroll" id="skill-detail"><div class="empty-tip">加载中…</div></div>');
try {
const d = await req('GET', '/api/skills/' + encodeURIComponent(SET.curSkill));
@@ -871,7 +871,7 @@
el.innerHTML = '<div class="skill-files">' + d.files.map(f => {
const a = encodeURIComponent(f.filename);
return '<div class="file-row" onclick="sUI.editFile(\'' + a + '\')">' +
'<svg class="file-ico" 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></svg>' +
'<svg class="file-ico" viewBox="0 0 24 24"><use href="#i-file-doc"/></svg>' +
'<span class="file-name">' + esc(f.filename) + '</span>' +
'<span class="file-size">' + fmtSize(f.size) + '</span>' +
'<button class="file-act" onclick="event.stopPropagation();sUI.editFile(\'' + a + '\')">编辑</button>' +
@@ -885,7 +885,7 @@
function setPageSkillEditor(ctx) {
setTitle(SET.editorLabel || '编辑文件');
setActions('<button class="icon-btn" title="保存" onclick="sUI.saveFile()">' +
'<svg class="ic" viewBox="0 0 24 24"><polyline points="20 6 9 17 4 12"></polyline></svg></button>');
'<svg class="ic" viewBox="0 0 24 24"><use href="#i-check"/></svg></button>');
setBody('<div class="set-editor"><textarea id="set-editor-area" spellcheck="false" autocomplete="off" autocapitalize="off"></textarea></div>');
$('set-editor-area').value = SET.editorText;
}
@@ -1066,7 +1066,7 @@
if (ev) ev.stopPropagation(); // 冒泡到分组头会误触折叠/展开
fetchBalance(pi + '-' + ki, pi, ki, true);
}
const BAL_REFRESH_SVG = '<svg 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></svg>';
const BAL_REFRESH_SVG = '<svg viewBox="0 0 24 24"><use href="#i-refresh"/></svg>';
// 平台卡折叠/展开(gk = 'p'+pi)。首次展开:给该平台每个 Key 行自动查一次余额(每页会话一次;手动刷新不受限)。
function toggleModelGroup(gk) {
const on = !SET.expandedGroups[gk];
@@ -1159,7 +1159,7 @@
}).join('') : '';
return '<div class="model-group' + (open ? ' open' : '') + '" id="mgrp-' + gk + '">' +
'<div class="model-group-head" onclick="sUI.toggleGroup(\'' + gk + '\')">' +
'<svg class="model-group-caret" viewBox="0 0 24 24"><polyline points="9 6 15 12 9 18"></polyline></svg>' +
'<svg class="model-group-caret" viewBox="0 0 24 24"><use href="#i-chevron-right-b"/></svg>' +
'<span class="model-group-name">' + esc(p.name || ('平台' + pi)) + '</span>' +
'<span class="model-group-badge">' + keys.length + ' keys</span>' +
'<span class="model-group-meta">' + models.filter(m => m.enable !== false).length + ' / ' + models.length + ' 模型</span>' +
@@ -1212,7 +1212,7 @@
function setPageModels(ctx) {
setTitle('模型池');
setActions('<button class="icon-btn" title="添加模型" onclick="sUI.openAdd()">' +
'<svg class="ic" 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></svg></button>');
'<svg class="ic" viewBox="0 0 24 24"><use href="#i-plus"/></svg></button>');
setBody('<div class="set-scroll" id="model-cards"><div class="empty-tip">加载中…</div></div>');
// 余额与展开态跨设置内导航保持(仅 closeSettings 回会话页时重置),重进本页不重复查余额
loadModelCards(ctx);
@@ -1622,7 +1622,7 @@
async function setPageMcp(ctx) {
setTitle('MCP 服务');
setActions('<button class="icon-btn" title="添加 MCP 服务" onclick="mcpUI.add()">' +
'<svg class="ic" 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></svg></button>');
'<svg class="ic" viewBox="0 0 24 24"><use href="#i-plus"/></svg></button>');
setBody('<div class="set-scroll" id="mcp-list"><div class="empty-tip">加载中…</div></div>');
await loadMcpList(ctx);
}
+2 -2
View File
@@ -99,8 +99,8 @@
// 队列本身在服务端(engine.pendings),关页面/换设备/重连都不丢;这里只负责画。
// 每条一行;只有队首有「干预 / 立即发送」,其余显示排队中(不能越过前一条先发)。
// 两条操作各配一枚图标:笔=撤回编辑(正文退回输入框),垃圾桶=直接丢弃这条
const SQ_EDIT_ICON = '<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round"><path d="M12 20h9"/><path d="M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z"/></svg>';
const SQ_TRASH_ICON = '<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round"><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"/></svg>';
const SQ_EDIT_ICON = '<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round"><use href="#i-pencil-b"/></svg>';
const SQ_TRASH_ICON = '<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round"><use href="#i-trash"/></svg>';
function renderSendQueue() {
const box = $('send-queue');