dev_hjm^2
hjm 6 years ago
parent 7c96278340
commit f0e6da586a

@ -54,12 +54,12 @@ class MemoDetail extends Component {
const { match } = this.props const { match } = this.props
const memoUrl = `/api/v1/memos/${match.params.memoId}`; const memoUrl = `/memos/${match.params.memoId}.json`;
this.setState({ this.setState({
memoLoading: true memoLoading: true
}) })
axios.get(memoUrl,{ axios.get(memoUrl,{
withCredentials: true, // withCredentials: true,
}) })
.then((response) => { .then((response) => {
const memo = response.data.memo const memo = response.data.memo
@ -91,9 +91,9 @@ class MemoDetail extends Component {
}) })
delete response.data.memo_replies; delete response.data.memo_replies;
this.props.initForumState(response.data) this.props.initForumState(response.data)
const user = response.data.current_user; // const user = response.data.current_user;
user.tidding_count = response.data.tidding_count; // user.tidding_count = response.data.tidding_count;
this.props.initCommonState(user) // this.props.initCommonState(user)
} }
this.setState({ this.setState({
memoLoading: false memoLoading: false
@ -119,7 +119,7 @@ class MemoDetail extends Component {
const deleteUrl = `/api/v1/memos/${memo.id}`; const deleteUrl = `/api/v1/memos/${memo.id}`;
// 获取memo list // 获取memo list
axios.delete(deleteUrl, { axios.delete(deleteUrl, {
withCredentials: true, // withCredentials: true,
}) })
.then((response) => { .then((response) => {
const status = response.data.status 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}`; const set_top_or_down_Url = `/api/v1/memos/${memo.id}/set-top-or-down?${paramsUrl}`;
// 获取memo list // 获取memo list
axios.get(set_top_or_down_Url, { axios.get(set_top_or_down_Url, {
withCredentials: true, // withCredentials: true,
}) })
.then((response) => { .then((response) => {
const status = response.data.status const status = response.data.status
@ -619,7 +619,7 @@ class MemoDetail extends Component {
score: _reward, score: _reward,
user_id: author_info.user_id user_id: author_info.user_id
}, { }, {
withCredentials: true, // withCredentials: true,
}) })
.then((response) => { .then((response) => {
const { code } = response.data; const { code } = response.data;
@ -659,10 +659,14 @@ class MemoDetail extends Component {
const { memo, recommend_shixun, current_user,author_info } = this.props; const { memo, recommend_shixun, current_user,author_info } = this.props;
const { comments, hasMoreComments, goldRewardDialogOpen } = this.state; const { comments, hasMoreComments, goldRewardDialogOpen } = this.state;
if (this.state.memoLoading) { if (!memo || this.state.memoLoading) {
return <div className="edu-back-white" id="forum_index_list"></div> return <div className="edu-back-white" id="forum_index_list"></div>
} }
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; memo.isDetailPage = true;
// TODO 图片上传地址 // TODO 图片上传地址
return ( return (
@ -681,11 +685,11 @@ class MemoDetail extends Component {
data-tip-down={`获得平台奖励金币:${memo.reward}`} > data-tip-down={`获得平台奖励金币:${memo.reward}`} >
<i className="iconfont icon-gift mr5"></i>{memo.reward} <i className="iconfont icon-gift mr5"></i>{memo.reward}
</span> } </span> }
{ 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) &&
<div className="edu-position-hidebox" style={{position: 'absolute', right: '18px',top:'4px'}}> <div className="edu-position-hidebox" style={{position: 'absolute', right: '18px',top:'4px'}}>
<a href="javascript:void(0);"><i className="fa fa-bars font-16"></i></a> <a href="javascript:void(0);"><i className="fa fa-bars font-16"></i></a>
<ul className="edu-position-hide undis"> <ul className="edu-position-hide undis">
{ current_user.admin === true && { _current_user.admin === true &&
( memo.sticky === true ? ( memo.sticky === true ?
<li><a href="javascript:void(0);" onClick={() => this.setTop(memo)}>取消置顶</a></li> <li><a href="javascript:void(0);" onClick={() => this.setTop(memo)}>取消置顶</a></li>
: :
@ -701,15 +705,15 @@ class MemoDetail extends Component {
</ul> </ul>
</div> </div>
} }
<Link className={`task-hide fr return_btn color-grey-6 mt2 ${ current_user && (current_user.admin === true <Link className={`task-hide fr return_btn color-grey-6 mt2 ${ _current_user && (_current_user.admin === true
|| current_user.user_id === author_info.user_id) ? '': 'no_mr'} `} to="/forums" > || _current_user.user_id === author_info.user_id) ? '': 'no_mr'} `} to="/forums" >
返回 返回
</Link> </Link>
</div> </div>
<div className="color-grey-9 clearfix"> <div className="color-grey-9 clearfix">
<span className="fl">{moment(memo.time).fromNow()} 发布</span> <span className="fl">{moment(memo.time).fromNow()} 发布</span>
<div className="fr"> <div className="fr">
{ current_user.admin && <Tooltip title={ "帖子奖励" }> { _current_user.admin && <Tooltip title={ "帖子奖励" }>
<span className="noteDetailNum rightline cdefault" style={{padding: '0 4px', cursor: 'pointer'}}> <span className="noteDetailNum rightline cdefault" style={{padding: '0 4px', cursor: 'pointer'}}>
<i className="iconfont icon-jiangli mr5" onClick={this.showRewardDialog}></i> <i className="iconfont icon-jiangli mr5" onClick={this.showRewardDialog}></i>
</span> </span>
@ -770,7 +774,7 @@ class MemoDetail extends Component {
<span className="count">{memo.replies_count}</span> <span className="count">{memo.replies_count}</span>
</div> </div>
<Comments comments={comments} user={current_user} <Comments comments={comments} user={_current_user}
replyComment={this.replyComment} replyComment={this.replyComment}
deleteComment={this.deleteComment} deleteComment={this.deleteComment}
commentPraise={this.commentPraise} commentPraise={this.commentPraise}

@ -251,7 +251,7 @@ class MemoNew extends Component {
}, },
attachments: attachmentsMap attachments: attachmentsMap
}, { }, {
withCredentials: true, // withCredentials: true,
}) })
.then((response) => { .then((response) => {
const { status, message, memo_id } = response.data; const { status, message, memo_id } = response.data;
@ -281,7 +281,7 @@ class MemoNew extends Component {
}, },
attachments: attachmentsMap attachments: attachmentsMap
}, { }, {
withCredentials: true, // withCredentials: true,
}) })
.then((response) => { .then((response) => {
const { status, message, memo_id } = response.data; const { status, message, memo_id } = response.data;
@ -298,7 +298,7 @@ class MemoNew extends Component {
componentDidMount() { componentDidMount() {
const newMemoUrl = `/api/v1/memos/new` const newMemoUrl = `/api/v1/memos/new`
axios.get(newMemoUrl,{ axios.get(newMemoUrl,{
withCredentials: true, // withCredentials: true,
}) })
.then((response) => { .then((response) => {
const data = response.data; const data = response.data;
@ -319,9 +319,9 @@ class MemoNew extends Component {
// repertoiresTagMap // repertoiresTagMap
}) })
const user = response.data.current_user; // const user = response.data.current_user;
user.tidding_count = response.data.tidding_count; // user.tidding_count = response.data.tidding_count;
this.props.initCommonState(user) // this.props.initCommonState(user)
// 初始化 csrf meta // 初始化 csrf meta
const $ = window.$ const $ = window.$
@ -338,7 +338,7 @@ class MemoNew extends Component {
if (memoId) { if (memoId) {
const memoUrl = `/api/v1/memos/${match.params.memoId}/edit`; const memoUrl = `/api/v1/memos/${match.params.memoId}/edit`;
axios.get(memoUrl,{ axios.get(memoUrl,{
withCredentials: true, // withCredentials: true,
}) })
.then((response) => { .then((response) => {
const tag_list = response.data.tag_list const tag_list = response.data.tag_list

@ -8,6 +8,9 @@
min-height: 400px; min-height: 400px;
position: relative; position: relative;
} }
#forum_index_list .forum_table .forum_table_item {
background: #fff;
}
.noMemosTip { .noMemosTip {
position: absolute; position: absolute;
right: 10px; right: 10px;

@ -46,11 +46,11 @@ class PostItem extends Component {
</p> </p>
<div className="clearfix mt5 color-grey-9"> <div className="clearfix mt5 color-grey-9">
<span className="fl">{memo.username}</span> <span className="fl">{memo.user_name}</span>
{/*todo{memo.username} {/*todo{memo.username}
memo.language && memo.language != 'other' && <span className="fl language-cir-orange mr10 mt3 ml6">{memo.language}</span> memo.language && memo.language != 'other' && <span className="fl language-cir-orange mr10 mt3 ml6">{memo.language}</span>
*/} */}
<span className="fl ml50">{moment(memo.updated_at).fromNow()}</span> {/* <span className="fl ml50">{moment(memo.updated_at).fromNow()}</span> */}
{memo.tag && memo.tag.length ? <span className="fl ml50">来自 {memo.tag.join('/')}</span> : ''} {memo.tag && memo.tag.length ? <span className="fl ml50">来自 {memo.tag.join('/')}</span> : ''}
{/*<span className="fl language-cir-orange mr10 mt3">C++</span>*/} {/*<span className="fl language-cir-orange mr10 mt3">C++</span>*/}

@ -165,7 +165,7 @@ return function wrap(WrappedComponent) {
let paramsUrl = queryString.stringify(params) let paramsUrl = queryString.stringify(params)
const memosUrl = '/api/v1/memos?' + paramsUrl // /${challenge.identifier}/star const memosUrl = '/memos.json?' + paramsUrl // /${challenge.identifier}/star
this.setState({ this.setState({
currentPage, currentPage,
@ -174,7 +174,7 @@ return function wrap(WrappedComponent) {
}) })
// 获取memo list // 获取memo list
axios.get(memosUrl,{ axios.get(memosUrl,{
withCredentials: true, // withCredentials: true,
}) })
.then((response) => { .then((response) => {
const memo_count = response.data.memo_count const memo_count = response.data.memo_count
@ -186,9 +186,9 @@ return function wrap(WrappedComponent) {
this.fetchMemos(maxPage); this.fetchMemos(maxPage);
return; return;
} }
const user = response.data.current_user; // const user = response.data.current_user;
user.tidding_count = response.data.tidding_count; // user.tidding_count = response.data.tidding_count;
this.props.initCommonState(user) // this.props.initCommonState(user)
this.props.initForumState(response.data) this.props.initForumState(response.data)
this.setState({ this.setState({
p_forum_id: params.forum, 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}`; const set_top_or_down_Url = `/api/v1/memos/${memo.id}/set-top-or-down?${paramsUrl}`;
// 获取memo list // 获取memo list
axios.get(set_top_or_down_Url, { axios.get(set_top_or_down_Url, {
withCredentials: true, // withCredentials: true,
}) })
.then((response) => { .then((response) => {
const status = response.data.status const status = response.data.status
@ -268,7 +268,7 @@ return function wrap(WrappedComponent) {
const deleteUrl = `/api/v1/memos/${memo.id}`; const deleteUrl = `/api/v1/memos/${memo.id}`;
// 获取memo list // 获取memo list
axios.delete(deleteUrl, { axios.delete(deleteUrl, {
withCredentials: true, // withCredentials: true,
}) })
.then((response) => { .then((response) => {
const status = response.data.status const status = response.data.status

@ -41,7 +41,7 @@ class UserSection extends Component {
render() { render() {
const { match, history, author_info , current_user } = this.props const { match, history, author_info , current_user } = this.props
if (!author_info) { if (!author_info || !current_user) {
return <div className="edu-back-white" id="forum_index_list"></div> return <div className="edu-back-white" id="forum_index_list"></div>
} }
return ( return (

@ -83,7 +83,7 @@ class MemoShixun extends Component {
} }
const stringifid = queryString.stringify(paramsObject); const stringifid = queryString.stringify(paramsObject);
const url = `/api/v1/discusses?${stringifid}` // /${challenge.identifier}/star const url = `/discusses.json?${stringifid}` // /${challenge.identifier}/star
// 获取memo list // 获取memo list
this.setState({ this.setState({
@ -91,13 +91,13 @@ class MemoShixun extends Component {
loadingMemos: true loadingMemos: true
}) })
axios.get(url,{ axios.get(url,{
withCredentials: true, // withCredentials: true,
}) })
.then((response) => { .then((response) => {
if (response.data) { if (response.data) {
const user = response.data.current_user; // const user = response.data.current_user;
user.tidding_count = response.data.tidding_count; // user.tidding_count = response.data.tidding_count;
this.props.initCommonState(user) // this.props.initCommonState(user)
this.props.initForumState(response.data) this.props.initForumState(response.data)
// const { hot_tags } = response.data; // const { hot_tags } = response.data;

Loading…
Cancel
Save