dev_auth
杨树林 6 years ago
parent 5a9b164521
commit 1ac84425e2

@ -95,6 +95,9 @@ export function initAxiosInterceptors(props) {
} }
// if (requestMap[config.url] === true) { // 避免重复的请求 导致页面f5刷新 也会被阻止 // if (requestMap[config.url] === true) { // 避免重复的请求 导致页面f5刷新 也会被阻止
// console.log(config);
// console.log(JSON.parse(config));
// console.log(config.url);
// console.log("被阻止了是重复请求================================="); // console.log("被阻止了是重复请求=================================");
// return false; // return false;
// } // }

@ -1,116 +1,116 @@
import React, { Component } from 'react'; import React, { Component } from 'react';
import { Redirect } from 'react-router'; import { Redirect } from 'react-router';
import { BrowserRouter as Router, Route, Link, Switch } from "react-router-dom"; import { BrowserRouter as Router, Route, Link, Switch } from "react-router-dom";
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import classNames from 'classnames' import classNames from 'classnames'
import Pagination from 'rc-pagination'; import Pagination from 'rc-pagination';
import { postPaginationHOC } from './PostPaginationHOC' import { postPaginationHOC } from './PostPaginationHOC'
import PostItem from './PostItem' import PostItem from './PostItem'
import ForumsNavTab from './ForumsNavTab' import ForumsNavTab from './ForumsNavTab'
// import queryString from 'query-string' // import queryString from 'query-string'
import { queryString } from 'educoder' import { queryString } from 'educoder'
import MemoList from './MemoList' import MemoList from './MemoList'
class MemoTechShare extends Component { class MemoTechShare extends Component {
constructor(props) { constructor(props) {
super(props) super(props)
this.handleLocationChange = this.handleLocationChange.bind(this); this.handleLocationChange = this.handleLocationChange.bind(this);
this.state = { this.state = {
} }
} }
onPaginationChange(pageNum, pageSize) { onPaginationChange(pageNum, pageSize) {
this.props.onPaginationChange(pageNum, pageSize) this.props.onPaginationChange(pageNum, pageSize)
} }
componentDidMount() { componentDidMount() {
// this.handleLocationChange(this.props.history.location); // this.handleLocationChange(this.props.history.location);
// this.unlisten = this.props.history.listen(this.handleLocationChange); // this.unlisten = this.props.history.listen(this.handleLocationChange);
} }
componentWillUnmount() { componentWillUnmount() {
// this.unlisten(); // this.unlisten();
} }
componentDidUpdate(prevProps) { componentDidUpdate(prevProps) {
if(this.props.match.params.memoType !== prevProps.match.params.memoType) { if(this.props.match.params.memoType !== prevProps.match.params.memoType) {
// do something // do something
console.log(`memoType changed`) console.log(`memoType changed`)
this.props.fetchMemos(); this.props.fetchMemos();
} }
} }
componentWillReceiveProps(newProps, newContext) { componentWillReceiveProps(newProps, newContext) {
if (newProps.match.url === this.props.match.url) { if (newProps.match.url === this.props.match.url) {
const oldParsed = queryString.parse(this.props.location.search); const oldParsed = queryString.parse(this.props.location.search);
const newParsed = queryString.parse(newProps.location.search); const newParsed = queryString.parse(newProps.location.search);
if (!newParsed.page && oldParsed.page || if (!newParsed.page && oldParsed.page ||
(oldParsed.order && newParsed.order && oldParsed.order != newParsed.order)) { (oldParsed.order && newParsed.order && oldParsed.order != newParsed.order)) {
this.props.fetchMemos(); this.props.fetchMemos();
} }
console.log('componentWillReceiveProps...') // console.log('componentWillReceiveProps...')
} }
} }
handleLocationChange(location) { handleLocationChange(location) {
console.log(`- - - location: '${location.pathname}'`); console.log(`- - - location: '${location.pathname}'`);
if (location.pathname) { if (location.pathname) {
if (location.pathname.indexOf('/forums/categories/all') != -1 if (location.pathname.indexOf('/forums/categories/all') != -1
&& this.props.location.search && this.props.location.search.indexOf('order=') != -1 && this.props.location.search && this.props.location.search.indexOf('order=') != -1
&& location.search.indexOf('order=') != -1) { && location.search.indexOf('order=') != -1) {
const oldParsed = queryString.parse(this.props.location.search); const oldParsed = queryString.parse(this.props.location.search);
const newParsed = queryString.parse(location.search); const newParsed = queryString.parse(location.search);
if (oldParsed.order != newParsed.order) { // 只有在热门和最新间跳转时,才需要处理 if (oldParsed.order != newParsed.order) { // 只有在热门和最新间跳转时,才需要处理
this.props.fetchMemos(); this.props.fetchMemos();
} }
} }
} }
} }
renderMemoList() { renderMemoList() {
// const { memo_list, user } = this.props; // const { memo_list, user } = this.props;
// if (!memo_list) { // if (!memo_list) {
// return '' // return ''
// } // }
// return memo_list.map( (item, index) => { // return memo_list.map( (item, index) => {
// return ( // return (
// <PostItem key={item.id} user={user} index={index} {...this.props} // <PostItem key={item.id} user={user} index={index} {...this.props}
// setTop={(memo)=>this.setTop(memo)} // setTop={(memo)=>this.setTop(memo)}
// setDown={(memo)=>this.setDown(memo)} memo={item} // setDown={(memo)=>this.setDown(memo)} memo={item}
// ></PostItem> // ></PostItem>
// ) // )
// }) // })
return this.props.renderMemoList(); return this.props.renderMemoList();
} }
render() { render() {
const { match, history, currentPage, memo_count ,memo_list } = this.props const { match, history, currentPage, memo_count ,memo_list } = this.props
return ( return (
<React.Fragment> <React.Fragment>
<ForumsNavTab {...this.props}></ForumsNavTab> <ForumsNavTab {...this.props}></ForumsNavTab>
<MemoList {...this.props} renderMemoList={() => this.renderMemoList()} <MemoList {...this.props} renderMemoList={() => this.renderMemoList()}
onPaginationChange={ (pageNum, pageSize) => this.props.onPaginationChange(pageNum, pageSize) } onPaginationChange={ (pageNum, pageSize) => this.props.onPaginationChange(pageNum, pageSize) }
> >
</MemoList> </MemoList>
</React.Fragment> </React.Fragment>
); );
} }
} }
export default postPaginationHOC() ( MemoTechShare ); export default postPaginationHOC() ( MemoTechShare );

@ -28,6 +28,7 @@ import educodernet from '../../../src/images/login/educodernet.png';
import LoginRegisterComponent from '../user/LoginRegisterComponent'; import LoginRegisterComponent from '../user/LoginRegisterComponent';
import FindPasswordComponent from '../user/FindPasswordComponent'; import FindPasswordComponent from '../user/FindPasswordComponent';
import passopen from "../../images/login/passopen.png"; import passopen from "../../images/login/passopen.png";
import {TPMIndexHOC} from "../tpm/TPMIndexHOC";
//educoder登入页面 //educoder登入页面
var sectionStyle = { var sectionStyle = {
"height": "100%", "height": "100%",
@ -109,7 +110,8 @@ class EducoderLogin extends Component {
} }
componentDidMount() { componentDidMount() {
console.log("EducoderLogin");
console.log(this.props);
} }
Setlogins=(i)=>{ Setlogins=(i)=>{
@ -206,8 +208,7 @@ class EducoderLogin extends Component {
} }
} }
export default SnackbarHOC() (TPMIndexHOC ( EducoderLogin ));
export default EducoderLogin;
// showbool === 2 ? // showbool === 2 ?
// <div style={{ // <div style={{
// display: "flex", // display: "flex",

@ -285,9 +285,14 @@ export function TPMIndexHOC(WrappedComponent) {
//获取当前定制信息 //获取当前定制信息
getAppdata=()=>{ getAppdata=()=>{
let url = "/setting.json"; let url = "/setting.json";
axios.get(url).then((response) => { axios.get(url,{
if(response){
if(response.data){ }).then((response) => {
console.log("开始请求/setting.json");
console.log("获取当前定制信息");
console.log(response);
if(response!=undefined){
if(response.status===200){
this.setState({ this.setState({
mygetHelmetapi:response.data.setting mygetHelmetapi:response.data.setting
}); });
@ -301,7 +306,7 @@ export function TPMIndexHOC(WrappedComponent) {
document.head.removeChild(oldLink); document.head.removeChild(oldLink);
} }
document.head.appendChild(link); document.head.appendChild(link);
}else { }else{
document.title = "EduCoder"; document.title = "EduCoder";
var link = document.createElement('link'), var link = document.createElement('link'),
oldLink = document.getElementById('dynamic-favicon'); oldLink = document.getElementById('dynamic-favicon');
@ -313,7 +318,6 @@ export function TPMIndexHOC(WrappedComponent) {
} }
document.head.appendChild(link); document.head.appendChild(link);
} }
}else{ }else{
document.title = "EduCoder"; document.title = "EduCoder";
var link = document.createElement('link'), var link = document.createElement('link'),
@ -328,6 +332,7 @@ export function TPMIndexHOC(WrappedComponent) {
} }
}).catch((error) => { }).catch((error) => {
console.log(error);
document.title = "EduCoder"; document.title = "EduCoder";
var link = document.createElement('link'), var link = document.createElement('link'),
oldLink = document.getElementById('dynamic-favicon'); oldLink = document.getElementById('dynamic-favicon');

Loading…
Cancel
Save