题库导入功能完成,考试计划功能完成。
This commit is contained in:
13
openspec/changes/fix-quizpage-useeffect-bug/proposal.md
Normal file
13
openspec/changes/fix-quizpage-useeffect-bug/proposal.md
Normal file
@@ -0,0 +1,13 @@
|
||||
# Change: Fix QuizPage useEffect Bug
|
||||
|
||||
## Why
|
||||
在QuizPage.tsx中,useEffect钩子末尾错误地调用了clearQuiz()函数,导致从SubjectSelectionPage传递过来的题目数据被立即清除,引发"Cannot read properties of undefined (reading 'type')"错误。
|
||||
|
||||
## What Changes
|
||||
- 移除QuizPage.tsx useEffect钩子末尾的clearQuiz()调用
|
||||
- 修改清除逻辑,只清除answers对象而保留题目数据
|
||||
- 添加对currentQuestion的空值检查,确保组件正确渲染
|
||||
|
||||
## Impact
|
||||
- Affected specs: quiz
|
||||
- Affected code: src/pages/QuizPage.tsx
|
||||
@@ -0,0 +1,17 @@
|
||||
## MODIFIED Requirements
|
||||
### Requirement: Quiz Page State Management
|
||||
The system SHALL preserve question data when navigating to QuizPage from other pages, and only clear答题状态(answers) to ensure proper component rendering.
|
||||
|
||||
#### Scenario: Navigation from SubjectSelectionPage
|
||||
- **WHEN** user selects a subject and navigates to QuizPage
|
||||
- **THEN** the system SHALL preserve the questions data
|
||||
- **THEN** the system SHALL clear only the answers state
|
||||
- **THEN** the system SHALL render the first question correctly
|
||||
|
||||
### Requirement: Quiz Page Error Handling
|
||||
The system SHALL properly handle null or undefined question data to prevent runtime errors during rendering.
|
||||
|
||||
#### Scenario: Null Question Data
|
||||
- **WHEN** currentQuestion is null or undefined
|
||||
- **THEN** the system SHALL display a loading state instead of crashing
|
||||
- **THEN** the system SHALL NOT attempt to access properties of undefined objects
|
||||
8
openspec/changes/fix-quizpage-useeffect-bug/tasks.md
Normal file
8
openspec/changes/fix-quizpage-useeffect-bug/tasks.md
Normal file
@@ -0,0 +1,8 @@
|
||||
## 1. Implementation
|
||||
- [x] 1.1 移除QuizPage.tsx useEffect钩子末尾的clearQuiz()调用
|
||||
- [x] 1.2 修改清除逻辑,只清除answers对象而保留题目数据
|
||||
- [x] 1.3 添加对currentQuestion的空值检查,确保组件正确渲染
|
||||
|
||||
## 2. Validation
|
||||
- [x] 2.1 运行项目确保bug已修复
|
||||
- [x] 2.2 验证从SubjectSelectionPage可以正常跳转到QuizPage并显示题目
|
||||
Reference in New Issue
Block a user