|
@@ -104,17 +104,20 @@ export default defineComponent({
|
|
|
// console.log(event);
|
|
|
if (!store.currentQuestion || !store.currentTask) return;
|
|
|
|
|
|
+ function indexOfCurrentQuestion() {
|
|
|
+ return store.currentTask?.questionList.findIndex(
|
|
|
+ (q) =>
|
|
|
+ q.mainNumber === store.currentQuestion?.mainNumber &&
|
|
|
+ q.subNumber === store.currentQuestion.subNumber
|
|
|
+ );
|
|
|
+ }
|
|
|
// 处理Enter跳下一题或submit
|
|
|
if (event.key === "Enter") {
|
|
|
if (!isNumber(store.currentQuestion.score)) {
|
|
|
// 当前题赋分不通过,Enter无效
|
|
|
return;
|
|
|
}
|
|
|
- const idx = store.currentTask?.questionList.findIndex(
|
|
|
- (q) =>
|
|
|
- q.mainNumber === store.currentQuestion?.mainNumber &&
|
|
|
- q.subNumber === store.currentQuestion.subNumber
|
|
|
- );
|
|
|
+ const idx = indexOfCurrentQuestion() as number;
|
|
|
if (idx + 1 === store.currentTask?.questionList.length) {
|
|
|
submit();
|
|
|
} else {
|
|
@@ -123,6 +126,18 @@ export default defineComponent({
|
|
|
keys = [];
|
|
|
return;
|
|
|
}
|
|
|
+ if (event.key === "ArrowLeft") {
|
|
|
+ const idx = indexOfCurrentQuestion() as number;
|
|
|
+ if (idx > 0) {
|
|
|
+ chooseQuestion(store.currentTask.questionList[idx - 1]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (event.key === "ArrowRight") {
|
|
|
+ const idx = indexOfCurrentQuestion() as number;
|
|
|
+ if (idx < store.currentTask.questionList.length - 1) {
|
|
|
+ chooseQuestion(store.currentTask.questionList[idx + 1]);
|
|
|
+ }
|
|
|
+ }
|
|
|
// TODO: 确认数字按键的间隔
|
|
|
if (event.timeStamp - keyPressTimestamp > 1.5 * 1000) {
|
|
|
keys = [];
|