diff --git a/public/react/config/webpack.config.dev.js b/public/react/config/webpack.config.dev.js index 80973be75..11cfc1962 100644 --- a/public/react/config/webpack.config.dev.js +++ b/public/react/config/webpack.config.dev.js @@ -29,7 +29,7 @@ const env = getClientEnvironment(publicUrl); module.exports = { // You may want 'eval' instead if you prefer to see the compiled output in DevTools. // See the discussion in https://github.com/facebookincubator/create-react-app/issues/343.s - devtool: "source-map", // 开启调试 + // devtool: "source-map", // 开启调试 // These are the "entry points" to our application. // This means they will be the "root" imports that are included in JS bundle. // The first two entry points enable "hot" CSS and auto-refreshes for JS. diff --git a/public/react/src/modules/comment/Comments.js b/public/react/src/modules/comment/Comments.js index ec7d6a5a8..c07bd5de2 100644 --- a/public/react/src/modules/comment/Comments.js +++ b/public/react/src/modules/comment/Comments.js @@ -1,579 +1,586 @@ -import React, { Component } from 'react'; - -import Dialog, { - DialogActions, - DialogContent, - DialogContentText, - DialogTitle, -} from 'material-ui/Dialog'; -import Button from 'material-ui/Button'; -import Tooltip from 'material-ui/Tooltip'; - -import Pagination from 'rc-pagination'; -import 'rc-pagination/assets/index.css'; - -import { getImageUrl, toPath } from 'educoder'; - -import Input, { InputLabel } from 'material-ui/Input'; - -import { FormControl, FormHelperText } from 'material-ui/Form'; - -import CommentItemKEEditor from './CommentItemKEEditor'; -import CommentItemMDEditor from './CommentItemMDEditor'; - -import './Comment.css' -import Modals from '../modals/Modals' - -/* - -------------------------- 样式相关 - class 改成 className - style 需要传入json对象 style="margin:0px"> -> style={{ margin:"0px" }}> - margin-top -> marginTop - onclick -> onClick 驼峰 - - -------------------------- 模板语法相关 - 页面都在前端组装、渲染 - rails模板的 if等逻辑改成js实现 - 客户端需要能判断 User.current.manager_of_shixun?(comment.dis_id) - - -------------------------- 现有ui控件的使用方式 - 方案1: 换成对应的react组件,然后再调用(控件简单时推荐) - 方案2: 在react环境中使用若干jquery插件(控件复杂,又无react环境下的替代方案时考虑使用) - - -------------------------- - 需要服务端提供对应的rest api - - -*/ - -const _origin = window.location.origin; - - -/* - 用到的props: - user user_url image_url - - loadingComments-- - comment_count_without_reply - currentPage - comments - - 接口 - deleteComment 删除 - onPaginationChange 翻页变化 - commentPraise 点赞 - hiddenComment 隐藏 - rewardCode 奖励 - -*/ -class Comments extends Component { - constructor(props) { - super(props) - - this.handleDialogClose = this.handleDialogClose.bind(this) - this.handleGoldRewardDialogClose = this.handleGoldRewardDialogClose.bind(this) - - this.state = { - dialogOpen: false, - goldRewardDialogOpen: false, - goldRewardInput: '', - - showReplyEditorFlag: false, // false->true or true->false时切换editor显示或隐藏 - currentReplyComment: null - } - } - componentWillUnmount() { - const $ = window.$; - $(document).off("onReply"); - } - componentDidMount() { - setTimeout(()=>{ - const $ = window.$; - // 绑定后会自动off? 加timeout试试 - $(document).on("onReply", (e, args)=>{ - const { commentContent, id, editor } = args; - - this.props.replyComment(commentContent, id, editor) - }); - }, 1000) - - } - initReply(comment) { - this.props.initReply && this.props.initReply(comment) - // 如果配置的使用kindEditor - if (window.__useKindEditor === true) { - const { user } = this.props; - console.log('initReply ', comment) - - const $ = window.$; - var id = comment.id - var reply_message_el = `#reply_message_${id}` - var reply_iconup_el = `#reply_iconup_${id}` - if($(reply_message_el).html() == "") { - $(".reply_to_message").html(""); - $(reply_message_el).html(`