1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-02 07:27:04 +00:00

repair history.back&history.go bug

This commit is contained in:
shanshuirenjia
2019-04-22 18:05:18 +08:00
parent a8852dccc2
commit 88e480b575
2 changed files with 13 additions and 0 deletions

View File

@@ -54,6 +54,14 @@ class App extends Component {
pathPrefix: [], pathPrefix: [],
}; };
this.dirViewPanels = ['my-libs', 'shared-libs', 'org']; // and group this.dirViewPanels = ['my-libs', 'shared-libs', 'org']; // and group
window.onpopstate = this.onpopstate;
}
onpopstate = (event) => {
if (event.state && event.state.currentTab && event.state.pathPrefix) {
let { currentTab, pathPrefix } = event.state;
this.setState({currentTab, pathPrefix});
}
} }
componentDidMount() { componentDidMount() {
@@ -129,6 +137,9 @@ class App extends Component {
this.setState({ this.setState({
currentTab: tabName, currentTab: tabName,
pathPrefix: pathPrefix pathPrefix: pathPrefix
}, () => {
let { currentTab, pathPrefix } = this.state;
window.history.replaceState({currentTab: currentTab, pathPrefix: pathPrefix}, null);
}); });
} }

View File

@@ -73,6 +73,7 @@ class LibContentView extends React.Component {
updateDetail: false, updateDetail: false,
}; };
this.oldonpopstate = window.onpopstate;
window.onpopstate = this.onpopstate; window.onpopstate = this.onpopstate;
this.lastModifyTime = new Date(); this.lastModifyTime = new Date();
this.isNeedUpdateHistoryState = true; // Load, refresh page, switch mode for the first time, no need to set historyState this.isNeedUpdateHistoryState = true; // Load, refresh page, switch mode for the first time, no need to set historyState
@@ -146,6 +147,7 @@ class LibContentView extends React.Component {
} }
componentWillUnmount() { componentWillUnmount() {
window.onpopstate = this.oldonpopstate;
collabServer.unwatchRepo(this.props.repoID, this.onRepoUpdateEvent); collabServer.unwatchRepo(this.props.repoID, this.onRepoUpdateEvent);
} }