From 1ac84425e294b1b78280f9f6e6356940278cda89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=9E=97?= <904079904@qq.com> Date: Tue, 15 Oct 2019 10:36:37 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/react/src/AppConfig.js | 3 + .../react/src/modules/forums/MemoTechShare.js | 232 +++++++++--------- .../react/src/modules/login/EducoderLogin.js | 7 +- public/react/src/modules/tpm/TPMIndexHOC.js | 15 +- 4 files changed, 133 insertions(+), 124 deletions(-) diff --git a/public/react/src/AppConfig.js b/public/react/src/AppConfig.js index 7867791cf..0510cd293 100644 --- a/public/react/src/AppConfig.js +++ b/public/react/src/AppConfig.js @@ -95,6 +95,9 @@ export function initAxiosInterceptors(props) { } // if (requestMap[config.url] === true) { // 避免重复的请求 导致页面f5刷新 也会被阻止 + // console.log(config); + // console.log(JSON.parse(config)); + // console.log(config.url); // console.log("被阻止了是重复请求================================="); // return false; // } diff --git a/public/react/src/modules/forums/MemoTechShare.js b/public/react/src/modules/forums/MemoTechShare.js index de6ba074c..d32bd2e2f 100644 --- a/public/react/src/modules/forums/MemoTechShare.js +++ b/public/react/src/modules/forums/MemoTechShare.js @@ -1,116 +1,116 @@ -import React, { Component } from 'react'; -import { Redirect } from 'react-router'; - -import { BrowserRouter as Router, Route, Link, Switch } from "react-router-dom"; - -import PropTypes from 'prop-types'; - -import classNames from 'classnames' - -import Pagination from 'rc-pagination'; - -import { postPaginationHOC } from './PostPaginationHOC' - -import PostItem from './PostItem' - -import ForumsNavTab from './ForumsNavTab' - -// import queryString from 'query-string' -import { queryString } from 'educoder' - -import MemoList from './MemoList' - - -class MemoTechShare extends Component { - constructor(props) { - super(props) - - this.handleLocationChange = this.handleLocationChange.bind(this); - - this.state = { - - } - } - - onPaginationChange(pageNum, pageSize) { - this.props.onPaginationChange(pageNum, pageSize) - } - - componentDidMount() { - // this.handleLocationChange(this.props.history.location); - // this.unlisten = this.props.history.listen(this.handleLocationChange); - } - - componentWillUnmount() { - // this.unlisten(); - } - componentDidUpdate(prevProps) { - if(this.props.match.params.memoType !== prevProps.match.params.memoType) { - // do something - console.log(`memoType changed`) - this.props.fetchMemos(); - } - } - - componentWillReceiveProps(newProps, newContext) { - if (newProps.match.url === this.props.match.url) { - const oldParsed = queryString.parse(this.props.location.search); - const newParsed = queryString.parse(newProps.location.search); - if (!newParsed.page && oldParsed.page || - (oldParsed.order && newParsed.order && oldParsed.order != newParsed.order)) { - this.props.fetchMemos(); - } - console.log('componentWillReceiveProps...') - } - } - - handleLocationChange(location) { - console.log(`- - - location: '${location.pathname}'`); - if (location.pathname) { - if (location.pathname.indexOf('/forums/categories/all') != -1 - && this.props.location.search && this.props.location.search.indexOf('order=') != -1 - && location.search.indexOf('order=') != -1) { - const oldParsed = queryString.parse(this.props.location.search); - const newParsed = queryString.parse(location.search); - if (oldParsed.order != newParsed.order) { // 只有在热门和最新间跳转时,才需要处理 - this.props.fetchMemos(); - } - } - } - } - - renderMemoList() { - - - // const { memo_list, user } = this.props; - // if (!memo_list) { - // return '' - // } - // return memo_list.map( (item, index) => { - - // return ( - // this.setTop(memo)} - // setDown={(memo)=>this.setDown(memo)} memo={item} - // > - // ) - // }) - return this.props.renderMemoList(); - } - - render() { - const { match, history, currentPage, memo_count ,memo_list } = this.props - - return ( - - - this.renderMemoList()} - onPaginationChange={ (pageNum, pageSize) => this.props.onPaginationChange(pageNum, pageSize) } - > - - - ); - } -} - -export default postPaginationHOC() ( MemoTechShare ); +import React, { Component } from 'react'; +import { Redirect } from 'react-router'; + +import { BrowserRouter as Router, Route, Link, Switch } from "react-router-dom"; + +import PropTypes from 'prop-types'; + +import classNames from 'classnames' + +import Pagination from 'rc-pagination'; + +import { postPaginationHOC } from './PostPaginationHOC' + +import PostItem from './PostItem' + +import ForumsNavTab from './ForumsNavTab' + +// import queryString from 'query-string' +import { queryString } from 'educoder' + +import MemoList from './MemoList' + + +class MemoTechShare extends Component { + constructor(props) { + super(props) + + this.handleLocationChange = this.handleLocationChange.bind(this); + + this.state = { + + } + } + + onPaginationChange(pageNum, pageSize) { + this.props.onPaginationChange(pageNum, pageSize) + } + + componentDidMount() { + // this.handleLocationChange(this.props.history.location); + // this.unlisten = this.props.history.listen(this.handleLocationChange); + } + + componentWillUnmount() { + // this.unlisten(); + } + componentDidUpdate(prevProps) { + if(this.props.match.params.memoType !== prevProps.match.params.memoType) { + // do something + console.log(`memoType changed`) + this.props.fetchMemos(); + } + } + + componentWillReceiveProps(newProps, newContext) { + if (newProps.match.url === this.props.match.url) { + const oldParsed = queryString.parse(this.props.location.search); + const newParsed = queryString.parse(newProps.location.search); + if (!newParsed.page && oldParsed.page || + (oldParsed.order && newParsed.order && oldParsed.order != newParsed.order)) { + this.props.fetchMemos(); + } + // console.log('componentWillReceiveProps...') + } + } + + handleLocationChange(location) { + console.log(`- - - location: '${location.pathname}'`); + if (location.pathname) { + if (location.pathname.indexOf('/forums/categories/all') != -1 + && this.props.location.search && this.props.location.search.indexOf('order=') != -1 + && location.search.indexOf('order=') != -1) { + const oldParsed = queryString.parse(this.props.location.search); + const newParsed = queryString.parse(location.search); + if (oldParsed.order != newParsed.order) { // 只有在热门和最新间跳转时,才需要处理 + this.props.fetchMemos(); + } + } + } + } + + renderMemoList() { + + + // const { memo_list, user } = this.props; + // if (!memo_list) { + // return '' + // } + // return memo_list.map( (item, index) => { + + // return ( + // this.setTop(memo)} + // setDown={(memo)=>this.setDown(memo)} memo={item} + // > + // ) + // }) + return this.props.renderMemoList(); + } + + render() { + const { match, history, currentPage, memo_count ,memo_list } = this.props + + return ( + + + this.renderMemoList()} + onPaginationChange={ (pageNum, pageSize) => this.props.onPaginationChange(pageNum, pageSize) } + > + + + ); + } +} + +export default postPaginationHOC() ( MemoTechShare ); diff --git a/public/react/src/modules/login/EducoderLogin.js b/public/react/src/modules/login/EducoderLogin.js index 393c1cf3c..c7a5a0cbf 100644 --- a/public/react/src/modules/login/EducoderLogin.js +++ b/public/react/src/modules/login/EducoderLogin.js @@ -28,6 +28,7 @@ import educodernet from '../../../src/images/login/educodernet.png'; import LoginRegisterComponent from '../user/LoginRegisterComponent'; import FindPasswordComponent from '../user/FindPasswordComponent'; import passopen from "../../images/login/passopen.png"; +import {TPMIndexHOC} from "../tpm/TPMIndexHOC"; //educoder登入页面 var sectionStyle = { "height": "100%", @@ -109,7 +110,8 @@ class EducoderLogin extends Component { } componentDidMount() { - + console.log("EducoderLogin"); + console.log(this.props); } Setlogins=(i)=>{ @@ -206,8 +208,7 @@ class EducoderLogin extends Component { } } - -export default EducoderLogin; +export default SnackbarHOC() (TPMIndexHOC ( EducoderLogin )); // showbool === 2 ? //
{ let url = "/setting.json"; - axios.get(url).then((response) => { - if(response){ - if(response.data){ + axios.get(url,{ + + }).then((response) => { + console.log("开始请求/setting.json"); + console.log("获取当前定制信息"); + console.log(response); + if(response!=undefined){ + if(response.status===200){ this.setState({ mygetHelmetapi:response.data.setting }); @@ -301,7 +306,7 @@ export function TPMIndexHOC(WrappedComponent) { document.head.removeChild(oldLink); } document.head.appendChild(link); - }else { + }else{ document.title = "EduCoder"; var link = document.createElement('link'), oldLink = document.getElementById('dynamic-favicon'); @@ -313,7 +318,6 @@ export function TPMIndexHOC(WrappedComponent) { } document.head.appendChild(link); } - }else{ document.title = "EduCoder"; var link = document.createElement('link'), @@ -328,6 +332,7 @@ export function TPMIndexHOC(WrappedComponent) { } }).catch((error) => { + console.log(error); document.title = "EduCoder"; var link = document.createElement('link'), oldLink = document.getElementById('dynamic-favicon');