/* * @Description: 学员测评页面 * @Author: tangjiang * @Github: * @Date: 2019-11-23 11:33:41 * @LastEditors : tangjiang * @LastEditTime : 2019-12-27 16:03:04 // */ import './index.scss'; import React, { useState, useEffect, useMemo } from 'react'; import { Divider } from 'antd'; import { connect } from 'react-redux'; import Comment from './comment'; import CommitRecord from './commitRecord'; import TaskDescription from './taskDescription'; import TextNumber from './../../components/textNumber'; import actions from '../../../../redux/actions'; import CommentForm from '../../../../common/components/comment/CommentForm'; // const { TabPane } = Tabs; const LeftPane = (props) => { const { hack, userCodeTab } = props; const { pass_count, submit_count, praises_count, /* 点赞数 */ comments_count, /* 评论数*/ user_praise // 用户是否点赞 } = hack; const [defaultActiveKey, setDefaultActiveKey] = useState('task'); const navItem = [ { title: '任务描述', key: 'task' }, { title: '提交记录', key: 'record' }, { title: '评论', key: 'comment' } ]; const Comp = { task: (), record: (), comment: () }; console.log('======>>>>>>>', props); useEffect(() => { setDefaultActiveKey(userCodeTab); }, [userCodeTab]) const renderComp = useMemo(() => { return Comp[defaultActiveKey]; }, [defaultActiveKey, setDefaultActiveKey]); const renderNavItem = navItem.map((item) => { const _classes = item.key === defaultActiveKey ? 'add_editor_item active' : 'add_editor_item'; return (
  • setDefaultActiveKey(item.key)} > {item.title}
  • ) }); // 点击消息 const handleClickMessage = () => { // 切换到评论tab setDefaultActiveKey('comment'); } // 点击点赞 const handleClickLike = () => { // 对OJ进行点赞 const {id, identifier } = props.hack; props.likeComment(identifier, id, { container_type: 'Hack', type: 1 }); }; // 点击不喜欢 // const handleClickDisLike = () => { // console.log('点击的DisLike---------'); // } // 添加评论 const handleAddComment = (ctx) => { // console.log('添加的评论内容: ', ctx, props.identifier); props.identifier && props.addComment(props.identifier, { comments: { content: ctx } }); }; const _style = { display: defaultActiveKey === 'record' ? 'none' : 'flex' }; return (
      { renderNavItem }
    { renderComp }
    {/* */}
    ); } const mapStateToProps = (state) => { const { hack, userCodeTab, comment_identifier} = state.ojForUserReducer; return { hack, userCodeTab, identifier: comment_identifier } } // changeUserCodeTab const mapDispatchToProps = (dispatch) => ({ changeUserCodeTab: (key) => dispatch(actions.changeUserCodeTab(key)), likeComment: (identifier, id, params) => dispatch(actions.likeComment(identifier, id, params)), addComment: (identifier, comments) => dispatch(actions.addComment(identifier, comments)) }); export default connect( mapStateToProps, mapDispatchToProps )(LeftPane);