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

@ -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 <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;
// TODO 图片上传地址
return (
@ -681,11 +685,11 @@ class MemoDetail extends Component {
data-tip-down={`获得平台奖励金币:${memo.reward}`} >
<i className="iconfont icon-gift mr5"></i>{memo.reward}
</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'}}>
<a href="javascript:void(0);"><i className="fa fa-bars font-16"></i></a>
<ul className="edu-position-hide undis">
{ current_user.admin === true &&
{ _current_user.admin === true &&
( memo.sticky === true ?
<li><a href="javascript:void(0);" onClick={() => this.setTop(memo)}>取消置顶</a></li>
:
@ -701,15 +705,15 @@ class MemoDetail extends Component {
</ul>
</div>
}
<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" >
<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" >
返回
</Link>
</div>
<div className="color-grey-9 clearfix">
<span className="fl">{moment(memo.time).fromNow()} 发布</span>
<div className="fr">
{ current_user.admin && <Tooltip title={ "帖子奖励" }>
{ _current_user.admin && <Tooltip title={ "帖子奖励" }>
<span className="noteDetailNum rightline cdefault" style={{padding: '0 4px', cursor: 'pointer'}}>
<i className="iconfont icon-jiangli mr5" onClick={this.showRewardDialog}></i>
</span>
@ -770,7 +774,7 @@ class MemoDetail extends Component {
<span className="count">{memo.replies_count}</span>
</div>
<Comments comments={comments} user={current_user}
<Comments comments={comments} user={_current_user}
replyComment={this.replyComment}
deleteComment={this.deleteComment}
commentPraise={this.commentPraise}

@ -251,7 +251,7 @@ class MemoNew extends Component {
},
attachments: attachmentsMap
}, {
withCredentials: true,
// withCredentials: true,
})
.then((response) => {
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

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

@ -46,11 +46,11 @@ class PostItem extends Component {
</p>
<div className="clearfix mt5 color-grey-9">
<span className="fl">{memo.username}</span>
<span className="fl">{memo.user_name}</span>
{/*todo{memo.username}
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> : ''}
{/*<span className="fl language-cir-orange mr10 mt3">C++</span>*/}

@ -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

@ -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 <div className="edu-back-white" id="forum_index_list"></div>
}
return (

@ -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;

Loading…
Cancel
Save