feat(M7.3): 前端体验批次——mdRender 渲染标题/列表(去##残留)、消息样式对齐豆包(去蓝粉底+灰线分割)、代码块无滚动条(pre-wrap)+操作栏(复制到编辑器/复制)、输入区高度拖拽、IME 组合态不触发发送(修复英文单词重复提交)、提交语言匹配提示;提示词追加 Allman/大括号/命名规范
这个提交包含在:
+78
-7
@@ -85,11 +85,16 @@ body{font-family:var(--sans);background:var(--bg);color:var(--text);font-size:14
|
|||||||
@keyframes blink{0%,100%{opacity:1}50%{opacity:.35}}
|
@keyframes blink{0%,100%{opacity:1}50%{opacity:.35}}
|
||||||
.msg{max-width:97%;padding:10px 13px;border-radius:10px;font-size:13.5px;line-height:1.7;white-space:normal;word-wrap:break-word;animation:fade .25s ease}
|
.msg{max-width:97%;padding:10px 13px;border-radius:10px;font-size:13.5px;line-height:1.7;white-space:normal;word-wrap:break-word;animation:fade .25s ease}
|
||||||
/* 会话分界符(P7.1):视觉分隔线,分界后算新一轮对话 */
|
/* 会话分界符(P7.1):视觉分隔线,分界后算新一轮对话 */
|
||||||
|
#edResizer{height:4px;cursor:row-resize;background:transparent;flex:0 0 4px;transition:background .15s}
|
||||||
|
#edResizer:hover{background:#c8d2e0}
|
||||||
.sep-line{margin:10px 0 4px;display:flex;align-items:center;gap:10px;color:var(--text3);font-size:12px}
|
.sep-line{margin:10px 0 4px;display:flex;align-items:center;gap:10px;color:var(--text3);font-size:12px}
|
||||||
.sep-line::before,.sep-line::after{content:'';flex:1;height:1px;background:var(--line2)}
|
.sep-line::before,.sep-line::after{content:'';flex:1;height:1px;background:var(--line2)}
|
||||||
@keyframes fade{from{opacity:0;transform:translateY(4px)}to{opacity:1;transform:none}}
|
@keyframes fade{from{opacity:0;transform:translateY(4px)}to{opacity:1;transform:none}}
|
||||||
.msg.ai{background:var(--blue-bg);border:1px solid #d4e4f3;align-self:flex-start;border-top-left-radius:3px}
|
.msg.ai{background:transparent;border:none;align-self:flex-start;padding:4px 2px}
|
||||||
.msg.user{background:var(--pink-bg);border:1px solid #f0d3db;align-self:flex-end;border-top-right-radius:3px}
|
.msg.user{background:#f2f3f5;border:none;align-self:flex-end;border-radius:10px;padding:8px 12px;max-width:88%}
|
||||||
|
/* 对话流消息间灰色细分割线(豆包风格),最后一条不显示 */
|
||||||
|
.chat-flow .msg{padding-top:10px;padding-bottom:6px;border-bottom:1px solid #eceef1}
|
||||||
|
.chat-flow .msg:last-child{border-bottom:none}
|
||||||
.msg.judge{border:1px solid var(--line);align-self:stretch;border-radius:10px;overflow:hidden}
|
.msg.judge{border:1px solid var(--line);align-self:stretch;border-radius:10px;overflow:hidden}
|
||||||
.msg.sys{background:var(--line2);color:var(--text2);font-size:12.5px;align-self:center;border-radius:20px;padding:4px 14px}
|
.msg.sys{background:var(--line2);color:var(--text2);font-size:12.5px;align-self:center;border-radius:20px;padding:4px 14px}
|
||||||
.msg .mdtable{width:100%;border-collapse:collapse;font-size:12px;margin-top:6px}
|
.msg .mdtable{width:100%;border-collapse:collapse;font-size:12px;margin-top:6px}
|
||||||
@@ -106,7 +111,11 @@ body{font-family:var(--sans);background:var(--bg);color:var(--text);font-size:14
|
|||||||
/* Markdown 代码块 */
|
/* Markdown 代码块 */
|
||||||
.md-code{background:#2d3a4d;border-radius:8px;margin:6px 0;overflow:hidden}
|
.md-code{background:#2d3a4d;border-radius:8px;margin:6px 0;overflow:hidden}
|
||||||
.md-code .md-code-lang{display:inline-block;background:#3d4c63;color:#a8c0e0;font-size:10.5px;padding:2px 10px;border-radius:0 0 6px 0;font-family:var(--mono)}
|
.md-code .md-code-lang{display:inline-block;background:#3d4c63;color:#a8c0e0;font-size:10.5px;padding:2px 10px;border-radius:0 0 6px 0;font-family:var(--mono)}
|
||||||
.md-code pre{background:#2d3a4d;color:#c8d3e0;font-family:var(--mono);font-size:12.5px;line-height:1.65;padding:10px 12px;white-space:pre;overflow-x:auto;margin:0;max-height:260px;overflow-y:auto}
|
.md-code pre{background:#2d3a4d;color:#c8d3e0;font-family:var(--mono);font-size:12.5px;line-height:1.65;padding:10px 12px;white-space:pre-wrap;word-break:break-word;overflow:visible;margin:0;max-height:none}
|
||||||
|
.md-code-bar{display:flex;align-items:center;gap:8px;background:#3d4c63;border-radius:6px 6px 0 0;padding:3px 8px}
|
||||||
|
.md-code-bar .md-code-lang{display:inline-block;background:#3d4c63;color:#a8c0e0;font-size:10.5px;padding:2px 6px;border-radius:4px;font-family:var(--mono);flex:1}
|
||||||
|
.md-code-bar button{background:#4a5a73;color:#dbe6f2;border:none;font-size:10.5px;padding:2px 10px;border-radius:4px;cursor:pointer;font-family:inherit}
|
||||||
|
.md-code-bar button:hover{background:#5a6c88}
|
||||||
.jc-actions{display:flex;gap:8px;padding:10px 14px;border-top:1px solid var(--line2);flex-wrap:wrap;align-items:center}
|
.jc-actions{display:flex;gap:8px;padding:10px 14px;border-top:1px solid var(--line2);flex-wrap:wrap;align-items:center}
|
||||||
/* 选择题卡片 */
|
/* 选择题卡片 */
|
||||||
.choice-block{background:var(--card);border:1.5px solid var(--line);border-radius:10px;padding:12px 14px;align-self:stretch}
|
.choice-block{background:var(--card);border:1.5px solid var(--line);border-radius:10px;padding:12px 14px;align-self:stretch}
|
||||||
@@ -243,13 +252,14 @@ body{font-family:var(--sans);background:var(--bg);color:var(--text);font-size:14
|
|||||||
</div>
|
</div>
|
||||||
<div class="chat-flow" id="chatFlow"></div>
|
<div class="chat-flow" id="chatFlow"></div>
|
||||||
<div class="chat-input">
|
<div class="chat-input">
|
||||||
<input id="chatText" placeholder="问 AI 问题… Enter 发送" onkeydown="if(event.key==='Enter'&&!event.shiftKey){sendChat();}">
|
<input id="chatText" placeholder="问 AI 问题… Enter 发送" onkeydown="if(event.key==='Enter'&&!event.shiftKey&&!event.isComposing){sendChat();}">
|
||||||
<button class="btn" onclick="sendChat()">发送</button>
|
<button class="btn" onclick="sendChat()">发送</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 右:统一输入区(对话/代码/LaTeX 三形态,无 tab) -->
|
<!-- 右:统一输入区(对话/代码/LaTeX 三形态,无 tab) -->
|
||||||
<div class="editor">
|
<div class="editor">
|
||||||
|
<div id="edResizer" title="拖拽调整输入区高度"></div>
|
||||||
<div class="editor-head">
|
<div class="editor-head">
|
||||||
<span>统一输入区</span>
|
<span>统一输入区</span>
|
||||||
<span class="morph" title="自动识别输入内容切换形态,可点选手动强制">
|
<span class="morph" title="自动识别输入内容切换形态,可点选手动强制">
|
||||||
@@ -388,7 +398,8 @@ function init(){
|
|||||||
else setMorph('dialog');
|
else setMorph('dialog');
|
||||||
});
|
});
|
||||||
document.getElementById('dialogArea').addEventListener('keydown', function(e){
|
document.getElementById('dialogArea').addEventListener('keydown', function(e){
|
||||||
if(e.key==='Enter' && !e.shiftKey){ e.preventDefault(); sendDialog(); }
|
// 输入法组合态(回车确认候选词)不触发发送,避免英文单词被重复提交
|
||||||
|
if(e.key==='Enter' && !e.shiftKey && !e.isComposing && e.keyCode!==229){ e.preventDefault(); sendDialog(); }
|
||||||
});
|
});
|
||||||
// 初始:加载会话历史(有则恢复,无则干净欢迎语);不自动加载题目(学科窗口建立后由 AI 出题/题库路由产生)
|
// 初始:加载会话历史(有则恢复,无则干净欢迎语);不自动加载题目(学科窗口建立后由 AI 出题/题库路由产生)
|
||||||
initConv();
|
initConv();
|
||||||
@@ -682,6 +693,12 @@ function sendDialog(){
|
|||||||
function LANG_NAME(){ var m={java:'Java',python:'Python',cpp:'C++'}; return m[CUR_LANG]||CUR_LANG; }
|
function LANG_NAME(){ var m={java:'Java',python:'Python',cpp:'C++'}; return m[CUR_LANG]||CUR_LANG; }
|
||||||
function submitCode(){
|
function submitCode(){
|
||||||
if(PENDING) return;
|
if(PENDING) return;
|
||||||
|
/* 语言匹配提示:题目指定语言与编辑器语言不符时提醒(如 Java 题用 C++ 提交会 CE) */
|
||||||
|
if(CUR_PROBLEM && CUR_PROBLEM.lang && CUR_PROBLEM.lang!==CUR_LANG){
|
||||||
|
if(!confirm('此题建议用 '+CUR_PROBLEM.lang.toUpperCase()+' 作答,当前选择 '+LANG_NAME()+'。语言不符可能导致编译错误(CE),仍要继续提交吗?')){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
var code=ED.getValue(); LAST_CODE=code; VER++;
|
var code=ED.getValue(); LAST_CODE=code; VER++;
|
||||||
PENDING=true; var dot=document.getElementById('sendDot'); dot.disabled=true;
|
PENDING=true; var dot=document.getElementById('sendDot'); dot.disabled=true;
|
||||||
addMsg('user', '<div style="font-family:var(--mono);font-size:12px;white-space:pre-wrap">提交代码('+LANG_NAME()+')· 版本 v'+VER+'</div>');
|
addMsg('user', '<div style="font-family:var(--mono);font-size:12px;white-space:pre-wrap">提交代码('+LANG_NAME()+')· 版本 v'+VER+'</div>');
|
||||||
@@ -815,6 +832,44 @@ function fallbackJudge(code){ /* 后端不可达时的本地演示(prototype m
|
|||||||
}
|
}
|
||||||
function loadVersion(i){ ED.setValue(SUBMISSIONS[i].code); setMorph('code'); lspCheck(); toast('已载入版本 v'+(i+1)+' 到编辑器'); }
|
function loadVersion(i){ ED.setValue(SUBMISSIONS[i].code); setMorph('code'); lspCheck(); toast('已载入版本 v'+(i+1)+' 到编辑器'); }
|
||||||
function copyToEditor(){ ED.setValue(LAST_CODE); setMorph('code'); lspCheck(); toast('已复制回编辑器(可继续修改)'); }
|
function copyToEditor(){ ED.setValue(LAST_CODE); setMorph('code'); lspCheck(); toast('已复制回编辑器(可继续修改)'); }
|
||||||
|
/* 对话流代码块 → 复制到编辑器(自动切换代码形态、替换编辑器原代码) */
|
||||||
|
function mdCopyToEditor(btn){
|
||||||
|
var pre=btn.closest('.md-code').querySelector('pre');
|
||||||
|
if(!pre) return;
|
||||||
|
ED.setValue(pre.textContent); setMorph('code'); lspCheck();
|
||||||
|
toast('已复制到编辑器(替换原代码)');
|
||||||
|
}
|
||||||
|
/* 对话流代码块 → 普通复制 */
|
||||||
|
function copyPlain(btn){
|
||||||
|
var pre=btn.closest('.md-code').querySelector('pre');
|
||||||
|
if(!pre) return;
|
||||||
|
var t=pre.textContent;
|
||||||
|
if(navigator.clipboard&&navigator.clipboard.writeText){ navigator.clipboard.writeText(t).then(function(){toast('代码已复制');},function(){fallbackCopy(t);}); }
|
||||||
|
else fallbackCopy(t);
|
||||||
|
}
|
||||||
|
function fallbackCopy(t){
|
||||||
|
var ta=document.createElement('textarea'); ta.value=t; document.body.appendChild(ta); ta.select();
|
||||||
|
try{document.execCommand('copy'); toast('代码已复制');}catch(e){toast('复制失败,请手动选中');}
|
||||||
|
document.body.removeChild(ta);
|
||||||
|
}
|
||||||
|
/* 输入区高度拖拽调整 */
|
||||||
|
(function(){
|
||||||
|
var rz=document.getElementById('edResizer'); if(!rz) return;
|
||||||
|
rz.addEventListener('mousedown',function(e){
|
||||||
|
e.preventDefault();
|
||||||
|
var ed=document.querySelector('.editor'); if(!ed) return;
|
||||||
|
var startY=e.clientY, startH=ed.offsetHeight;
|
||||||
|
function move(ev){
|
||||||
|
var h=startH+(ev.clientY-startY);
|
||||||
|
var maxH=window.innerHeight-160;
|
||||||
|
if(h>=120&&h<=maxH){ ed.style.flex='none'; ed.style.height=h+'px'; }
|
||||||
|
}
|
||||||
|
function up(){ document.removeEventListener('mousemove',move); document.removeEventListener('mouseup',up); rz.style.background=''; }
|
||||||
|
rz.style.background='var(--blue)';
|
||||||
|
document.addEventListener('mousemove',move);
|
||||||
|
document.addEventListener('mouseup',up);
|
||||||
|
});
|
||||||
|
})();
|
||||||
function askAnalyze(){ addMsg('sys','已请求 AI 分析上次评测(评测上下文自动带入)…'); aiExplain(true); }
|
function askAnalyze(){ addMsg('sys','已请求 AI 分析上次评测(评测上下文自动带入)…'); aiExplain(true); }
|
||||||
function nextProblem(){ addMsg('sys','(原型演示)AI 自适应推荐:完成本章 3/5 → 建议 04-2 边界条件微练习,或进入 05 方法。'); }
|
function nextProblem(){ addMsg('sys','(原型演示)AI 自适应推荐:完成本章 3/5 → 建议 04-2 边界条件微练习,或进入 05 方法。'); }
|
||||||
|
|
||||||
@@ -1078,13 +1133,29 @@ function mdRender(md){
|
|||||||
var esc=mdInline(md);
|
var esc=mdInline(md);
|
||||||
esc=esc.replace(/^> (.+)$/gm,'<div style="border-left:3px solid var(--blue);background:var(--blue-bg);padding:6px 10px;border-radius:0 6px 6px 0;margin:6px 0;color:#3a5a78">$1</div>');
|
esc=esc.replace(/^> (.+)$/gm,'<div style="border-left:3px solid var(--blue);background:var(--blue-bg);padding:6px 10px;border-radius:0 6px 6px 0;margin:6px 0;color:#3a5a78">$1</div>');
|
||||||
esc=esc.replace(/\n{2,}/g,'<br>');
|
esc=esc.replace(/\n{2,}/g,'<br>');
|
||||||
|
// 2.5) 标题(一级→h3 二级→h4 三级→h5,避免层级过大)
|
||||||
|
esc=esc.replace(/^### (.+)$/gm,'<h5 style="margin:8px 0 4px;font-size:13px">$1</h5>');
|
||||||
|
esc=esc.replace(/^## (.+)$/gm,'<h4 style="margin:8px 0 4px;font-size:14px">$1</h4>');
|
||||||
|
esc=esc.replace(/^# (.+)$/gm,'<h3 style="margin:8px 0 4px;font-size:15px">$1</h3>');
|
||||||
|
// 2.6) 无序/有序列表 → <ul>/<ol>
|
||||||
|
esc=esc.replace(/(?:^|\n)((?:[ \t]*[-*+] .+(?:\n|$))+)/g, function(_,blk){
|
||||||
|
var items=blk.split('\n').filter(function(l){return l.trim();}).map(function(l){return '<li>'+l.replace(/^\s*[-*+]\s+/,'')+'</li>';});
|
||||||
|
return '<ul style="margin:4px 0;padding-left:20px">'+items.join('')+'</ul>';
|
||||||
|
});
|
||||||
|
esc=esc.replace(/(?:^|\n)((?:\d+[.)] .+(?:\n|$))+)/g, function(_,blk){
|
||||||
|
var items=blk.split('\n').filter(function(l){return l.trim();}).map(function(l){return '<li>'+l.replace(/^\s*\d+[.)]\s+/,'')+'</li>';});
|
||||||
|
return '<ol style="margin:4px 0;padding-left:20px">'+items.join('')+'</ol>';
|
||||||
|
});
|
||||||
// 3) 还原表格
|
// 3) 还原表格
|
||||||
for(var i=0;i<tbls.length;i++) esc=esc.replace('\u0000TBL'+i+'\u0000', tbls[i]);
|
for(var i=0;i<tbls.length;i++) esc=esc.replace('\u0000TBL'+i+'\u0000', tbls[i]);
|
||||||
// 4) 还原代码块
|
// 4) 还原代码块(带操作栏:复制到编辑器 / 复制)
|
||||||
for(var j=0;j<codes.length;j++){
|
for(var j=0;j<codes.length;j++){
|
||||||
var c=codes[j];
|
var c=codes[j];
|
||||||
esc=esc.replace('\u0000CD'+j+'\u0000',
|
esc=esc.replace('\u0000CD'+j+'\u0000',
|
||||||
'<div class="md-code">'+(c.lang?'<span class="md-code-lang">'+escapeHtml(c.lang)+'</span>':'')+'<pre>'+escapeHtml(c.code)+'</pre></div>');
|
'<div class="md-code"><div class="md-code-bar">'+(c.lang?'<span class="md-code-lang">'+escapeHtml(c.lang)+'</span>':'<span class="md-code-lang"></span>')+
|
||||||
|
'<button onclick="mdCopyToEditor(this)" title="把代码填入右侧编辑器(自动切换代码形态)">↳ 复制到编辑器</button>'+
|
||||||
|
'<button onclick="copyPlain(this)" title="复制代码到剪贴板">复制</button></div>'+
|
||||||
|
'<pre>'+escapeHtml(c.code)+'</pre></div>');
|
||||||
}
|
}
|
||||||
return esc;
|
return esc;
|
||||||
}
|
}
|
||||||
|
|||||||
在新工单中引用
屏蔽一个用户