diff --git a/app/server/public/css/style.css b/app/server/public/css/style.css index 753bd8b..ba07ab0 100644 --- a/app/server/public/css/style.css +++ b/app/server/public/css/style.css @@ -1684,18 +1684,18 @@ body.pv-max .pv-code { max-width: none; padding-left: 16px; padding-right: 16px; @media (max-width: 959px) { .pv-cl::before { width: 28px; margin-right: 6px; padding-right: 4px; } } -/* Prism token 配色(GitHub 亮色系):代码预览、md 围栏代码块、Git 面板 diff 共用 */ -:is(.pv-code, .pv-doc, .vcs-line) :is(.token.comment, .token.prolog, .token.doctype, .token.cdata) { color: #6a737d; font-style: italic; } -:is(.pv-code, .pv-doc, .vcs-line) .token.punctuation { color: #24292e; } -:is(.pv-code, .pv-doc, .vcs-line) .token.namespace { opacity: .7; } -:is(.pv-code, .pv-doc, .vcs-line) :is(.token.property, .token.tag, .token.boolean, .token.number, .token.constant, .token.symbol, .token.deleted) { color: #005cc5; } -:is(.pv-code, .pv-doc, .vcs-line) :is(.token.selector, .token.attr-name, .token.string, .token.char, .token.builtin, .token.inserted) { color: #032f62; } -:is(.pv-code, .pv-doc, .vcs-line) :is(.token.operator, .token.entity, .token.url) { color: #d73a49; } -:is(.pv-code, .pv-doc, .vcs-line) :is(.token.atrule, .token.attr-value, .token.keyword) { color: #d73a49; } -:is(.pv-code, .pv-doc, .vcs-line) :is(.token.function, .token.class-name) { color: #6f42c1; } -:is(.pv-code, .pv-doc, .vcs-line) :is(.token.regex, .token.important, .token.variable) { color: #e36209; } -:is(.pv-code, .pv-doc, .vcs-line) .token.bold { font-weight: 600; } -:is(.pv-code, .pv-doc, .vcs-line) .token.italic { font-style: italic; } +/* Prism token 配色(GitHub 亮色系):代码预览、md 围栏代码块(预览与对话正文)、Git 面板 diff 共用 */ +:is(.pv-code, .pv-doc, .vcs-line, .md) :is(.token.comment, .token.prolog, .token.doctype, .token.cdata) { color: #6a737d; font-style: italic; } +:is(.pv-code, .pv-doc, .vcs-line, .md) .token.punctuation { color: #24292e; } +:is(.pv-code, .pv-doc, .vcs-line, .md) .token.namespace { opacity: .7; } +:is(.pv-code, .pv-doc, .vcs-line, .md) :is(.token.property, .token.tag, .token.boolean, .token.number, .token.constant, .token.symbol, .token.deleted) { color: #005cc5; } +:is(.pv-code, .pv-doc, .vcs-line, .md) :is(.token.selector, .token.attr-name, .token.string, .token.char, .token.builtin, .token.inserted) { color: #032f62; } +:is(.pv-code, .pv-doc, .vcs-line, .md) :is(.token.operator, .token.entity, .token.url) { color: #d73a49; } +:is(.pv-code, .pv-doc, .vcs-line, .md) :is(.token.atrule, .token.attr-value, .token.keyword) { color: #d73a49; } +:is(.pv-code, .pv-doc, .vcs-line, .md) :is(.token.function, .token.class-name) { color: #6f42c1; } +:is(.pv-code, .pv-doc, .vcs-line, .md) :is(.token.regex, .token.important, .token.variable) { color: #e36209; } +:is(.pv-code, .pv-doc, .vcs-line, .md) .token.bold { font-weight: 600; } +:is(.pv-code, .pv-doc, .vcs-line, .md) .token.italic { font-style: italic; } .pv-trunc { max-width: 880px; margin: 12px auto 0; padding: 0 20px; font-size: 12px; color: var(--gray-light); } .pv-loading.inline { position: static; background: transparent; padding: 56px 0; } .pv-none { margin: auto; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 44px 24px; text-align: center; } diff --git a/app/server/public/js/chat.js b/app/server/public/js/chat.js index 7965a1d..ef7910c 100644 --- a/app/server/public/js/chat.js +++ b/app/server/public/js/chat.js @@ -380,6 +380,7 @@ } // 历史渲染收口:给本轮新渲染出的代码块补复制按钮(目标可能是分页离屏容器,装饰后再随节点搬迁) decorateCodePre(target); + pvHighlightMdCode(target); // 对话正文里的围栏代码块也上色(与预览同一套) return { closeArc }; } diff --git a/app/server/public/js/stream.js b/app/server/public/js/stream.js index 1009c5d..5267883 100644 --- a/app/server/public/js/stream.js +++ b/app/server/public/js/stream.js @@ -313,6 +313,7 @@ state.streamEl.className = 'bubble-ai' + (r.fmt ? ' md' : ''); // 增量期间是纯文本,收尾统一换 md 排版 state.streamEl.innerHTML = r.html; decorateCodePre(state.streamEl); // 流式期间不插按钮(每帧整块换 innerHTML),收尾统一装饰一次 + pvHighlightMdCode(state.streamEl); // 围栏代码块上色 } else { // 无文本时去掉气泡(纯工具调用/纯思考也要保留思考面板) state.streamEl.remove(); @@ -326,6 +327,7 @@ bubble.className = 'bubble-ai' + (r.fmt ? ' md' : ''); bubble.innerHTML = r.html; decorateCodePre(bubble); + pvHighlightMdCode(bubble); state.streamWrap.appendChild(bubble); } // 「压缩」总结回合的最终答复(后端已保证只有压缩回合里首条无工具调用的收尾回复才带 is_summary,