From f0e6da586ad340b22241b3799a5be7696d939f1e Mon Sep 17 00:00:00 2001 From: hjm <63528605@qq.com> Date: Wed, 31 Jul 2019 16:59:08 +0800 Subject: [PATCH] foruM --- public/react/src/modules/forums/MemoDetail.js | 36 ++++++++++--------- public/react/src/modules/forums/MemoNew.js | 14 ++++---- public/react/src/modules/forums/Post.css | 3 ++ public/react/src/modules/forums/PostItem.js | 4 +-- .../src/modules/forums/PostPaginationHOC.js | 14 ++++---- .../react/src/modules/forums/UserSection.js | 2 +- .../src/modules/forums/shixun/MemoShixun.js | 10 +++--- 7 files changed, 45 insertions(+), 38 deletions(-) diff --git a/public/react/src/modules/forums/MemoDetail.js b/public/react/src/modules/forums/MemoDetail.js index e504dae77..f2be85ffe 100644 --- a/public/react/src/modules/forums/MemoDetail.js +++ b/public/react/src/modules/forums/MemoDetail.js @@ -54,12 +54,12 @@ class MemoDetail extends Component { const { match } = this.props - const memoUrl = `/api/v1/memos/${match.params.memoId}`; + const memoUrl = `/memos/${match.params.memoId}.json`; this.setState({ memoLoading: true }) axios.get(memoUrl,{ - withCredentials: true, + // withCredentials: true, }) .then((response) => { const memo = response.data.memo @@ -91,9 +91,9 @@ class MemoDetail extends Component { }) delete response.data.memo_replies; this.props.initForumState(response.data) - const user = response.data.current_user; - user.tidding_count = response.data.tidding_count; - this.props.initCommonState(user) + // const user = response.data.current_user; + // user.tidding_count = response.data.tidding_count; + // this.props.initCommonState(user) } this.setState({ memoLoading: false @@ -119,7 +119,7 @@ class MemoDetail extends Component { const deleteUrl = `/api/v1/memos/${memo.id}`; // 获取memo list axios.delete(deleteUrl, { - withCredentials: true, + // withCredentials: true, }) .then((response) => { const status = response.data.status @@ -587,7 +587,7 @@ class MemoDetail extends Component { const set_top_or_down_Url = `/api/v1/memos/${memo.id}/set-top-or-down?${paramsUrl}`; // 获取memo list axios.get(set_top_or_down_Url, { - withCredentials: true, + // withCredentials: true, }) .then((response) => { const status = response.data.status @@ -619,7 +619,7 @@ class MemoDetail extends Component { score: _reward, user_id: author_info.user_id }, { - withCredentials: true, + // withCredentials: true, }) .then((response) => { const { code } = response.data; @@ -659,10 +659,14 @@ class MemoDetail extends Component { const { memo, recommend_shixun, current_user,author_info } = this.props; const { comments, hasMoreComments, goldRewardDialogOpen } = this.state; - if (this.state.memoLoading) { + if (!memo || this.state.memoLoading) { return
} - current_user.user_url = `/users/${current_user.login}`; + let _current_user = {} + if (current_user) { + _current_user = current_user + } + (_current_user.user_url = `/users/${_current_user.login}`); memo.isDetailPage = true; // TODO 图片上传地址 return ( @@ -681,11 +685,11 @@ class MemoDetail extends Component { data-tip-down={`获得平台奖励金币:${memo.reward}`} > {memo.reward} } - { current_user && (current_user.admin === true || current_user.user_id === author_info.user_id) && + { _current_user && (_current_user.admin === true || _current_user.user_id === author_info.user_id) &&
} - + 返回
{moment(memo.time).fromNow()} 发布
- { current_user.admin && + { _current_user.admin && @@ -770,7 +774,7 @@ class MemoDetail extends Component { {memo.replies_count}
- { const { status, message, memo_id } = response.data; @@ -281,7 +281,7 @@ class MemoNew extends Component { }, attachments: attachmentsMap }, { - withCredentials: true, + // withCredentials: true, }) .then((response) => { const { status, message, memo_id } = response.data; @@ -298,7 +298,7 @@ class MemoNew extends Component { componentDidMount() { const newMemoUrl = `/api/v1/memos/new` axios.get(newMemoUrl,{ - withCredentials: true, + // withCredentials: true, }) .then((response) => { const data = response.data; @@ -319,9 +319,9 @@ class MemoNew extends Component { // repertoiresTagMap }) - const user = response.data.current_user; - user.tidding_count = response.data.tidding_count; - this.props.initCommonState(user) + // const user = response.data.current_user; + // user.tidding_count = response.data.tidding_count; + // this.props.initCommonState(user) // 初始化 csrf meta const $ = window.$ @@ -338,7 +338,7 @@ class MemoNew extends Component { if (memoId) { const memoUrl = `/api/v1/memos/${match.params.memoId}/edit`; axios.get(memoUrl,{ - withCredentials: true, + // withCredentials: true, }) .then((response) => { const tag_list = response.data.tag_list diff --git a/public/react/src/modules/forums/Post.css b/public/react/src/modules/forums/Post.css index d10857a60..7b9792dea 100644 --- a/public/react/src/modules/forums/Post.css +++ b/public/react/src/modules/forums/Post.css @@ -8,6 +8,9 @@ min-height: 400px; position: relative; } + #forum_index_list .forum_table .forum_table_item { + background: #fff; + } .noMemosTip { position: absolute; right: 10px; diff --git a/public/react/src/modules/forums/PostItem.js b/public/react/src/modules/forums/PostItem.js index aa610184f..a56badb80 100644 --- a/public/react/src/modules/forums/PostItem.js +++ b/public/react/src/modules/forums/PostItem.js @@ -46,11 +46,11 @@ class PostItem extends Component {

- {memo.username} + {memo.user_name} {/*最后回复:todo{memo.username} memo.language && memo.language != 'other' && {memo.language} */} - {moment(memo.updated_at).fromNow()} + {/* {moment(memo.updated_at).fromNow()} */} {memo.tag && memo.tag.length ? 来自 {memo.tag.join('/')} : ''} {/*C++*/} diff --git a/public/react/src/modules/forums/PostPaginationHOC.js b/public/react/src/modules/forums/PostPaginationHOC.js index 25e397318..8e16f2e50 100644 --- a/public/react/src/modules/forums/PostPaginationHOC.js +++ b/public/react/src/modules/forums/PostPaginationHOC.js @@ -165,7 +165,7 @@ return function wrap(WrappedComponent) { let paramsUrl = queryString.stringify(params) - const memosUrl = '/api/v1/memos?' + paramsUrl // /${challenge.identifier}/star + const memosUrl = '/memos.json?' + paramsUrl // /${challenge.identifier}/star this.setState({ currentPage, @@ -174,7 +174,7 @@ return function wrap(WrappedComponent) { }) // 获取memo list axios.get(memosUrl,{ - withCredentials: true, + // withCredentials: true, }) .then((response) => { const memo_count = response.data.memo_count @@ -186,9 +186,9 @@ return function wrap(WrappedComponent) { this.fetchMemos(maxPage); return; } - const user = response.data.current_user; - user.tidding_count = response.data.tidding_count; - this.props.initCommonState(user) + // const user = response.data.current_user; + // user.tidding_count = response.data.tidding_count; + // this.props.initCommonState(user) this.props.initForumState(response.data) this.setState({ p_forum_id: params.forum, @@ -245,7 +245,7 @@ return function wrap(WrappedComponent) { const set_top_or_down_Url = `/api/v1/memos/${memo.id}/set-top-or-down?${paramsUrl}`; // 获取memo list axios.get(set_top_or_down_Url, { - withCredentials: true, + // withCredentials: true, }) .then((response) => { const status = response.data.status @@ -268,7 +268,7 @@ return function wrap(WrappedComponent) { const deleteUrl = `/api/v1/memos/${memo.id}`; // 获取memo list axios.delete(deleteUrl, { - withCredentials: true, + // withCredentials: true, }) .then((response) => { const status = response.data.status diff --git a/public/react/src/modules/forums/UserSection.js b/public/react/src/modules/forums/UserSection.js index 8ea9bad2a..4e8bdb45c 100644 --- a/public/react/src/modules/forums/UserSection.js +++ b/public/react/src/modules/forums/UserSection.js @@ -41,7 +41,7 @@ class UserSection extends Component { render() { const { match, history, author_info , current_user } = this.props - if (!author_info) { + if (!author_info || !current_user) { return
} return ( diff --git a/public/react/src/modules/forums/shixun/MemoShixun.js b/public/react/src/modules/forums/shixun/MemoShixun.js index 9d75da00d..f82ed2e34 100644 --- a/public/react/src/modules/forums/shixun/MemoShixun.js +++ b/public/react/src/modules/forums/shixun/MemoShixun.js @@ -83,7 +83,7 @@ class MemoShixun extends Component { } const stringifid = queryString.stringify(paramsObject); - const url = `/api/v1/discusses?${stringifid}` // /${challenge.identifier}/star + const url = `/discusses.json?${stringifid}` // /${challenge.identifier}/star // 获取memo list this.setState({ @@ -91,13 +91,13 @@ class MemoShixun extends Component { loadingMemos: true }) axios.get(url,{ - withCredentials: true, + // withCredentials: true, }) .then((response) => { if (response.data) { - const user = response.data.current_user; - user.tidding_count = response.data.tidding_count; - this.props.initCommonState(user) + // const user = response.data.current_user; + // user.tidding_count = response.data.tidding_count; + // this.props.initCommonState(user) this.props.initForumState(response.data) // const { hot_tags } = response.data;