|
@@ -159,26 +159,34 @@ export default defineComponent({
|
|
|
}
|
|
|
|
|
|
if (scoreStr.value.length === 0) {
|
|
|
- message.error({ content: "请输入分数", duration: 10 });
|
|
|
+ message.error({ content: "请输入分数", duration: 5 });
|
|
|
console.log("请输入分数");
|
|
|
return;
|
|
|
}
|
|
|
+
|
|
|
+ // 0 分
|
|
|
+ // 整数分 (开始不为0)
|
|
|
+ // 小数分 (开始和结束不为0,结束必须为1-9
|
|
|
if (
|
|
|
- !(/^\d+$/.test(scoreStr.value) || /^\d+\.\d+$/.test(scoreStr.value))
|
|
|
+ !(
|
|
|
+ scoreStr.value === "0" ||
|
|
|
+ /^[1-9]\d*$/.test(scoreStr.value) ||
|
|
|
+ /^[1-9]\d*\.\d*[1-9]$/.test(scoreStr.value)
|
|
|
+ )
|
|
|
) {
|
|
|
- message.error({ content: "分数格式不正确", duration: 10 });
|
|
|
+ message.error({ content: "分数格式不正确", duration: 5 });
|
|
|
console.log("分数格式不正确");
|
|
|
return;
|
|
|
}
|
|
|
const score = parseFloat(scoreStr.value);
|
|
|
// console.log(score);
|
|
|
if (!isNumber(score)) {
|
|
|
- message.error({ content: "非数字输入", duration: 10 });
|
|
|
+ message.error({ content: "非数字输入", duration: 5 });
|
|
|
console.log("非数字输入");
|
|
|
return;
|
|
|
}
|
|
|
if (!questionScoreSteps.value.includes(score)) {
|
|
|
- message.error({ content: "输入的分数不在有效间隔内", duration: 10 });
|
|
|
+ message.error({ content: "输入的分数不在有效间隔内", duration: 5 });
|
|
|
return;
|
|
|
}
|
|
|
store.currentQuestion.score = score;
|
|
@@ -208,7 +216,7 @@ export default defineComponent({
|
|
|
// 处理回退删除分数
|
|
|
if (event.key === "Backspace") {
|
|
|
if (scoreStr.value.length > 0) {
|
|
|
- scoreStr.value = scoreStr.value.slice(0, scoreStr.value.length - 2);
|
|
|
+ scoreStr.value = scoreStr.value.slice(0, -1);
|
|
|
} else {
|
|
|
return;
|
|
|
}
|