feat(M7): 初始界面去题化+响应式布局——登录不自动加载题目/欢迎语只提可用学科/crumb动态;宽<860或高≥1000上下布局(去对话流小输入框)+窄屏侧栏抽屉;loadProblem改手动入口
这个提交包含在:
+37
-17
@@ -53,15 +53,20 @@ body{font-family:var(--sans);background:var(--bg);color:var(--text);font-size:14
|
||||
.modal-body{padding:14px 16px}
|
||||
.modal-body label{display:block;font-size:12px;color:var(--text2);margin-bottom:5px}
|
||||
.modal-foot{padding:10px 16px;border-top:1px solid var(--line2);display:flex;justify-content:flex-end}
|
||||
/* 高窗口(≥760px):上下布局 —— 上对话流(含输入框,贴近普通 AI 工具体验),下编辑器 */
|
||||
.main-inner{flex:1;display:flex;min-height:0;flex-direction:column}
|
||||
.chat{width:100%;min-width:0;border-right:none;border-bottom:1px solid var(--line);background:var(--card);display:flex;flex-direction:column;min-height:0;flex:5}
|
||||
.editor{flex:4;min-height:180px}
|
||||
/* 低窗口:左右布局(屏幕高度不足的折中) */
|
||||
@media (max-height:759px){
|
||||
.main-inner{flex-direction:row}
|
||||
.chat{width:46%;min-width:400px;border-right:1px solid var(--line);border-bottom:none;flex:none}
|
||||
.editor{flex:1;min-height:0}
|
||||
/* 布局规则(响应式):宽<860 或 高≥1000 → 上下布局;其余(宽屏矮窗)→ 左右分屏
|
||||
上下布局时去掉对话流下方小输入框(输入统一走底部编辑器),侧栏收起为抽屉 */
|
||||
.main-inner{flex:1;display:flex;min-height:0;flex-direction:row}
|
||||
.chat{width:46%;min-width:400px;border-right:1px solid var(--line);border-bottom:none;background:var(--card);display:flex;flex-direction:column;min-height:0;flex:none}
|
||||
.editor{flex:1;min-height:0}
|
||||
@media (max-width:859px), (min-height:1000px){
|
||||
.main-inner{flex-direction:column}
|
||||
.chat{width:100%;min-width:0;border-right:none;border-bottom:1px solid var(--line);flex:5}
|
||||
.editor{flex:4;min-height:180px}
|
||||
.chat-input{display:none} /* 上下布局:输入统一走底部编辑器,去掉对话流下小输入框 */
|
||||
.side{position:fixed;left:0;top:52px;bottom:0;z-index:60;width:224px;transform:translateX(-102%);transition:transform .2s ease;box-shadow:4px 0 18px rgba(20,28,40,.16)}
|
||||
.side.open{transform:translateX(0)}
|
||||
#sideToggle{display:inline-flex}
|
||||
#sideMask{display:block}
|
||||
}
|
||||
.chat-head{flex:none;padding:10px 16px;border-bottom:1px solid var(--line2);font-size:12px;color:var(--text2);display:flex;gap:10px;align-items:center}
|
||||
.chat-head .prog{flex:1;height:5px;background:var(--line2);border-radius:3px;overflow:hidden}
|
||||
@@ -121,8 +126,8 @@ body{font-family:var(--sans);background:var(--bg);color:var(--text);font-size:14
|
||||
.chat-input input{flex:1;border:1.5px solid var(--line);border-radius:8px;padding:9px 12px;font-size:13px;outline:none;font-family:var(--sans)}
|
||||
.chat-input input:focus{border-color:var(--blue)}
|
||||
/* ===== 右:统一输入区 ===== */
|
||||
.editor{flex:4;min-width:0;display:flex;flex-direction:column;background:var(--card);min-height:180px}
|
||||
@media (max-height:759px){ .editor{flex:1;min-height:0} }
|
||||
.editor{flex:1;min-width:0;display:flex;flex-direction:column;background:var(--card);min-height:0}
|
||||
@media (max-width:859px), (min-height:1000px){ .editor{flex:4;min-height:180px} }
|
||||
.editor-head{flex:none;display:flex;align-items:center;gap:10px;padding:9px 16px;border-bottom:1px solid var(--line2);background:var(--line2);font-size:12px;color:var(--text2)}
|
||||
.editor-head .morph{display:flex;gap:4px;background:#fff;border:1px solid var(--line);border-radius:16px;padding:2px;font-size:11.5px}
|
||||
.editor-head .morph span{padding:3px 12px;border-radius:13px;color:var(--text3)}
|
||||
@@ -192,8 +197,9 @@ body{font-family:var(--sans);background:var(--bg);color:var(--text);font-size:14
|
||||
|
||||
<!-- ===== 顶栏 ===== -->
|
||||
<div class="topbar">
|
||||
<button id="sideToggle" onclick="toggleSide()" style="display:none;border:none;background:transparent;font-size:19px;cursor:pointer;color:var(--text2);padding:0 4px" title="会话列表">☰</button>
|
||||
<div class="brand"><span class="dot">f</span>fluent-learn</div>
|
||||
<div class="crumb">AP CSA · 方法入门 › <b>01 方法入门</b> › 1021 makes10(热身 106)</div>
|
||||
<div class="crumb" id="crumb" style="display:none"></div>
|
||||
<span class="spacer"></span>
|
||||
<div class="progress-note" id="progNote">🎯 今日 <b>0/8</b> · 距目标还差 <b>8 题</b> · 连续打卡 <b>0 天</b></div>
|
||||
<div class="mode-switch">
|
||||
@@ -209,6 +215,8 @@ body{font-family:var(--sans);background:var(--bg);color:var(--text);font-size:14
|
||||
|
||||
<!-- ===== 主区 ===== -->
|
||||
<div class="main">
|
||||
<!-- 侧栏遮罩(窄屏抽屉时点空白关闭) -->
|
||||
<div id="sideMask" style="display:none;position:fixed;inset:0;background:rgba(20,28,40,.3);z-index:59" onclick="toggleSide()"></div>
|
||||
<!-- 左:侧边栏(会话 = 学科窗口,继承源续接,如普通 AI 工具) -->
|
||||
<div class="side">
|
||||
<div class="side-head">
|
||||
@@ -379,9 +387,8 @@ function init(){
|
||||
document.getElementById('dialogArea').addEventListener('keydown', function(e){
|
||||
if(e.key==='Enter' && !e.shiftKey){ e.preventDefault(); sendDialog(); }
|
||||
});
|
||||
// 初始欢迎:先加载历史对话(有则渲染,无则欢迎语)
|
||||
// 初始:加载会话历史(有则恢复,无则干净欢迎语);不自动加载题目(学科窗口建立后由 AI 出题/题库路由产生)
|
||||
initConv();
|
||||
loadProblem();
|
||||
loadProgress();
|
||||
loadLatexChips(); // LaTeX 常用公式合集(按学科)
|
||||
latexLive(); // 预览区默认示例
|
||||
@@ -571,11 +578,23 @@ function loadConvHistory(convId, isFirst){
|
||||
fetch(url,{headers:authHeaders({})}).then(function(r){return r.json();}).then(function(d){
|
||||
var msgs=d.messages||[];
|
||||
if(msgs.length){ msgs.forEach(renderHistoryMsg); }
|
||||
else if(isFirst){ addMsg('ai','<b>👋 你好,我是 fluent-learn 的 AI 助手。</b><br>直接打字问我任何问题都可以——学习、概念、方法、闲聊都行;写代码或 LaTeX 会自动切换到对应输入模式。左侧可新建「学科窗口」会话,让每个学科有自己的学习流。'); }
|
||||
else if(isFirst){ addMsg('ai','<b>👋 欢迎来到 fluent-learn</b><br>点击左上角「+ 新建」开启学科窗口:<b>USACO</b> · <b>AP CSA</b> 可选,其余学科即将上线。<br>每个会话一个学科,可续接进度;直接打字问我任何问题都可以——学习、概念、方法、闲聊都行,写代码或 LaTeX 会自动切换到对应输入模式。'); }
|
||||
var cf=document.querySelector('.chat-flow'); if(cf) cf.scrollTop=cf.scrollHeight;
|
||||
msgs.forEach(function(m){ if(m.meta && m.meta.announcement) LAST_ANN_ID=Math.max(LAST_ANN_ID, m.id); });
|
||||
if(!ANN_POLL){ ANN_POLL=setInterval(pollAnn, 6000); pollAnn(); }
|
||||
}).catch(function(){ if(isFirst) addMsg('ai','<b>👋 你好,我是 fluent-learn 的 AI 助手。</b><br>直接打字问我任何问题都可以。'); });
|
||||
}).catch(function(){ if(isFirst) addMsg('ai','<b>👋 欢迎来到 fluent-learn</b><br>点击左上角「+ 新建」开启学科窗口:USACO · AP CSA 可选。'); });
|
||||
}
|
||||
/* 侧栏抽屉开关(窄屏时顶栏 ☰ 与遮罩点击) */
|
||||
function toggleSide(){
|
||||
var s=document.querySelector('.side'), m=document.getElementById('sideMask');
|
||||
if(!s) return;
|
||||
var open=s.classList.toggle('open');
|
||||
if(m) m.style.display=open?'block':'none';
|
||||
}
|
||||
function setCrumb(title){
|
||||
var c=document.getElementById('crumb'); if(!c) return;
|
||||
if(title){ c.innerHTML='学习流 › <b>'+escapeHtml(title)+'</b>'; c.style.display=''; }
|
||||
else { c.style.display='none'; }
|
||||
}
|
||||
function openNewConv(){
|
||||
var sel=document.getElementById('convCourse');
|
||||
@@ -1000,6 +1019,7 @@ function loadProblemByPid(hpid){
|
||||
if(!p||!p.id){ toast('未找到题目 '+hpid); return; }
|
||||
CUR_PROBLEM=p;
|
||||
if(p.course){ CUR_COURSE=p.course; loadLatexChips(); latexLive(); }
|
||||
setCrumb(p.title+' · '+p.hydro_pid);
|
||||
addMsg('ai', mdRender('📌 **'+p.title+' · '+p.hydro_pid+'**\n\n'+p.statement_md));
|
||||
if(p.latex_explain) addMsg('judge','<div class="judge-card" style="border-color:#c8b273"><div class="jc-status" style="background:#f6efd9;color:#8a6d3b">🧮 <span class="verdict-pill" style="background:#8a6d3b">公式小课堂</span></div><div class="jc-body">'+mdRender(p.latex_explain)+'</div></div>');
|
||||
if(p.quiz && p.quiz.length) renderQuiz(p.quiz);
|
||||
@@ -1093,12 +1113,12 @@ function loadProblem(){
|
||||
if(!list||!list.length){ addMsg('ai','⚠️ 后端暂无题目(请确认已导入题库)。'); return; }
|
||||
CUR_PROBLEM=list[0];
|
||||
if(CUR_PROBLEM.course){ CUR_COURSE=CUR_PROBLEM.course; loadLatexChips(); latexLive(); }
|
||||
setCrumb(CUR_PROBLEM.title+' · '+CUR_PROBLEM.hydro_pid);
|
||||
addMsg('ai', mdRender('**'+CUR_PROBLEM.title+' · '+CUR_PROBLEM.hydro_pid+'**\n\n'+CUR_PROBLEM.statement_md));
|
||||
if(CUR_PROBLEM.latex_explain){
|
||||
addMsg('judge','<div class="judge-card" style="border-color:#c8b273"><div class="jc-status" style="background:#f6efd9;color:#8a6d3b">🧮 <span class="verdict-pill" style="background:#8a6d3b">公式小课堂</span> <span style="font-weight:400;font-size:12px">题面 LaTeX 用法解释(新手友好)</span></div><div class="jc-body">'+mdRender(CUR_PROBLEM.latex_explain)+'<div style="margin-top:8px"><button class="btn sm gray" onclick="openSheet()">∑ 打开 LaTeX 速查表</button></div></div></div>');
|
||||
}
|
||||
if(CUR_PROBLEM.quiz && CUR_PROBLEM.quiz.length) renderQuiz(CUR_PROBLEM.quiz);
|
||||
addMsg('ai','<b>👋 欢迎来到 fluent-learn 学习工作台</b><br>想学哪个方向?<b>USACO</b>(竞赛算法)· <b>AP CSA</b>(Java 编程)· <b>AP 微积分 / 物理 / 化学 / 生物</b><br>当前已为你加载 <b>'+CUR_PROBLEM.title+'</b>(AP CSA 热身题),右侧可直接写代码提交评测。<br>也可以<b>直接问我任何问题</b>——概念、学习方法、别的科目都行,我随时在。');
|
||||
}).catch(function(){
|
||||
addMsg('ai','⚠️ 后端不可达:判题与 AI 为<b>本地演示</b>模式。');
|
||||
renderChoiceQ1();
|
||||
|
||||
在新工单中引用
屏蔽一个用户