fix: 修复点击设置报 Cannot set properties of null (setting 'textContent')

根因:#fullScoresHint 是 #fullScoresBox 的子元素,而 renderFullScores()
用 box.innerHTML 渲染试卷列表时会把它销毁,紧接着的
$('#fullScoresHint').textContent = ... 即变成 null.textContent 抛错。

只要 state.projects 非空(连上卷王、有可答卷)点设置必触发;
projects 为空时走 early return 反而不报错,故此前长期潜伏未被发现
(自 8686eb9 设置重构引入)。

修复:
- index.php:把 #fullScoresHint 移出 #fullScoresBox,改为兄弟元素,
  并加注释说明为何不能放回去
- assets/app.js:新增 setFullScoresHint() 带 null 守卫,三个分支统一走它;
  即使将来 DOM 结构再变动也不会让整个设置弹窗打不开
This commit is contained in:
2026-09-10 12:50:39 +08:00
parent 6def49b969
commit a65ec682ce
2 changed files with 14 additions and 3 deletions
+4 -2
View File
@@ -211,9 +211,11 @@ $rosterCount = Roster::count();
<div class="fi full">
<label>各试卷独立满分</label>
<div id="fullScoresBox" class="fullscores">
<span class="hint" id="fullScoresHint">未选中试卷时,此处为空;选中某套试卷后保存即在设置中为该卷单独设定满分</span>
<span class="hint">未选中试卷时,此处为空;选中某套试卷后保存即在设置中为该卷单独设定满分</span>
</div>
<p class="hint">给某卷填入数字即可单独覆盖默认满分;留空=用默认</p>
<!-- 注意:#fullScoresHint 必须放在 #fullScoresBox 之外,
否则 renderFullScores() 的 box.innerHTML 覆盖会把它销毁,导致 textContent 赋值报 null -->
<p class="hint" id="fullScoresHint">给某卷填入数字即可单独覆盖默认满分;留空=用默认</p>
</div>
<div class="fi full checks">
<label><input type="checkbox" id="cfgDedupe"> 同一学号只保留最新一份答卷</label>