version 3
This commit is contained in:
@@ -94,7 +94,7 @@
|
||||
</div>
|
||||
<span class="progress-text">{{ dailyProgress.completed[currentSubject] || 0 }}/{{ dailyLimits[currentSubject] || 25 }} 题</span>
|
||||
</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-info">
|
||||
<h4 class="task-title">{{ task.title }}</h4>
|
||||
@@ -327,6 +327,13 @@ const currentAnswer = ref('');
|
||||
const experimentResult = ref('');
|
||||
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 = {
|
||||
math: 25,
|
||||
@@ -2507,9 +2514,9 @@ const checkAnswer = (option: string) => {
|
||||
isCorrect.value = option === currentGame.value.answer;
|
||||
const subject = currentGame.value.subject;
|
||||
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;
|
||||
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);
|
||||
} else if (subject === 'science') {
|
||||
starsPerQuestion = Math.ceil((task.reward || 5) / 10);
|
||||
@@ -2530,9 +2537,9 @@ const checkChineseAnswer = (option?: string) => {
|
||||
isCorrect.value = option === currentGame.value.answer;
|
||||
const subject = currentGame.value.subject;
|
||||
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;
|
||||
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);
|
||||
} else if (subject === 'science') {
|
||||
starsPerQuestion = Math.ceil((task.reward || 5) / 10);
|
||||
@@ -2549,9 +2556,9 @@ const checkChineseAnswer = (option?: string) => {
|
||||
isCorrect.value = currentAnswer.value === currentGame.value.answer;
|
||||
const subject = currentGame.value.subject;
|
||||
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;
|
||||
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);
|
||||
} else if (subject === 'science') {
|
||||
starsPerQuestion = Math.ceil((task.reward || 5) / 10);
|
||||
@@ -2571,9 +2578,9 @@ const checkEnglishAnswer = (option: string) => {
|
||||
isCorrect.value = option === currentGame.value.answer;
|
||||
const subject = currentGame.value.subject;
|
||||
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;
|
||||
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);
|
||||
} else if (subject === 'science') {
|
||||
starsPerQuestion = Math.ceil((task.reward || 5) / 10);
|
||||
@@ -2592,7 +2599,7 @@ const checkScienceAnswer = () => {
|
||||
isCorrect.value = true; // 科学实验只要完成就正确
|
||||
const subject = currentGame.value.subject;
|
||||
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;
|
||||
if (subject === 'math' || subject === 'chinese' || subject === 'english' || subject === 'japanese' || subject === 'geography') {
|
||||
starsPerQuestion = Math.ceil((task.reward || 5) / 20);
|
||||
@@ -2609,7 +2616,7 @@ const checkJapaneseAnswer = (option: string) => {
|
||||
isCorrect.value = option === currentGame.value.answer;
|
||||
const subject = currentGame.value.subject;
|
||||
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;
|
||||
if (subject === 'math' || subject === 'chinese' || subject === 'english' || subject === 'japanese' || subject === 'geography') {
|
||||
starsPerQuestion = Math.ceil((task.reward || 5) / 20);
|
||||
@@ -2630,7 +2637,7 @@ const checkGeographyAnswer = (option: string) => {
|
||||
isCorrect.value = option === currentGame.value.answer;
|
||||
const subject = currentGame.value.subject;
|
||||
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;
|
||||
if (subject === 'math' || subject === 'chinese' || subject === 'english' || subject === 'japanese' || subject === 'geography') {
|
||||
starsPerQuestion = Math.ceil((task.reward || 5) / 20);
|
||||
@@ -2661,7 +2668,7 @@ const nextQuestion = () => {
|
||||
// 每完成一题获得星星能量
|
||||
const subject = currentGame.value.subject;
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user