|
|
@@ -18,7 +18,8 @@ import {
|
|
|
sparklesOutline,
|
|
|
chevronBackOutline,
|
|
|
chevronForwardOutline,
|
|
|
- createOutline
|
|
|
+ createOutline,
|
|
|
+ saveOutline
|
|
|
} from 'ionicons/icons';
|
|
|
|
|
|
// 单词数据接口
|
|
|
@@ -136,6 +137,9 @@ listSwipeDirection: 'left' | 'right' | null = null;
|
|
|
showStyleModal: boolean = false;
|
|
|
defaultStyles: string = '比如:童话、青春、悬疑、励志、科幻...';
|
|
|
|
|
|
+ // 退出确认弹窗状态
|
|
|
+ showExitModal: boolean = false;
|
|
|
+
|
|
|
// 生成状态
|
|
|
isGenerating: boolean = false;
|
|
|
|
|
|
@@ -179,7 +183,8 @@ listSwipeDirection: 'left' | 'right' | null = null;
|
|
|
sparklesOutline,
|
|
|
chevronBackOutline,
|
|
|
chevronForwardOutline,
|
|
|
- createOutline
|
|
|
+ createOutline,
|
|
|
+ saveOutline
|
|
|
});
|
|
|
// 从其他页通过 state 进入做题页时恢复故事
|
|
|
const nav = this.router.getCurrentNavigation();
|
|
|
@@ -843,9 +848,15 @@ listSwipeDirection: 'left' | 'right' | null = null;
|
|
|
|
|
|
// 返回上一页
|
|
|
goBack() {
|
|
|
+ // 评分结果页面点击返回,弹出确认弹窗
|
|
|
+ if (this.showExerciseView && this.scoreResult) {
|
|
|
+ this.showExitModal = true;
|
|
|
+ return;
|
|
|
+ }
|
|
|
if (this.showExerciseView) {
|
|
|
this.showExerciseView = false;
|
|
|
this.exerciseStory = null;
|
|
|
+ this.scoreResult = null;
|
|
|
return;
|
|
|
}
|
|
|
if (this.isGenerating) {
|
|
|
@@ -856,4 +867,50 @@ listSwipeDirection: 'left' | 'right' | null = null;
|
|
|
this.router.navigate(['/tabs/tab2']);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ // 关闭退出确认弹窗
|
|
|
+ closeExitModal() {
|
|
|
+ this.showExitModal = false;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 确认退出 - 重置状态并回到tab2页面
|
|
|
+ confirmExit() {
|
|
|
+ this.showExitModal = false;
|
|
|
+ this.resetState();
|
|
|
+ this.router.navigate(['/tabs/tab2']);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 保存故事 - 存入数据库(先不实现),然后重置状态回到tab2页面
|
|
|
+ saveStory() {
|
|
|
+ // TODO: 将数据存入数据库
|
|
|
+ console.log('保存故事:', {
|
|
|
+ story: this.exerciseStory,
|
|
|
+ score: this.scoreResult,
|
|
|
+ answers: this.exerciseBlanks
|
|
|
+ });
|
|
|
+
|
|
|
+ // 重置状态并回到tab2页面
|
|
|
+ this.resetState();
|
|
|
+ this.router.navigate(['/tabs/tab2']);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 重置页面状态
|
|
|
+ private resetState() {
|
|
|
+ this.showExerciseView = false;
|
|
|
+ this.exerciseStory = null;
|
|
|
+ this.exerciseBlanks = [];
|
|
|
+ this.availableWords = [];
|
|
|
+ this.focusedBlankIndex = null;
|
|
|
+ this.scoreResult = null;
|
|
|
+ this.storyResponse = null;
|
|
|
+ this.storyError = null;
|
|
|
+ this.isGenerating = false;
|
|
|
+ this.flashWords = [];
|
|
|
+ this.currentFlashIndex = 0;
|
|
|
+ this.showStyleModal = false;
|
|
|
+ this.showExitModal = false;
|
|
|
+ // 重置单词选中状态
|
|
|
+ this.learningWords.forEach(word => word.selected = false);
|
|
|
+ this.learnedWords.forEach(word => word.selected = false);
|
|
|
+ }
|
|
|
}
|