Commit 7afe8d8f by zhanghaozhe

智能选课

parent 95f355c3
...@@ -69,8 +69,7 @@ class App extends Component { ...@@ -69,8 +69,7 @@ class App extends Component {
this.getUser() this.getUser()
this.utm() this.utm()
const {history, location} = this.props const {history} = this.props
this.records.push(location)
this.setNavigationRecord(this.props.location, this.props.history.action) this.setNavigationRecord(this.props.location, this.props.history.action)
this.setPreviousLocation() this.setPreviousLocation()
...@@ -142,13 +141,12 @@ class App extends Component { ...@@ -142,13 +141,12 @@ class App extends Component {
const {pathname, search, hash} = location const {pathname, search, hash} = location
let isLastRecord = location.pathname === (this.records.length && this.records[this.records.length - 1].pathname) let isLastRecord = location.pathname === (this.records.length && this.records[this.records.length - 1].pathname)
let needHistoryMutation = location.pathname !== this.previousLocation.pathname let needHistoryMutation = location.pathname !== this.previousLocation.pathname
switch (action) { switch (action) {
case 'POP': case 'POP':
if (needHistoryMutation) { if (needHistoryMutation) {
this.firstLoad ? this.records.push({pathname, search, hash}) : this.records.pop() this.firstLoad ? this.records.push({pathname, search, hash}) : this.records.pop()
} else { } else {
this.records[this.records.length - 1] = location this.records.length ? (this.records[this.records.length - 1] = location) : this.records = [location]
} }
break break
case 'REPLACE': case 'REPLACE':
...@@ -160,8 +158,10 @@ class App extends Component { ...@@ -160,8 +158,10 @@ class App extends Component {
location.state && location.state.records location.state && location.state.records
? (location.state.records = this.records) ? (location.state.records = this.records)
: location.state ? location.state = {...location.state, records: this.records} : location.state ? location.state = {
: (location.state = {records: this.records}) ...location.state,
records: this.records,
} : (location.state = {records: this.records})
} }
......
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