forked from Gitlink/forgeplus-react
页面跳转时未滚动到顶部
This commit is contained in:
parent
191e79e05a
commit
aef1451455
10
src/App.js
10
src/App.js
|
@ -80,16 +80,6 @@ const http500 = Loadable({
|
|||
loader: () => import('./modules/500/http500'),
|
||||
loading: Loading,
|
||||
})
|
||||
// const InfosIndex = Loadable({
|
||||
// loader: () => import('./forge/users/Index'),
|
||||
// loading: Loading,
|
||||
// })
|
||||
// 组织
|
||||
// const OrganizeIndex = Loadable({
|
||||
// loader: () => import('./forge/Team/Index'),
|
||||
// loading: Loading,
|
||||
// })
|
||||
|
||||
class App extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
|
|
@ -59,7 +59,7 @@ export function initAxiosInterceptors(props) {
|
|||
// TODO 避免重复的请求 https://github.com/axios/axios#cancellation
|
||||
var
|
||||
proxy = "http://localhost:3000"
|
||||
proxy = "https://testforgeplus.trustie.net"
|
||||
proxy = "https://forum.trustie.net"
|
||||
|
||||
const requestMap = {};
|
||||
window.setfalseInRequestMap = function (keyName) {
|
||||
|
|
|
@ -39,6 +39,13 @@ class Index extends Component{
|
|||
})
|
||||
}
|
||||
|
||||
componentDidUpdate=()=>{
|
||||
this.props.history.listen(()=>{
|
||||
if (document.body.scrollTop || document.documentElement.scrollTop > 0) {
|
||||
window.scrollTo(0, 0)
|
||||
}
|
||||
})
|
||||
}
|
||||
render(){
|
||||
return(
|
||||
<Switch {...this.props}>
|
||||
|
|
|
@ -27,7 +27,9 @@ const New = Loadable({
|
|||
class Index extends Component {
|
||||
componentDidUpdate=()=>{
|
||||
this.props.history.listen(()=>{
|
||||
|
||||
if (document.body.scrollTop || document.documentElement.scrollTop > 0) {
|
||||
window.scrollTo(0, 0)
|
||||
}
|
||||
})
|
||||
}
|
||||
render() {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import React from "react";
|
||||
import React, { useEffect } from "react";
|
||||
import { TPMIndexHOC } from "../modules/tpm/TPMIndexHOC";
|
||||
import { SnackbarHOC } from "educoder";
|
||||
import { CNotificationHOC } from "../modules/courses/common/CNotificationHOC";
|
||||
|
@ -31,6 +31,15 @@ const Blocks = Loadable({
|
|||
});
|
||||
|
||||
function Index(props) {
|
||||
const history = props.history;
|
||||
useEffect(()=>{
|
||||
history.listen(()=>{
|
||||
if (document.body.scrollTop || document.documentElement.scrollTop > 0) {
|
||||
window.scrollTo(0, 0)
|
||||
}
|
||||
})
|
||||
},[history])
|
||||
|
||||
return (
|
||||
<div className="newMain">
|
||||
<UserInfo {...props}></UserInfo>
|
||||
|
|
Loading…
Reference in New Issue