Commit 22523b6c by zhanghaozhe

ai测试

parent efaeef74
...@@ -152,7 +152,7 @@ class Exam extends Component { ...@@ -152,7 +152,7 @@ class Exam extends Component {
const {answer, time, recordId, elapsed} = this.state const {answer, time, recordId, elapsed} = this.state
const {history} = this.props const {history} = this.props
clearInterval(this.timer) clearInterval(this.timer)
this.store.setAll({time, answer, recordId, elapsed}) this.store.session.setAll({time, answer, recordId, elapsed})
history.push('/ai-test/submit') history.push('/ai-test/submit')
} }
......
...@@ -8,27 +8,9 @@ import Analysis from "@components/ai-test/analysis" ...@@ -8,27 +8,9 @@ import Analysis from "@components/ai-test/analysis"
import Assist from "@components/ai-test/assist" import Assist from "@components/ai-test/assist"
import Help from '@components/ai-test/share' import Help from '@components/ai-test/share'
import Report from '@components/ai-test/report' import Report from '@components/ai-test/report'
import storage from 'store2'
class AiTest extends Component { 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() { render() {
const {match} = this.props const {match} = this.props
return ( return (
......
...@@ -296,6 +296,7 @@ ...@@ -296,6 +296,7 @@
padding: 10px; padding: 10px;
color: #fff; color: #fff;
font-size: 0; font-size: 0;
z-index: 100;
button { button {
width: 100%; width: 100%;
......
...@@ -15,20 +15,21 @@ class SubmitAnswer extends Component { ...@@ -15,20 +15,21 @@ class SubmitAnswer extends Component {
timer = null timer = null
state = { state = {
time: this.store.get('time') || {d: 0, h: 0, m: 0, s: 0}, time: this.store.session.get('time') || {d: 0, h: 0, m: 0, s: 0},
answer: this.store.get('answer'), answer: this.store.session.get('answer'),
recordId: this.store.get('recordId'), recordId: this.store.session.get('recordId'),
analysis: [], analysis: [],
results: [], results: [],
elapsed: this.store.get('elapsed'), elapsed: this.store.session.get('elapsed'),
} }
componentDidMount() { componentDidMount() {
if (isEmpty(this.state.answer) || !this.state.recordId) { if (isEmpty(this.state.answer) || !this.state.recordId) {
this.props.history.replace('/ai-test') 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() this.getAnalysis()
} else { } else {
this.setCounter() this.setCounter()
...@@ -67,7 +68,7 @@ class SubmitAnswer extends Component { ...@@ -67,7 +68,7 @@ class SubmitAnswer extends Component {
}).then(res => { }).then(res => {
const {code, msg} = res.data const {code, msg} = res.data
if (code === 200) { if (code === 200) {
this.store.set('submitted', true) this.store.session.set('submitted', true)
clearInterval(this.timer) clearInterval(this.timer)
this.props.history.push('/ai-test/report') this.props.history.push('/ai-test/report')
} else { } else {
...@@ -150,4 +151,4 @@ class SubmitAnswer extends Component { ...@@ -150,4 +151,4 @@ class SubmitAnswer extends Component {
} }
} }
export default SubmitAnswer; export default SubmitAnswer;
\ No newline at end of file
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