From 3fe9e97ae5d9192b9d87ce32c6dabbd1be4392bf Mon Sep 17 00:00:00 2001 From: caishi <1149225589@qq.com> Date: Mon, 15 Jun 2020 15:31:21 +0800 Subject: [PATCH] =?UTF-8?q?/=E9=BB=98=E8=AE=A4=E8=BF=9B=E5=85=A5=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.js | 8 ++------ src/AppConfig.js | 2 +- src/forge/Home.jsx | 26 -------------------------- src/forge/Index.js | 21 ++++++++++++++++++--- src/forge/users/Index.jsx | 26 ++++++++++++++++++++++++++ src/forge/users/Infos.js | 22 +++++++++++----------- 6 files changed, 58 insertions(+), 47 deletions(-) delete mode 100644 src/forge/Home.jsx create mode 100644 src/forge/users/Index.jsx diff --git a/src/App.js b/src/App.js index 83ac6d76..b2a84807 100644 --- a/src/App.js +++ b/src/App.js @@ -46,10 +46,6 @@ const Projects = Loadable({ loader: () => import('./forge/Index'), loading: Loading, }) -const Home = Loadable({ - loader: () => import('./forge/Home'), - loading: Loading, -}) //403页面 const Shixunauthority = Loadable({ loader: () => import('./modules/403/Shixunauthority'), @@ -67,7 +63,7 @@ const http500 = Loadable({ loading: Loading, }) const InfosIndex = Loadable({ - loader: () => import('./forge/users/Infos'), + loader: () => import('./forge/users/Index'), loading: Loading, }) // 组织 @@ -253,7 +249,7 @@ class App extends Component { ( - + ) } /> diff --git a/src/AppConfig.js b/src/AppConfig.js index e0799627..decab74c 100644 --- a/src/AppConfig.js +++ b/src/AppConfig.js @@ -30,7 +30,7 @@ if (isDev) { } debugType = window.location.search.indexOf('debug=t') !== -1 ? 'teacher' : window.location.search.indexOf('debug=s') !== -1 ? 'student' : - window.location.search.indexOf('debug=a') !== -1 ? 'admin' : parsed.debug || 'admin' + window.location.search.indexOf('debug=a') !== -1 ? 'admin' : parsed.debug || '' } function clearAllCookie() { cookie.remove('_educoder_session', { path: '/' }); diff --git a/src/forge/Home.jsx b/src/forge/Home.jsx deleted file mode 100644 index a7bae4d1..00000000 --- a/src/forge/Home.jsx +++ /dev/null @@ -1,26 +0,0 @@ -import React , { useEffect } from 'react'; -import { SnackbarHOC } from "educoder"; -import { CNotificationHOC } from "../modules/courses/common/CNotificationHOC"; -import { TPMIndexHOC } from "../modules/tpm/TPMIndexHOC"; -import ProjectIndex from './Main/Index'; -import PersonIndex from './users/Infos'; - -import { Spin } from 'antd'; - -export default (CNotificationHOC()(SnackbarHOC()( - TPMIndexHOC((props)=>{ - const { pathname } = props.history.location; - const { current_user } = props; - useEffect(()=>{ - if(pathname === "/" && (current_user && current_user.login)){ - props.history.push(`/users/${current_user && current_user.login}`) - } - }) - return( - pathname === "/" && (current_user && current_user.login) ? - - : - - ) - }) -))) \ No newline at end of file diff --git a/src/forge/Index.js b/src/forge/Index.js index ea8b5711..9b59eedd 100644 --- a/src/forge/Index.js +++ b/src/forge/Index.js @@ -27,6 +27,11 @@ const ProjectDetail = Loadable({ loading: Loading, }); +const Infos = Loadable({ + loader: () => import("./users/Infos"), + loading: Loading, +}); + class Index extends Component { render() { return ( @@ -35,20 +40,30 @@ class Index extends Component { ( - + )} > ( - + )} > ( - + + )} + > + ( + this.props.current_user && this.props.current_user.login ? + + : + )} > diff --git a/src/forge/users/Index.jsx b/src/forge/users/Index.jsx new file mode 100644 index 00000000..6fd3d6f5 --- /dev/null +++ b/src/forge/users/Index.jsx @@ -0,0 +1,26 @@ +import React from 'react'; +import { Route, Switch } from "react-router-dom"; +import Loadable from "react-loadable"; +import Loading from "../../Loading"; +import { withRouter } from "react-router"; +import { SnackbarHOC } from "educoder"; +import { CNotificationHOC } from "../../modules/courses/common/CNotificationHOC"; +import { TPMIndexHOC } from "../../modules/tpm/TPMIndexHOC"; +const Infos = Loadable({ + loader: () => import("./Infos"), + loading: Loading, +}); +export default withRouter( + (CNotificationHOC()(SnackbarHOC()(TPMIndexHOC((props)=>{ + return( + + { + return ; + }} + > + + ) + })))) +) \ No newline at end of file diff --git a/src/forge/users/Infos.js b/src/forge/users/Infos.js index 37172aa4..bfe4efe8 100644 --- a/src/forge/users/Infos.js +++ b/src/forge/users/Infos.js @@ -8,9 +8,6 @@ import { getImageUrl } from "educoder"; import { Route, Switch } from "react-router-dom"; import { withRouter } from "react-router"; -import { SnackbarHOC } from "educoder"; -import { CNotificationHOC } from "../../modules/courses/common/CNotificationHOC"; -import { TPMIndexHOC } from "../../modules/tpm/TPMIndexHOC"; import "./new_user.css"; import "../css/index.css"; import './Index.scss'; @@ -60,7 +57,10 @@ class Infos extends Component { this.setState({ isSpin: true, }); - let url = `/users/${this.props.match.params.username}.json`; + const { current_user } = this.props; + const { username } = this.props.match.params; + + let url = `/users/${username || (current_user && current_user.login)}.json`; axios .get(url) .then((result) => { @@ -281,7 +281,12 @@ class Infos extends Component { return ; }} > - + { + return ; + }} + > )} @@ -292,9 +297,4 @@ class Infos extends Component { ); } } -export default withRouter( - ImageLayerOfCommentHOC({ - imgSelector: ".imageLayerParent img, .imageLayerParent .imageTarget", - parentSelector: ".newMain", - })(CNotificationHOC()(SnackbarHOC()(TPMIndexHOC(Infos)))) -); +export default Infos;