detail接口

dev_hjm^2
hjm 6 years ago
parent 7b556ee4bf
commit 85861a3396

@ -349,8 +349,12 @@ class App extends Component {
{/*课堂*/}
<Route path="/courses" component={CoursesIndex} {...this.props}></Route>
{/* <Route path="/forums" component={ForumsIndexComponent}>
</Route> */}
<Route path="/forums"
render={
(props)=>(<ForumsIndexComponent {...this.props} {...props} {...this.state}></ForumsIndexComponent>)
}
>
</Route>
<Route path="/comment" component={CommentComponent}/>
<Route path="/testMaterial" component={TestMaterialDesignComponent}/>

@ -90,6 +90,8 @@ class MemoDetail extends Component {
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;
@ -116,7 +118,7 @@ class MemoDetail extends Component {
$('body>#root').off('onMemoDelete')
}
onMemoDelete(memo) {
const deleteUrl = `/api/v1/memos/${memo.id}`;
const deleteUrl = `/memos/${memo.id}.json`;
// 获取memo list
axios.delete(deleteUrl, {
// withCredentials: true,
@ -158,14 +160,14 @@ class MemoDetail extends Component {
clickPraise(){
const { memo } = this.props;
const url = `/api/v1/discusses/${memo.id}/plus`;
const url = `/discusses/${memo.id}/plus.json`;
console.log(url)
axios.post(url, {
container_type: 'Memo',
type: 1 // "踩0赞1"
},
{
withCredentials: true
// withCredentials: true
}
).then((response) => {
console.log(response);
@ -223,7 +225,8 @@ class MemoDetail extends Component {
this.createNewComment(commentContent, id, editor);
return;
}
const url = `/memos/${id}/reply.json`;
// /${id}
const url = `/memos/reply.json`;
const { comments } = this.state;
const user = this._getUser();
/*
@ -235,12 +238,14 @@ class MemoDetail extends Component {
commentContent = commentContent.replace(/(\n<p>\n\t<br \/>\n<\/p>)*$/g,'');
}
axios.post(url, {
parent_id: id,
content: commentContent
},
{
withCredentials: true
// withCredentials: true
}
).then((response) => {
response.data.memo = response.data
if (response.data.memo) {
let newDiscuss = response.data.memo;
@ -303,12 +308,12 @@ class MemoDetail extends Component {
if (childCommentId) {
deleteCommentId = childCommentId;
}
const url = `/api/v1/memos/${deleteCommentId}`
const url = `/memos/${deleteCommentId}.json`
let comments = this.state.comments;
axios.delete(url,
{
withCredentials: true
// withCredentials: true
}
).then((response) => {
// TODO 删除成功或失败
@ -346,7 +351,7 @@ class MemoDetail extends Component {
const { comments } = this.state;
const commentIndex = this._findById(discussId, comments);
const url = `/api/v1/discusses/${discussId}/plus`
const url = `/discusses/${discussId}/plus.json`
axios.post(url, {
// id: discussId,
// container_id: challenge.id,
@ -354,7 +359,7 @@ class MemoDetail extends Component {
type: comments[commentIndex].user_praise === true ? 0 : 1, // "踩0赞1"
},
{
withCredentials: true
// withCredentials: true
}
).then((response) => {
if (response.data.praise_count === 0 || response.data.praise_count) {
@ -379,7 +384,7 @@ class MemoDetail extends Component {
handleComment = childComment;
}
let handleCommentId = handleComment.id;
const url = `/api/v1/discusses/${handleCommentId}/reward_code`
const url = `/discusses/${handleCommentId}/reward_code.json`
axios.post(url, {
id: handleCommentId,
@ -389,7 +394,7 @@ class MemoDetail extends Component {
user_id: handleComment.user_id
},
{
withCredentials: true
// withCredentials: true
}
).then((response) => {
if (response.data && response.data.code) {
@ -423,7 +428,7 @@ class MemoDetail extends Component {
const id = item.id
const { showSnackbar } = this.props;
const user = this._getUser();
const url = `/api/v1/memos/${id}/hidden`
const url = `/memos/${id}/hidden.json`
const { comments } = this.state;
const commentIndex = this._findById(id, comments);
@ -432,7 +437,7 @@ class MemoDetail extends Component {
hidden: !comment.hidden ? "1" : "0"
},
{
withCredentials: true
// withCredentials: true
}
).then((response) => {
if (response.data.status === -1) {
@ -473,10 +478,12 @@ class MemoDetail extends Component {
return;
}
}
const url = `/memos/${memo.id}/reply.json`;
// /${memo.id}
const url = `/memos/reply.json`;
let { comments } = this.state;
const user = this._getUser();
axios.post(url, {
parent_id: memo.id,
content: content
},
{
@ -488,6 +495,7 @@ class MemoDetail extends Component {
return;
}
if (response.data) {
response.data.memo = response.data
const newMemo = response.data.memo;
// ke
editor.html && editor.html('');
@ -536,12 +544,12 @@ class MemoDetail extends Component {
let { comments, pageCount } = this.state;
let { memo } = this.props;
const user = this._getUser();
const url = `/api/v1/memos/${memo.id}/more_reply?page=${pageCount}`;
const url = `/memos/${memo.id}/more_reply.json?page=${pageCount}`;
axios.get(url, {
},
{
withCredentials: true
// withCredentials: true
}
).then((response) => {
if (response.data.status === -1) {
@ -608,9 +616,8 @@ class MemoDetail extends Component {
const { memo, author_info } = this.props;
const newMemo = Object.assign({}, memo);
const _reward = parseInt(inputVal)
const newMemoUrl = `/api/v1/memos/${memo.id}/update`
const url = `/api/v1/discusses/${memo.id}/reward_code`
const url = `/discusses/${memo.id}/reward_code.json`
axios.post(url, {
id: memo.id,

@ -42,7 +42,7 @@ class MemoDetailMDEditor extends Component {
window.__tt = 400;
setTimeout(() => {
var commentMDEditor = window.create_editorMD_4comment("memo_comment_editorMd", '', this.props.height || 240, placeholder, imageUrl, () => {
commentMDEditor.focus()
// commentMDEditor.focus()
this.isMDInited = true
this.initDrag()

@ -15,6 +15,7 @@ import Upload from 'rc-upload';
import axios from 'axios'
import 'antd/lib/select/style/index.css'
import TPMMDEditor from '../tpm/challengesnew/TPMMDEditor'
import { getUrl } from 'educoder'
const Option = Select.Option;
@ -130,6 +131,7 @@ const languageSeparator = '/'
class MemoNew extends Component {
constructor(props) {
super(props)
this.mdRef = React.createRef();
// https://testbdweb.trustie.net/uploads.js?attachment_id=1&filename=jqui.js
// https://ant.design/components/upload-cn/
@ -179,7 +181,7 @@ class MemoNew extends Component {
}
let mdVal;
try {
mdVal = this.taskpass_editormd.getValue()
mdVal = this.mdRef.current.getValue()
} catch (e) {
showSnackbar('编辑器还未加载完毕,请稍后')
@ -205,6 +207,7 @@ class MemoNew extends Component {
// collect attachments
const $ = window.$;
const attachmentsMap = {};
const attachmentIds = []
$('#attachments_fields .attachment').each(( index, item ) => {
const filename = $(item).find('.upload_filename').val();
// $($('#attachments_fields .attachment')[0]).find('input:nth-child(6)').val()
@ -215,13 +218,14 @@ class MemoNew extends Component {
token,
attachment_id
}
attachmentIds.push(attachment_id)
})
if (currentMemoId) {
this.updateMemo(attachmentsMap)
this.updateMemo(attachmentIds)
} else {
this.newMemo(attachmentsMap)
this.newMemo(attachmentIds)
}
}
onCancel() {
@ -235,20 +239,20 @@ class MemoNew extends Component {
}
updateMemo(attachmentsMap) {
const { memoSubject, memoRepertoire, memoLanguage, memoType, currentMemoId, content } = this.state;
const mdVal = this.taskpass_editormd.getValue()
const mdVal = this.mdRef.current.getValue()
console.log('isContentEdit: ', mdVal === content);
const newMemoUrl = `/api/v1/memos/${currentMemoId}/update`
axios.post(newMemoUrl, {
const newMemoUrl = `/memos/${currentMemoId}.json`
axios.put(newMemoUrl, {
content_changed: this.contentChanged,
tags: memoLanguage,
memo:{
// memo:{
subject: memoSubject ,
content: mdVal,
forum_id: memoType,
repertoire_name: memoRepertoire,
// language: memoLanguage.join(languageSeparator),
//
},
// },
attachments: attachmentsMap
}, {
// withCredentials: true,
@ -267,18 +271,18 @@ class MemoNew extends Component {
}
newMemo(attachmentsMap) {
const { memoSubject, memoRepertoire, memoLanguage, memoType } = this.state;
const mdVal = this.taskpass_editormd.getValue()
const mdVal = this.mdRef.current.getValue()
const newMemoUrl = `/api/v1/memos/create`
const newMemoUrl = `/memos.json`
axios.post(newMemoUrl, {
tags: memoLanguage,
memo:{
// memo:{
subject: memoSubject ,
content: mdVal,
forum_id: memoType,
repertoire_name: memoRepertoire,
// repertoire_name: memoRepertoire,
},
// },
attachments: attachmentsMap
}, {
// withCredentials: true,
@ -296,7 +300,7 @@ class MemoNew extends Component {
})
}
componentDidMount() {
const newMemoUrl = `/api/v1/memos/new`
const newMemoUrl = `/memos/new.json`
axios.get(newMemoUrl,{
// withCredentials: true,
})
@ -336,7 +340,7 @@ class MemoNew extends Component {
const { match } = this.props
const memoId = match.params.memoId;
if (memoId) {
const memoUrl = `/api/v1/memos/${match.params.memoId}/edit`;
const memoUrl = `/memos/${match.params.memoId}/edit.json`;
axios.get(memoUrl,{
// withCredentials: true,
})
@ -344,10 +348,12 @@ class MemoNew extends Component {
const tag_list = response.data.tag_list
if (tag_list) {
// this.setState({...response.data})
const { content, forum_id, id, tag, repertoire_name, subject,
current_user, tag_list, attachments_url } = response.data;
const { content, forum_id, id, repertoire_name, subject,
current_user, tag_list, attachments_url, memo_tags } = 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) => {
@ -355,7 +361,7 @@ class MemoNew extends Component {
})
}
this.setState({
currentMemoId: id,
currentMemoId: memoId,
memoSubject: subject,
memoType: forum_id,
memoRepertoire: repertoire_name,
@ -377,7 +383,7 @@ class MemoNew extends Component {
window.$("html,body").animate({"scrollTop":0})
this.props.initForumState({
current_user,
// current_user,
tag_list
})
}
@ -394,6 +400,8 @@ class MemoNew extends Component {
}
initMD(initValue) {
return;
this.contentChanged = false;
const placeholder = "";
// amp;
@ -566,9 +574,12 @@ class MemoNew extends Component {
<div className="df">
<span className="mr30 color-orange pt10">*</span>
<div className="flex1 mr20">
<div className="flex1 break_word show_content_grey new_li" id="memoMD">
<TPMMDEditor ref={this.mdRef} placeholder={''} watch={false}
mdID={'memoMD'} initValue={this.state.content} className="memoMD">
</TPMMDEditor>
{/* <div className="flex1 break_word show_content_grey new_li" id="memoMD">
<textarea style={{'display':'none'}}></textarea>
</div>
</div> */}
<p id="e_tip_memoNew" className="edu-txt-right color-grey-cd font-12"></p>
<p id="e_tips_memoNew" className="edu-txt-right color-grey-cd font-12"></p>
</div>

Loading…
Cancel
Save