调整填空题下划线最小长度为8个字符

1. 将填空题下划线最小宽度从2个字符(8px)调整为8个字符(32px)
2. 更新默认宽度策略:单个填空32px,多个填空30-40px循环
3. 确保无论答案长度如何,下划线都有足够的空间供用户书写

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
燕陇琪 2025-11-18 02:44:08 +08:00
parent 2c090d5fbd
commit 78413e98d7

View File

@ -156,23 +156,23 @@ const ExamPrint: React.FC = () => {
// 优先使用 answer_lengths 字段(在 show_answer=false 时也会返回)
if (question.answer_lengths && question.answer_lengths[blankIndex] !== undefined) {
const answerLength = question.answer_lengths[blankIndex]
// 每个字符对应约4px宽度最少2个字符=8px最多60px
return Math.max(Math.max(answerLength, 2) * 4, 8)
// 每个字符对应约4px宽度最少8个字符=32px最多60px
return Math.max(Math.max(answerLength, 8) * 4, 32)
}
// 如果有实际的答案数据,使用答案长度
if (answers[blankIndex]) {
const answerText = String(answers[blankIndex])
// 每个字符对应约4px宽度最少2个字符=8px
return Math.max(Math.max(answerText.length, 2) * 4, 8)
// 每个字符对应约4px宽度最少8个字符=32px
return Math.max(Math.max(answerText.length, 8) * 4, 32)
}
// 如果没有任何答案数据,使用默认策略
if (totalBlanks === 1) {
return 20 // 单个填空20px约5个字符)
return 32 // 单个填空32px约8个字符)
} else {
// 多个填空:15-25px循环4-6个字符)
const widths = [15, 20, 25, 18, 22]
// 多个填空:30-40px循环约8-10个字符)
const widths = [32, 36, 40, 34, 38]
return widths[blankIndex % widths.length]
}
}