From aef1451455f0de2e969e378b54c64231746765ef Mon Sep 17 00:00:00 2001 From: caishi <1149225589@qq.com> Date: Mon, 10 May 2021 18:03:23 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E8=B7=B3=E8=BD=AC=E6=97=B6?= =?UTF-8?q?=E6=9C=AA=E6=BB=9A=E5=8A=A8=E5=88=B0=E9=A1=B6=E9=83=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.js | 10 ---------- src/AppConfig.js | 2 +- src/exchange/index.js | 7 +++++++ src/forums/Index.jsx | 4 +++- src/user_info/Index.jsx | 11 ++++++++++- 5 files changed, 21 insertions(+), 13 deletions(-) diff --git a/src/App.js b/src/App.js index 0fc569b1..7f4617f5 100644 --- a/src/App.js +++ b/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); diff --git a/src/AppConfig.js b/src/AppConfig.js index cd01c04b..5103c6bc 100644 --- a/src/AppConfig.js +++ b/src/AppConfig.js @@ -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) { diff --git a/src/exchange/index.js b/src/exchange/index.js index 761e4f0b..20c92ae8 100644 --- a/src/exchange/index.js +++ b/src/exchange/index.js @@ -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( diff --git a/src/forums/Index.jsx b/src/forums/Index.jsx index 09382a4a..068faecb 100644 --- a/src/forums/Index.jsx +++ b/src/forums/Index.jsx @@ -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() { diff --git a/src/user_info/Index.jsx b/src/user_info/Index.jsx index e9a69fdc..ed75be45 100644 --- a/src/user_info/Index.jsx +++ b/src/user_info/Index.jsx @@ -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 (