version 3
This commit is contained in:
@@ -94,7 +94,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<span class="progress-text">{{ dailyProgress.completed[currentSubject] || 0 }}/{{ dailyLimits[currentSubject] || 25 }} 题</span>
|
<span class="progress-text">{{ dailyProgress.completed[currentSubject] || 0 }}/{{ dailyLimits[currentSubject] || 25 }} 题</span>
|
||||||
</div>
|
</div>
|
||||||
<div v-for="(task, index) in (tasks[currentSubject] || [])" :key="index" class="task-card">
|
<div v-for="(task, index) in currentTasks" :key="index" class="task-card">
|
||||||
<div class="task-icon">{{ task.icon }}</div>
|
<div class="task-icon">{{ task.icon }}</div>
|
||||||
<div class="task-info">
|
<div class="task-info">
|
||||||
<h4 class="task-title">{{ task.title }}</h4>
|
<h4 class="task-title">{{ task.title }}</h4>
|
||||||
@@ -327,6 +327,13 @@ const currentAnswer = ref('');
|
|||||||
const experimentResult = ref('');
|
const experimentResult = ref('');
|
||||||
const currentQuestionIndex = ref(0);
|
const currentQuestionIndex = ref(0);
|
||||||
|
|
||||||
|
// 计算当前学科的任务列表(确保始终返回数组)
|
||||||
|
const currentTasks = computed(() => {
|
||||||
|
if (!currentSubject.value) return [];
|
||||||
|
const tasksList = tasks.value[currentSubject.value as keyof typeof tasks.value];
|
||||||
|
return Array.isArray(tasksList) ? tasksList : [];
|
||||||
|
});
|
||||||
|
|
||||||
// 每日题目上限
|
// 每日题目上限
|
||||||
const dailyLimits = {
|
const dailyLimits = {
|
||||||
math: 25,
|
math: 25,
|
||||||
@@ -2507,15 +2514,15 @@ const checkAnswer = (option: string) => {
|
|||||||
isCorrect.value = option === currentGame.value.answer;
|
isCorrect.value = option === currentGame.value.answer;
|
||||||
const subject = currentGame.value.subject;
|
const subject = currentGame.value.subject;
|
||||||
const taskIndex = currentGame.value.taskIndex;
|
const taskIndex = currentGame.value.taskIndex;
|
||||||
const task = tasks.value[subject] && tasks.value[subject][taskIndex] ? tasks.value[subject][taskIndex] : { reward: 5 };
|
const task = tasks.value[subject]?.[taskIndex] || { reward: 5 };
|
||||||
let starsPerQuestion = 1;
|
let starsPerQuestion = 1;
|
||||||
if (subject === 'math' || subject === 'chinese' || subject === 'english') {
|
if (subject === 'math' || subject === 'chinese' || subject === 'english' || subject === 'japanese' || subject === 'geography') {
|
||||||
starsPerQuestion = Math.ceil((task.reward || 5) / 20);
|
starsPerQuestion = Math.ceil((task.reward || 5) / 20);
|
||||||
} else if (subject === 'science') {
|
} else if (subject === 'science') {
|
||||||
starsPerQuestion = Math.ceil((task.reward || 5) / 10);
|
starsPerQuestion = Math.ceil((task.reward || 5) / 10);
|
||||||
}
|
}
|
||||||
feedbackMessage.value = isCorrect.value
|
feedbackMessage.value = isCorrect.value
|
||||||
? `太棒了!回答正确!正确答案是 ${currentGame.value.answer}。获得 ${starsPerQuestion} 颗星星能量!`
|
? `太棒了!回答正确!正确答案是 ${currentGame.value.answer}。获得 ${starsPerQuestion} 颗星星能量!`
|
||||||
: `再试一次,加油!你选择的是 ${option}。`;
|
: `再试一次,加油!你选择的是 ${option}。`;
|
||||||
showFeedback.value = true;
|
showFeedback.value = true;
|
||||||
if (isCorrect.value) {
|
if (isCorrect.value) {
|
||||||
@@ -2530,15 +2537,15 @@ const checkChineseAnswer = (option?: string) => {
|
|||||||
isCorrect.value = option === currentGame.value.answer;
|
isCorrect.value = option === currentGame.value.answer;
|
||||||
const subject = currentGame.value.subject;
|
const subject = currentGame.value.subject;
|
||||||
const taskIndex = currentGame.value.taskIndex;
|
const taskIndex = currentGame.value.taskIndex;
|
||||||
const task = tasks.value[subject] && tasks.value[subject][taskIndex] ? tasks.value[subject][taskIndex] : { reward: 5 };
|
const task = tasks.value[subject]?.[taskIndex] || { reward: 5 };
|
||||||
let starsPerQuestion = 1;
|
let starsPerQuestion = 1;
|
||||||
if (subject === 'math' || subject === 'chinese' || subject === 'english') {
|
if (subject === 'math' || subject === 'chinese' || subject === 'english' || subject === 'japanese' || subject === 'geography') {
|
||||||
starsPerQuestion = Math.ceil((task.reward || 5) / 20);
|
starsPerQuestion = Math.ceil((task.reward || 5) / 20);
|
||||||
} else if (subject === 'science') {
|
} else if (subject === 'science') {
|
||||||
starsPerQuestion = Math.ceil((task.reward || 5) / 10);
|
starsPerQuestion = Math.ceil((task.reward || 5) / 10);
|
||||||
}
|
}
|
||||||
feedbackMessage.value = isCorrect.value
|
feedbackMessage.value = isCorrect.value
|
||||||
? `太棒了!答对了!正确答案是 ${currentGame.value.answer}。获得 ${starsPerQuestion} 颗星星能量!`
|
? `太棒了!答对了!正确答案是 ${currentGame.value.answer}。获得 ${starsPerQuestion} 颗星星能量!`
|
||||||
: `再试一次,加油!你选择的是 ${option}。`;
|
: `再试一次,加油!你选择的是 ${option}。`;
|
||||||
showFeedback.value = true;
|
showFeedback.value = true;
|
||||||
if (isCorrect.value) {
|
if (isCorrect.value) {
|
||||||
@@ -2549,15 +2556,15 @@ const checkChineseAnswer = (option?: string) => {
|
|||||||
isCorrect.value = currentAnswer.value === currentGame.value.answer;
|
isCorrect.value = currentAnswer.value === currentGame.value.answer;
|
||||||
const subject = currentGame.value.subject;
|
const subject = currentGame.value.subject;
|
||||||
const taskIndex = currentGame.value.taskIndex;
|
const taskIndex = currentGame.value.taskIndex;
|
||||||
const task = tasks.value[subject] && tasks.value[subject][taskIndex] ? tasks.value[subject][taskIndex] : { reward: 5 };
|
const task = tasks.value[subject]?.[taskIndex] || { reward: 5 };
|
||||||
let starsPerQuestion = 1;
|
let starsPerQuestion = 1;
|
||||||
if (subject === 'math' || subject === 'chinese' || subject === 'english') {
|
if (subject === 'math' || subject === 'chinese' || subject === 'english' || subject === 'japanese' || subject === 'geography') {
|
||||||
starsPerQuestion = Math.ceil((task.reward || 5) / 20);
|
starsPerQuestion = Math.ceil((task.reward || 5) / 20);
|
||||||
} else if (subject === 'science') {
|
} else if (subject === 'science') {
|
||||||
starsPerQuestion = Math.ceil((task.reward || 5) / 10);
|
starsPerQuestion = Math.ceil((task.reward || 5) / 10);
|
||||||
}
|
}
|
||||||
feedbackMessage.value = isCorrect.value
|
feedbackMessage.value = isCorrect.value
|
||||||
? `太棒了!拼字正确!正确答案是 ${currentGame.value.answer}。获得 ${starsPerQuestion} 颗星星能量!`
|
? `太棒了!拼字正确!正确答案是 ${currentGame.value.answer}。获得 ${starsPerQuestion} 颗星星能量!`
|
||||||
: `再试一次,加油!你选择的是 ${currentAnswer.value}。`;
|
: `再试一次,加油!你选择的是 ${currentAnswer.value}。`;
|
||||||
showFeedback.value = true;
|
showFeedback.value = true;
|
||||||
if (isCorrect.value) {
|
if (isCorrect.value) {
|
||||||
@@ -2571,15 +2578,15 @@ const checkEnglishAnswer = (option: string) => {
|
|||||||
isCorrect.value = option === currentGame.value.answer;
|
isCorrect.value = option === currentGame.value.answer;
|
||||||
const subject = currentGame.value.subject;
|
const subject = currentGame.value.subject;
|
||||||
const taskIndex = currentGame.value.taskIndex;
|
const taskIndex = currentGame.value.taskIndex;
|
||||||
const task = tasks.value[subject] && tasks.value[subject][taskIndex] ? tasks.value[subject][taskIndex] : { reward: 5 };
|
const task = tasks.value[subject]?.[taskIndex] || { reward: 5 };
|
||||||
let starsPerQuestion = 1;
|
let starsPerQuestion = 1;
|
||||||
if (subject === 'math' || subject === 'chinese' || subject === 'english') {
|
if (subject === 'math' || subject === 'chinese' || subject === 'english' || subject === 'japanese' || subject === 'geography') {
|
||||||
starsPerQuestion = Math.ceil((task.reward || 5) / 20);
|
starsPerQuestion = Math.ceil((task.reward || 5) / 20);
|
||||||
} else if (subject === 'science') {
|
} else if (subject === 'science') {
|
||||||
starsPerQuestion = Math.ceil((task.reward || 5) / 10);
|
starsPerQuestion = Math.ceil((task.reward || 5) / 10);
|
||||||
}
|
}
|
||||||
feedbackMessage.value = isCorrect.value
|
feedbackMessage.value = isCorrect.value
|
||||||
? `Great! Correct! The correct answer is ${currentGame.value.answer}. 获得 ${starsPerQuestion} 颗星星能量!`
|
? `Great! Correct! The correct answer is ${currentGame.value.answer}. 获得 ${starsPerQuestion} 颗星星能量!`
|
||||||
: `Try again! You selected ${option}.`;
|
: `Try again! You selected ${option}.`;
|
||||||
showFeedback.value = true;
|
showFeedback.value = true;
|
||||||
if (isCorrect.value) {
|
if (isCorrect.value) {
|
||||||
@@ -2592,7 +2599,7 @@ const checkScienceAnswer = () => {
|
|||||||
isCorrect.value = true; // 科学实验只要完成就正确
|
isCorrect.value = true; // 科学实验只要完成就正确
|
||||||
const subject = currentGame.value.subject;
|
const subject = currentGame.value.subject;
|
||||||
const taskIndex = currentGame.value.taskIndex;
|
const taskIndex = currentGame.value.taskIndex;
|
||||||
const task = tasks.value[subject] && tasks.value[subject][taskIndex] ? tasks.value[subject][taskIndex] : { reward: 5 };
|
const task = tasks.value[subject]?.[taskIndex] || { reward: 5 };
|
||||||
let starsPerQuestion = 1;
|
let starsPerQuestion = 1;
|
||||||
if (subject === 'math' || subject === 'chinese' || subject === 'english' || subject === 'japanese' || subject === 'geography') {
|
if (subject === 'math' || subject === 'chinese' || subject === 'english' || subject === 'japanese' || subject === 'geography') {
|
||||||
starsPerQuestion = Math.ceil((task.reward || 5) / 20);
|
starsPerQuestion = Math.ceil((task.reward || 5) / 20);
|
||||||
@@ -2609,15 +2616,15 @@ const checkJapaneseAnswer = (option: string) => {
|
|||||||
isCorrect.value = option === currentGame.value.answer;
|
isCorrect.value = option === currentGame.value.answer;
|
||||||
const subject = currentGame.value.subject;
|
const subject = currentGame.value.subject;
|
||||||
const taskIndex = currentGame.value.taskIndex;
|
const taskIndex = currentGame.value.taskIndex;
|
||||||
const task = tasks.value[subject] && tasks.value[subject][taskIndex] ? tasks.value[subject][taskIndex] : { reward: 5 };
|
const task = tasks.value[subject]?.[taskIndex] || { reward: 5 };
|
||||||
let starsPerQuestion = 1;
|
let starsPerQuestion = 1;
|
||||||
if (subject === 'math' || subject === 'chinese' || subject === 'english' || subject === 'japanese' || subject === 'geography') {
|
if (subject === 'math' || subject === 'chinese' || subject === 'english' || subject === 'japanese' || subject === 'geography') {
|
||||||
starsPerQuestion = Math.ceil((task.reward || 5) / 20);
|
starsPerQuestion = Math.ceil((task.reward || 5) / 20);
|
||||||
} else if (subject === 'science') {
|
} else if (subject === 'science') {
|
||||||
starsPerQuestion = Math.ceil((task.reward || 5) / 10);
|
starsPerQuestion = Math.ceil((task.reward || 5) / 10);
|
||||||
}
|
}
|
||||||
feedbackMessage.value = isCorrect.value
|
feedbackMessage.value = isCorrect.value
|
||||||
? `すごい!回答正确!正确答案是 ${currentGame.value.answer}。获得 ${starsPerQuestion} 颗星星能量!`
|
? `すごい!回答正确!正确答案是 ${currentGame.value.answer}。获得 ${starsPerQuestion} 颗星星能量!`
|
||||||
: `もう一度やってみて!你选择的是 ${option}。`;
|
: `もう一度やってみて!你选择的是 ${option}。`;
|
||||||
showFeedback.value = true;
|
showFeedback.value = true;
|
||||||
if (isCorrect.value) {
|
if (isCorrect.value) {
|
||||||
@@ -2630,15 +2637,15 @@ const checkGeographyAnswer = (option: string) => {
|
|||||||
isCorrect.value = option === currentGame.value.answer;
|
isCorrect.value = option === currentGame.value.answer;
|
||||||
const subject = currentGame.value.subject;
|
const subject = currentGame.value.subject;
|
||||||
const taskIndex = currentGame.value.taskIndex;
|
const taskIndex = currentGame.value.taskIndex;
|
||||||
const task = tasks.value[subject] && tasks.value[subject][taskIndex] ? tasks.value[subject][taskIndex] : { reward: 5 };
|
const task = tasks.value[subject]?.[taskIndex] || { reward: 5 };
|
||||||
let starsPerQuestion = 1;
|
let starsPerQuestion = 1;
|
||||||
if (subject === 'math' || subject === 'chinese' || subject === 'english' || subject === 'japanese' || subject === 'geography') {
|
if (subject === 'math' || subject === 'chinese' || subject === 'english' || subject === 'japanese' || subject === 'geography') {
|
||||||
starsPerQuestion = Math.ceil((task.reward || 5) / 20);
|
starsPerQuestion = Math.ceil((task.reward || 5) / 20);
|
||||||
} else if (subject === 'science') {
|
} else if (subject === 'science') {
|
||||||
starsPerQuestion = Math.ceil((task.reward || 5) / 10);
|
starsPerQuestion = Math.ceil((task.reward || 5) / 10);
|
||||||
}
|
}
|
||||||
feedbackMessage.value = isCorrect.value
|
feedbackMessage.value = isCorrect.value
|
||||||
? `太棒了!回答正确!正确答案是 ${currentGame.value.answer}。获得 ${starsPerQuestion} 颗星星能量!`
|
? `太棒了!回答正确!正确答案是 ${currentGame.value.answer}。获得 ${starsPerQuestion} 颗星星能量!`
|
||||||
: `再试一次,加油!你选择的是 ${option}。`;
|
: `再试一次,加油!你选择的是 ${option}。`;
|
||||||
showFeedback.value = true;
|
showFeedback.value = true;
|
||||||
if (isCorrect.value) {
|
if (isCorrect.value) {
|
||||||
@@ -2661,8 +2668,8 @@ const nextQuestion = () => {
|
|||||||
// 每完成一题获得星星能量
|
// 每完成一题获得星星能量
|
||||||
const subject = currentGame.value.subject;
|
const subject = currentGame.value.subject;
|
||||||
const taskIndex = currentGame.value.taskIndex;
|
const taskIndex = currentGame.value.taskIndex;
|
||||||
const task = tasks.value[subject] && tasks.value[subject][taskIndex] ? tasks.value[subject][taskIndex] : { reward: 5 };
|
const task = tasks.value[subject]?.[taskIndex] || { reward: 5 };
|
||||||
|
|
||||||
// 计算每题的星星奖励(降低获得量)
|
// 计算每题的星星奖励(降低获得量)
|
||||||
let starsPerQuestion = 1;
|
let starsPerQuestion = 1;
|
||||||
if (subject === 'math' || subject === 'chinese' || subject === 'english' || subject === 'japanese' || subject === 'geography') {
|
if (subject === 'math' || subject === 'chinese' || subject === 'english' || subject === 'japanese' || subject === 'geography') {
|
||||||
@@ -2674,7 +2681,7 @@ const nextQuestion = () => {
|
|||||||
// 总奖励为8-12,分成10题,每题0.8-1.2颗,向上取整为1颗
|
// 总奖励为8-12,分成10题,每题0.8-1.2颗,向上取整为1颗
|
||||||
starsPerQuestion = Math.ceil((task.reward || 5) / 15); // 15题任务的计算方式,降低获得量
|
starsPerQuestion = Math.ceil((task.reward || 5) / 15); // 15题任务的计算方式,降低获得量
|
||||||
}
|
}
|
||||||
|
|
||||||
// 添加星星能量
|
// 添加星星能量
|
||||||
starEnergyStore.addEnergy(starsPerQuestion, 'knowledge');
|
starEnergyStore.addEnergy(starsPerQuestion, 'knowledge');
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user