|
|
@ -1,83 +1,71 @@
|
|
|
|
import React,{ Component } from "react";
|
|
|
|
import React, { useMemo } from "react";
|
|
|
|
import { getImageUrl, markdownToHTML, WordsBtn } from 'educoder';
|
|
|
|
import { getImageUrl, markdownToHTML } from 'educoder';
|
|
|
|
import { Tooltip } from 'antd'
|
|
|
|
import { Tooltip } from 'antd'
|
|
|
|
|
|
|
|
|
|
|
|
const _origin = ''
|
|
|
|
const _origin = ''
|
|
|
|
class Graduationtaskitem extends Component{
|
|
|
|
export default ({ item, onDelete, isChildCommentPagination, loadMoreChildComments }) => {
|
|
|
|
constructor(props){
|
|
|
|
const { content, id, user_login, image_url, username, comment_role, score, is_invalid, time, children, isAllChildrenLoaded, } = item
|
|
|
|
super(props);
|
|
|
|
const md = useMemo(() => {
|
|
|
|
|
|
|
|
return markdownToHTML(content)
|
|
|
|
|
|
|
|
}, [content])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function onDeleteHandler() {
|
|
|
|
|
|
|
|
onDelete(item)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
parseCommentContent = (oldContent) => {
|
|
|
|
|
|
|
|
return markdownToHTML(oldContent);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
renderChildenComments = () => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function onLoadMoreComments() {
|
|
|
|
|
|
|
|
loadMoreChildComments(item)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
render(){
|
|
|
|
|
|
|
|
let { item }=this.props;
|
|
|
|
console.log(md, '-----------')
|
|
|
|
const _content = item.content && this.parseCommentContent(item.content)
|
|
|
|
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<div className="comment_item_cont appraise df clearfix" key={item.id}>
|
|
|
|
<div className="comment_item_cont appraise df clearfix" key={id}>
|
|
|
|
<div className="J_Comment_Face fl">
|
|
|
|
<div className="J_Comment_Face fl">
|
|
|
|
<a href={`${_origin}/users/${item.user_login}`} target="_blank">
|
|
|
|
<a href={`${_origin}/users/${user_login}`} target="_blank">
|
|
|
|
<img alt="用户头像" height="50" src={getImageUrl(`images/${item.image_url}`)} width="50"/>
|
|
|
|
<img alt="用户头像" height="50" src={getImageUrl(`images/${image_url}`)} width="50" />
|
|
|
|
</a>
|
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<div className="t_content fl">
|
|
|
|
<div className="t_content fl">
|
|
|
|
<div className="J_Comment_Reply">
|
|
|
|
<div className="J_Comment_Reply">
|
|
|
|
<div className="comment_orig_content" style={{ margin: "0px" }}>
|
|
|
|
<div className="comment_orig_content" style={{ margin: "0px" }}>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div className="J_Comment_Info clearfix mt3">
|
|
|
|
<div className="J_Comment_Info clearfix mt3">
|
|
|
|
<div className="t_info fl">
|
|
|
|
<div className="t_info fl">
|
|
|
|
<a href={`${_origin}/users/${item.user_login}`} className="content-username hide fl">
|
|
|
|
<a href={`${_origin}/users/${user_login}`} className="content-username hide fl"> {username}({comment_role}) </a>
|
|
|
|
{item.username}({item.comment_role})
|
|
|
|
<span className="t_area fl">{time}</span>
|
|
|
|
</a>
|
|
|
|
{score != null && score >= 0 && <span className="score_area fl">{score}分</span>}
|
|
|
|
<span className="t_area fl">{item.time}</span>
|
|
|
|
|
|
|
|
{/* 分数 */}
|
|
|
|
|
|
|
|
{item.score != null && item.score >= 0 && <span className="score_area fl">{item.score}分</span>}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{ !item.is_invalid && item.delete && <Tooltip title={ "删除" } >
|
|
|
|
{!is_invalid && item.delete && <Tooltip title={"删除"} >
|
|
|
|
<i className="iconfont icon-shanchu mr5 fr" style={{ marginLeft: '6px' }}
|
|
|
|
<i className="iconfont icon-shanchu mr5 fr" style={{ marginLeft: '6px' }}
|
|
|
|
onClick={() => this.props.onDelete(item)}>
|
|
|
|
onClick={onDeleteHandler}>
|
|
|
|
</i>
|
|
|
|
</i>
|
|
|
|
</Tooltip>}
|
|
|
|
</Tooltip>}
|
|
|
|
{/* <WordsBtn style="blue" className="fr">回复</WordsBtn> */}
|
|
|
|
{is_invalid ? <span className="validate_area fr">失效</span> : ''}
|
|
|
|
{ item.is_invalid ? <span className="validate_area fr">失效</span> : ''}
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
{!!_content && <div className="comment_content clearfix" id={`reply_content_${item.id}`}>
|
|
|
|
{!!md ? <div className="comment_content clearfix" id={`reply_content_${id}`}>
|
|
|
|
<div className="color-grey-3" id={`reply_content_${item.id}`}>
|
|
|
|
<div className="color-grey-3" id={`reply_content_${id}`}>
|
|
|
|
<div className={"break_word_comments"} dangerouslySetInnerHTML={{__html: _content}}></div>
|
|
|
|
<div className={"break_word_comments"} dangerouslySetInnerHTML={{ __html: md }}></div>
|
|
|
|
<div className="cl"></div>
|
|
|
|
<div className="cl"></div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>}
|
|
|
|
</div> : <span className="color656565 mt2 color-grey-9 font-12 mr8" style={{ display: 'inline-block' }}>{"暂未写评语"}</span>}
|
|
|
|
{!_content && <span className="color656565 mt2 color-grey-9 font-12 mr8" style={{ display: 'inline-block'}}>{"暂未写评语"}</span>}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div className="childrenCommentsView">
|
|
|
|
<div className="childrenCommentsView">
|
|
|
|
{(item && item.children && item.children.length) ? <div className="trangle"></div>: ''}
|
|
|
|
{(children && children.length) ? <div className="trangle"></div> : ''}
|
|
|
|
{this.renderChildenComments(item)}
|
|
|
|
{isAllChildrenLoaded != true && children && isChildCommentPagination == true && children.length >= 5 ?
|
|
|
|
{ item.isAllChildrenLoaded != true && item.children && this.props.isChildCommentPagination == true && item.children.length >= 5?
|
|
|
|
|
|
|
|
<Tooltip title={"点击查看更多回复"} disableFocusListener={true}>
|
|
|
|
<Tooltip title={"点击查看更多回复"} disableFocusListener={true}>
|
|
|
|
<div className="loadMoreChildComments" onClick={() => {this.props.loadMoreChildComments && this.props.loadMoreChildComments(item)}}>
|
|
|
|
<div className="loadMoreChildComments" onClick={onLoadMoreComments}>
|
|
|
|
<i className="iconfont icon-xiajiantou"></i>
|
|
|
|
<i className="iconfont icon-xiajiantou"></i>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</Tooltip>
|
|
|
|
</Tooltip>
|
|
|
|
: ''}
|
|
|
|
: ''}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
{/*mr10 */}
|
|
|
|
<p className="fr orig_reply"></p>
|
|
|
|
<p className="fr orig_reply">
|
|
|
|
|
|
|
|
{/* 第二排右侧按钮区域 */}
|
|
|
|
|
|
|
|
</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default Graduationtaskitem;
|
|
|
|
|