From c9719b72ec254b1d51d8c106a89e9a1cad39a98e Mon Sep 17 00:00:00 2001 From: caishi <1149225589@qq.com> Date: Sat, 9 May 2020 11:15:19 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=BB=E9=99=A4=E6=95=99=E5=AD=A6=E6=A1=88?= =?UTF-8?q?=E4=BE=8B=E3=80=81=E8=AE=BA=E5=9D=9B=E4=BA=A4=E6=B5=81=E7=9A=84?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/courses/boards/TopicDetail.js | 1 - .../busyWork/reply/CommonWorkAppraiseReply.js | 1 - .../tasks/GraduationTasksappraiseReply.js | 1 - .../GraduationTasksappraiseReplyChild.js | 1 - .../tasks/GraduationTaskssettingReply.js | 1 - .../graduation/topics/GraduateTopicReply.js | 1 - src/modules/forums/ForumsIndex.css | 69 -- src/modules/forums/ForumsIndex.js | 266 ------ src/modules/forums/ForumsNavTab.js | 106 --- src/modules/forums/MemoDetail.js | 834 ------------------ src/modules/forums/MemoDetailEditor.css | 25 - src/modules/forums/MemoDetailMDEditor.js | 217 ----- src/modules/forums/MemoList.js | 79 -- src/modules/forums/MemoMyPublish.js | 73 -- src/modules/forums/MemoNew.js | 617 ------------- src/modules/forums/MemoOldGuide.js | 65 -- src/modules/forums/MemoOldHottest.js | 84 -- src/modules/forums/MemoOldNewest.js | 63 -- src/modules/forums/MemoTechShare.js | 116 --- src/modules/forums/Post.css | 224 ----- src/modules/forums/PostItem.js | 222 ----- src/modules/forums/PostPaginationHOC.js | 352 -------- src/modules/forums/RecommendShixun.js | 62 -- src/modules/forums/RightHotLabel.js | 56 -- src/modules/forums/RightHotQuestion.js | 53 -- src/modules/forums/RightMemoLabel.js | 47 - src/modules/forums/RightMyPublish.js | 75 -- src/modules/forums/RightSection.css | 61 -- src/modules/forums/UserSection.js | 87 -- src/modules/forums/shixun/MemoShixun.css | 21 - src/modules/forums/shixun/MemoShixun.js | 227 ----- src/modules/forums/shixun/ShiXunPostItem.js | 69 -- src/modules/moop_cases/CaseDetail.js | 172 ---- src/modules/moop_cases/CaseItem.js | 59 -- src/modules/moop_cases/CaseList.js | 173 ---- src/modules/moop_cases/CaseNew.js | 475 ---------- src/modules/moop_cases/CaseTags.js | 37 - src/modules/moop_cases/Success.js | 28 - src/modules/moop_cases/css/moopCases.css | 178 ---- src/modules/moop_cases/index.js | 134 --- 40 files changed, 5432 deletions(-) delete mode 100644 src/modules/forums/ForumsIndex.css delete mode 100644 src/modules/forums/ForumsIndex.js delete mode 100644 src/modules/forums/ForumsNavTab.js delete mode 100644 src/modules/forums/MemoDetail.js delete mode 100644 src/modules/forums/MemoDetailEditor.css delete mode 100644 src/modules/forums/MemoDetailMDEditor.js delete mode 100644 src/modules/forums/MemoList.js delete mode 100644 src/modules/forums/MemoMyPublish.js delete mode 100644 src/modules/forums/MemoNew.js delete mode 100644 src/modules/forums/MemoOldGuide.js delete mode 100644 src/modules/forums/MemoOldHottest.js delete mode 100644 src/modules/forums/MemoOldNewest.js delete mode 100644 src/modules/forums/MemoTechShare.js delete mode 100644 src/modules/forums/Post.css delete mode 100644 src/modules/forums/PostItem.js delete mode 100644 src/modules/forums/PostPaginationHOC.js delete mode 100644 src/modules/forums/RecommendShixun.js delete mode 100644 src/modules/forums/RightHotLabel.js delete mode 100644 src/modules/forums/RightHotQuestion.js delete mode 100644 src/modules/forums/RightMemoLabel.js delete mode 100644 src/modules/forums/RightMyPublish.js delete mode 100644 src/modules/forums/RightSection.css delete mode 100644 src/modules/forums/UserSection.js delete mode 100644 src/modules/forums/shixun/MemoShixun.css delete mode 100644 src/modules/forums/shixun/MemoShixun.js delete mode 100644 src/modules/forums/shixun/ShiXunPostItem.js delete mode 100644 src/modules/moop_cases/CaseDetail.js delete mode 100644 src/modules/moop_cases/CaseItem.js delete mode 100644 src/modules/moop_cases/CaseList.js delete mode 100644 src/modules/moop_cases/CaseNew.js delete mode 100644 src/modules/moop_cases/CaseTags.js delete mode 100644 src/modules/moop_cases/Success.js delete mode 100644 src/modules/moop_cases/css/moopCases.css delete mode 100644 src/modules/moop_cases/index.js diff --git a/src/modules/courses/boards/TopicDetail.js b/src/modules/courses/boards/TopicDetail.js index 3e24cd504..0882cf75f 100644 --- a/src/modules/courses/boards/TopicDetail.js +++ b/src/modules/courses/boards/TopicDetail.js @@ -5,7 +5,6 @@ import Comments from '../../comment/Comments' import { ImageLayerOfCommentHOC } from '../../page/layers/ImageLayerOfCommentHOC' import MemoDetailMDEditor from '../../forums/MemoDetailMDEditor' import { RouteHOC } from './common.js' -import '../../forums/Post.css' import '../../forums/RightSection.css' import './TopicDetail.css' import '../common/courseMessage.css' diff --git a/src/modules/courses/busyWork/reply/CommonWorkAppraiseReply.js b/src/modules/courses/busyWork/reply/CommonWorkAppraiseReply.js index e6c62b226..1a5889fd4 100644 --- a/src/modules/courses/busyWork/reply/CommonWorkAppraiseReply.js +++ b/src/modules/courses/busyWork/reply/CommonWorkAppraiseReply.js @@ -9,7 +9,6 @@ import _ from 'lodash'; import {ImageLayerOfCommentHOC} from '../../../page/layers/ImageLayerOfCommentHOC'; import GraduationTasksappraiseMainEditor from '../../graduation/tasks/GraduationTasksappraiseMainEditor'; import CCommentItem from '../../common/comments/CCommentItem'; -import '../../../forums/Post.css'; import '../../../comment/Comment.css'; import '../../common/courseMessage.css'; diff --git a/src/modules/courses/graduation/tasks/GraduationTasksappraiseReply.js b/src/modules/courses/graduation/tasks/GraduationTasksappraiseReply.js index 6c7085ca2..010e0935f 100644 --- a/src/modules/courses/graduation/tasks/GraduationTasksappraiseReply.js +++ b/src/modules/courses/graduation/tasks/GraduationTasksappraiseReply.js @@ -5,7 +5,6 @@ import moment from 'moment' import { getImageUrl,WordsBtn } from 'educoder'; import {ImageLayerOfCommentHOC} from '../../../page/layers/ImageLayerOfCommentHOC'; import GraduationTasksappraiseReplyChild from './GraduationTasksappraiseReplyChild'; -import '../../../forums/Post.css' import '../../../comment/Comment.css' import '../../common/courseMessage.css' import './GraduationTasksappraiseReply.css' diff --git a/src/modules/courses/graduation/tasks/GraduationTasksappraiseReplyChild.js b/src/modules/courses/graduation/tasks/GraduationTasksappraiseReplyChild.js index 27739b611..620122376 100644 --- a/src/modules/courses/graduation/tasks/GraduationTasksappraiseReplyChild.js +++ b/src/modules/courses/graduation/tasks/GraduationTasksappraiseReplyChild.js @@ -3,7 +3,6 @@ import { Pagination } from "antd"; import {ImageLayerOfCommentHOC} from '../../../page/layers/ImageLayerOfCommentHOC' import GraduationTasksappraiseMainEditor from './GraduationTasksappraiseMainEditor' import Graduationtaskitem from './Graduationtaskitem' -import '../../../forums/Post.css' import '../../../comment/Comment.css' import '../../common/courseMessage.css' import './GraduationTasksappraiseReply.css' diff --git a/src/modules/courses/graduation/tasks/GraduationTaskssettingReply.js b/src/modules/courses/graduation/tasks/GraduationTaskssettingReply.js index ce0554488..85313805e 100644 --- a/src/modules/courses/graduation/tasks/GraduationTaskssettingReply.js +++ b/src/modules/courses/graduation/tasks/GraduationTaskssettingReply.js @@ -5,7 +5,6 @@ import update from 'immutability-helper' import axios from 'axios' import MemoDetailMDEditor from '../../../forums/MemoDetailMDEditor' -import '../../../forums/Post.css' import '../../../forums/RightSection.css' import {ImageLayerOfCommentHOC} from '../../../page/layers/ImageLayerOfCommentHOC' diff --git a/src/modules/courses/graduation/topics/GraduateTopicReply.js b/src/modules/courses/graduation/topics/GraduateTopicReply.js index f08938b4e..5faf626f6 100644 --- a/src/modules/courses/graduation/topics/GraduateTopicReply.js +++ b/src/modules/courses/graduation/topics/GraduateTopicReply.js @@ -5,7 +5,6 @@ import update from 'immutability-helper' import axios from 'axios' import MemoDetailMDEditor from '../../../forums/MemoDetailMDEditor' -import '../../../forums/Post.css' import '../../../forums/RightSection.css' import {ImageLayerOfCommentHOC} from '../../../page/layers/ImageLayerOfCommentHOC' diff --git a/src/modules/forums/ForumsIndex.css b/src/modules/forums/ForumsIndex.css deleted file mode 100644 index 22925f882..000000000 --- a/src/modules/forums/ForumsIndex.css +++ /dev/null @@ -1,69 +0,0 @@ -/*Nav START*/ -._forum_tab { - padding-bottom: 26px; -} -.discuss-tab { - height: 90px; -} - .discuss-tab ._forum_tab a.navItem { - line-height: 2; - } - .discuss-tab ._forum_tab a.navItem:hover { - color: #4CACFF !important; - border-bottom: none !important; - } - .discuss-tab ._forum_tab a.navItem.active { - border-bottom: none !important; - border: 1px solid #4CACFF !important; - color: #4CACFF !important; - border-radius:24px; - } - .discuss-tab a.returnBtnA:hover { - border-bottom: none!important; - } -/*Nav END*/ - -#forum_list { - display: flex; - flex-direction: column; -} - - - -.rc-pagination { - padding: 30px 20px; - background: #FAFAFA; - margin: 0 auto; - width: fit-content; - -} - - /*分页*/ -.ec-pagination .rc-pagination-item{ - border-radius: 2px; - width: 30px; - height: 32px; - line-height: 32px; -} -.ec-pagination a{outline: none;} -.ec-pagination .rc-pagination-jump-next{ - height: 32px; - line-height: 32px; -} -.ec-pagination .rc-pagination-item:hover{ - border: 1px solid #4cacff; - color: #4cacff; -} -.ec-pagination .rc-pagination-item-active{ - background-color: #4CACFF; -} -.ec-pagination .rc-pagination-prev, .ec-pagination .rc-pagination-next{display: none} -.ec-pagination .rc-pagination-options-quick-jumper input{ - height: 32px; - border-radius: 2px; -} -.ec-pagination .rc-pagination-options-quick-jumper{ - height: 34px; - line-height: 34px; - margin-left: 0px; -} \ No newline at end of file diff --git a/src/modules/forums/ForumsIndex.js b/src/modules/forums/ForumsIndex.js deleted file mode 100644 index a4f3c61bd..000000000 --- a/src/modules/forums/ForumsIndex.js +++ /dev/null @@ -1,266 +0,0 @@ -import React, { Component } from 'react'; -import { Redirect } from 'react-router'; - -import { BrowserRouter as Router, Route, Link, Switch } from "react-router-dom"; - -import PropTypes from 'prop-types'; - -import Loading from '../../Loading' - -import Loadable from 'react-loadable'; - -import classNames from 'classnames' - -import MemoTechShare from './MemoTechShare' -// import MemoGuide from './MemoGuide' -// import MemoNewest from './MemoNewest' -// import MemoHottest from './MemoHottest' - -import MemoDetail from './MemoDetail' -import MemoNew from './MemoNew' -import MemoMyPublish from './MemoMyPublish' -import MemoShixun from './shixun/MemoShixun' - - -import { TPMIndexHOC } from '../tpm/TPMIndexHOC' - -import RightMyPublish from './RightMyPublish' -import UserSection from './UserSection' -import RightHotLabel from './RightHotLabel' -import RightHotQuestion from './RightHotQuestion' -import RightMemoLabel from './RightMemoLabel' -import RecommendShixun from './RecommendShixun' - - -import ForumsNavTab from './ForumsNavTab' - -import axios from 'axios' - - -import 'rc-select/assets/index.css'; -import './ForumsIndex.css' -import './RightSection.css' - -import { SnackbarHOC, getUrl } from 'educoder' -import { CNotificationHOC } from '../courses/common/CNotificationHOC' - - -let _url_origin = getUrl() - -const $ = window.$ -$('head').append( $('') - .attr('href', `${_url_origin}/stylesheets/css/edu-admin.css?6`) ); -$('head').append( $('') - .attr('href', `${_url_origin}/stylesheets/css/edu-forum.css?1525440977`) ); -$('head').append( $('') - .attr('href', `${_url_origin}/stylesheets/educoder/magic-check.css?1525440977`) ); - -setTimeout(()=>{ - // 附件上传滚动条 \public\stylesheets\jquery\jquery-ui-1.9.2.css - $('head').append( $('') - .attr('href', `${_url_origin}/stylesheets/jquery/jquery-ui-1.9.2.css`) ); -}, 1000) - -class ForumsIndex extends Component { - constructor(props) { - super(props) - - this.state = { - searchValue: '', - enterKeyFlag: false, - showSearchValue: false, - selectedHotLabelIndex: -1, - } - } - - setSearchValue = (searchValue, enterKeyFlag) => { - if (enterKeyFlag === true) { - this.setState({ - selectedHotLabelIndex: -1 - }) - } - this.setState({ - searchValue, - showSearchValue: (enterKeyFlag && searchValue) ? true : false, - enterKeyFlag: enterKeyFlag === true ? !this.state.enterKeyFlag : this.state.enterKeyFlag - }) - } - - setHotLabelIndex = (index, callback) => { - const newState = { - selectedHotLabelIndex: index, - } - if (index != -1) { - newState.searchValue = '' - newState.showSearchValue = false - } - this.setState({ - ...newState - }, callback) - } - - initForumState(data) { - this.setState({...data}) - } - - - componentDidMount() { - window.document.title = '交流问答' - - } - - - - componentWillReceiveProps(newProps, newContext) { - - } - - - - render() { - const { match, history, resLoading } = this.props - const { memo } = this.state; - - const techSharePath = `${match.path}/categories/:memoType` - const guidePath = `${match.path}/categories/:memoType` - const hottestPath = `${match.path}/categories/:memoType` // ?order=hottest - const newestPath = `${match.path}/categories/:memoType` // ?order=newest - - const shixunDiscussPath = `/forums/categories/shixun_discuss` - const locationPath = history.location.pathname - - - const isWidth100 = (locationPath.indexOf('forums/new') !== -1 - || locationPath.indexOf('/edit') !== -1) ? true : false - - const pathArray = locationPath.split('/'); - const isMemoDetail = (!isWidth100 && - pathArray.length === 3 && !isNaN(parseInt(pathArray[2])) ) ? true : false - - const isGuide = locationPath.indexOf('/forums/categories/3') !== -1 - - return ( -
-
- {/* 左边栏 component={TechShare} - */} -
- - - - (this.initForumState(data)} - setSearchValue={this.setSearchValue} - setHotLabelIndex={this.setHotLabelIndex} - />) - }> - (this.initForumState(data)} - setSearchValue={this.setSearchValue} - setHotLabelIndex={this.setHotLabelIndex} - />) - }> - (this.initForumState(data)} - setSearchValue={this.setSearchValue} - setHotLabelIndex={this.setHotLabelIndex} - />) - }> - - - {/* - (this.initForumState(data)} />) - }> - (this.initForumState(data)} />) - }> - (this.initForumState(data)} />) - }> */} - - {/* :forumTypeId/ */} - (this.initForumState(data)} - />) - }> - - (this.initForumState(data)} - />) - }> - - - - (this.initForumState(data)} - />) - }> - - - - - - - - - -
- - - {/* 右边栏 */} - { !isWidth100 &&
-
- {isMemoDetail ? - - this.initForumState(data)} > - {/*todo 新增RightMemoLabel 和 推荐实训RecommendShixun */} - { memo && memo.tag && } - - - : - - - { !isGuide && } - - - - } - - - - -
-
- } - -
-
- ); - } -} - -export default CNotificationHOC() (SnackbarHOC() ( TPMIndexHOC ( ForumsIndex ) )); - -/* -: -列表所有: -http://localhost:3000/forums/categories/all -: -详情: -: -http://localhost:3000/forums/5 -: -http://localhost:3000/forums/new -: -http://localhost:3000/forums/categories/my_published -*/ \ No newline at end of file diff --git a/src/modules/forums/ForumsNavTab.js b/src/modules/forums/ForumsNavTab.js deleted file mode 100644 index 8e12912bb..000000000 --- a/src/modules/forums/ForumsNavTab.js +++ /dev/null @@ -1,106 +0,0 @@ -import React, { Component } from 'react'; -import { Redirect } from 'react-router'; - -import { BrowserRouter as Router, Route, Link, Switch } from "react-router-dom"; - -import PropTypes from 'prop-types'; - -import classNames from 'classnames' - -class ForumsNavTab extends Component { - constructor(props) { - super(props) - - this.state = { - - } - } - - onNavClick(active) { - // TODO 为什么事件发不过去 - // https://github.com/facebook/react/issues/3249#issuecomment-177750141 - // window.$(window).trigger('setSearchValue', '', true); - this.props.setSearchValue('') - - if (!active) { - this.props.initForumState({ - selectedHotLabelIndex: -1, - }) - } - } - render() { - const { match, history, currentPage } = this.props - - const techSharePath = `/forums/categories/5` - const guidePath = `/forums/categories/3` - const guidePaths = `/forums/categories/16` - const hottestPath = `/forums/categories/all?order=hottest` // ?order=hottest - const newestPath = `/forums/categories/all?order=newest` // ?order=newest - - const shixunDiscussPath = `/forums/categories/shixun_discuss` - const locationPath = history.location.pathname + history.location.search - /* - - */ - return ( -
-

- {/* - 技术分享 - 219 - */} - this.onNavClick(locationPath.indexOf('order=newest') !== -1)} - > - 最新回复 - - this.onNavClick(locationPath.indexOf('order=hottest') !== -1)} - > - 热门话题 - - this.onNavClick(locationPath.indexOf('shixun_discuss') !== -1)} - > - 实训回复 - - - this.onNavClick(locationPath.indexOf(techSharePath) === 0)} - > - 技术分享 - - this.onNavClick(locationPath.indexOf(guidePath) === 0)} - > - 操作指南 - - this.onNavClick(locationPath.indexOf(guidePaths) === 0)} - > - 通知公告 - - {/* - 实训交流 - 1391 - */} -

-
- ); - } -} - -export default ForumsNavTab; diff --git a/src/modules/forums/MemoDetail.js b/src/modules/forums/MemoDetail.js deleted file mode 100644 index c7f500335..000000000 --- a/src/modules/forums/MemoDetail.js +++ /dev/null @@ -1,834 +0,0 @@ -import React, { Component } from 'react'; -import { Link } from "react-router-dom"; -import axios from 'axios' - -import moment from 'moment' - -import Comments from '../comment/Comments' - -import update from 'immutability-helper' -import RewardDialog from '../common/RewardDialog'; - -import { ImageLayerOfCommentHOC } from '../page/layers/ImageLayerOfCommentHOC' - -import MemoDetailMDEditor from './MemoDetailMDEditor' - -import { CBreadcrumb, htmlEncode } from 'educoder' -import { Tooltip } from 'antd' - -// import CBreadcrumb from '../courses/common/CBreadcrumb' -import { typeNameMap2 } from './MemoNew' -const $ = window.$ -function urlStringify(params) { - let noParams = true; - let paramsUrl = ''; - for (let key in params) { - noParams = false; - paramsUrl += `${key}=${params[key]}&` - } - if (noParams) { - return ''; - } - paramsUrl = paramsUrl.substring(0, paramsUrl.length - 1); - return paramsUrl; -} -class MemoDetail extends Component { - constructor(props) { - super(props) - - this.state = { - memoLoading: true, - hasMoreComments: false, - pageCount: 2, - - goldRewardDialogOpen: false - } - } - componentDidMount() { - // window.$("html,body").animate({"scrollTop":0}) - - const { match } = this.props - - const memoUrl = `/memos/${match.params.memoId}.json`; - this.setState({ - memoLoading: true - }) - axios.get(memoUrl, { - // withCredentials: true, - }) - .then((response) => { - const memo = response.data.memo - if (response.data.status === -1) { - setTimeout(() => { - this.props.showNotification('帖子不存在!') - }, 300) - this.props.history.push(`/forums`) - return; - } else if (memo) { - // this.setState({...response.data}) - - const { memo_replies, memo } = response.data; - let hasMoreComments = false; - if (memo_replies && memo_replies.length === 10 && memo.replies_count > 10) { - // 遍历一遍,计算下是否还有评论未加载 - let totalCount = 10; - memo_replies.forEach(item => { - totalCount += item.children.length - }) - if (totalCount < memo.replies_count) { - hasMoreComments = true; - } - } - this.setState({ - hasMoreComments, - pageCount: 2, - comments: memo_replies - }) - delete response.data.memo_replies; - // reset - response.data.memo.praise_count = response.data.memo.memo_praise_count - this.props.initForumState(response.data) - // const user = response.data.current_user; - // user.tidding_count = response.data.tidding_count; - // this.props.initCommonState(user) - } - this.setState({ - memoLoading: false - }) - - }).catch((error) => { - console.log(error) - }) - - $('body>#root').on('onMemoDelete', (event) => { - // const val = $('body>#root').data('onMemoDelete') - const val = window.onMemoDelete; - this.onMemoDelete(JSON.parse(decodeURIComponent(val))) - }) - - - - } - componentWillUnmount() { - $('body>#root').off('onMemoDelete') - } - onMemoDelete(memo) { - const deleteUrl = `/memos/${memo.id}.json`; - // 获取memo list - axios.delete(deleteUrl, { - // withCredentials: true, - }) - .then((response) => { - const status = response.data.status - if (status === 0) { - - this.props.showNotification('删除成功'); - this.props.history.push(`/forums`) - - } else if (status === -1) { - this.props.showNotification('帖子已被删除'); - this.props.history.push(`/forums`) - } - }).catch((error) => { - console.log(error) - }) - } - - componentDidUpdate(prevProps, prevState, snapshot) { - // if (this.props.memo && this.props.memo.content - // && (!prevProps.memo || prevProps.memo.content != this.props.memo.content) ) { - if (this.props.memo && this.props.memo.content && prevState.memoLoading === true && this.state.memoLoading === false) { - // md渲染content,等xhr执行完(即memoLoading变化),memo.content更新后初始化md - if (this.props.memo.is_md) { - setTimeout(() => { - var shixunDescr = window.editormd.markdownToHTML("memo_content_editorMd", { - htmlDecode: "style,script,iframe", // you can filter tags decode - taskList: true, - tex: true, // 默认不解析 - flowChart: true, // 默认不解析 - sequenceDiagram: true // 默认不解析 - }); - }, 200) - } - } - } - - clickPraise() { - const { memo } = this.props; - const url = `/discusses/${memo.id}/plus.json`; - console.log(url) - axios.post(url, { - container_type: 'Memo', - type: 1 // "踩0;赞1" - }, - { - // withCredentials: true - } - ).then((response) => { - - const newMemo = Object.assign({}, this.props.memo) - newMemo.praise_count = response.data.praise_count - newMemo.user_praise = !newMemo.user_praise - this.props.initForumState({ memo: newMemo }) - }).catch((error) => { - console.log(error) - }) - } - renderAttachment() { - const { memo, attachments_list } = this.props; - const attachments = [] - attachments_list.forEach((item, index) => { - const ar = item.url.split('/') - const fileName = item.title - let filesize = item.filesize - - attachments.push( -
- - - - 30 ? fileName : ''} - className="mr12 color9B9B overflowHidden1" length="58" style={{ maxWidth: '480px' }}> - {fileName} - - {filesize} - -
- ) - }) - return attachments; - } - // ------------------------------------------------------------------------------------------- comments START - // ------------------------------------------------------------------------------------------- comments START - _getUser() { - const { current_user } = this.props; - current_user.user_url = `/users/${current_user.login}`; - return current_user; - } - _findById(id, arg_comments) { - const comments = arg_comments; - for (let i = 0; i < comments.length; i++) { - if (id === comments[i].id) { - return i; - } - } - } - replyComment = (commentContent, id, editor) => { - const { showNotification } = this.props; - if (!commentContent || commentContent.length === 0) { - showNotification('必须填写内容!') - return; - } - - if (this.props.memo.id === id) { // 回复帖子 - this.createNewComment(commentContent, id, editor); - return; - } - // /${id} - const url = `/memos/reply.json`; - const { comments } = this.state; - const user = this._getUser(); - /* - 移除末尾的空行 - .replace(/(\n

\n\t
\n<\/p>)*$/g,''); - - */ - if (commentContent) { - commentContent = commentContent.replace(/(\n

\n\t
\n<\/p>)*$/g, ''); - } - - commentContent = htmlEncode(commentContent) - axios.post(url, { - parent_id: id, - content: commentContent - }, - { - // withCredentials: true - } - ).then((response) => { - response.data.memo = response.data - if (response.data.memo) { - let newDiscuss = response.data.memo; - - var commentIndex = this._findById(id, comments); - let comment = comments[commentIndex]; - if (!comment.children) { - comment.children = [] - } - // TODO userName iamge_url - comment.children.push({ - "can_delete": true, - "content": commentContent, - - "image_url": user.image_url, - "username": user.username, - "user_login": user.login, - - "id": newDiscuss.id, - // "position": newDiscuss.position, - "time": "1分钟前", - "praise_count": 0, - - "user_id": newDiscuss.author_id, - }) - - - comments[commentIndex] = comment - // ke - editor.html && editor.html('') - // md - if (editor.setValue) { - editor.setValue('') - const $ = window.$ - var view_selector = `.commentItemMDEditorView_${id}` - $(view_selector).hide(); - } - - - this.setState({ - // runTesting: false, - comments: comments - }, () => { - // keditor代码美化 - editor.html && window.prettyPrint() - }) - - const newMemo2 = Object.assign({}, this.props.memo); - newMemo2.replies_count = newMemo2.replies_count + 1; - this.props.initForumState({ - memo: newMemo2 - }) - } - - }).catch((error) => { - console.log(error) - }) - } - deleteComment = (parrentComment, childCommentId) => { - let deleteCommentId = parrentComment.id - if (childCommentId) { - deleteCommentId = childCommentId; - } - const url = `/memos/${deleteCommentId}.json` - let comments = this.state.comments; - - axios.delete(url, - { - // withCredentials: true - } - ).then((response) => { - // TODO 删除成功或失败 - if (response.data && response.data.status === 0) { - const commentIndex = this._findById(parrentComment.id, comments); - - // https://stackoverflow.com/questions/29527385/removing-element-from-array-in-component-state - if (!childCommentId) { - this.setState((prevState) => ({ - comments: update(prevState.comments, { $splice: [[commentIndex, 1]] }) - })) - - // if (this.state.comments.length <= 5) { - // this.fetchComment() - // } - } else { - let childCommentIndex = this._findById(childCommentId, comments[commentIndex].children); - comments[commentIndex].children = update(comments[commentIndex].children, { $splice: [[childCommentIndex, 1]] }) - this.setState({ comments }) - } - - const newMemo = Object.assign({}, this.props.memo); - newMemo.replies_count = newMemo.replies_count - 1; - this.props.initForumState({ - memo: newMemo - }) - } - - }).catch((error) => { - console.log(error) - }) - } - // 评论点赞 - commentPraise = (discussId) => { - const { comments } = this.state; - const commentIndex = this._findById(discussId, comments); - - const url = `/discusses/${discussId}/plus.json` - axios.post(url, { - // id: discussId, - // container_id: challenge.id, - container_type: 'Memo', //Discuss - type: comments[commentIndex].user_praise === true ? 0 : 1, // "踩0;赞1" - }, - { - // withCredentials: true - } - ).then((response) => { - if (response.data.praise_count === 0 || response.data.praise_count) { - - comments[commentIndex].user_praise = !comments[commentIndex].user_praise; - comments[commentIndex].praise_count = response.data.praise_count; - - this.setState({ - comments - }) - } - - }).catch((error) => { - console.log(error) - }) - } - rewardCode = (parrentComment, childComment, amount) => { - const { showNotification } = this.props; - const { comments } = this.state; - let handleComment = parrentComment - if (childComment) { - handleComment = childComment; - } - let handleCommentId = handleComment.id; - const url = `/discusses/${handleCommentId}/reward_code.json` - - axios.post(url, { - id: handleCommentId, - - container_type: 'Memo', - score: amount, - user_id: handleComment.user_id - }, - { - // withCredentials: true - } - ).then((response) => { - if (response.data && response.data.code) { - const commentIndex = this._findById(parrentComment.id, comments); - - if (childComment) { - const childCommentIndex = this._findById(handleComment.id, parrentComment.children); - const newChildComment = Object.assign({}, childComment); - newChildComment.reward = response.data.code - parrentComment.children[childCommentIndex] = newChildComment - - comments[commentIndex] = parrentComment; - - this.setState({ - comments - }) - } else { - comments[commentIndex].reward = response.data.code; - - this.setState({ - comments - }) - } - } - }).catch((error) => { - console.log(error) - showNotification('奖励失败,请联系系统管理员!') - }) - } - hiddenComment = (item, childCommentId) => { - const id = item.id - const { showNotification } = this.props; - const user = this._getUser(); - const url = `/memos/${id}/hidden.json` - const { comments } = this.state; - - const commentIndex = this._findById(id, comments); - const comment = comments[commentIndex]; - axios.post(url, { - hidden: !comment.hidden ? "1" : "0" - }, - { - // withCredentials: true - } - ).then((response) => { - if (response.data.status === -1) { - showNotification(response.data.message) - return; - } - if (response.data.status === 0) { - - if (!childCommentId) { - comment.hidden = !comment.hidden; - this.setState({ - comments: comments - }) - } else { // TODO 目前子回复没hidden字段 - let childCommentIndex = this._findById(childCommentId, comments[commentIndex].children); - const childComment = comments[commentIndex].children[childCommentIndex] - childComment.hidden = !childComment.hidden; - this.setState({ comments }) - } - - } - // {"message":"Couldn't find Discuss with id=911","status":-1} - - }).catch((error) => { - console.log(error) - }) - } - createNewComment = (commentContent, id, editor) => { - let content = commentContent; - const { memo } = this.props; - if (content != undefined) { - content = content.replace(/(\n

\n\t
\n<\/p>)*$/g, ''); - - var beforeImage = content.split(""); - if (beforeImage[0] == "" && afterImage[1] == "") { - window.notice_box('不支持纯图片评论
请在评论中增加文字信息'); - return; - } - } - // /${memo.id} - const url = `/memos/reply.json`; - let { comments } = this.state; - const user = this._getUser(); - content = htmlEncode(content) - axios.post(url, { - parent_id: memo.id, - content: content - }, - { - // withCredentials: true - } - ).then((response) => { - if (response.data.status === -1) { - console.error('服务端异常') - return; - } - if (response.data) { - response.data.memo = response.data - const newMemo = response.data.memo; - // ke - editor.html && editor.html(''); - editor.afterBlur && editor.afterBlur() - // md - editor.setValue && editor.setValue('') - if (!comments) { - comments = []; - } - comments.unshift({ - "can_delete": true, - "admin": user.admin, - "content": content, - - "image_url": user.image_url, - "username": user.username, - "user_login": user.login, - - "id": newMemo.id, - "reward": null, - "hidden": newMemo.hidden, - - "user_praise": false, - "time": "1分钟前", - "praise_count": 0, - - "user_id": user.user_id, - }) - - - this.setState({ - comments - }) - const newMemo2 = Object.assign({}, this.props.memo); - newMemo2.replies_count = newMemo2.replies_count + 1; - this.props.initForumState({ - memo: newMemo2 - }) - - } - }).catch((error) => { - console.log(error) - }) - } - moreMemos = () => { - let { comments, pageCount } = this.state; - let { memo } = this.props; - const user = this._getUser(); - const url = `/memos/${memo.id}/more_reply.json?page=${pageCount}`; - axios.get(url, { - - }, - { - // withCredentials: true - } - ).then((response) => { - if (response.data.status === -1) { - console.error('服务端异常') - return; - } - let { memo_replies } = response.data; - if (!memo_replies || memo_replies.length === 0) { - this.setState({ - hasMoreComments: false - }) - return; - } - if (response.data.memos_count) { - const newComments = comments.concat(memo_replies); - const hasMoreComments = memo_replies.length === 10 - this.setState({ - comments: newComments, - hasMoreComments, - pageCount: pageCount + 1 - }) - } - }).catch((error) => { - console.log(error) - }) - } - - - // ------------------------------------------------------------------------------------------- comments END - // ------------------------------------------------------------------------------------------- comments END - // 置顶 - setTop(memo) { - const params = { - sticky: memo.sticky ? 0 : 1, - } - if (this.state.p_s_order) { - params.order = this.state.p_s_order; - } - if (this.state.p_forum_id) { - params.forum_id = this.state.p_forum_id; - } - let paramsUrl = urlStringify(params) - const set_top_or_down_Url = `/memos/${memo.id}/sticky_or_cancel.json?${paramsUrl}`; - // 获取memo list - axios.post(set_top_or_down_Url, { - // withCredentials: true, - }) - .then((response) => { - const status = response.data.status - if (status === 0) { - this.props.showNotification(memo.sticky ? '取消置顶成功' : '置顶成功'); - memo.sticky = memo.sticky ? false : true - this.setState({ - memo: Object.assign({}, memo) - }) - } - }).catch((error) => { - console.log(error) - }) - } - // --------------------------------------------------------------------------------------------帖子獎勵 - rewardCodeMemo = (inputVal) => { - console.log(inputVal) - const { memo, author_info } = this.props; - const newMemo = Object.assign({}, memo); - const _reward = parseInt(inputVal) - - const url = `/discusses/${memo.id}/reward_code.json` - - axios.post(url, { - id: memo.id, - - container_type: 'Memo', - score: _reward, - user_id: author_info.user_id - }, { - // withCredentials: true, - }) - .then((response) => { - const { code } = response.data; - if (code > 0) { - newMemo.reward = code - this.props.initForumState({ - memo: newMemo - }) - this.props.showNotification('奖励成功'); - } else { - this.props.showNotification('奖励失败,请联系系统管理员!'); - } - }).catch((error) => { - console.log(error) - }) - } - setRewardDialogVisible = (visible) => { - this.setState({ - goldRewardDialogOpen: visible - }) - } - showRewardDialog = () => { - this.setState({ - goldRewardDialogOpen: true - }) - } - // --------------------------------------------------------------------------------------------帖子獎勵 END - showCommentInput = () => { - this.refs.editor.showEditor(); - } - render() { - const { match, history } = this.props - const { memo, recommend_shixun, current_user, author_info } = this.props; - const { comments, hasMoreComments, goldRewardDialogOpen } = this.state; - document.title = memo && memo.subject != undefined ? memo && memo.subject : "交流问答"; - if (!memo || this.state.memoLoading) { - return

- } - let _current_user = {} - if (current_user) { - _current_user = current_user - } - (_current_user.user_url = `/users/${_current_user.login}`); - memo.isDetailPage = true; - // TODO 图片上传地址 - return ( - - -
{/* fl with100 */} - - - -
-
-
-
- {/* overflowHidden1 */} - {memo.subject} - {memo.sticky && 置顶} - {!!memo.reward && - - - - {memo.reward} - - - } - -
- {_current_user && (_current_user.admin === true || _current_user.user_id === author_info.user_id) && - - } -
-
-
- {moment(memo.time).fromNow()} 发布 -
- - {_current_user.admin && - - - - } - - {memo.viewed_count} - - {!!memo.replies_count && - - - {memo.replies_count} - - - } -
-
-
- - -
- {!memo.is_md ? -
: - -
- -
- } -
- -
- - -
-

{ this.clickPraise() }} > -
- {memo.praise_count} -

-
- - {this.props.attachments_list && -
- {this.renderAttachment()} -
- } -
- {window.__useKindEditor === true ? null : } - {/* onClick={ this.createNewComment } */} -
-
- 全部回复 - {memo.replies_count} -
- - - {hasMoreComments ? -
- 查看更多评论 -
写评论
-
- : -
-
写评论
-
} -
- -
-
-
- -
- ); - } -} - -export default ImageLayerOfCommentHOC()(MemoDetail); diff --git a/src/modules/forums/MemoDetailEditor.css b/src/modules/forums/MemoDetailEditor.css deleted file mode 100644 index 15138ff3d..000000000 --- a/src/modules/forums/MemoDetailEditor.css +++ /dev/null @@ -1,25 +0,0 @@ - -.editorMD ol, .editorMD ul, .editorMD li { - list-style-type: decimal; -} - -/*md编辑器 resizeBar*/ -.editor__resize { - position: absolute; - width: 120px; - height: 4px; - left: 50%; - transform: translateX(-50%); - margin-top: 2px; - border-top: 1px solid #ccc; - border-bottom: 1px solid #ccc; - cursor: row-resize; - text-indent: 110%; - white-space: nowrap; - overflow: hidden; - text-transform: capitalize; - - box-sizing: border-box; - /*transform: translateX(-22%);*/ -} - diff --git a/src/modules/forums/MemoDetailMDEditor.js b/src/modules/forums/MemoDetailMDEditor.js deleted file mode 100644 index 07f195444..000000000 --- a/src/modules/forums/MemoDetailMDEditor.js +++ /dev/null @@ -1,217 +0,0 @@ -import React, { Component } from 'react'; - -import { getUploadActionUrl } from 'educoder'; - -import './MemoDetailEditor.css'; - -require('codemirror/lib/codemirror.css'); - -const $ = window.$; - -class MemoDetailMDEditor extends Component { - constructor(props) { - super(props) - this.state = { - isInited: this.props.usingMockInput ? false : true, - isError: false, - errorMsg: '' - } - } - componentDidUpdate(prevProps, prevState, snapshot) { - if (this.props.memo && (!prevProps.memo || this.props.memo.id != prevProps.memo.id)) { - // this.keEditor = window.sd_create_editor_from_data(this.props.memo.id, null, "100%", "Memo"); - // window._kk = this.keEditor - } - } - - initMDEditor = () => { - - // 因为props.memo不存在时,本组件不会被加载,这里直接在didMount里初始化即可 - const placeholder = '我要回复...' - // const imageUrl = `/upload_with_markdown?container_id=${this.props.memo.id}&container_type=Memo`; - const imageUrl = `${getUploadActionUrl()}`; - if (this.isMDInited) { - return; - } - this.isMDInited = true - - // 执行太快了,样式不正常 - window.__tt = 400; - setTimeout(() => { - var commentMDEditor = window.create_editorMD_4comment("memo_comment_editorMd", '', this.props.height || 240, placeholder, imageUrl, () => { - // commentMDEditor.focus() - - this.initDrag() - - commentMDEditor.cm.on("change", (_cm, changeObj) => { - this.setState({ - isError: false, - errorMsg: '' - }) - }) - // commentMDEditor.cm.focus() - }, { - watch: false, - dialogLockScreen: false, - }); - this.commentMDEditor = commentMDEditor; - window.commentMDEditor = commentMDEditor; - - }, window.__tt) - } - componentDidMount() { - !this.props.usingMockInput && this.initMDEditor() - } - initDrag = () => { - window.initMDEditorDragResize(".editor__resize", this.commentMDEditor) - } - - onCommit = () => { - if (this.props.checkIfLogin() === false) { - this.props.showLoginDialog() - return - } - if (this.props.checkIfProfileCompleted() === false) { - this.props.showaccountprofileDialog() - return - } - const content = this.commentMDEditor.getValue(); - // this.props.showError == - if (this.props.showError == true) { - if (!content || content.trim() == "") { - this.setState({ - isError: true, - errorMsg: '不能为空' - }) - return; - } else if (content.length > 2000) { - this.setState({ - isError: true, - errorMsg: '不能超过2000个字符' - }) - return; - } - - this.setState({ - isError: false, - errorMsg: '' - }) - } - if (this.props.replyComment) { - this.props.replyComment(content, this.props.memo.id, this.commentMDEditor) - } else { - window.$(document).trigger("onReply", { - commentContent: content - , id: this.props.memo.id, editor: this.commentMDEditor - }); - } - - - } - - showEditor() { - $("html, body").animate({ scrollTop: $('.commentInput:visible').offset().top - 100 }, 1000, () => { - if (this.commentMDEditor) { - this.commentMDEditor.cm.focus() - } else { - this.onMockInputClick() - } - }); - } - close = () => { - this.setState({ isInited: false }) - } - onMockInputClick = () => { - this.setState({ isInited: true }) - if (!this.isMDInited) { - this.initMDEditor() - } else { - setTimeout(() => { - this.commentMDEditor && this.commentMDEditor.cm.focus() - }, 10) - } - } - render() { - const { match, history, memo, placeholder, className, imageExpand } = this.props - const { isInited, errorMsg } = this.state - if (!memo) { - return
- } - - return ( - - -
- - - {this.props.buttonText || '发送'} - -
- -
-
- -
-
调整高度
- {errorMsg && {errorMsg}} -
- - {this.props.buttonText || '发送'} - -
-
-
- ); - } -} - -export default (MemoDetailMDEditor); diff --git a/src/modules/forums/MemoList.js b/src/modules/forums/MemoList.js deleted file mode 100644 index b5a2f45d1..000000000 --- a/src/modules/forums/MemoList.js +++ /dev/null @@ -1,79 +0,0 @@ -import React, { Component } from "react"; -import { Redirect } from "react-router"; - -import { BrowserRouter as Router, Route, Link, Switch } from "react-router-dom"; - -import PropTypes from "prop-types"; - -import classNames from "classnames"; - -import Pagination from "rc-pagination"; - -import { getImageUrl, toPath } from "educoder"; - -import { postPaginationHOC } from "./PostPaginationHOC"; - -import PostItem from "./PostItem"; - -import ForumsNavTab from "./ForumsNavTab"; - -import { queryString, ThemeContext } from "educoder"; -import styled from "styled-components"; -import 'rc-pagination/assets/index.css'; - -class MemoList extends Component { - render() { - const { - match, - history, - currentPage, - memo_count, - memo_list, - renderMemoList, - onPaginationChange, - } = this.props; - let theme = this.context; - - return ( - -
- -
- {!memo_list || memo_list.length === 0 ? ( -
- -

暂时还没有相关数据哦!

-
- ) : ( - renderMemoList() - )} -
-
- {!!memo_count && memo_count > 15 && ( -
- - onPaginationChange(pageNum, pageSize) - } - showQuickJumper - current={currentPage} - total={memo_count} - pageSize={15} - /> -
- )} -
- ); - } -} -MemoList.contextType = ThemeContext; - -export default MemoList; diff --git a/src/modules/forums/MemoMyPublish.js b/src/modules/forums/MemoMyPublish.js deleted file mode 100644 index d1adca32a..000000000 --- a/src/modules/forums/MemoMyPublish.js +++ /dev/null @@ -1,73 +0,0 @@ -import React, { Component } from 'react'; -import { Redirect } from 'react-router'; - -import { BrowserRouter as Router, Route, Link, Switch } from "react-router-dom"; - -import PropTypes from 'prop-types'; - -import classNames from 'classnames' - -import Pagination from 'rc-pagination'; - -import { postPaginationHOC } from './PostPaginationHOC' - -import PostItem from './PostItem' - -import ForumsNavTab from './ForumsNavTab' - -// import queryString from 'query-string' -import { queryString } from 'educoder' -import MemoList from './MemoList' - - -class MemoMyPublish extends Component { - constructor(props) { - super(props) - - this.state = { - - } - } - - onPaginationChange(pageNum, pageSize) { - this.props.onPaginationChange(pageNum, pageSize) - } - - componentDidMount() { - - } - - componentWillUnmount() { - - } - componentWillReceiveProps(newProps, newContext) { - - } - renderMemoList() { - - - return this.props.renderMemoList(); - } - - render() { - const { match, history, currentPage, memo_count, memo_list } = this.props - - return ( - -
-

- 我的发布 - 返回 -

-
- this.renderMemoList()} - onPaginationChange={ (pageNum, pageSize) => this.props.onPaginationChange(pageNum, pageSize) } - > - -
- - ); - } -} - -export default postPaginationHOC({ isMyPublish: true }) ( MemoMyPublish ); diff --git a/src/modules/forums/MemoNew.js b/src/modules/forums/MemoNew.js deleted file mode 100644 index b6ca3512b..000000000 --- a/src/modules/forums/MemoNew.js +++ /dev/null @@ -1,617 +0,0 @@ -import React, { Component } from 'react'; -import { Select, Icon, Upload, Button } from 'antd'; -import axios from 'axios' - -import 'antd/lib/select/style/index.css' -import TPMMDEditor from '../tpm/challengesnew/TPMMDEditor' - -import { getUrl, getUploadActionUrl, appendFileSizeToUploadFileAll, appendFileSizeToUploadFile } from 'educoder' -const Option = Select.Option; -const $ = window.$; - -let origin = getUrl(); - -// load -if (!window.postUpMsg) { - $.getScript( - `${origin}/javascripts/attachments.js`, - (data, textStatus, jqxhr) => { - - }); -} - - -const typeNameMap = { - '技术分享': 5, - '操作指南': 3, - '通知公告': 16, -} -export const typeNameMap2 = { - 5: '技术分享', - 3: '操作指南', - 16: '通知公告', -} -const defaultType = '技术分享' - -class MemoNew extends Component { - constructor(props) { - super(props) - this.mdRef = React.createRef(); - - this.uploaderProps = { - action: '/uploads.js', - data: { attachment_id: 1 }, // , filename: 2 - headers: { - Authorization: 'authorization-text', - }, - multiple: true, - beforeUpload(file) { - // console.log('beforeUpload', file.name); - }, - onStart: (file) => { - console.log('onStart', file.name); - // this.refs.inner.abort(file); - }, - onSuccess(file) { - console.log('onSuccess', file); - }, - onProgress(step, file) { - console.log('onProgress', Math.round(step.percent), file.name); - }, - onError(err) { - console.log('onError', err); - }, - }; - - this.state = { - memoSubject: '', - memoContent: '', - memoType: typeNameMap[defaultType], - memoRepertoire: '', - memoLanguage: [], - - repertoires: [], - currentSelectRepertoiresIndex: -1, - repertoiresTagMap: {}, - - fileList: [], - forums: [{ id: 5, name: "技术分享" }, { id: 3, name: "技术指南" }, { id: 16, name: "通知公告" }], - } - } - onCommit() { - const { memoSubject, memoRepertoire, memoLanguage, currentMemoId, memoType } = this.state; - const { showNotification } = this.props; - if (!memoSubject) { - showNotification('请先输入话题名称') - return - } - let mdVal; - try { - mdVal = this.mdRef.current.getValue() - - } catch (e) { - showNotification('编辑器还未加载完毕,请稍后') - return - } - - if (!mdVal) { - showNotification('请先输入话题内容') - return - } - // !memoRepertoire || - if (memoType === 5 && (!memoLanguage || memoLanguage.length === 0)) { - showNotification('请先选择技术标签') - return - } - /* - - - - http://localhost:3000/attachments/download/185790/Git-2.17.1.2-32-bit.exe - https://www.educoder.net/attachments/205112.js?attachment_id=1 - */ - // collect attachments - const $ = window.$; - const attachmentsMap = {}; - const attachmentIds = this.state.fileList.map(item => { - return item.response ? item.response.id : item.id - }) - - if (currentMemoId) { - this.updateMemo(attachmentIds) - } else { - this.newMemo(attachmentIds) - } - } - onCancel() { - const { currentMemoId, memoType } = this.state; - if (currentMemoId) { // 编辑 - this.props.history.push(`/forums/${currentMemoId}`) - } else { // 新建 - this.props.history.push(`/forums`) - } - ; this.props.history.goBack() - } - updateMemo(attachmentsMap) { - const { memoSubject, memoRepertoire, memoLanguage, memoType, currentMemoId, content } = this.state; - const mdVal = this.mdRef.current.getValue() - console.log('isContentEdit: ', mdVal === content); - const newMemoUrl = `/memos/${currentMemoId}.json` - axios.put(newMemoUrl, { - content_changed: this.contentChanged, - tags: memoLanguage, - // memo:{ - subject: memoSubject, - content: mdVal, - forum_id: memoType, - repertoire_name: memoRepertoire, - // language: memoLanguage.join(languageSeparator), - // - // }, - attachment_ids: attachmentsMap - }, { - // withCredentials: true, - }) - .then((response) => { - const { status, message, memo_id } = response.data; - if (status === 0) { - window.$("html,body").animate({ "scrollTop": 0 }) - this.props.history.push(`/forums/${currentMemoId}`) - } else { - this.props.showNotification(message) - } - }).catch((error) => { - console.log(error) - }) - } - newMemo(attachmentsMap) { - const { memoSubject, memoRepertoire, memoLanguage, memoType } = this.state; - const mdVal = this.mdRef.current.getValue() - - const newMemoUrl = `/memos.json` - axios.post(newMemoUrl, { - tags: memoLanguage, - // memo:{ - subject: memoSubject, - content: mdVal, - forum_id: memoType, - // repertoire_name: memoRepertoire, - - // }, - attachment_ids: attachmentsMap - }, { - // withCredentials: true, - }) - .then((response) => { - const { status, message, memo_id } = response.data; - if (status === 0) { - window.$("html,body").animate({ "scrollTop": 0 }) - this.props.history.push(`/forums/${memo_id}`) - } else { - this.props.showNotification(message) - } - }).catch((error) => { - console.log(error) - }) - } - componentDidMount() { - const newMemoUrl = `/memos/new.json` - axios.get(newMemoUrl, { - // withCredentials: true, - }) - .then((response) => { - const data = response.data; - if (data.tag_list) { - document.title = "交流问答"; - this.setState({ - tag_list: data.tag_list - }) - - // 初始化 csrf meta - const $ = window.$ - $('head').append($('')) - $('head').append($(``)) - } - if (data.forums) { - this.setState({ - forums: data.forums === undefined || data.forums === null || data.forums.length === 0 ? this.state.forums : data.forums - }) - } - }).catch((error) => { - console.log(error) - }) - - // 如果是编辑 - const { match } = this.props - const memoId = match.params.memoId; - if (memoId) { - const memoUrl = `/memos/${match.params.memoId}/edit.json`; - axios.get(memoUrl, { - // withCredentials: true, - }) - .then((response) => { - const tag_list = response.data.tag_list - if (tag_list) { - // this.setState({...response.data}) - - document.title = response.data.subject; - const { content, forum_id, id, repertoire_name, subject, - current_user, tag_list, attachments_url, memo_tags, attachments } = response.data; - this.initMD(content); - // this.onRepertoiresChange(repertoire_name) - // tag -> memo_tags - const tag = memo_tags; - let memoLanguage = [] - if (tag) { - memoLanguage = tag.map((item, index) => { - return item.id + "" - }) - } - const fileList = attachments.map(item => { - return { - id: item.id, - uid: item.id, - name: appendFileSizeToUploadFile(item), - url: item.url, - filesize: item.filesize, - status: 'done' - } - }) - this.setState({ - fileList, - currentMemoId: memoId, - memoSubject: subject, - memoType: forum_id, - memoRepertoire: repertoire_name, - memoLanguage, - attachments_url, - content - - // repertoires: [], - // currentSelectRepertoiresIndex: -1, - }, () => { - // 解决有时候编辑时内容不显示的问题 - setTimeout(() => { - this.mdRef.current && this.mdRef.current.setValue(content || '') - }, 2000) - - $('.upload_filename').each((index, item) => { - var width = window._textWidth($(item), '14px'); - console.log(width) - $(item).css('width', width + 20) - }) - - }) - // 加载完后滚动条滚动 - window.$("html,body").animate({ "scrollTop": 0 }) - - this.props.initForumState({ - // current_user, - tag_list - }) - } - - }).catch((error) => { - console.log(error) - }) - } else { - this.initMD(); - } - - - - - } - - renderOptions(array) { - const elementArray = []; - array.forEach((item, index) => { - elementArray.push( - - ) - }) - return elementArray - } - onRepertoiresChange(value) { - - const index = this.state.repertoires.indexOf(value) - - this.setState({ - currentSelectRepertoiresIndex: index, - memoRepertoire: value, - memoLanguage: '' - }); - }; - - renderTag() { - const { tag_list } = this.state; - if (!tag_list || tag_list.length === 0) { - return '' - } - const result = [] - - tag_list.forEach((item, index) => { - result.push() - }) - - return result; - } - - onTagChange(value) { - if (value && value.length > 3) { - this.props.showNotification(`最多选择3个技术标签`) - - return; - } - this.setState({ - memoLanguage: value - }) - } - - onTypeChange(value) { - - this.setState({ - memoType: typeNameMap[value] - }) - } - onMemoNameChange(e) { - this.setState({ - memoSubject: e.target.value - }) - } - renderAttachment() { - const { attachments_url } = this.state; - const attachments = [] - attachments_url.forEach((item, index) => { - const ar = item.url.split('/') - attachments.push( - - - - - - {window.conver_size(item.id)} - - - -
- {/**/} - -
-
-
- - ) - }) - return attachments; - } - handleChange = (info) => { - if (info.file.status === 'uploading' || info.file.status === 'done' || info.file.status === 'removed') { - let fileList = info.fileList; - this.setState({ - fileList: appendFileSizeToUploadFileAll(fileList) - }); - } - } - onAttachmentRemove = (file) => { - if (!file.percent || file.percent == 100) { - this.props.confirm({ - // title: '确定要删除这个附件吗?', - content: '是否确认删除?', - - okText: '确定', - cancelText: '取消', - // content: 'Some descriptions', - onOk: () => { - this.deleteAttachment(file) - }, - onCancel() { - console.log('Cancel'); - }, - }); - return false; - } - - } - deleteAttachment = (file) => { - // 初次上传不能直接取uid - const url = `/attachments/${file.response ? file.response.id : file.uid}.json` - axios.delete(url, { - }) - .then((response) => { - if (response.data) { - const { status } = response.data; - if (status == 0) { - console.log('--- success') - - this.setState((state) => { - const index = state.fileList.indexOf(file); - const newFileList = state.fileList.slice(); - newFileList.splice(index, 1); - return { - fileList: newFileList, - }; - }); - } - } - }) - .catch(function (error) { - console.log(error); - }); - } - render() { - const { match, history, forums } = this.props - const { - // repertoires, repertoiresTagMap, currentSelectRepertoiresIndex, memoRepertoire, - tag_list, - memoSubject, memoType, - memoLanguage, attachments_url, fileList } = this.state; - const memoId = match.params.memoId; - - const uploadProps = { - width: 600, - fileList, - multiple: true, - // https://github.com/ant-design/ant-design/issues/15505 - // showUploadList={false},然后外部拿到 fileList 数组自行渲染列表。 - // showUploadList: false, - action: `${getUploadActionUrl()}`, - onChange: this.handleChange, - onRemove: this.onAttachmentRemove, - beforeUpload: (file) => { - console.log('beforeUpload', file.name); - const isLt150M = file.size / 1024 / 1024 < 150; - if (!isLt150M) { - this.props.showNotification('文件大小必须小于150MB!'); - } - return isLt150M; - }, - }; - return ( -
-

交流问答 / 详情

-
- {memoId ? '编辑话题' : '发布话题'} - {/* - */} -
- -
-
-

话题名称

-
- * -
- this.onMemoNameChange(val)} placeholder=""> - -
-
- - 必填项 - -
-
-
-
- -
-
-

内容

-
- * -
- - - {/*
- -
*/} -

-

-
-
- - 必填项 - -
-
- - - {/*开始上传*/} - - - (单个文件150M以内) - - -
-
- {/* TODOTODO 这里重复的html代码太多,如果有其他页面有类似需求,需要封装*/} - -
-
-

话题类型

-
- * -
- -
-
- - 必填项 - -
-
-
-
- - {memoType === typeNameMap['技术分享'] && -
-
-

技术标签

-
- * - -
- -
- -
- - 必填项 - -
-
-
-
} - -
- { this.onCommit() }}>提交 - { this.onCancel() }} className="defalutCancelbtn fl">取消 -
- -
- ); - } -} - -export default MemoNew; diff --git a/src/modules/forums/MemoOldGuide.js b/src/modules/forums/MemoOldGuide.js deleted file mode 100644 index 85813e5cd..000000000 --- a/src/modules/forums/MemoOldGuide.js +++ /dev/null @@ -1,65 +0,0 @@ -import React, { Component } from 'react'; -import { Redirect } from 'react-router'; - -import { BrowserRouter as Router, Route, Link, Switch } from "react-router-dom"; - -import PropTypes from 'prop-types'; - -import classNames from 'classnames' - -import Pagination from 'rc-pagination'; - -import { postPaginationHOC } from './PostPaginationHOC' - -import PostItem from './PostItem' - - -import ForumsNavTab from './ForumsNavTab' - -class MemoGuide extends Component { - constructor(props) { - super(props) - - this.state = { - - } - } - - onPaginationChange(pageNum, pageSize) { - - this.props.onPaginationChange(pageNum, pageSize) - } - - - renderMemoList() { - // const { memo_list, user } = this.props; - // if (!memo_list) { - // return '' - // } - // return memo_list.map( (item, index) => { - // return ( - // - // ) - // }) - return this.props.renderMemoList(); - } - render() { - const { match, history, currentPage, memo_count } = this.props - - return ( - - -
- - {this.renderMemoList()} - - { !!memo_count && this.onPaginationChange(pageNum, pageSize)} - showQuickJumper current={currentPage} total={memo_count} pageSize={15}/> } -
-
- - ); - } -} - -export default postPaginationHOC( MemoGuide ); diff --git a/src/modules/forums/MemoOldHottest.js b/src/modules/forums/MemoOldHottest.js deleted file mode 100644 index 9a1190c07..000000000 --- a/src/modules/forums/MemoOldHottest.js +++ /dev/null @@ -1,84 +0,0 @@ -import React, { Component } from 'react'; -import { Redirect } from 'react-router'; - -import { BrowserRouter as Router, Route, Link, Switch } from "react-router-dom"; - -import PropTypes from 'prop-types'; - -import classNames from 'classnames' - -import Pagination from 'rc-pagination'; - -import { postPaginationHOC } from './PostPaginationHOC' - -import PostItem from './PostItem' - - -import ForumsNavTab from './ForumsNavTab' - -class MemoHottest extends Component { - constructor(props) { - super(props) - - this.handleLocationChange = this.handleLocationChange.bind(this); - - this.state = { - - } - } - - onPaginationChange(pageNum, pageSize) { - - this.props.onPaginationChange(pageNum, pageSize) - } - - componentDidMount() { - // this.handleLocationChange(this.props.history.location); - this.unlisten = this.props.history.listen(this.handleLocationChange); - } - - componentWillUnmount() { - this.unlisten(); - } - - handleLocationChange(location) { - // your staff here - console.log(`- - - location: '${location.pathname}'`); - if (location.pathname && location.pathname.indexOf('/forums/categories/all') != -1 - && this.locationSearch != location.search) { - this.props.fetchMemos(); - } - this.locationSearch = location.search; - } - - renderMemoList() { - // const { memo_list, user } = this.props; - // if (!memo_list) { - // return '' - // } - // return memo_list.map( (item, index) => { - // return ( - // - // ) - // }) - return this.props.renderMemoList(); - } - render() { - const { match, history, currentPage, memo_count } = this.props - - return ( - - -
- - {this.renderMemoList()} - - { !!memo_count && this.onPaginationChange(pageNum, pageSize)} - showQuickJumper current={currentPage} total={memo_count} pageSize={15}/> } -
-
- ); - } -} - -export default postPaginationHOC( MemoHottest ); diff --git a/src/modules/forums/MemoOldNewest.js b/src/modules/forums/MemoOldNewest.js deleted file mode 100644 index 618262dac..000000000 --- a/src/modules/forums/MemoOldNewest.js +++ /dev/null @@ -1,63 +0,0 @@ -import React, { Component } from 'react'; -import { Redirect } from 'react-router'; - -import { BrowserRouter as Router, Route, Link, Switch } from "react-router-dom"; - -import PropTypes from 'prop-types'; - -import classNames from 'classnames' - -import Pagination from 'rc-pagination'; - -import { postPaginationHOC } from './PostPaginationHOC' - -import PostItem from './PostItem' - - -import ForumsNavTab from './ForumsNavTab' - -class MemoNewest extends Component { - constructor(props) { - super(props) - - this.state = { - - } - } - - onPaginationChange(pageNum, pageSize) { - - this.props.onPaginationChange(pageNum, pageSize) - } - - - renderMemoList() { - // const { memo_list, user } = this.props; - // if (!memo_list) { - // return '' - // } - // return memo_list.map( (item, index) => { - // return ( - // - // ) - // }) - return this.props.renderMemoList(); - } - render() { - const { match, history, currentPage, memo_count } = this.props - - return ( - - -
- {this.renderMemoList()} - - { !!memo_count && this.onPaginationChange(pageNum, pageSize)} - showQuickJumper current={currentPage} total={memo_count} pageSize={15}/> } -
-
- ); - } -} - -export default postPaginationHOC( MemoNewest ); diff --git a/src/modules/forums/MemoTechShare.js b/src/modules/forums/MemoTechShare.js deleted file mode 100644 index d32bd2e2f..000000000 --- a/src/modules/forums/MemoTechShare.js +++ /dev/null @@ -1,116 +0,0 @@ -import React, { Component } from 'react'; -import { Redirect } from 'react-router'; - -import { BrowserRouter as Router, Route, Link, Switch } from "react-router-dom"; - -import PropTypes from 'prop-types'; - -import classNames from 'classnames' - -import Pagination from 'rc-pagination'; - -import { postPaginationHOC } from './PostPaginationHOC' - -import PostItem from './PostItem' - -import ForumsNavTab from './ForumsNavTab' - -// import queryString from 'query-string' -import { queryString } from 'educoder' - -import MemoList from './MemoList' - - -class MemoTechShare extends Component { - constructor(props) { - super(props) - - this.handleLocationChange = this.handleLocationChange.bind(this); - - this.state = { - - } - } - - onPaginationChange(pageNum, pageSize) { - this.props.onPaginationChange(pageNum, pageSize) - } - - componentDidMount() { - // this.handleLocationChange(this.props.history.location); - // this.unlisten = this.props.history.listen(this.handleLocationChange); - } - - componentWillUnmount() { - // this.unlisten(); - } - componentDidUpdate(prevProps) { - if(this.props.match.params.memoType !== prevProps.match.params.memoType) { - // do something - console.log(`memoType changed`) - this.props.fetchMemos(); - } - } - - componentWillReceiveProps(newProps, newContext) { - if (newProps.match.url === this.props.match.url) { - const oldParsed = queryString.parse(this.props.location.search); - const newParsed = queryString.parse(newProps.location.search); - if (!newParsed.page && oldParsed.page || - (oldParsed.order && newParsed.order && oldParsed.order != newParsed.order)) { - this.props.fetchMemos(); - } - // console.log('componentWillReceiveProps...') - } - } - - handleLocationChange(location) { - console.log(`- - - location: '${location.pathname}'`); - if (location.pathname) { - if (location.pathname.indexOf('/forums/categories/all') != -1 - && this.props.location.search && this.props.location.search.indexOf('order=') != -1 - && location.search.indexOf('order=') != -1) { - const oldParsed = queryString.parse(this.props.location.search); - const newParsed = queryString.parse(location.search); - if (oldParsed.order != newParsed.order) { // 只有在热门和最新间跳转时,才需要处理 - this.props.fetchMemos(); - } - } - } - } - - renderMemoList() { - - - // const { memo_list, user } = this.props; - // if (!memo_list) { - // return '' - // } - // return memo_list.map( (item, index) => { - - // return ( - // this.setTop(memo)} - // setDown={(memo)=>this.setDown(memo)} memo={item} - // > - // ) - // }) - return this.props.renderMemoList(); - } - - render() { - const { match, history, currentPage, memo_count ,memo_list } = this.props - - return ( - - - this.renderMemoList()} - onPaginationChange={ (pageNum, pageSize) => this.props.onPaginationChange(pageNum, pageSize) } - > - - - ); - } -} - -export default postPaginationHOC() ( MemoTechShare ); diff --git a/src/modules/forums/Post.css b/src/modules/forums/Post.css deleted file mode 100644 index e28cf6019..000000000 --- a/src/modules/forums/Post.css +++ /dev/null @@ -1,224 +0,0 @@ -/*MemoDetail --------------------------------- START */ -.educontent { - margin-bottom: 20px; -} - -/* 左侧区域最小高度*/ -#forum_index_list { - min-height: 400px; - position: relative; -} - #forum_index_list .forum_table .forum_table_item { - background: #fff; - } - .noMemosTip { - position: absolute; - right: 10px; - top: 58px; - z-index: 999; - } -#forum_list { - background: #f9f9f9; -} - #forum_list .return_btn { - line-height: 38px; - /* margin-right: 15px; */ - font-size: 14px; - cursor: pointer; - } - #forum_list .return_btn.no_mr { - margin-right: -24px !important; - } - div#forum_list>div { - background: #fff; - } -.memoContent img { - max-width: 815px; -} -.memoReplies { - position: relative; - margin-top: 8px; -} - .memoReplies .-fit { - position: static; - } - .replies_count { - margin-left: 12px; - } - .replies_count .label { - color: #666666; - } - .replies_count .count { - color: #999999; - margin-left: 10px; - } - - .memoMore { - padding-top: 10px; - height: 50px; - line-height: 50px; - text-align: center; - color: rgba(69,155,230,1); - cursor: pointer; - position: relative; - } - .memoMore .writeCommentBtn{ - position: absolute; - right: 0px; - color: #666666; - top: 15px; - } - .memoMore .writeCommentBtn:hover { - color: #4DACFF; - } -/*使用md編輯器用为子回复时,宽度会变*/ -.panel-comment_item .comment_orig_content { - width: 705px; -} - -.iconfont.icon-xiazai { - font-size: 22px!important; - margin-right: 6px; -} -/* MemoDetail --------------------------------- END */ - -/* PostItem --------------------------------- START */ -.forum_table_item { - padding-left: 20px; -} - /* 置顶 */ - .forum_table_item .btn-top { - border-radius: 11px; - padding: 0px 6px; - background: #FF4343; - - } - -/* 管理员操作 */ -.edu-position-hide { - position: absolute; - top: 15px; - left: -20px; - box-shadow: 0px 2px 8px rgba(146, 153, 169, 0.5); - background: #fff; - z-index: 1001; - padding: 5px 0; - z-index: 999999; -} - .edu-position-hide li a:hover { - background: #4CACFF; - color: #fff; - } -.edu-position-hidebox>a:link{ - color: #4CACFF; -} - .edu-position-hidebox:hover .edu-position-hide { - display: block; - } - .edu-position-hide li a { - display: inline-block; - height: 30px; - width: 100px; - line-height: 30px; - text-align: center; - font-size: 12px!important; - } -/* PostItem --------------------------------- END */ - - -/* MemoNew --------------------------------- START */ - -#attachments_fields div.ui-progressbar { - width: 120px; - height: 10px; - margin: 2px 0 -2px 8px; - display: inline-block; -} -.ui-widget-header { - border: 1px solid #4CACFF; - background: #4CACFF; -} -.iconfont.icon-fujian { - color: #29BD8B -} - -/* rc-select样式覆写*/ -.ecSelect { - width: 300px; -} -.ecSelect .rc-select-selection { - height: 40px; -} - .ecSelect .rc-select-search--inline .rc-select-search__field { - padding-top: 6px; - } - .ecSelect .rc-select-selection--single .rc-select-selection-selected-value - , .ecSelect .rc-select-selection__placeholder { - top: 6px; - - } - .ecSelect .rc-select-arrow { - top: 6px; - } -.defalutCancelbtn { - cursor: pointer; -} -.defalutSubmitbtnysl{ - display: block;border: 1px solid #4CACFF;background-color: #4CACFF;color: #fff!important;width: 120px;text-align: center;line-height: 40px;border-radius: 2px; - width: 130px; - height: 40px; - background: rgba(76,172,255,1); - border-radius: 4px; - font-size: 16px; - font-family: MicrosoftYaHei; - font-weight: 400; - color: rgba(255,255,255,1); -} -#attachments_fields { - margin-left: -77px; - display: flex; - flex-direction: column; -} -.uploadBtn { - /* margin-left: 46px; */ -} -#memoMD.show_content_grey { - padding: 0; -} -.newForm .attachments_fields { - /*margin-left: -39px !important*/ -} -#attachments_fields div.ui-progressbar { - width: 120px; - height: 10px; - margin: 2px 0 -2px 8px; - display: inline-block; -} -.ui-progressbar-value.ui-widget-header { - border: 1px solid #4CACFF; - background: #4CACFF; -} -/* MemoNew --------------------------------- END */ - - -/*RightMyPublish*/ -.publishMemoSection { - padding-bottom: 0px !important; -} -.advertisement { - margin-top: 10px; - height: 155px; -} -.advertisement img{ - width: 100%; -} - -/* MyPublish*/ -.returnBtn { - font-size:16px; - color:rgba(153,153,153,1); - float: right; - margin-right: 50px; - position: relative; - bottom: 12px; -} \ No newline at end of file diff --git a/src/modules/forums/PostItem.js b/src/modules/forums/PostItem.js deleted file mode 100644 index 7d793dbd0..000000000 --- a/src/modules/forums/PostItem.js +++ /dev/null @@ -1,222 +0,0 @@ -import React, { Component } from "react"; -import { Redirect } from "react-router"; - -import { BrowserRouter as Router, Route, Link, Switch } from "react-router-dom"; - -import PropTypes from "prop-types"; - -import classNames from "classnames"; - -import { getImageUrl, toPath, ThemeContext } from "educoder"; - -import moment from "moment"; - -import { Tooltip } from "antd"; -import styled from "styled-components"; - -const Container = styled.div` - &:last-child .forum_table_item { - border-bottom: none; - } - .forum_table .forum_table_item:nth-child(odd) { - background: #fafbfb; - } - .forum_table_item { - padding: 20px 15px; - display: flex; - } - .forum_table_item .item_name { - color: #333; - } - .forum_table_item .item_name:hover { - color: #4cacff; - } - .forum_table_item { - padding-left: 20px; - } - /* 置顶 */ - .forum_table_item .btn-top { - border-radius: 11px; - padding: 0px 6px; - background: #ff4343; - } - .bor-radius-all { - border-radius: 50%; - } - .forum_table_item { - padding: 20px 15px; - display: flex; - border-bottom: 1px solid #ebebeb; - } -`; - -class PostItem extends Component { - _toTenThousand(num) { - if (num > 10000) { - return ((num - 500) / 10000).toFixed(1) + "万"; - } - return num; - } - - render() { - const { - match, - history, - currentPage, - memo, - user, - setTop, - setDown, - } = this.props; - return ( - -
- - 用户头像 - -
-

- {/* target="_blank" */} - 46 ? memo.subject : "" - } - className="clearfix task-hide item_name fl" - style={{ maxWidth: "600px" }} - > - {memo.subject} - - - {memo.sticky && ( - 置顶 - )} - - {memo.reward && ( - - - - {memo.reward} - - - )} -

- -
- {memo.user_name} - {/*最后回复:todo{memo.username} - memo.language && memo.language != 'other' && {memo.language} - */} - {/* {moment(memo.updated_at).fromNow()} */} - {memo.tag && memo.tag.length ? ( - 来自 {memo.tag.join("/")} - ) : ( - "" - )} - - {/*C++*/} - -

- {/* data-tip-down="回复数" {memo.replies_count} - {memo.praise_count}*/} - {memo.replies_count ? ( - - {memo.replies_count} 回复 - - ) : ( - "" - )} - - {memo.praise_count ? ( - - {memo.praise_count} 赞 - - ) : ( - "" - )} - - {memo.viewed_count ? ( - - {this._toTenThousand(memo.viewed_count)} 浏览 - - ) : ( - "" - )} -

-
- {user && (user.admin === true || user.login === memo.login) && ( -
- - - - -
- )} -
-
-
- ); - } -} -PostItem.contextType = ThemeContext; - -export default PostItem; diff --git a/src/modules/forums/PostPaginationHOC.js b/src/modules/forums/PostPaginationHOC.js deleted file mode 100644 index 9105be1ac..000000000 --- a/src/modules/forums/PostPaginationHOC.js +++ /dev/null @@ -1,352 +0,0 @@ -import React from 'react' -import ReactDOM from 'react-dom' -import axios from 'axios' -import update from 'immutability-helper' -import PostItem from './PostItem' - -import { CircularProgress } from 'material-ui/Progress'; - -import { queryString } from 'educoder' -import { on, off, updatePageParams } from 'educoder' -import './Post.css' -const $ = window.$ - -function urlStringify(params) { - let noParams = true; - let paramsUrl = ''; - for (let key in params) { - noParams = false; - paramsUrl += `${key}=${params[key]}&` - } - if (noParams) { - return ''; - } - paramsUrl = paramsUrl.substring(0, paramsUrl.length - 1); - return paramsUrl; -} -export function postPaginationHOC(options = {}) { -// options.isMyPublish -return function wrap(WrappedComponent) { - - return class II extends React.Component { - constructor(props) { - super(props) - - this.state = { - currentPage: 1, - loadingMemos: true - - } - } - - - componentDidMount() { - $('body>#root').on('onMemoDelete', (event) => { - // const val = $('body>#root').data('onMemoDelete') - const val = window.onMemoDelete ; - this.onMemoDelete( JSON.parse(decodeURIComponent(val)) ) - }) - window.$('#shixun_search_input').val('') - - this.props.setSearchValue('') - - this.fetchMemos(null, '') - - const that = this; - $(window).on('popstate', (e) => { - var state = e.originalEvent.state; - console.log('popstate', state) - if (state !== null) { - - let currentPage = that.state.currentPage;; - // // 浏览器地址改变了 - const search = that.props.history.location.search - const parsed = queryString.parse(search); - if (parsed.page != currentPage) { - currentPage = parseInt( parsed.page || 1) - // that.setSearchValue('') - that.fetchMemos(currentPage) - this.setState({ - currentPage, - }) - } - } - }); - - // RightMyPublish组件发过来的消息 - // $(window).on('setSearchValue', (event, val, noFetch)=>{ - - // }) - - on('hotTagClick', (event, tagName, index) => { - this.props.setHotLabelIndex(tagName.selectedHotLabelIndex, () => { - this.fetchMemos(1, undefined) - }) - }) - } - componentWillReceiveProps(newProps, newContext) { - if (newProps.enterKeyFlag !== this.props.enterKeyFlag) { - const childPath = this.props.match.path.split('/:')[0] - // 加入一个浏览地址 - const _search = this.props.location.search; - if (_search) { - const parsed = queryString.parse(_search); - if (parsed.page != 1) { - parsed.page = 1; - this.props.history.push(`${this.props.match.url}?${queryString.stringify(parsed)}`) - } - } - this.fetchMemos(1, newProps.searchValue, newProps.selectedHotLabelIndex) // 搜索框模糊搜索,重置为第一页 - - } - } - componentWillUnmount() { - // 要移除掉,不然到了MemoDetail页面,可能会有2个onMemoDelete监听 - $('body>#root').off('onMemoDelete') - $(window).off('setSearchValue') - $(window).off('popstate') - off('hotTagClick') - } - fetchMemos(arg_currentPage, arg_searchValue, arg_selectedHotLabelIndex) { - let { match, history } = this.props - - let searchValue = arg_searchValue != undefined ? arg_searchValue : this.props.searchValue - // 根据参数初始化页数 - - const memoType = match.params.memoType; - const urlArray = match.url.split('/') - const lastPath = urlArray[2] - - // 1 问题反馈 - // 3 操作指南 5 技术分享 - - const memoTypeMap = { - 'guide': 3, - 'techShare': 5 - } - const orderTypeMap = { - 'hottest': 'replies_count', - 'newest': 'updated_at', // 'created_at', - } - const _search = this.props.history.location.search; - const parsed = queryString.parse(_search); - - let currentPage = parseInt( arg_currentPage ? arg_currentPage : (parsed.page || 1) ) - - const params = { - // replies_count最热 created_at 最新 - // s_order: 'replies_count', - page: currentPage, - - // forum: // forum_id - // user_id - } - if (searchValue) { - params.search = searchValue.trim() - } - let orderType = '' - if (memoType==='all') { - orderType = parsed.order || 'hottest'; - params.order = orderTypeMap[orderType] - } else if (options.isMyPublish) { - params.user_id = -1 - } else if (memoType) { - params.forum = memoType - if (memoType == 5) { // 讨论区的技术分享tab按照创建时间倒序 - params.order = 'created_at' - } - } - - let { selectedHotLabelIndex, hot_tags } = this.props; - selectedHotLabelIndex = arg_selectedHotLabelIndex ? arg_selectedHotLabelIndex : selectedHotLabelIndex - if (selectedHotLabelIndex !== -1 && hot_tags[selectedHotLabelIndex]) { - params.tag_repertoire_id = hot_tags[selectedHotLabelIndex].tag_repertoire_id // encodeURIComponent() - } - - - let paramsUrl = queryString.stringify(params) - const memosUrl = '/memos.json?' + paramsUrl // /${challenge.identifier}/star - - this.setState({ - currentPage, - loadingMemos: true, - orderType: orderType - }) - // 获取memo list - axios.get(memosUrl,{ - // withCredentials: true, - }) - .then((response) => { - const memo_count = response.data.memo_count - if (memo_count>=0) { - - const maxPage = Math.ceil( memo_count / 15 ) - // page超出,显示最后一页 - if (maxPage != 0 && maxPage < currentPage) { - this.fetchMemos(maxPage); - return; - } - // 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, - p_s_order: params.s_order, - loadingMemos: false - }) - } - - }).catch((error) => { - console.log(error) - }) - } - - - onCurrentPageChange(pageNum) { - this.setState({ - currentPage: pageNum - }) - } - - onPaginationChange(pageNum, pageSize) { - window.$("html,body").animate({"scrollTop":0}) - - updatePageParams(pageNum, this.props) - - // 加入一个浏览地址 - // const params = { - // page: pageNum - // } - // if (this.state.orderType) { - // params.order = this.state.orderType; - // } - // this.props.history.push(`${url}?${queryString.stringify(parsed)}`) - - this.fetchMemos(pageNum); - - // this.setState({ - // currentPage: pageNum - // }) - } - - // 置顶 - setTop(memo) { - const params = { - sticky: memo.sticky ? 0 : 1, - } - if (this.state.p_s_order) { - params.order = this.state.p_s_order; - } - if (this.state.p_forum_id) { - params.forum_id = this.state.p_forum_id; - } - let paramsUrl = urlStringify(params) - const set_top_or_down_Url = `/memos/${memo.id}/sticky_or_cancel.json?${paramsUrl}`; - // 获取memo list - axios.post(set_top_or_down_Url, { - // withCredentials: true, - }) - .then((response) => { - const status = response.data.status - if (status === 0) { - this.fetchMemos(1, '') - - // const { memo_list } = response.data; - // this.props.initForumState({ memo_list }) - // 刷新列表 - // TODO 服务端直接返回第一页列表 - // this.props.history.replace('/') - } - }).catch((error) => { - console.log(error) - }) - } - // 取消置顶 - setDown(memo) { - this.setTop(memo); - } - onMemoDelete(memo) { - const deleteUrl = `/memos/${memo.id}.json`; - // 获取memo list - axios.delete(deleteUrl, { - // withCredentials: true, - }) - .then((response) => { - const status = response.data.status - if (status === 0) { - - this.props.showNotification('删除成功'); - // 刷新列表 - this.fetchMemos(); - } - }).catch((error) => { - console.log(error) - }) - } - // item渲染 - // - renderMemoList() { - const { memo_list, user } = this.props; - if (!memo_list) { - return '' - } - return memo_list.map( (item, index) => { - return ( - this.setTop(memo)} - setDown={(memo)=>this.setDown(memo)} - memo={item} - > - ) - }) - } - - render() { - const { loadingMemos } = this.state; - const { memo_list, searchValue, showSearchValue, memo_count, selectedHotLabelIndex, hot_tags} = this.props; - - // 规则: 搜索框输入了值 或者 选择了热门标签的时候显示该提示 - const _showSearchValue = showSearchValue || selectedHotLabelIndex != -1 - let _searchValue; - if (showSearchValue) { - _searchValue = searchValue - } else if (selectedHotLabelIndex != -1){ - _searchValue = hot_tags[selectedHotLabelIndex].name || hot_tags[selectedHotLabelIndex] - } - - return ( - -
{/* fl with100 */} -
- { _showSearchValue && -
- - 共找到  - {memo_count}个" - {_searchValue}"相关的结果 - -
} - - - { !loadingMemos && - this.onPaginationChange(pageNum, pageSize)} - onCurrentPageChange={(pageNum, pageSize) => this.onCurrentPageChange(pageNum, pageSize)} - - renderMemoList={() => this.renderMemoList()} - fetchMemos={(arg1, arg2) => this.fetchMemos(arg1, arg2)} - - > - } -
- -
- ) - } - } -} -} \ No newline at end of file diff --git a/src/modules/forums/RecommendShixun.js b/src/modules/forums/RecommendShixun.js deleted file mode 100644 index 535b027cc..000000000 --- a/src/modules/forums/RecommendShixun.js +++ /dev/null @@ -1,62 +0,0 @@ -import React, { Component } from 'react'; -import { Redirect } from 'react-router'; - -import { BrowserRouter as Router, Route, Link, Switch } from "react-router-dom"; - -import PropTypes from 'prop-types'; - -import classNames from 'classnames' - -class RecommendShixun extends Component { - constructor(props) { - super(props) - - this.state = { - - } - } - - showRecommandShixun(){ - const { recommend_shixuns } = this.props; - if (!recommend_shixuns) { - return ''; - } - const result = []; - recommend_shixuns.forEach((shixun, index) => { - const _shixun = shixun - result.push( -
- - - {`${_shixun.id}`} - - -
- 9 ? _shixun.name : ''} - className="color-grey-6 task-hide mb10 recomment-name" style={{maxWidth:'147px'}}> - {_shixun.name} - -

{_shixun.myshixuns_count} 人学习

-
-
- ) - }) - return result; - } - - render() { - const { match, history, currentPage } = this.props - - // 参考 TPMShixunDiscuss.js 推荐实训, 页面路径:http://localhost:3007/shixuns/uznmbg54/shixun_discuss - return ( -
-

推荐实训

-
- {this.showRecommandShixun()} -
-
- ); - } -} - -export default RecommendShixun; diff --git a/src/modules/forums/RightHotLabel.js b/src/modules/forums/RightHotLabel.js deleted file mode 100644 index c066168e1..000000000 --- a/src/modules/forums/RightHotLabel.js +++ /dev/null @@ -1,56 +0,0 @@ -import React, { Component } from 'react'; -import { Redirect } from 'react-router'; - -import { BrowserRouter as Router, Route, Link, Switch } from "react-router-dom"; - -import PropTypes from 'prop-types'; - -import classNames from 'classnames' - -import { trigger } from 'educoder' - -class RightHotLabel extends Component { - constructor(props) { - super(props) - - this.state = { - - } - } - - renderTags() { - const { hot_tags, selectedHotLabelIndex } = this.props; - if (!hot_tags) { - return '' - } - const result = hot_tags.map((item, index) => { - let params = {} - if (typeof item === 'string') { - params.name = item; - } else { - params = item; - } - params.selectedHotLabelIndex = index; - return ( - trigger('hotTagClick', params)} key={index} - className={classNames({ "selected": selectedHotLabelIndex === index })}> - {item.name || item} - ) - }) - return result - } - render() { - const { match, history, currentPage, selectedHotLabelIndex } = this.props - - return ( -
-

热门标签

-
- {this.renderTags()} -
-
- ); - } -} - -export default RightHotLabel; diff --git a/src/modules/forums/RightHotQuestion.js b/src/modules/forums/RightHotQuestion.js deleted file mode 100644 index d5e7ce713..000000000 --- a/src/modules/forums/RightHotQuestion.js +++ /dev/null @@ -1,53 +0,0 @@ -import React, { Component } from 'react'; -import { Redirect } from 'react-router'; - -import { BrowserRouter as Router, Route, Link, Switch } from "react-router-dom"; - -import PropTypes from 'prop-types'; - -import classNames from 'classnames' - -class RightHotQuestion extends Component { - constructor(props) { - super(props) - - this.state = { - - } - } - - // - renderHotMemos() { - const { hot_memos } = this.props; - if (!hot_memos) { - return '' - } - return hot_memos.map((item, index) => { - return
- 15 ? item.subject : '' } - > - {item.subject} - -

- {item.replies_count} 回答 - { !!item.tag && item.tag.length ? 来自 {item.tag.join('/')} : ''} -

-
- }) - } - render() { - const { match, history, currentPage } = this.props - - return ( -
-

热门问题

-
- {this.renderHotMemos()} -
-
- ); - } -} - -export default RightHotQuestion; diff --git a/src/modules/forums/RightMemoLabel.js b/src/modules/forums/RightMemoLabel.js deleted file mode 100644 index 30225104f..000000000 --- a/src/modules/forums/RightMemoLabel.js +++ /dev/null @@ -1,47 +0,0 @@ -import React, { Component } from 'react'; -import { Redirect } from 'react-router'; - -import { BrowserRouter as Router, Route, Link, Switch } from "react-router-dom"; - -import PropTypes from 'prop-types'; - -import classNames from 'classnames' - -import { trigger } from 'educoder' - -class MemoLabel extends Component { - constructor(props) { - super(props) - - this.state = { - - } - } - - renderTags() { - const { memo } = this.props; - - const arrays = memo.tag.map((item, index) => { - return {item} - }) - return arrays - } - render() { - const { match, history, currentPage, memo } = this.props - - if (!memo || !memo.tag || memo.tag.length === 0) { - return '' - } - - return ( -
-

话题标签

-
- {this.renderTags()} -
-
- ); - } -} - -export default MemoLabel; diff --git a/src/modules/forums/RightMyPublish.js b/src/modules/forums/RightMyPublish.js deleted file mode 100644 index 69ce9912c..000000000 --- a/src/modules/forums/RightMyPublish.js +++ /dev/null @@ -1,75 +0,0 @@ -import React, { Component } from 'react'; -import { Redirect } from 'react-router'; - -import { BrowserRouter as Router, Route, Link, Switch } from "react-router-dom"; - -import PropTypes from 'prop-types'; - -import classNames from 'classnames' - -import { getImageUrl, toPath, LinkAfterLogin } from 'educoder' - -import match_adImg from '../../images/ad/match_ad.jpg' -const $ = window.$ - -class RightMyPublish extends Component { - constructor(props) { - super(props) - - this.state = { - - } - } - - handleKeyPress = (event) => { - if(event.type !== 'keypress' || event.key == 'Enter'){ - this.props.setSearchValue( this.props.searchValue, true); - // $(window).trigger('setSearchValue', $('#shixun_search_input').val()) - } - } - handleInput = (event) => { - this.props.setSearchValue(event.target.value); - } - - render() { - const { match, history, currentPage, my_memos_count, setSearchValue, searchValue } = this.props - - return ( - -
- {/*
-
- - - × -
- -
*/} -
- - - - - - -
- 发布话题 - {/*

- 我的发布
- {my_memos_count} -

*/} -
- -
- -
-
- ); - } -} - -export default RightMyPublish; diff --git a/src/modules/forums/RightSection.css b/src/modules/forums/RightSection.css deleted file mode 100644 index a31b1dff8..000000000 --- a/src/modules/forums/RightSection.css +++ /dev/null @@ -1,61 +0,0 @@ -/* 右侧搜索区域*/ -.searchFor .searchCon { - width: 215px; -} - -.search-new { - width:237px!important; - height: 30px; - margin-bottom: 30px; - /*margin-right: 35px;*/ -} -.search-newysl { - - height: 30px; - margin-bottom: 30px; -} -.search-newyslw{ - width:237px!important; -} - .search-new-input { - padding-left: 16px; - height: 30px; - } - .search-span { - border-radius: 17px; - } - -.search-new img { - right: 10px; -} - - -/* 右侧 热门标签 */ -.HotLabelList a{display: block;float: left;padding: 0px 9px;height: 28px;line-height: 28px;border-radius: 14px;background-color: #f5f5f5;color: #666;margin-right: 10px;margin-bottom: 9px;} -.HotLabelList a.selected { - background: #4CACFF; - color: #fff; -} - - - -/* 右侧 热门问题 */ -.hotQuestionItem{padding:20px 0px;border-bottom: 1px solid #eee;} -.questiontName{max-width: 100%;display: block;} - - - -/* 用户信息-UserSection*/ -.user_default_btn {width: 114px;} -.userPrivateName{line-height: 25px;margin-bottom: 9px;} -.userPrivatePost{line-height: 20px;} -.noteDetailTitle{line-height: 38px;font-size: 24px;font-weight: normal;text-align:justify } - -.noteDetailNum{float: left;padding:0px 12px;position: relative;color: #999!important;height: 28px;line-height: 26px;} -.noteDetailNum.rightline:after{position: absolute;content: '';right: 0px;width: 1px;background-color: #EAEAEA;height: 8px;top:10px;} - -/*帖子详情点赞*/ -.noteDetailPoint{width: 100px;height: 70px;background-color: #4cacff;border-radius: 35px;color: #FFFFff;text-align: center;margin: 0px auto;box-sizing: border-box;padding: 2px 0px;cursor: pointer; line-height: 22px; - padding-top: 12px;} -.Pointed{background-color:#f0f0f0;color: #b3b3b3; cursor: default} -.notefileDownload{height: 25px;line-height: 22px;} diff --git a/src/modules/forums/UserSection.js b/src/modules/forums/UserSection.js deleted file mode 100644 index 45233bfc6..000000000 --- a/src/modules/forums/UserSection.js +++ /dev/null @@ -1,87 +0,0 @@ -import React, { Component } from 'react'; - -import { BrowserRouter as Router, Route, Link, Switch } from "react-router-dom"; - -import PropTypes from 'prop-types'; - -import classNames from 'classnames' - -import axios from 'axios' - -class UserSection extends Component { - constructor(props) { - super(props) - - this.state = { - - } - } - /*点击关注或者取消关注*/ - AboutFocus() { - const { author_info } = this.props - /*http://localhost:3000/api/v1/users/155/watch?object_id=156&object_type=user*/ - - // const focusUrl = `/api/v1/users/${author_info.user_id}/${this.props.author_info.watched ? 'unwatch' : 'watch'}?object_id=${author_info.user_id}&object_type=user` - - // axios.get(focusUrl,{ - // }) - // .then((response) => { - // const status = response.data.status; - // console.log(status); - // if(status == 1){ - // const new_author_info = Object.assign({}, this.props.author_info) - // new_author_info.watched = !new_author_info.watched - // this.props.initForumState({author_info: new_author_info}) - // } - // }).catch((error) => { - // console.log(error) - // }) - - let url = `/users/${author_info.user_id}/watch.json`; - // 取消关注 - if (author_info.watched) { - axios.delete(url).then((result) => { - if (result) { - const new_author_info = Object.assign({}, this.props.author_info) - new_author_info.watched = !new_author_info.watched - this.props.initForumState({ author_info: new_author_info }) - } - }).catch((error) => { - console.log(error) - }) - } else { - // 关注 - axios.post(url).then((result) => { - if (result) { - const new_author_info = Object.assign({}, this.props.author_info) - new_author_info.watched = !new_author_info.watched - this.props.initForumState({ author_info: new_author_info }) - } - }).catch((error) => { - console.log(error); - }) - } - } - - - render() { - const { match, history, author_info, current_user } = this.props - if (!author_info || !current_user) { - return
- } - return ( -
- -

{author_info.username}

-

{author_info.identity}

- {author_info.user_id !== current_user.user_id && -

- { this.AboutFocus() }}>{author_info.watched == true ? "取消关注" : "关注"} - 私信 -

} -
- ); - } -} - -export default UserSection; diff --git a/src/modules/forums/shixun/MemoShixun.css b/src/modules/forums/shixun/MemoShixun.css deleted file mode 100644 index c1421e02f..000000000 --- a/src/modules/forums/shixun/MemoShixun.css +++ /dev/null @@ -1,21 +0,0 @@ -.sxReturnItem{ - width: 100%; - padding-left:20px; - box-sizing: border-box; -} -.ItemLine{ - border-bottom: 1px solid #EBEBEB; - padding:30px 0px; -} -.ItemLineHeadPhoto{ - height:48px; - width: 48px; - float: left; - margin-top: 4px; -} -.shixunReply{ - max-width: 604px; -} -.sxReturnItem:last-child .ItemLine{ - border-bottom: none; -} \ No newline at end of file diff --git a/src/modules/forums/shixun/MemoShixun.js b/src/modules/forums/shixun/MemoShixun.js deleted file mode 100644 index 89a8f45c2..000000000 --- a/src/modules/forums/shixun/MemoShixun.js +++ /dev/null @@ -1,227 +0,0 @@ -import React, { Component } from 'react'; -import { Redirect } from 'react-router'; - -import { BrowserRouter as Router, Route, Link, Switch } from "react-router-dom"; - -import PropTypes from 'prop-types'; - -import classNames from 'classnames' - -import Pagination from 'rc-pagination'; - -import ShiXunPostItem from './ShiXunPostItem' -import ForumsNavTab from '../ForumsNavTab' -import { CircularProgress } from 'material-ui/Progress'; -import { on, off } from 'educoder' -import './MemoShixun.css' - -// import queryString from 'query-string' -import { queryString, updatePageParams } from 'educoder' -import MemoList from '../MemoList' -import axios from 'axios' - -const $ = window.$; -class MemoShixun extends Component { - constructor(props) { - super(props) - - this.state = { - currentPage: 1, - loadingMemos: true - } - } - - onPaginationChange(pageNum, pageSize) { - window.$("html,body").animate({"scrollTop":0}) - updatePageParams(pageNum, this.props) - this.fetchShixunMemos(pageNum); - } - componentWillReceiveProps(newProps, newContext) { - if (newProps.enterKeyFlag !== this.props.enterKeyFlag) { - // const childPath = this.props.match.path.split('/:')[0] - // // 加入一个浏览地址 - // const _search = this.props.location.search; - // if (_search) { - // const parsed = queryString.parse(_search); - // if (parsed.page != 1) { - // parsed.page = 1; - - // this.props.history.push(`${this.props.match.url}?${queryString.stringify(parsed)}`) - // } - // } - this.fetchShixunMemos(1, newProps.searchValue, newProps.selectedHotLabelIndex) // 搜索框模糊搜索,重置为第一页 - - } - } - - fetchShixunMemos(arg_currentPage, arg_searchValue, arg_selectedHotLabelIndex) { - /* - page = params[:page].to_i - offset = page * 15 - search = params[:search] - tag = params[:tag_repertoire_id] - */ - - const _search = this.props.history.location.search; - const parsed = queryString.parse(_search); - - let currentPage = parseInt( arg_currentPage ? arg_currentPage : (parsed.page || 1) ) - - const paramsObject = { - page: currentPage // - 1 从1开始 - } - - let searchValue = arg_searchValue != undefined ? arg_searchValue : this.props.searchValue - - if (searchValue) { - paramsObject.search = searchValue - } - let { selectedHotLabelIndex, hot_tags } = this.props; - selectedHotLabelIndex = arg_selectedHotLabelIndex ? arg_selectedHotLabelIndex : selectedHotLabelIndex - if (selectedHotLabelIndex !== -1 && hot_tags[selectedHotLabelIndex]) { - paramsObject.tag_repertoire_id = hot_tags[selectedHotLabelIndex].id - } - - const stringifid = queryString.stringify(paramsObject); - const url = `/discusses/forum_discusses.json?${stringifid}` // /${challenge.identifier}/star - - // 获取memo list - this.setState({ - currentPage: currentPage , - loadingMemos: true - }) - axios.get(url,{ - // withCredentials: true, - }) - .then((response) => { - if (response.data) { - // 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; - // if (hot_tags && hot_tags.length) { - // this.tagNameIdMap = {} - // hot_tags.forEach( (item, index) => { - // this.tagNameIdMap[item.name] = item.id - // }) - // } - - this.setState({ - - // p_forum_id: params.forum, - // p_s_order: params.s_order, - loadingMemos: false - }) - } - }).catch((error) => { - console.log(error) - }) - } - componentDidMount() { - this.fetchShixunMemos(); - - on('hotTagClick', (event, tagName) => { - this.props.setHotLabelIndex(tagName.selectedHotLabelIndex, () => { - this.fetchShixunMemos(1, undefined) - }) - - - }) - - $(window).on('popstate', (e) => { - var state = e.originalEvent.state; - console.log('popstate', state) - if (state !== null) { - - let currentPage = this.state.currentPage;; - // // 浏览器地址改变了 - const search = this.props.history.location.search - const parsed = queryString.parse(search); - if (parsed.page != currentPage) { - currentPage = parseInt( parsed.page || 1) - // this.setSearchValue('') - this.fetchShixunMemos(currentPage) - this.setState({ - currentPage, - }) - } - } - }); - } - componentWillUnmount() { - off('hotTagClick') - $(window).off('popstate') - } - - renderMemoList() { - - const { memo_list, user } = this.props; - if (!memo_list) { - return '' - } - /* - this.setTop(memo)} - setDown={(memo)=>this.setDown(memo)} - memo={item} - > - */ - return memo_list.map( (item, index) => { - return ( - - - ) - }) - } - - render() { - const { match, history , memo_count ,memo_list, showSearchValue, searchValue - , selectedHotLabelIndex, hot_tags } = this.props; - const { currentPage, loadingMemos } = this.state; - - // 规则: 搜索框输入了值 或者 选择了热门标签的时候显示该提示 - const _showSearchValue = showSearchValue || selectedHotLabelIndex != -1 - let _searchValue; - if (showSearchValue) { - _searchValue = searchValue - } else if (selectedHotLabelIndex != -1){ - _searchValue = hot_tags[selectedHotLabelIndex].name || hot_tags[selectedHotLabelIndex] - } - - return ( -
{/* fl with100 */} -
- { _showSearchValue && -
- - 共找到  - {memo_count}个" - {_searchValue}"相关的结果 - -
} - - - { !loadingMemos && - - - this.renderMemoList()} - onPaginationChange={ (pageNum, pageSize) => this.onPaginationChange(pageNum, pageSize) } - {...this.state} - > - - - } -
- -
- - ); - } -} - -export default MemoShixun; diff --git a/src/modules/forums/shixun/ShiXunPostItem.js b/src/modules/forums/shixun/ShiXunPostItem.js deleted file mode 100644 index e7d89771a..000000000 --- a/src/modules/forums/shixun/ShiXunPostItem.js +++ /dev/null @@ -1,69 +0,0 @@ -import React, { Component } from 'react'; -import { Redirect } from 'react-router'; - -import { BrowserRouter as Router, Route, Link, Switch } from "react-router-dom"; - -import PropTypes from 'prop-types'; - -import classNames from 'classnames' - -import moment from 'moment' -import './MemoShixun.css' - -class ShiXunPostItem extends Component -{ - constructor(props) - { - super(props) - - this.state = { - - } - } - - render() { - const { memo } = this.props; - let tagStr = '' - if (memo.shixun_tag && memo.shixun_tag.length) { - - memo.shixun_tag.forEach( tag => { - tagStr += ` ${tag}` - }) - } - return ( - -
-
- - - -
-
-

- {memo.subject} -

- { memo.reward && - - {memo.reward} - - } -
-

- {memo.username} - {/* {moment(memo.updated_at).fromNow()} */} - { !!tagStr && 来自 {tagStr}} - { !!memo.praises_count && {memo.praises_count} 赞} - { !!memo.replies_count && {memo.replies_count} 回复} -

-
-
-
-
- ); - } - -} -export default ShiXunPostItem \ No newline at end of file diff --git a/src/modules/moop_cases/CaseDetail.js b/src/modules/moop_cases/CaseDetail.js deleted file mode 100644 index 7ec4ba49d..000000000 --- a/src/modules/moop_cases/CaseDetail.js +++ /dev/null @@ -1,172 +0,0 @@ -import React, { Component } from "react"; -import './css/moopCases.css' -import '../courses/css/Courses.css' - -import { getImageUrl, MarkdownToHtml, ActionBtn, AttachmentList } from 'educoder'; - -import Tags from './CaseTags' - -import axios from 'axios'; -import Modals from '../modals/Modals' - -// import AttachmentList from '../../common/components/attachment/AttachmentList' - -class CaseDetail extends Component { - constructor(props) { - super(props); - this.state = { - modalsType: "", - modalsTopval: "", - modalsBottomval: "", - modalCancel: "", - } - } - - componentDidMount = () => { - let caseID = this.props.match.params.caseID; - this.props.getDetail(caseID); - } - // 是否删除 - delCases = () => { - this.setState({ - modalsType: true, - modalsTopval: "是否确认删除?", - modalsBottomval: "" - }) - } - - // 取消删除 - cancelDelClasses = () => { - this.setState({ - modalsType: false, - modalsTopval: "", - modalsBottomval: "" - }) - } - // 确定删除 - sureDelClasses = () => { - let caseID = this.props.match.params.caseID; - let url = `/libraries/${caseID}.json`; - axios.delete(url).then((result) => { - if (result) { - this.props.showNotification("删除成功"); - this.props.history.push("/moop_cases"); - } - }).catch((error) => { - console.log(error); - }) - } - - - render() { - let { CaseDetail, praise_count, creator, operation, user_praised, tags, attachments } = this.props - let { - modalsType, - modalsTopval, - modalsBottomval, - } = this.state; - document.title = CaseDetail && CaseDetail.title != undefined ? CaseDetail && CaseDetail.title : "教学案例"; - return ( -
- { - CaseDetail && - - - -

- 教学案例 > {CaseDetail.title} -

-

- - {CaseDetail.title} - - - - { - CaseDetail.status == "pending" && 草稿 - } - { - CaseDetail.status == "processing" && 审核中 - } - { - CaseDetail.status == "refused" && 未通过 - } - - 返回 -

-
-
-
- 82274?1563067098 -
-
  • - {creator && creator.name} - { - operation && operation.can_deletable ? 删除 : "" - } - - { - operation && operation.can_editable ? 编辑 : "" - } -
  • -
  • - {creator && creator.school_name} - - 编码:{CaseDetail.uuid} - { - CaseDetail && CaseDetail.status == "published" ? - 发布时间:{CaseDetail.published_at} - : - 上传时间:{CaseDetail.created_at} - } - -
  • -
    -
    -
    - 作者:{CaseDetail.author_name}/{CaseDetail.author_school_name} -
    - -
    - {CaseDetail.content && } -
    - {attachments && -
    - -
    - } -
    - { - user_praised ? -

    - 已赞 - {praise_count} -

    - : -

    this.props.praisePoint(this.props.match.params.caseID)} className="pointsBtn"> - - {praise_count} -

    - } -
    -
    -
    -
    - } -
    - ) - } -} -export default CaseDetail; \ No newline at end of file diff --git a/src/modules/moop_cases/CaseItem.js b/src/modules/moop_cases/CaseItem.js deleted file mode 100644 index d72c0c321..000000000 --- a/src/modules/moop_cases/CaseItem.js +++ /dev/null @@ -1,59 +0,0 @@ -import React,{ Component } from "react"; -import './css/moopCases.css' -import '../courses/css/Courses.css' - -import { getUrl } from 'educoder'; - -import Tags from './CaseTags' - -class CaseItem extends Component{ - constructor(props){ - super(props); - } - - render(){ - let { libraries } = this.props; - console.log(libraries) - return( -
    - { - libraries && libraries.map((item,key)=>{ - return( - -
  • - {item.id} -
    -

    - {item.title} - -

    -

    - {item.author_name} - {item.author_school_name} - - { - item.visited_count && item.visited_count != 0 ? - {item.visited_count} 浏览:"" - } - { - item.praise_count && item.praise_count != 0 ? - {item.praise_count} 赞:"" - } - { - item.download_count && item.download_count != 0 ? - {item.download_count} 下载:"" - } - -

    -
    -
  • - - ) - }) - } - -
    - ) - } -} -export default CaseItem; \ No newline at end of file diff --git a/src/modules/moop_cases/CaseList.js b/src/modules/moop_cases/CaseList.js deleted file mode 100644 index 3d53004f8..000000000 --- a/src/modules/moop_cases/CaseList.js +++ /dev/null @@ -1,173 +0,0 @@ -import React, { Component } from "react"; -import { Input, Spin, Pagination } from "antd"; -import './css/moopCases.css' -import '../courses/css/Courses.css' - -import { ActionBtn, LinkAfterLogin, getImageUrl } from 'educoder'; - -import axios from 'axios' - -import NoneData from '../courses/coursesPublic/NoneData' - -import mainImg from '../../images/moop_cases/teach_ex.jpg' -import CaseItem from './CaseItem' - - - - -const Search = Input.Search; -class CaseList extends Component { - constructor(props) { - super(props); - this.state = { - type: 0, - search: undefined, - page: 1, - pageSize: 20, - libraries: undefined, - totalCount: undefined, - isSpin: true - } - } - - componentDidMount = () => { - window.document.title = '教学案例' - let { type, search, page, pageSize } = this.state; - this.InitList(type, search, page, pageSize); - } - - // 列表 - InitList = (type, search, page, pageSize) => { - let url = `/libraries.json`; - axios.get(url, { - params: { - type: type == 0 ? undefined : "mine", - keyword: search, - page, - per_page: pageSize - } - }).then((result) => { - if (result) { - this.setState({ - libraries: result.data.libraries, - totalCount: result.data.count, - isSpin: false - }) - } else { - this.setState({ - isSpin: false - }) - } - }).catch((error) => { - console.log(error); - this.setState({ - isSpin: false - }) - }) - } - - // tab切换 - changeType = (type) => { - this.setState({ - type, - page: 1, - isSpin: true - }) - let { search, page, pageSize } = this.state; - this.InitList(type, search, page, pageSize); - } - - // 输入搜索内容 - inputStudent = (e) => { - this.setState({ - search: e.target.value - }) - } - - // 搜索 - searchInfo = () => { - this.setState({ - isSpin: true - }) - let { type, search, pageSize } = this.state; - this.InitList(type, search, 1, pageSize); - } - - // 切换分页 - onChangePage = (pageNumber) => { - this.setState({ - page: pageNumber - }) - let { type, search, pageSize } = this.state; - this.InitList(type, search, pageNumber, pageSize); - } - - render() { - let { type, search, libraries, totalCount, pageSize, page } = this.state; - let { checkIfLogin } = this.props; - - return ( - - - -
    -
    -

    - 教学案例 - 发布案例 - {/* 发布案例 */} -

    -
    -
      -
    • this.changeType(0)}> - 全部 -
    • - { - checkIfLogin() && -
    • this.changeType(1)}> - 我的 -
    • - } -
    -
    - -
    -
    -
    - - { - libraries && libraries.length > 0 && - } - { - libraries && libraries.length == 0 &&
    - } - { - totalCount && totalCount > pageSize && -
    - -
    - } -
    -
    -
    - ) - } -} -export default CaseList \ No newline at end of file diff --git a/src/modules/moop_cases/CaseNew.js b/src/modules/moop_cases/CaseNew.js deleted file mode 100644 index 1ed9907e4..000000000 --- a/src/modules/moop_cases/CaseNew.js +++ /dev/null @@ -1,475 +0,0 @@ -import React,{ Component } from "react"; -import './css/moopCases.css' -import '../courses/css/Courses.css' -import { Form , Input , Upload , Button , Icon , message , Tooltip } from "antd"; - -import { getImageUrl , setImagesUrl , MarkdownToHtml , ActionBtn , appendFileSizeToUploadFile , appendFileSizeToUploadFileAll , getUrl , getUploadActionUrl } from 'educoder'; - -import Tags from './CaseTags' - -import axios from 'axios'; -import TPMMDEditor from '../tpm/challengesnew/TPMMDEditor'; -import _ from 'lodash' -const { Dragger } = Upload; -function beforeUpload(file) { - const isJpgOrPng = file.type === 'image/jpeg' || file.type === 'image/png'; - if (!isJpgOrPng) { - message.error('You can only upload JPG/PNG file!'); - } - const isLt2M = file.size / 1024 / 1024 < 2; - if (!isLt2M) { - message.error('Image must smaller than 2MB!'); - } - return isJpgOrPng && isLt2M; -} -function getBase64(img, callback) { - const reader = new FileReader(); - reader.addEventListener('load', () => callback(reader.result)); - reader.readAsDataURL(img); -} - const $ = window.$; -class CaseNew extends Component{ - constructor(props){ - super(props); - this.DescMdRef = React.createRef(); - - this.state={ - casesTags:[], - contentFileList:[], - filesID:[], - imageUrl:undefined, - loading: false, - checkTag:false, - checkFile:false, - coverID:undefined, - library_tags:undefined - } - } - - // 上传附件-删除确认框 - onAttachmentRemove = (file, stateName) => { - if(!file.percent || file.percent == 100){ - this.props.confirm({ - content: '是否确认删除?', - onOk: () => { - this.deleteAttachment(file, stateName) - }, - onCancel() { - console.log('Cancel'); - }, - }); - return false; - } - } - - // 上传附件-确认删除 - deleteAttachment = (file, stateName) => { - // 初次上传不能直接取uid - const url = `/attachments/${file.response ? file.response.id : file.uid}.json` - axios.delete(url, { - }).then((response) => { - if (response.data) { - const { status } = response.data; - if (status == 0) { - console.log('--- success') - - this.setState((state) => { - const index = state[stateName].indexOf(file); - const newFileList = state[stateName].slice(); - newFileList.splice(index, 1); - console.log("newFileList"); - console.log(newFileList.map(item =>{ return( item.id )})); - return { - [stateName]: newFileList, - filesID:newFileList.map(item =>{ return( item.id )}) - }; - }); - } - } - }) - .catch(function (error) { - console.log(error); - }); - } - // 上传附件-change - handleContentUploadChange = (info) => { - if (info.file.status === 'done' || info.file.status === 'uploading' || info.file.status === 'removed') { - let contentFileList = info.fileList; - this.setState({ contentFileList: appendFileSizeToUploadFileAll(contentFileList)}); - let list = appendFileSizeToUploadFileAll(contentFileList); - let arr = list.map(item=>{ - return ( item.response && item.response.id ) - }) - this.setState({ - filesID:arr, - checkFile:arr.length > 0 ? false : true - }) - } - } - - // 上传封面图-change - handleChange = (info) => { - if (info.file.status === 'uploading') { - this.setState({ loading: true }); - return; - } - if (info.file.status === 'done') { - // Get this url from response in real world. - getBase64(info.file.originFileObj, imageUrl => - this.setState({ - imageUrl, - loading: false - }), - ); - console.log(info.file); - this.setState({ - coverID:info.file.response && info.file.response.id - }) - } - }; - - // 编辑时加载数据 - componentDidMount=()=>{ - - if(this.props.match.params.caseID){ - this.InitEditData(); - }else{ - window.document.title = '教学案例' - } - let url=`/library_tags.json`; - axios.get(url).then((result) => { - console.log(result) - if(result.data.status===0){ - this.setState({ - library_tags:result.data.library_tags - }) - } - }).catch((error) => { - console.log(error); - }) - } - - componentDidUpdate=(prevState)=>{ - if(this.props.CaseDetail && prevState.CaseDetail != this.props.CaseDetail){ - this.props.form.setFieldsValue({ - caseTitle:this.props.CaseDetail.title, - userName:this.props.CaseDetail.author_name, - userUnit:this.props.CaseDetail.author_school_name, - }) - this.setState({ - contentFileList:this.props.attachments.map(item => { - return { - id: item.id, - uid: item.id, - name: appendFileSizeToUploadFile(item), - url: item.url, - filesize: item.filesize, - status: 'done' - } - }), - filesID:this.props.attachments.map(item => { - return ( item.id ) - }), - coverID:this.props.cover && this.props.cover.id, - imageUrl:this.props.CaseDetail.cover && setImagesUrl(this.props.CaseDetail.cover.url), - casesTags:this.props.tags.map(item=>{ - return (item.id); - }) - }) - console.log(this.props.attachments.map(item => { - return ( item.id ) - })) - } - } - - InitEditData=()=>{ - let caseID = this.props.match.params.caseID; - this.props.getDetail(caseID); - } - - // 申请提交和保存 - handleSubmit = (type) => { - let caseID = this.props.match.params.caseID; - console.log(type); - this.props.form.validateFieldsAndScroll((err, values) => { - let { casesTags , filesID } = this.state; - if(casesTags.length == 0){ - $("html").animate({ scrollTop: $("#tagFormItem").offset().top - 100 }); - this.setState({ - checkTag:true - }) - return; - } - if(filesID.length == 0){ - $("html").animate({ scrollTop: $("#fileFormItem").offset().top - 100 }); - this.setState({ - checkFile:true - }) - return; - } - - const mdContnet = this.DescMdRef.current.getValue().trim(); - console.log(mdContnet) - values.description = mdContnet; - - console.log(values); - let url = caseID ? `/libraries/${caseID}.json`: `/libraries.json`; - if(caseID){ - axios.put((url),{ - title:values.caseTitle, - author_name:values.userName, - author_school_name:values.userUnit, - content:values.description, - attachment_ids:this.state.contentFileList.map(item=>{ - return (item.response ? item.response.id : item.id ) - }), - tag_ids:this.state.casesTags, - cover_id:this.state.coverID, - publish:type == 'save' ? false : true - }).then((result)=>{ - if(result){ - this.props.showNotification(type == 'save' ? `案例保存成功!`: `提交成功!`); - this.props.history.push(type == 'save' ? `/moop_cases/${result.data.id}` : `/moop_cases/${result.data.id}/publish_success`); - } - }).catch((error)=>{ - console.log(error); - }) - }else{ - axios.post((url),{ - title:values.caseTitle, - author_name:values.userName, - author_school_name:values.userUnit, - content:values.description, - attachment_ids:this.state.filesID, - tag_ids:this.state.casesTags, - cover_id:this.state.coverID, - publish:type == 'save' ? false : true - }).then((result)=>{ - if(result){ - this.props.showNotification(type == 'save' ? `案例保存成功!`: `提交成功!`); - this.props.history.push(type == 'save' ? `/moop_cases/${result.data.id}` : `/moop_cases/${result.data.id}/publish_success`); - } - }).catch((error)=>{ - console.log(error); - }) - } - - }) - } - - // 选择标签 - changeType=(type)=>{ - // console.log(this.state.casesTags); - - let tags = []; - - if(this.state.casesTags.indexOf(type) > -1){ - tags = this.state.casesTags.filter(item => item != type); - }else{ - tags = this.state.casesTags.concat(type); - } - const tagUniqed = _.uniq(tags); - this.setState({ - casesTags: tagUniqed, - checkTag:tags.length > 0 ? false : true - }) - } - - render(){ - let { caseID } = this.props.match.params; - let { CaseDetail } = this.props; - let { casesTags , contentFileList , imageUrl , checkTag , checkFile,library_tags } = this.state; - const {getFieldDecorator} = this.props.form; - - - // 上传附件点击事件 - const uploadProps = { - width: 600, - multiple: true, - fileList:contentFileList, - action: `${getUploadActionUrl()}`, - onChange: this.handleContentUploadChange, - onRemove: (file) => this.onAttachmentRemove(file, 'contentFileList'), - beforeUpload: (file) => { - const isLt150M = file.size / 1024 / 1024 < 150; - if (!isLt150M) { - //this.props.showNotification('文件大小必须小于150MB!'); - this.props.define({ - title:'提示', - content:"该文件无法上传。超过文件大小限制(150MB),建议上传到百度云等其它共享工具里,然后再txt文档里给出链接以及共享密码并上传" - }) - return isLt150M; - } - } - }; - // 上传封面图-html - const uploadButton = ( -
    - -
    - ); - // 上传封面图点击事件 - const uploadCover = { - listType:"picture-card", - className:"avatar-uploader", - showUploadList:false, - action:`${getUploadActionUrl()}`, - onChange:this.handleChange, - } - // console.log('111'); - // console.log(!caseID || (CaseDetail && CaseDetail.status == "pending")); - return( -
    - -

    - 教学案例 > { caseID ? "编辑" : "新建" } -

    -

    上传教学案例

    -
    -
    - - {getFieldDecorator('caseTitle', { - rules: [{required: true, message: "案例标题不能为空"}], - })( - - )} - 简明扼要介绍文档/视频所包含的主要的内容 - -
    - - {getFieldDecorator('userName', { - rules: [{required: true, message: "请输入作者姓名"}], - })( - - )} - - - {getFieldDecorator('userUnit', { - rules: [{required: true, message: "请输入作者单位名称"}], - })( - - )} - -
    -
    - 标签 -
      - {library_tags&&library_tags.map((item,key)=>{ - return( -
    • -1 ? "active" :"" } onClick={()=>this.changeType(item.id)}>{item.name}
    • - ) - })} -
    - { - checkTag &&
    请选择标签
    - } -
    - - {getFieldDecorator('description', { - rules: [{ - required: true, message: '请输入描述内容' - }], - })( - - )} - -
    - -

    上传附件

    -

    从我的电脑选择要上传的文档:按住CTRL可以上传多份文档。单个文件最大限制:150MB

    -
    - { - checkFile == true &&
    请先上传附件
    - } -
    -

    - 封面图(上传尺寸:120*90 px) -

    -
    - - { imageUrl ? - - avatar - - : - - {uploadButton} - - } - -
    -
    -
    -
  • 审核说明
  • -
      -
    • 平台管理员将对每天新上传的文档进行审核,审核通过的文档将公开显示,否则将私有化或移除
    • -
    -
    -
    -
  • 温馨提示
  • -
      -
    • 1.请勿上传已设置加密口令的文档资源;
    • -
    • 2.可以上传符合教学案例标准的文档资料,如 - 案例入库标准、 - 案例使用说明书以及其他资料等,上传支持的文件最大容量:100MB;
    • -
    • 3.请确保上传内容无侵权或违反国家关于互联网政策的不良行为;
    • -
    • 4.请使用Chrome,Firefox,Safari,IE11(及以上版本)浏览器;
    • -
    -
    - -
    - { - (!caseID || (CaseDetail && CaseDetail.status == "pending" || CaseDetail && CaseDetail.status == "refused")) ? : "" - } - this.handleSubmit("save")}>保存 -
    -
    - -
    - ) - } -} -const WrappedCoursesNewApp = Form.create({name: 'CaseNew'})(CaseNew); -export default WrappedCoursesNewApp; \ No newline at end of file diff --git a/src/modules/moop_cases/CaseTags.js b/src/modules/moop_cases/CaseTags.js deleted file mode 100644 index b4c1a03af..000000000 --- a/src/modules/moop_cases/CaseTags.js +++ /dev/null @@ -1,37 +0,0 @@ -import React,{ Component } from "react"; -import './css/moopCases.css' -import '../courses/css/Courses.css' - -class CaseTags extends Component{ - constructor(props){ - super(props); - } - - render(){ - let { tags } = this.props; - return( - - { - tags && tags.map((item,key)=>{ - return( - - { - item.name == "获奖案例" ? - {item.name} - : - item.name == "入库案例" ? - {item.name} - :item.name =='企业案例'? - {item.name} - : {item.name} - } - - ) - }) - } - - - ) - } -} -export default CaseTags; \ No newline at end of file diff --git a/src/modules/moop_cases/Success.js b/src/modules/moop_cases/Success.js deleted file mode 100644 index d612758c8..000000000 --- a/src/modules/moop_cases/Success.js +++ /dev/null @@ -1,28 +0,0 @@ -import React,{ Component } from "react"; -import './css/moopCases.css' -import '../courses/css/Courses.css' -import { getImageUrl } from 'educoder'; -import success from '../../images/moop_cases/success.png' - -class Success extends Component{ - constructor(props){ - super(props); - } - render(){ - return( -
    -
    - -

    恭喜!

    -

    提交成功

    -

    平台正在审核您的申请,审核结果将以平台消息的形式通知您

    -
  • - 查看已上传文档 - 继续上传 -
  • -
    -
    - ) - } -} -export default Success; \ No newline at end of file diff --git a/src/modules/moop_cases/css/moopCases.css b/src/modules/moop_cases/css/moopCases.css deleted file mode 100644 index c32896206..000000000 --- a/src/modules/moop_cases/css/moopCases.css +++ /dev/null @@ -1,178 +0,0 @@ -.winput-300-35{ - width: 300px; - height: 35px; - padding: 5px; - box-sizing: border-box; -} -.library_nav li { - float: left; - cursor: pointer; - margin-right: 30px; - position: relative; - color: #05101A; - height: 40px; - line-height: 20px; - font-size: 16px; -} -.library_nav li.active a, .library_nav li:hover a{ - color: #4cacff!important; -} -.library_list { - margin-bottom: 30px; -} -.library_list_item:hover { - box-shadow: 0px 4px 8px rgba(158,158,158,0.16); -} -.library_list_item { - background: #fff; - padding: 20px 30px; - margin-bottom: 30px; - display: flex; -} -.library_list_item .library_l_name { - max-width: 600px; - float: left; -} - -.edu-activity-red { - background-color: #FC2B6A; - color: #fff!important; - cursor: pointer; - border: 1px solid #FC2B6A; - line-height: 17px; -} -.edu-activity-green { - background-color: green; - color: #fff!important; - cursor: pointer; - border: 1px solid green; - line-height: 17px; -} -.edu-activity-orange { - background-color: #ff6800; - color: #fff!important; - cursor: pointer; - border: 1px solid #ff6800; - line-height: 17px; -} -.edu-activity-blue { - background-color: #4CACFF; - color: #fff!important; - cursor: pointer; - border: 1px solid #4CACFF; - line-height: 17px; -} -.edu-activity-orange-sub { - background-color: #FF781B; - color: #fff!important; - cursor: pointer; - border: 1px solid #ff6800; - line-height: 17px; -} -.edu-activity-36c53c-sub { - background-color: #36c53c; - color: #fff!important; - cursor: pointer; - border: 1px solid #36c53c; - line-height: 17px; -} -.pointsBtn { - width: 70px; - height: 70px; - background-color: #4cacff; - border-radius: 50%; - color: #fff; - text-align: center; - margin: 0 auto; - -webkit-box-sizing: border-box; - box-sizing: border-box; - padding: 2px 0; - cursor: pointer; - line-height: 22px; - padding-top: 12px; -} -.pointedBtn{ - background: #BCD1E3; - cursor: default -} -.pointsBtn span{ - display: block; -} -.upload_Title { - position: relative; - margin-right: 20px; - float: left; - line-height: 35px; - font-size: 16px; - /*width: 56px;*/ - color:rgba(0, 0, 0, 0.85); - text-align: center -} -.upload_Title.must:before { - display: inline-block; - margin-right: 4px; - color: #f5222d; - font-size: 14px; - font-family: SimSun, sans-serif; - line-height: 1; - content: '*'; -} -.upload_Title:after{ - content: ':'; - position: relative; - top: -0.5px; - margin: 0 8px 0 2px; -} -.libraries_tab li { - width: 120px; - height: 35px; - line-height: 33px; - border-radius: 18px; - border: 1px solid #4C98FF; - color: #4C98FF; - cursor: pointer; - margin-right: 30px; - float: left; - text-align: center; -} -.libraries_tab li.active { - background: #4C98FF; - color: #fff; -} -.librariesField .ant-upload{ - width: 100%; - background: #F2F9FF; - justify-content: center; - align-items: center; - display: -webkit-flex; - text-align: center; - height: 120px!important; - border-radius: 4px; - border: 1px dashed #4cacff!important; - display: block; - cursor: pointer; -} -.librariesField .ant-upload.ant-upload-drag{ - border:none!important; -} -.uploadImage .ant-upload.ant-upload-select-picture-card{ - width:120px; - height: 90px; -} -.uploadImage .ant-upload.ant-upload-select-picture-card > .ant-upload{ - padding:0px!important; -} -.successPage { - justify-content: center; - align-items: center; - display: -webkit-flex; - height: 570px; - text-align: center; - margin-bottom: 50px; -} -.changebtn { - width:166px; - font-size: 16px; - height: 45px; - line-height: 45px; -} \ No newline at end of file diff --git a/src/modules/moop_cases/index.js b/src/modules/moop_cases/index.js deleted file mode 100644 index 8ac4aa33f..000000000 --- a/src/modules/moop_cases/index.js +++ /dev/null @@ -1,134 +0,0 @@ -import React,{ Component } from "react"; -import './css/moopCases.css' -import '../courses/css/Courses.css' - -import { SnackbarHOC } from 'educoder'; - -import { TPMIndexHOC } from '../tpm/TPMIndexHOC'; -import { CNotificationHOC } from '../courses/common/CNotificationHOC' - -import {BrowserRouter as Router,Route,Switch} from 'react-router-dom'; -import Loading from '../../Loading'; -import Loadable from 'react-loadable'; - -import axios from 'axios'; - -const CaseList = Loadable({ - loader: () => import('./CaseList'), - loading:Loading, -}) -const CaseDetail = Loadable({ - loader: () => import('./CaseDetail'), - loading:Loading, -}) -const CaseNew = Loadable({ - loader: () => import('./CaseNew'), - loading:Loading, -}) -const CaseSuccess = Loadable({ - loader: () => import('./Success'), - loading:Loading, -}) - - - -class Index extends Component{ - constructor(props){ - super(props); - this.state={ - praise_count:0, - CaseDetail:undefined, - cover:undefined, - creator:undefined, - operation:undefined, - tags:undefined, - attachments:undefined, - user_praised:true, - } - } - componentDidMount(){ - - } - // 获取案例详情 - getDetail = (caseID) =>{ - let url=`/libraries/${caseID}.json` - axios.get(url).then((result)=>{ - if(result){ - this.setState({ - CaseDetail:result.data, - praise_count:result.data.praise_count, - cover:result.data.cover, - creator:result.data.creator, - operation:result.data.operation, - user_praised:result.data.operation.user_praised, - tags:result.data.tags, - attachments:result.data.attachments - }) - window.document.title = result.data.title; - } - }).catch((error)=>{ - console.log(error); - }) - } - // 点赞 - praisePoint=(caseID)=>{ - let { praise_count }=this.state; - let url =`/praise_tread/like.json`; - axios.post(url,{ - object_id:caseID, - object_type:"library" - }).then((result)=>{ - if(result){ - this.setState({ - praise_count: parseInt(praise_count)+1, - user_praised:true - }) - } - }).catch((error)=>{ - console.log(error); - }) - } - - render(){ - - return( -
    - - - () - } - > - - () - } - > - - () - } - > - - - () - } - > - - () - } - > - - -
    - ) - } -} -export default CNotificationHOC() ( SnackbarHOC() ( TPMIndexHOC(Index) )); \ No newline at end of file