Commit 22523b6c by zhanghaozhe

ai测试

parent efaeef74
......@@ -152,7 +152,7 @@ class Exam extends Component {
const {answer, time, recordId, elapsed} = this.state
const {history} = this.props
clearInterval(this.timer)
this.store.setAll({time, answer, recordId, elapsed})
this.store.session.setAll({time, answer, recordId, elapsed})
history.push('/ai-test/submit')
}
......
......@@ -8,27 +8,9 @@ import Analysis from "@components/ai-test/analysis"
import Assist from "@components/ai-test/assist"
import Help from '@components/ai-test/share'
import Report from '@components/ai-test/report'
import storage from 'store2'
class AiTest extends Component {
examStore = storage.namespace('aiTestExam')
componentDidMount() {
window.addEventListener('beforeunload', this.handleBeforeUnload)
}
componentWillUnmount() {
this.handleBeforeUnload()
window.removeEventListener('beforeunload', this.handleBeforeUnload)
}
handleBeforeUnload = () => {
this.examStore.clearAll()
}
render() {
const {match} = this.props
return (
......
......@@ -296,6 +296,7 @@
padding: 10px;
color: #fff;
font-size: 0;
z-index: 100;
button {
width: 100%;
......
......@@ -15,20 +15,21 @@ class SubmitAnswer extends Component {
timer = null
state = {
time: this.store.get('time') || {d: 0, h: 0, m: 0, s: 0},
answer: this.store.get('answer'),
recordId: this.store.get('recordId'),
time: this.store.session.get('time') || {d: 0, h: 0, m: 0, s: 0},
answer: this.store.session.get('answer'),
recordId: this.store.session.get('recordId'),
analysis: [],
results: [],
elapsed: this.store.get('elapsed'),
elapsed: this.store.session.get('elapsed'),
}
componentDidMount() {
if (isEmpty(this.state.answer) || !this.state.recordId) {
this.props.history.replace('/ai-test')
this.store.remove('submitted')
this.store.session.remove('submitted')
}
if (this.store.get('submitted')) {
console.log(this.store.session.get('submitted'))
if (this.store.session.get('submitted')) {
this.getAnalysis()
} else {
this.setCounter()
......@@ -67,7 +68,7 @@ class SubmitAnswer extends Component {
}).then(res => {
const {code, msg} = res.data
if (code === 200) {
this.store.set('submitted', true)
this.store.session.set('submitted', true)
clearInterval(this.timer)
this.props.history.push('/ai-test/report')
} else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment