Merge branch 'yslaliyun1015' of https://bdgit.educoder.net/Hjqreturn/educoder into dev_aliyun
commit
8f6a6d3fe3
@ -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 );
|
||||||
|
@ -1,30 +1,30 @@
|
|||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
|
|
||||||
import { BrowserRouter as Router, Route, Link, Switch } from "react-router-dom";
|
import { BrowserRouter as Router, Route, Link, Switch } from "react-router-dom";
|
||||||
|
|
||||||
import Loading from '../../Loading';
|
import Loading from '../../Loading';
|
||||||
|
|
||||||
import Loadable from 'react-loadable';
|
import Loadable from 'react-loadable';
|
||||||
|
|
||||||
// import { TPMIndexHOC } from '../tpm/TPMIndexHOC';
|
// import { TPMIndexHOC } from '../tpm/TPMIndexHOC';
|
||||||
|
|
||||||
import { SnackbarHOC, getImageUrl } from 'educoder';
|
import { SnackbarHOC, getImageUrl } from 'educoder';
|
||||||
import LoginRegisterComponent from './LoginRegisterComponent';
|
import LoginRegisterComponent from './LoginRegisterComponent';
|
||||||
import FindPasswordComponent from './FindPasswordComponent';
|
import FindPasswordComponent from './FindPasswordComponent';
|
||||||
|
|
||||||
class LoginRegisterPage extends Component {
|
class LoginRegisterPage extends Component {
|
||||||
render() {
|
render() {
|
||||||
// newMain clearfix
|
// newMain clearfix
|
||||||
return (
|
return (
|
||||||
<div className="">
|
<div className="">
|
||||||
login
|
|
||||||
<LoginRegisterComponent {...this.props} {...this.state}></LoginRegisterComponent>
|
<LoginRegisterComponent {...this.props} {...this.state}></LoginRegisterComponent>
|
||||||
<br></br>
|
<br></br>
|
||||||
<br></br>
|
<br></br>
|
||||||
<FindPasswordComponent {...this.props} {...this.state}></FindPasswordComponent>
|
<FindPasswordComponent {...this.props} {...this.state}></FindPasswordComponent>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default SnackbarHOC() ( ( LoginRegisterPage ));
|
export default SnackbarHOC() ( ( LoginRegisterPage ));
|
||||||
|
Loading…
Reference in new issue