version 3
This commit is contained in:
@@ -29,7 +29,7 @@
|
||||
<div class="subject-emoji">🐿️</div>
|
||||
<h3 class="subject-title">数学魔法课</h3>
|
||||
<p class="subject-desc">和数字松鼠一起冒险</p>
|
||||
<div class="subject-reward">⭐ +15 能量</div>
|
||||
<div class="subject-reward">⭐ +1 能量</div>
|
||||
</div>
|
||||
|
||||
<!-- 语文魔法课 -->
|
||||
@@ -38,7 +38,7 @@
|
||||
<div class="subject-emoji">🧚</div>
|
||||
<h3 class="subject-title">语文魔法课</h3>
|
||||
<p class="subject-desc">帮汉字小精灵拼偏旁</p>
|
||||
<div class="subject-reward">⭐ +15 能量</div>
|
||||
<div class="subject-reward">⭐ +1 能量</div>
|
||||
</div>
|
||||
|
||||
<!-- 英语魔法课 -->
|
||||
@@ -47,7 +47,7 @@
|
||||
<div class="subject-emoji">🐦</div>
|
||||
<h3 class="subject-title">英语魔法课</h3>
|
||||
<p class="subject-desc">和字母小鸟走迷宫</p>
|
||||
<div class="subject-reward">⭐ +15 能量</div>
|
||||
<div class="subject-reward">⭐ +1 能量</div>
|
||||
</div>
|
||||
|
||||
<!-- 科学魔法课 -->
|
||||
@@ -56,7 +56,7 @@
|
||||
<div class="subject-emoji">🌱</div>
|
||||
<h3 class="subject-title">科学魔法课</h3>
|
||||
<p class="subject-desc">在植物实验室做实验</p>
|
||||
<div class="subject-reward">⭐ +15 能量</div>
|
||||
<div class="subject-reward">⭐ +1 能量</div>
|
||||
</div>
|
||||
|
||||
<!-- 日语魔法课 -->
|
||||
@@ -65,27 +65,36 @@
|
||||
<div class="subject-emoji">🌸</div>
|
||||
<h3 class="subject-title">日语魔法课</h3>
|
||||
<p class="subject-desc">学习简单的日语和50音图</p>
|
||||
<div class="subject-reward">⭐ +15 能量</div>
|
||||
<div class="subject-reward">⭐ +1 能量</div>
|
||||
</div>
|
||||
|
||||
<!-- 地理魔法课 -->
|
||||
<div class="subject-card geography" @click="selectSubject('geography')">
|
||||
<div class="subject-icon">🗺️</div>
|
||||
<div class="subject-emoji">🌏</div>
|
||||
<h3 class="subject-title">地理魔法课</h3>
|
||||
<p class="subject-desc">学习中国地理常识和南北方差异</p>
|
||||
<div class="subject-reward">⭐ +1 能量</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 课程内容 -->
|
||||
<div class="subject-content" v-if="currentSubject">
|
||||
<div class="content-header">
|
||||
<h3 class="content-title">{{ subjectTitles[currentSubject] }}</h3>
|
||||
<h3 class="content-title">{{ currentSubject ? subjectTitles[currentSubject as keyof typeof subjectTitles] : '' }}</h3>
|
||||
<button class="back-btn" @click="currentSubject = null">返回</button>
|
||||
</div>
|
||||
|
||||
<!-- 任务列表 -->
|
||||
<div class="tasks" v-if="!currentGame">
|
||||
<div class="tasks" v-if="!currentGame && currentSubject">
|
||||
<div class="daily-progress">
|
||||
<h4>今日进度</h4>
|
||||
<div class="progress-bar">
|
||||
<div class="progress-fill" :style="{ width: (dailyProgress.completed[currentSubject] / dailyLimits[currentSubject]) * 100 + '%' }"></div>
|
||||
<div class="progress-fill" :style="{ width: ((dailyProgress.completed[currentSubject as keyof typeof dailyProgress.completed] || 0) / dailyLimits[currentSubject as keyof typeof dailyLimits]) * 100 + '%' }"></div>
|
||||
</div>
|
||||
<span class="progress-text">{{ dailyProgress.completed[currentSubject] }}/{{ dailyLimits[currentSubject] }} 题</span>
|
||||
<span class="progress-text">{{ dailyProgress.completed[currentSubject as keyof typeof dailyProgress.completed] || 0 }}/{{ dailyLimits[currentSubject as keyof typeof dailyLimits] }} 题</span>
|
||||
</div>
|
||||
<div v-for="(task, index) in tasks[currentSubject]" :key="index" class="task-card">
|
||||
<div v-for="(task, index) in (tasks[currentSubject as keyof typeof tasks] || [])" :key="index" class="task-card">
|
||||
<div class="task-icon">{{ task.icon }}</div>
|
||||
<div class="task-info">
|
||||
<h4 class="task-title">{{ task.title }}</h4>
|
||||
@@ -95,8 +104,8 @@
|
||||
<span>{{ task.reward }} 颗星星能量</span>
|
||||
</div>
|
||||
</div>
|
||||
<button class="task-btn" @click="startGame(currentSubject, index)" :disabled="isDailyLimitReached(currentSubject)">
|
||||
{{ task.completed ? '已完成' : isDailyLimitReached(currentSubject) ? '今日已达上限' : '开始' }}
|
||||
<button class="task-btn" @click="startGame(currentSubject || '', index)" :disabled="isDailyLimitReached(currentSubject || '')">
|
||||
{{ task.completed ? '已完成' : isDailyLimitReached(currentSubject || '') ? '今日已达上限' : '开始' }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -267,6 +276,33 @@
|
||||
<button class="next-btn" @click="nextQuestion">下一题</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 地理游戏 -->
|
||||
<div v-else-if="currentGame.subject === 'geography'" class="geography-game">
|
||||
<div class="game-question">
|
||||
<div class="question-with-audio">
|
||||
<h4>{{ currentGame.question }}</h4>
|
||||
<button class="audio-btn" @click="playAudio(currentGame.question)">🔊</button>
|
||||
</div>
|
||||
<div class="word-options">
|
||||
<div
|
||||
v-for="(option, idx) in currentGame.options"
|
||||
:key="idx"
|
||||
class="option-btn"
|
||||
@click="checkGeographyAnswer(option)"
|
||||
>
|
||||
<span>{{ option }}</span>
|
||||
<div class="option-audio-btn" @click.stop="playAudio(option)">🔊</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="game-feedback" v-if="showFeedback">
|
||||
<div :class="['feedback-message', isCorrect ? 'correct' : 'incorrect']">
|
||||
{{ feedbackMessage }}
|
||||
</div>
|
||||
<button class="next-btn" @click="nextQuestion">下一题</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -297,7 +333,8 @@ const dailyLimits = {
|
||||
chinese: 25,
|
||||
english: 25,
|
||||
science: 25,
|
||||
japanese: 25
|
||||
japanese: 25,
|
||||
geography: 25
|
||||
};
|
||||
|
||||
// 题目进度跟踪
|
||||
@@ -333,6 +370,11 @@ const progress = ref({
|
||||
directions: 0,
|
||||
items: 0,
|
||||
greetings: 0
|
||||
},
|
||||
geography: {
|
||||
map: 0,
|
||||
basics: 0,
|
||||
northSouth: 0
|
||||
}
|
||||
});
|
||||
|
||||
@@ -344,13 +386,18 @@ const dailyProgress = ref({
|
||||
chinese: 0,
|
||||
english: 0,
|
||||
science: 0,
|
||||
japanese: 0
|
||||
japanese: 0,
|
||||
geography: 0
|
||||
}
|
||||
});
|
||||
|
||||
// 检查是否达到每日上限
|
||||
const isDailyLimitReached = (subject: string) => {
|
||||
return dailyProgress.value.completed[subject as keyof typeof dailyProgress.value.completed] >= dailyLimits[subject as keyof typeof dailyLimits];
|
||||
console.log('检查每日上限:', subject);
|
||||
const completed = dailyProgress.value.completed[subject as keyof typeof dailyProgress.value.completed] || 0;
|
||||
const limit = dailyLimits[subject as keyof typeof dailyLimits] || 25;
|
||||
console.log('已完成:', completed, '上限:', limit);
|
||||
return completed >= limit;
|
||||
};
|
||||
|
||||
// 初始化时加载语音合成API的voices和进度数据
|
||||
@@ -410,7 +457,8 @@ const checkDateUpdate = () => {
|
||||
chinese: 0,
|
||||
english: 0,
|
||||
science: 0,
|
||||
japanese: 0
|
||||
japanese: 0,
|
||||
geography: 0
|
||||
}
|
||||
};
|
||||
|
||||
@@ -427,7 +475,8 @@ const subjectTitles = {
|
||||
chinese: '语文魔法课',
|
||||
english: '英语魔法课',
|
||||
science: '科学魔法课',
|
||||
japanese: '日语魔法课'
|
||||
japanese: '日语魔法课',
|
||||
geography: '地理魔法课'
|
||||
};
|
||||
|
||||
// 任务数据
|
||||
@@ -595,11 +644,64 @@ const tasks = ref({
|
||||
completed: false,
|
||||
icon: '👋'
|
||||
}
|
||||
],
|
||||
geography: [
|
||||
{
|
||||
title: '中国地图认知',
|
||||
description: '认识中国地图的形状和主要省份',
|
||||
reward: 5,
|
||||
completed: false,
|
||||
icon: '🗺️'
|
||||
},
|
||||
{
|
||||
title: '中国地理常识',
|
||||
description: '学习中国的地理位置、面积等基本常识',
|
||||
reward: 5,
|
||||
completed: false,
|
||||
icon: '🌏'
|
||||
},
|
||||
{
|
||||
title: '南北方差异',
|
||||
description: '了解中国南北方的地理文化差异',
|
||||
reward: 5,
|
||||
completed: false,
|
||||
icon: '🌵'
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
// 游戏数据
|
||||
const gameData = {
|
||||
geography: {
|
||||
// 中国地图认知
|
||||
map: [
|
||||
{ question: '中国地图的形状像什么?', options: ['公鸡', '兔子', '大象', '龙'], answer: '公鸡' },
|
||||
{ question: '中国的首都是哪里?', options: ['上海', '北京', '广州', '深圳'], answer: '北京' },
|
||||
{ question: '中国最大的岛屿是哪个?', options: ['海南岛', '台湾岛', '崇明岛', '舟山群岛'], answer: '台湾岛' },
|
||||
{ question: '中国最长的河流是哪条?', options: ['黄河', '长江', '珠江', '松花江'], answer: '长江' },
|
||||
{ question: '中国的母亲河是哪条?', options: ['长江', '黄河', '珠江', '淮河'], answer: '黄河' }
|
||||
],
|
||||
// 中国地理常识
|
||||
basics: [
|
||||
{ question: '中国位于哪个大洲?', options: ['欧洲', '亚洲', '非洲', '北美洲'], answer: '亚洲' },
|
||||
{ question: '中国的土地面积大约是多少?', options: ['960万平方公里', '860万平方公里', '760万平方公里', '660万平方公里'], answer: '960万平方公里' },
|
||||
{ question: '中国的邻国中,面积最大的是哪个国家?', options: ['俄罗斯', '印度', '蒙古', '朝鲜'], answer: '俄罗斯' },
|
||||
{ question: '中国的四大直辖市是北京、上海、天津和哪里?', options: ['重庆', '广州', '深圳', '成都'], answer: '重庆' },
|
||||
{ question: '中国的地势特点是什么?', options: ['东高西低', '西高东低', '南高北低', '北高南低'], answer: '西高东低' },
|
||||
{ question: '中国最大的高原是哪个?', options: ['青藏高原', '内蒙古高原', '黄土高原', '云贵高原'], answer: '青藏高原' },
|
||||
{ question: '中国最大的平原是哪个?', options: ['东北平原', '华北平原', '长江中下游平原', '关中平原'], answer: '东北平原' },
|
||||
{ question: '中国的南海诸岛属于哪个省级行政区?', options: ['广东省', '海南省', '福建省', '台湾省'], answer: '海南省' },
|
||||
{ question: '中国的五岳中,位于山东省的是哪座山?', options: ['泰山', '华山', '衡山', '恒山'], answer: '泰山' }
|
||||
],
|
||||
// 南北方差异
|
||||
northSouth: [
|
||||
{ question: '中国南北方的分界线是什么?', options: ['秦岭-淮河', '长江', '黄河', '长城'], answer: '秦岭-淮河' },
|
||||
{ question: '北方地区的主要粮食作物是什么?', options: ['小麦', '水稻', '玉米', '高粱'], answer: '小麦' },
|
||||
{ question: '南方地区的主要粮食作物是什么?', options: ['水稻', '小麦', '玉米', '高粱'], answer: '水稻' },
|
||||
{ question: '北方人喜欢吃的面食是?', options: ['面条', '米饭', '馒头', '饺子'], answer: '面条' },
|
||||
{ question: '南方人喜欢吃的主食是?', options: ['米饭', '面条', '馒头', '饺子'], answer: '米饭' }
|
||||
]
|
||||
},
|
||||
math: {
|
||||
// 数数练习(1-100 认知)
|
||||
counting: [
|
||||
@@ -2241,89 +2343,163 @@ const playAudio = (text: string) => {
|
||||
|
||||
// 选择学科
|
||||
const selectSubject = (subject: string) => {
|
||||
console.log('=== 选择学科开始 ===');
|
||||
console.log('参数 subject:', subject);
|
||||
console.log('currentSubject.value 修改前:', currentSubject.value);
|
||||
currentSubject.value = subject;
|
||||
currentGame.value = null;
|
||||
console.log('currentSubject.value 修改后:', currentSubject.value);
|
||||
console.log('currentGame.value:', currentGame.value);
|
||||
console.log('=== 选择学科结束 ===');
|
||||
};
|
||||
|
||||
// 开始游戏
|
||||
const startGame = (subject: string, taskIndex: number) => {
|
||||
console.log('开始游戏:', subject, taskIndex);
|
||||
try {
|
||||
console.log('开始游戏函数被调用:', subject, taskIndex);
|
||||
console.log('类型检查 - subject:', typeof subject, 'taskIndex:', typeof taskIndex);
|
||||
|
||||
// 检查是否达到每日上限
|
||||
if (isDailyLimitReached(subject)) {
|
||||
const subjectName = subject === 'math' ? '数学' : subject === 'chinese' ? '语文' : subject === 'english' ? '英语' : subject === 'japanese' ? '日语' : '科学';
|
||||
const limit = dailyLimits[subject as keyof typeof dailyLimits];
|
||||
alert(`今日${subjectName}题目已达上限(${limit}题),明天再来挑战吧!`);
|
||||
return;
|
||||
}
|
||||
// 检查是否达到每日上限
|
||||
if (isDailyLimitReached(subject)) {
|
||||
const subjectName = subject === 'math' ? '数学' : subject === 'chinese' ? '语文' : subject === 'english' ? '英语' : subject === 'japanese' ? '日语' : subject === 'geography' ? '地理' : '科学';
|
||||
const limit = dailyLimits[subject as keyof typeof dailyLimits];
|
||||
alert(`今日${subjectName}题目已达上限(${limit}题),明天再来挑战吧!`);
|
||||
return;
|
||||
}
|
||||
|
||||
// 根据学科和任务索引选择不同的题目集
|
||||
let taskType = '';
|
||||
let gameDataSubject: any = null;
|
||||
let startIndex = 0;
|
||||
// 根据学科和任务索引选择不同的题目集
|
||||
let taskType = '';
|
||||
let gameDataSubject: any = null;
|
||||
let startIndex = 0;
|
||||
|
||||
switch (subject) {
|
||||
case 'math':
|
||||
const mathTasks = ['counting', 'shapes', 'calculation'];
|
||||
taskType = mathTasks[taskIndex] || 'counting';
|
||||
gameDataSubject = gameData.math[taskType as keyof typeof gameData.math];
|
||||
startIndex = progress.value.math[taskType as keyof typeof progress.value.math];
|
||||
break;
|
||||
case 'chinese':
|
||||
const chineseTasks = ['radicals', 'pinyin', 'stories'];
|
||||
taskType = chineseTasks[taskIndex] || 'radicals';
|
||||
gameDataSubject = gameData.chinese[taskType as keyof typeof gameData.chinese];
|
||||
startIndex = progress.value.chinese[taskType as keyof typeof progress.value.chinese];
|
||||
break;
|
||||
case 'english':
|
||||
const englishTasks = ['maze', 'animal', 'dialogue'];
|
||||
taskType = englishTasks[taskIndex] || 'maze';
|
||||
gameDataSubject = gameData.english[taskType as keyof typeof gameData.english];
|
||||
startIndex = progress.value.english[taskType as keyof typeof progress.value.english];
|
||||
break;
|
||||
case 'science':
|
||||
const scienceTasks = ['plants', 'buoyancy', 'colors', 'chemistry', 'physics', 'experiments'];
|
||||
taskType = scienceTasks[taskIndex] || 'plants';
|
||||
gameDataSubject = gameData.science[taskType as keyof typeof gameData.science];
|
||||
startIndex = progress.value.science[taskType as keyof typeof progress.value.science];
|
||||
break;
|
||||
case 'japanese':
|
||||
const japaneseTasks = ['hiragana', 'animals', 'fruits', 'body', 'directions', 'items', 'greetings'];
|
||||
taskType = japaneseTasks[taskIndex] || 'hiragana';
|
||||
gameDataSubject = gameData.japanese[taskType as keyof typeof gameData.japanese];
|
||||
startIndex = progress.value.japanese[taskType as keyof typeof progress.value.japanese];
|
||||
break;
|
||||
default:
|
||||
gameDataSubject = gameData[subject as keyof typeof gameData];
|
||||
}
|
||||
switch (subject) {
|
||||
case 'math':
|
||||
const mathTasks = ['counting', 'shapes', 'calculation'];
|
||||
taskType = mathTasks[taskIndex] || 'counting';
|
||||
gameDataSubject = gameData.math[taskType as keyof typeof gameData.math];
|
||||
startIndex = progress.value.math[taskType as keyof typeof progress.value.math] || 0;
|
||||
break;
|
||||
case 'chinese':
|
||||
const chineseTasks = ['radicals', 'pinyin', 'words'];
|
||||
taskType = chineseTasks[taskIndex] || 'radicals';
|
||||
gameDataSubject = gameData.chinese[taskType as keyof typeof gameData.chinese];
|
||||
startIndex = progress.value.chinese[taskType as keyof typeof progress.value.chinese] || 0;
|
||||
break;
|
||||
case 'english':
|
||||
const englishTasks = ['maze', 'animal', 'dialogue'];
|
||||
taskType = englishTasks[taskIndex] || 'maze';
|
||||
gameDataSubject = gameData.english[taskType as keyof typeof gameData.english];
|
||||
startIndex = progress.value.english[taskType as keyof typeof progress.value.english] || 0;
|
||||
break;
|
||||
case 'science':
|
||||
const scienceTasks = ['plants', 'buoyancy', 'colors', 'chemistry', 'physics', 'experiments'];
|
||||
taskType = scienceTasks[taskIndex] || 'plants';
|
||||
gameDataSubject = gameData.science[taskType as keyof typeof gameData.science];
|
||||
startIndex = progress.value.science[taskType as keyof typeof progress.value.science] || 0;
|
||||
break;
|
||||
case 'japanese':
|
||||
const japaneseTasks = ['hiragana', 'animals', 'fruits', 'body', 'directions', 'items', 'greetings'];
|
||||
taskType = japaneseTasks[taskIndex] || 'hiragana';
|
||||
gameDataSubject = gameData.japanese[taskType as keyof typeof gameData.japanese];
|
||||
startIndex = progress.value.japanese[taskType as keyof typeof progress.value.japanese] || 0;
|
||||
break;
|
||||
case 'geography':
|
||||
const geographyTasks = ['map', 'basics', 'northSouth'];
|
||||
taskType = geographyTasks[taskIndex] || 'map';
|
||||
gameDataSubject = gameData.geography[taskType as keyof typeof gameData.geography];
|
||||
startIndex = progress.value.geography[taskType as keyof typeof progress.value.geography] || 0;
|
||||
break;
|
||||
default:
|
||||
gameDataSubject = gameData[subject as keyof typeof gameData];
|
||||
startIndex = 0;
|
||||
}
|
||||
|
||||
console.log('选择的任务类型:', taskType);
|
||||
console.log('游戏数据:', gameDataSubject);
|
||||
console.log('开始索引:', startIndex);
|
||||
console.log('选择的任务类型:', taskType);
|
||||
console.log('游戏数据:', gameDataSubject);
|
||||
console.log('开始索引:', startIndex);
|
||||
|
||||
if (gameDataSubject && gameDataSubject[0]) {
|
||||
// 确保startIndex不超过题目总数
|
||||
const effectiveIndex = Math.min(startIndex, gameDataSubject.length - 1);
|
||||
console.log('gameDataSubject类型:', typeof gameDataSubject);
|
||||
console.log('gameDataSubject是否为数组:', Array.isArray(gameDataSubject));
|
||||
console.log('gameDataSubject长度:', gameDataSubject ? gameDataSubject.length : 'N/A');
|
||||
|
||||
currentGame.value = {
|
||||
subject,
|
||||
taskIndex,
|
||||
taskType,
|
||||
question: gameDataSubject[effectiveIndex].question,
|
||||
options: gameDataSubject[effectiveIndex].options,
|
||||
parts: gameDataSubject[effectiveIndex].parts,
|
||||
items: gameDataSubject[effectiveIndex].items,
|
||||
answer: gameDataSubject[effectiveIndex].answer,
|
||||
audio: gameDataSubject[effectiveIndex].audio
|
||||
};
|
||||
console.log('当前游戏设置:', currentGame.value);
|
||||
} else {
|
||||
console.error('游戏数据未找到:', subject, taskType);
|
||||
// 确保gameDataSubject是数组且有数据
|
||||
if (gameDataSubject && Array.isArray(gameDataSubject) && gameDataSubject.length > 0) {
|
||||
// 确保startIndex不超过题目总数
|
||||
const effectiveIndex = Math.min(startIndex, gameDataSubject.length - 1);
|
||||
console.log('effectiveIndex:', effectiveIndex);
|
||||
|
||||
// 获取题目数据
|
||||
const questionData = gameDataSubject[effectiveIndex];
|
||||
console.log('questionData:', questionData);
|
||||
|
||||
if (!questionData) {
|
||||
console.error('题目数据未找到:', subject, taskType, effectiveIndex);
|
||||
// 即使没有题目数据,也设置currentGame.value
|
||||
currentGame.value = {
|
||||
subject,
|
||||
taskIndex,
|
||||
taskType,
|
||||
question: '暂无题目数据',
|
||||
options: [],
|
||||
parts: [],
|
||||
items: [],
|
||||
answer: '',
|
||||
audio: ''
|
||||
};
|
||||
return;
|
||||
}
|
||||
|
||||
let shuffledOptions = null;
|
||||
let shuffledAnswer = questionData.answer;
|
||||
|
||||
// 如果有选项,随机打乱顺序
|
||||
if (questionData.options) {
|
||||
// 创建选项的副本并打乱
|
||||
shuffledOptions = [...questionData.options];
|
||||
for (let i = shuffledOptions.length - 1; i > 0; i--) {
|
||||
const j = Math.floor(Math.random() * (i + 1));
|
||||
[shuffledOptions[i], shuffledOptions[j]] = [shuffledOptions[j], shuffledOptions[i]];
|
||||
}
|
||||
}
|
||||
|
||||
// 设置currentGame.value
|
||||
currentGame.value = {
|
||||
subject,
|
||||
taskIndex,
|
||||
taskType,
|
||||
question: questionData.question || '暂无题目',
|
||||
options: shuffledOptions || questionData.options || [],
|
||||
parts: questionData.parts || [],
|
||||
items: questionData.items || [],
|
||||
answer: shuffledAnswer || '',
|
||||
audio: questionData.audio || ''
|
||||
};
|
||||
console.log('当前游戏设置:', currentGame.value);
|
||||
console.log('currentGame.value设置后:', currentGame.value);
|
||||
} else {
|
||||
console.error('游戏数据未找到或为空:', subject, taskType, gameDataSubject);
|
||||
// 即使没有游戏数据,也设置currentGame.value,避免界面无反应
|
||||
currentGame.value = {
|
||||
subject,
|
||||
taskIndex,
|
||||
taskType,
|
||||
question: '暂无题目数据',
|
||||
options: [],
|
||||
parts: [],
|
||||
items: [],
|
||||
answer: '',
|
||||
audio: ''
|
||||
};
|
||||
}
|
||||
currentQuestionIndex.value = startIndex;
|
||||
showFeedback.value = false;
|
||||
currentAnswer.value = '';
|
||||
experimentResult.value = '';
|
||||
console.log('函数执行完毕,currentGame.value:', currentGame.value);
|
||||
} catch (error) {
|
||||
console.error('开始游戏时发生错误:', error);
|
||||
alert('开始游戏时发生错误,请重试');
|
||||
}
|
||||
currentQuestionIndex.value = startIndex;
|
||||
showFeedback.value = false;
|
||||
currentAnswer.value = '';
|
||||
experimentResult.value = '';
|
||||
};
|
||||
|
||||
// 检查数学答案
|
||||
@@ -2437,6 +2613,25 @@ const checkJapaneseAnswer = (option: string) => {
|
||||
}
|
||||
};
|
||||
|
||||
// 检查地理答案
|
||||
const checkGeographyAnswer = (option: string) => {
|
||||
isCorrect.value = option === currentGame.value.answer;
|
||||
const task = tasks.value[currentGame.value.subject as keyof typeof tasks.value][currentGame.value.taskIndex];
|
||||
let starsPerQuestion = 1;
|
||||
if (currentGame.value.subject === 'math' || currentGame.value.subject === 'chinese' || currentGame.value.subject === 'english' || currentGame.value.subject === 'japanese' || currentGame.value.subject === 'geography') {
|
||||
starsPerQuestion = Math.ceil(task.reward / 20);
|
||||
} else if (currentGame.value.subject === 'science') {
|
||||
starsPerQuestion = Math.ceil(task.reward / 10);
|
||||
}
|
||||
feedbackMessage.value = isCorrect.value
|
||||
? `太棒了!回答正确!正确答案是 ${currentGame.value.answer}。获得 ${starsPerQuestion} 颗星星能量!`
|
||||
: `再试一次,加油!你选择的是 ${option}。`;
|
||||
showFeedback.value = true;
|
||||
if (isCorrect.value) {
|
||||
playAudio(`太棒了,正确答案是 ${currentGame.value.answer}`);
|
||||
}
|
||||
};
|
||||
|
||||
// 选择语文偏旁
|
||||
const selectPart = (part: string) => {
|
||||
currentAnswer.value += part;
|
||||
@@ -2454,12 +2649,16 @@ const nextQuestion = () => {
|
||||
const taskIndex = currentGame.value.taskIndex;
|
||||
const task = tasks.value[subject as keyof typeof tasks.value][taskIndex];
|
||||
|
||||
// 计算每题的星星奖励(总奖励除以题目数量)
|
||||
// 计算每题的星星奖励(降低获得量)
|
||||
let starsPerQuestion = 1;
|
||||
if (subject === 'math' || subject === 'chinese' || subject === 'english') {
|
||||
if (subject === 'math' || subject === 'chinese' || subject === 'english' || subject === 'japanese' || subject === 'geography') {
|
||||
// 降低数学、语文、英语、日语、地理的奖励获得量
|
||||
// 总奖励为5,分成20题,每题0.25颗,向上取整为1颗
|
||||
starsPerQuestion = Math.ceil(task.reward / 20); // 20题任务
|
||||
} else if (subject === 'science') {
|
||||
starsPerQuestion = Math.ceil(task.reward / 10); // 10题任务
|
||||
// 降低科学的奖励获得量
|
||||
// 总奖励为8-12,分成10题,每题0.8-1.2颗,向上取整为1颗
|
||||
starsPerQuestion = Math.ceil(task.reward / 15); // 15题任务的计算方式,降低获得量
|
||||
}
|
||||
|
||||
// 添加星星能量
|
||||
@@ -2485,6 +2684,9 @@ const nextQuestion = () => {
|
||||
case 'japanese':
|
||||
progress.value.japanese[taskType as keyof typeof progress.value.japanese]++;
|
||||
break;
|
||||
case 'geography':
|
||||
progress.value.geography[taskType as keyof typeof progress.value.geography]++;
|
||||
break;
|
||||
}
|
||||
|
||||
// 更新每日完成记录
|
||||
@@ -2495,7 +2697,7 @@ const nextQuestion = () => {
|
||||
|
||||
// 检查是否达到每日上限
|
||||
if (isDailyLimitReached(subject)) {
|
||||
const subjectName = subject === 'math' ? '数学' : subject === 'chinese' ? '语文' : subject === 'english' ? '英语' : subject === 'japanese' ? '日语' : '科学';
|
||||
const subjectName = subject === 'math' ? '数学' : subject === 'chinese' ? '语文' : subject === 'english' ? '英语' : subject === 'japanese' ? '日语' : subject === 'geography' ? '地理' : '科学';
|
||||
const limit = dailyLimits[subject as keyof typeof dailyLimits];
|
||||
alert(`今日${subjectName}题目已达上限(${limit}题),明天再来挑战吧!`);
|
||||
currentGame.value = null;
|
||||
@@ -2522,21 +2724,38 @@ const nextQuestion = () => {
|
||||
case 'japanese':
|
||||
gameDataSubject = gameData.japanese[taskType as keyof typeof gameData.japanese];
|
||||
break;
|
||||
case 'geography':
|
||||
gameDataSubject = gameData.geography[taskType as keyof typeof gameData.geography];
|
||||
break;
|
||||
default:
|
||||
gameDataSubject = gameData[subject as keyof typeof gameData];
|
||||
}
|
||||
|
||||
if (gameDataSubject && currentQuestionIndex.value < gameDataSubject.length) {
|
||||
const questionData = gameDataSubject[currentQuestionIndex.value];
|
||||
let shuffledOptions = null;
|
||||
let shuffledAnswer = questionData.answer;
|
||||
|
||||
// 如果有选项,随机打乱顺序
|
||||
if (questionData.options) {
|
||||
// 创建选项的副本并打乱
|
||||
shuffledOptions = [...questionData.options];
|
||||
for (let i = shuffledOptions.length - 1; i > 0; i--) {
|
||||
const j = Math.floor(Math.random() * (i + 1));
|
||||
[shuffledOptions[i], shuffledOptions[j]] = [shuffledOptions[j], shuffledOptions[i]];
|
||||
}
|
||||
}
|
||||
|
||||
currentGame.value = {
|
||||
subject,
|
||||
taskIndex,
|
||||
taskType,
|
||||
question: gameDataSubject[currentQuestionIndex.value].question,
|
||||
options: gameDataSubject[currentQuestionIndex.value].options,
|
||||
parts: gameDataSubject[currentQuestionIndex.value].parts,
|
||||
items: gameDataSubject[currentQuestionIndex.value].items,
|
||||
answer: gameDataSubject[currentQuestionIndex.value].answer,
|
||||
audio: gameDataSubject[currentQuestionIndex.value].audio
|
||||
question: questionData.question,
|
||||
options: shuffledOptions || questionData.options,
|
||||
parts: questionData.parts,
|
||||
items: questionData.items,
|
||||
answer: shuffledAnswer,
|
||||
audio: questionData.audio
|
||||
};
|
||||
showFeedback.value = false;
|
||||
currentAnswer.value = '';
|
||||
@@ -2745,6 +2964,7 @@ const nextQuestion = () => {
|
||||
.subject-card.chinese::before { background: linear-gradient(90deg, #9370DB, #DDA0DD); }
|
||||
.subject-card.english::before { background: linear-gradient(90deg, #87CEEB, #4682B4); }
|
||||
.subject-card.science::before { background: linear-gradient(90deg, #98FB98, #32CD32); }
|
||||
.subject-card.geography::before { background: linear-gradient(90deg, #FFA500, #FFD700); }
|
||||
|
||||
.subject-icon {
|
||||
font-size: 50px;
|
||||
|
||||
Reference in New Issue
Block a user