From 8854a363de729ea8a1714d178aa138cda8d8d830 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Fri, 10 Jan 2020 10:40:51 +0800 Subject: [PATCH 1/3] seo --- public/react/public/index.html | 12 ++++++++++++ public/react/src/modules/tpm/TPMIndexHOC.js | 21 +++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/public/react/public/index.html b/public/react/public/index.html index 303128b18..4aa03bc6b 100755 --- a/public/react/public/index.html +++ b/public/react/public/index.html @@ -7,6 +7,18 @@ + + + + + + + + + + + + diff --git a/public/react/src/modules/tpm/TPMIndexHOC.js b/public/react/src/modules/tpm/TPMIndexHOC.js index aa88d7ea7..363acdba1 100644 --- a/public/react/src/modules/tpm/TPMIndexHOC.js +++ b/public/react/src/modules/tpm/TPMIndexHOC.js @@ -166,6 +166,27 @@ export function TPMIndexHOC(WrappedComponent) { document.title="翻转课堂"; } + // if(this.props.match.path==="/"){ + // document.title="EduCoder-IT实践教学平台_信息技术类精品课程网_大学生MOOC平台"; + // }else if(this.props.match.path==="/403"){ + // document.title="你没有权限访问"; + // }else if(this.props.match.path==="/nopage"){ + // document.title="没有找到该页面"; + // }else if(this.props.match.path==="/shixuns"){ + // document.title="EduCoder-IT实践教学平台_信息技术类精品课程网_大学生MOOC平台"; + // }else if(this.props.match.path==="/paths"){ + // document.title="实践课程_项目实战开发_web前端开发实训_web后端开发实战_人工智能技术-EduCoder"; + // }else if(this.props.match.path==="/courses"){ + // document.title="实训项目_php后端开发_app前端开发_java_python实训_C语言入门课程-EduCoder"; + // }else if(this.props.match.path==="/competitions"){ + // document.title="在线竞赛_计算机应用大赛_编程大赛_大学生设计大赛_全国高校绿色计算大赛-EduCoder"; + // }else if(this.props.match.path==="/moop_cases"){ + // document.title="教学案例-EduCoder"; + // }else if(this.props.match.path==="/forums"){ + // document.title="交流问答-EduCoder"; + // }else if(this.props.match.path==="/forums"){ + // document.title="交流问答-EduCoder"; + // } $.ajaxSetup({ cache: true From 12ad095236bf9087309e70593d1fdd977206b0a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Fri, 10 Jan 2020 13:51:12 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/modules/courses/boards/TopicDetail.js | 132 +++++++++--------- .../courses/common/comments/CommonReply.js | 46 +++--- .../graduation/topics/GraduateTopicReply.js | 44 +++--- public/react/src/modules/forums/MemoDetail.js | 124 ++++++++-------- .../src/modules/forums/MemoDetailKEEditor.js | 32 ++--- .../src/modules/forums/MemoDetailMDEditor.js | 41 +++--- .../modules/forums/MemoDetailMDEditortwo.js | 14 +- public/react/src/search/searchc.css | 5 +- 8 files changed, 224 insertions(+), 214 deletions(-) diff --git a/public/react/src/modules/courses/boards/TopicDetail.js b/public/react/src/modules/courses/boards/TopicDetail.js index d42b68c17..e8767fb87 100644 --- a/public/react/src/modules/courses/boards/TopicDetail.js +++ b/public/react/src/modules/courses/boards/TopicDetail.js @@ -65,7 +65,7 @@ class TopicDetail extends Component { const topicId = this.props.match.params.topicId const bid = this.props.match.params.boardId - + const memoUrl = `/messages/${topicId}.json`; this.setState({ memoLoading: true @@ -73,7 +73,7 @@ class TopicDetail extends Component { axios.get(memoUrl,{ }) .then((response) => { - + if (response.data.status === -1) { setTimeout(() => { this.props.showNotification('帖子不存在!') @@ -81,7 +81,7 @@ class TopicDetail extends Component { // this.props.toListPage(response.data.data.course_id, bid) return; } else { - + this.setState({ memo: Object.assign({}, { ...response.data.data, @@ -93,7 +93,7 @@ class TopicDetail extends Component { // const { memo_replies, memo } = response.data; // let hasMoreComments = false; - // if (memo_replies && memo_replies.length === 10 && memo.total_replies_count > 10) { + // if (memo_replies && memo_replies.length === 10 && memo.total_replies_count > 10) { // // 遍历一遍,计算下是否还有评论未加载 // let totalCount = 10; // memo_replies.forEach(item=>{ @@ -123,14 +123,14 @@ class TopicDetail extends Component { }) this.fetchReplies() - - $('body>#root').on('onMemoDelete', (event) => { + + $('body>#root').on('onMemoDelete', (event) => { // const val = $('body>#root').data('onMemoDelete') const val = window.onMemoDelete ; this.onMemoDelete( JSON.parse(decodeURIComponent(val)) ) }) - + } onPaginationChange = (pageCount) => { @@ -157,7 +157,7 @@ class TopicDetail extends Component { this.props.showNotification('删除成功'); const props = Object.assign({}, this.props, {}) this.props.toListPage( Object.assign({}, this.props.match.params, {'coursesId': this.state.memo.course_id} ) ) - + } else if (status === -1) { this.props.showNotification('帖子已被删除'); this.props.history.push(`/forums`) @@ -168,11 +168,11 @@ class TopicDetail extends Component { } componentDidUpdate(prevProps, prevState, snapshot) { - // if (this.state.memo && this.state.memo.content + // if (this.state.memo && this.state.memo.content // && (!prevProps.memo || prevProps.memo.content != this.state.memo.content) ) { if (this.state.memo && this.state.memo.content && prevState.memoLoading === true && this.state.memoLoading === false) { // md渲染content,等xhr执行完(即memoLoading变化),memo.content更新后初始化md - + setTimeout(()=>{ // var shixunDescr = window.editormd.markdownToHTML("memo_content_editorMd", { // htmlDecode: "style,script,iframe", // you can filter tags decode @@ -183,7 +183,7 @@ class TopicDetail extends Component { // }); }, 200) } - + } clickPraise(){ @@ -192,7 +192,7 @@ class TopicDetail extends Component { const url = memo.user_praise ? '/praise_tread/unlike.json' : `/praise_tread/like.json`; const _method = memo.user_praise ? axios.delete : axios.post let _data = { - object_id: memo.id, + object_id: memo.id, object_type: 'message', //Discuss } if (memo.user_praise) { @@ -204,10 +204,10 @@ class TopicDetail extends Component { ..._data }, { - + } ).then((response) => { - + const newMemo = Object.assign({}, this.state.memo) newMemo.praises_count = newMemo.user_praise ? newMemo.praises_count - 1 : newMemo.praises_count + 1 newMemo.total_praises_count = newMemo.user_praise ? newMemo.total_praises_count - 1 : newMemo.total_praises_count + 1 @@ -248,10 +248,10 @@ class TopicDetail extends Component { className="mr12 color9B9B overflowHidden1" length="58" style={{maxWidth: '480px'}}> {fileName} - + {item.filesize} - + ) }) @@ -268,7 +268,7 @@ class TopicDetail extends Component { permission: true, // children: children, child_message_count: reply.total_count, - hidden: reply.is_hidden, + hidden: reply.is_hidden, id: reply.id, image_url: reply.author.image_url, reward: null, // @@ -289,7 +289,7 @@ class TopicDetail extends Component { }) .then((response) => { const { replies, liked, total_replies_count, total_count } = response.data.data - + const memo = Object.assign({}, this.state.memo) memo.user_praise = liked memo.total_replies_count = total_replies_count; @@ -322,15 +322,15 @@ class TopicDetail extends Component { return; } const url = `/messages/${id}/reply.json`; - + const { comments } = this.state; const user = this._getUser(); /* 移除末尾的空行 .replace(/(\n
\n\t
\n<\/p>)*$/g,'');
-
+
*/
-
+
commentContent = handleContentBeforeCreateSecondLevelComment(commentContent)
if (!commentContent) {
this.props.showNotification('不能为空')
@@ -340,9 +340,9 @@ class TopicDetail extends Component {
content: commentContent
},
{
- }
+ }
).then((response) => {
- if (response.data.data.id) {
+ if (response.data.data.id) {
let newId = response.data.data.id;
const commentIndex = this._findById(id, comments);
const parentComment = comments[commentIndex]
@@ -361,7 +361,7 @@ class TopicDetail extends Component {
memo: newMemo2
})
}
-
+
}).catch((error) => {
console.log(error)
})
@@ -369,14 +369,14 @@ class TopicDetail extends Component {
// 公共接口 --- 删除回复
deleteComment = (parrentComment, childCommentId) => {
handleDeleteComment(this, parrentComment, childCommentId, 'message')
-
+
}
// 公共接口 --- 回复点赞
commentPraise = (discussId) => {
handleCommentPraise(this, discussId, 'message', (old_user_praise) => {
const newMemo2 = Object.assign({}, this.state.memo);
- newMemo2.total_praises_count = old_user_praise
+ newMemo2.total_praises_count = old_user_praise
? newMemo2.total_praises_count - 1 : newMemo2.total_praises_count + 1;
this.setState({
memo: newMemo2
@@ -390,7 +390,7 @@ class TopicDetail extends Component {
createNewComment = (commentContent, id, editor) => {
let content = handleContentBeforeCreateNew(commentContent);
const { memo } = this.props;
-
+
const url = `/messages/${id}/reply.json`;
// const url = `/api/v1/memos/${memo.id}/reply`;
@@ -399,7 +399,7 @@ class TopicDetail extends Component {
content: content
},
{
- }
+ }
).then((response) => {
if (response.data.status === -1) {
console.error('服务端异常')
@@ -407,15 +407,15 @@ class TopicDetail extends Component {
}
// this.props.showNotification('帖子发表成功')
- if (response.data) {
+ if (response.data) {
const _id = response.data.data.id;
// ke
editor.html && editor.html('');
editor.afterBlur && editor.afterBlur()
// md
editor.setValue && editor.setValue('')
-
-
+
+
const user = this._getUser();
this.setState({
comments: addNewComment(comments, _id, content, user, this.props.isSuperAdmin(), this)
@@ -427,8 +427,8 @@ class TopicDetail extends Component {
})
this.refs.editor.showEditor();
this.refs.editor.close();
-
-
+
+
}
}).catch((error) => {
console.log(error)
@@ -444,7 +444,7 @@ class TopicDetail extends Component {
})
.then((response) => {
const { replies, liked, total_replies_count } = response.data.data
-
+
// const memo = Object.assign({}, this.state.memo)
// memo.total_replies_count = total_replies_count;
this.setState({
@@ -460,19 +460,19 @@ class TopicDetail extends Component {
// 置顶
setTop(memo) {
// const params = {
- // sticky: memo.sticky ? 0 : 1,
+ // sticky: memo.sticky ? 0 : 1,
// }
- // if (this.state.p_s_order) {
+ // if (this.state.p_s_order) {
// params.order = this.state.p_s_order;
// }
- // if (this.state.p_forum_id) {
+ // if (this.state.p_forum_id) {
// params.forum_id = this.state.p_forum_id;
// }
// let paramsUrl = urlStringify(params)
const set_top_or_down_Url = `/messages/${memo.id}/sticky_top.json`;
// 获取memo list
axios.put(set_top_or_down_Url, {
-
+
})
.then((response) => {
const status = response.data.status
@@ -487,7 +487,7 @@ class TopicDetail extends Component {
console.log(error)
})
}
-
+
setRewardDialogVisible = (visible) => {
this.setState({
goldRewardDialogOpen: visible
@@ -512,7 +512,7 @@ class TopicDetail extends Component {
}
}
-
+
render() {
const { match, history } = this.props
const { recommend_shixun, current_user,author_info } = this.props;
@@ -567,7 +567,7 @@ class TopicDetail extends Component {
\n\t
\n<\/p>)*$/g,'');
-
+
*/
if (commentContent) {
commentContent = commentContent.replace(/(\n
\n\t
\n<\/p>)*$/g,'');
@@ -254,10 +254,10 @@ class MemoDetail extends Component {
},
{
// withCredentials: true
- }
+ }
).then((response) => {
response.data.memo = response.data
- if (response.data.memo) {
+ if (response.data.memo) {
let newDiscuss = response.data.memo;
var commentIndex = this._findById(id, comments);
@@ -278,8 +278,8 @@ class MemoDetail extends Component {
// "position": newDiscuss.position,
"time": "1分钟前",
"praise_count": 0,
-
- "user_id": newDiscuss.author_id,
+
+ "user_id": newDiscuss.author_id,
})
@@ -292,9 +292,9 @@ class MemoDetail extends Component {
const $ = window.$
var view_selector = `.commentItemMDEditorView_${id}`
$(view_selector).hide();
- }
+ }
+
-
this.setState({
// runTesting: false,
comments: comments
@@ -320,15 +320,15 @@ class MemoDetail extends Component {
deleteCommentId = childCommentId;
}
const url = `/memos/${deleteCommentId}.json`
- let comments = this.state.comments;
+ let comments = this.state.comments;
axios.delete(url,
{
// withCredentials: true
- }
+ }
).then((response) => {
// TODO 删除成功或失败
- if (response.data && response.data.status === 0) {
+ 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
@@ -371,13 +371,13 @@ class MemoDetail extends Component {
},
{
// withCredentials: true
- }
+ }
).then((response) => {
- if (response.data.praise_count === 0 || response.data.praise_count) {
-
+ 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
})
@@ -406,9 +406,9 @@ class MemoDetail extends Component {
},
{
// withCredentials: true
- }
+ }
).then((response) => {
- if (response.data && response.data.code) {
+ if (response.data && response.data.code) {
const commentIndex = this._findById(parrentComment.id, comments);
if (childComment) {
@@ -418,13 +418,13 @@ class MemoDetail extends Component {
parrentComment.children[childCommentIndex] = newChildComment
comments[commentIndex] = parrentComment;
-
+
this.setState({
comments
})
} else {
comments[commentIndex].reward = response.data.code;
-
+
this.setState({
comments
})
@@ -449,14 +449,14 @@ class MemoDetail extends Component {
},
{
// withCredentials: true
- }
+ }
).then((response) => {
- if (response.data.status === -1) {
+ if (response.data.status === -1) {
showNotification(response.data.message)
return;
}
- if (response.data.status === 0) {
-
+ if (response.data.status === 0) {
+
if (!childCommentId) {
comment.hidden = !comment.hidden;
this.setState({
@@ -468,7 +468,7 @@ class MemoDetail extends Component {
childComment.hidden = !childComment.hidden;
this.setState({ comments })
}
-
+
}
// {"message":"Couldn't find Discuss with id=911","status":-1}
@@ -481,7 +481,7 @@ class MemoDetail extends Component {
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] == ""){
@@ -500,13 +500,13 @@ class MemoDetail extends Component {
},
{
// withCredentials: true
- }
+ }
).then((response) => {
if (response.data.status === -1) {
console.error('服务端异常')
return;
}
- if (response.data) {
+ if (response.data) {
response.data.memo = response.data
const newMemo = response.data.memo;
// ke
@@ -533,11 +533,11 @@ class MemoDetail extends Component {
"user_praise": false,
"time": "1分钟前",
"praise_count": 0,
-
- "user_id": user.user_id,
+
+ "user_id": user.user_id,
})
-
+
this.setState({
comments
})
@@ -558,11 +558,11 @@ class MemoDetail extends Component {
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('服务端异常')
@@ -575,7 +575,7 @@ class MemoDetail extends Component {
})
return;
}
- if (response.data.memos_count) {
+ if (response.data.memos_count) {
const newComments = comments.concat(memo_replies);
const hasMoreComments = memo_replies.length === 10
this.setState({
@@ -595,12 +595,12 @@ class MemoDetail extends Component {
// 置顶
setTop(memo) {
const params = {
- sticky: memo.sticky ? 0 : 1,
+ sticky: memo.sticky ? 0 : 1,
}
- if (this.state.p_s_order) {
+ if (this.state.p_s_order) {
params.order = this.state.p_s_order;
}
- if (this.state.p_forum_id) {
+ if (this.state.p_forum_id) {
params.forum_id = this.state.p_forum_id;
}
let paramsUrl = urlStringify(params)
@@ -628,7 +628,7 @@ class MemoDetail extends Component {
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, {
@@ -667,6 +667,8 @@ class MemoDetail extends Component {
}
// --------------------------------------------------------------------------------------------帖子獎勵 END
showCommentInput = () => {
+
+ debugger
if (window.__useKindEditor === true) {
this.refs.editor.showEditor();
} else {
@@ -702,8 +704,8 @@ class MemoDetail extends Component {
margin-top: 6px;
}
`}
-
-