统一 noti

dev_admin
hjm 6 years ago
parent 85842e5226
commit 2fb774e243

@ -42,6 +42,7 @@ import './ForumsIndex.css'
import './RightSection.css' import './RightSection.css'
import { SnackbarHOC, getUrl } from 'educoder' import { SnackbarHOC, getUrl } from 'educoder'
import { CNotificationHOC } from '../courses/common/CNotificationHOC'
let _url_origin = getUrl() let _url_origin = getUrl()
@ -248,7 +249,7 @@ class ForumsIndex extends Component {
} }
} }
export default SnackbarHOC() ( TPMIndexHOC ( ForumsIndex ) ); export default CNotificationHOC() (SnackbarHOC() ( TPMIndexHOC ( ForumsIndex ) ));
/* /*
: :

@ -65,7 +65,7 @@ class MemoDetail extends Component {
const memo = response.data.memo const memo = response.data.memo
if (response.data.status === -1) { if (response.data.status === -1) {
setTimeout(() => { setTimeout(() => {
this.props.showSnackbar('帖子不存在!') this.props.showNotification('帖子不存在!')
}, 300) }, 300)
this.props.history.push(`/forums`) this.props.history.push(`/forums`)
return; return;
@ -127,11 +127,11 @@ class MemoDetail extends Component {
const status = response.data.status const status = response.data.status
if (status === 0) { if (status === 0) {
this.props.showSnackbar('删除成功'); this.props.showNotification('删除成功');
this.props.history.push(`/forums`) this.props.history.push(`/forums`)
} else if (status === -1) { } else if (status === -1) {
this.props.showSnackbar('帖子已被删除'); this.props.showNotification('帖子已被删除');
this.props.history.push(`/forums`) this.props.history.push(`/forums`)
} }
}).catch((error) => { }).catch((error) => {
@ -213,9 +213,9 @@ class MemoDetail extends Component {
} }
} }
replyComment = (commentContent, id, editor) => { replyComment = (commentContent, id, editor) => {
const { showSnackbar } = this.props; const { showNotification } = this.props;
if (!commentContent || commentContent.length === 0) { if (!commentContent || commentContent.length === 0) {
showSnackbar('必须填写内容!') showNotification('必须填写内容!')
return; return;
} }
@ -375,7 +375,7 @@ class MemoDetail extends Component {
}) })
} }
rewardCode = (parrentComment, childComment, amount) => { rewardCode = (parrentComment, childComment, amount) => {
const { showSnackbar } = this.props; const { showNotification } = this.props;
const { comments } = this.state; const { comments } = this.state;
let handleComment = parrentComment let handleComment = parrentComment
if (childComment) { if (childComment) {
@ -419,12 +419,12 @@ class MemoDetail extends Component {
} }
}).catch((error) => { }).catch((error) => {
console.log(error) console.log(error)
showSnackbar('奖励失败,请联系系统管理员!') showNotification('奖励失败,请联系系统管理员!')
}) })
} }
hiddenComment = (item, childCommentId) => { hiddenComment = (item, childCommentId) => {
const id = item.id const id = item.id
const { showSnackbar } = this.props; const { showNotification } = this.props;
const user = this._getUser(); const user = this._getUser();
const url = `/memos/${id}/hidden.json` const url = `/memos/${id}/hidden.json`
const { comments } = this.state; const { comments } = this.state;
@ -439,7 +439,7 @@ class MemoDetail extends Component {
} }
).then((response) => { ).then((response) => {
if (response.data.status === -1) { if (response.data.status === -1) {
showSnackbar(response.data.message) showNotification(response.data.message)
return; return;
} }
if (response.data.status === 0) { if (response.data.status === 0) {
@ -598,7 +598,7 @@ class MemoDetail extends Component {
.then((response) => { .then((response) => {
const status = response.data.status const status = response.data.status
if (status === 0) { if (status === 0) {
this.props.showSnackbar( memo.sticky ? '取消置顶成功' : '置顶成功'); this.props.showNotification( memo.sticky ? '取消置顶成功' : '置顶成功');
memo.sticky = memo.sticky ? false : true memo.sticky = memo.sticky ? false : true
this.setState({ this.setState({
memo: Object.assign({}, memo) memo: Object.assign({}, memo)
@ -633,9 +633,9 @@ class MemoDetail extends Component {
this.props.initForumState({ this.props.initForumState({
memo: newMemo memo: newMemo
}) })
this.props.showSnackbar( '奖励成功' ); this.props.showNotification( '奖励成功' );
} else { } else {
this.props.showSnackbar( '奖励失败,请联系系统管理员!' ); this.props.showNotification( '奖励失败,请联系系统管理员!' );
} }
}).catch((error) => { }).catch((error) => {
console.log(error) console.log(error)

@ -176,9 +176,9 @@ class MemoNew extends Component {
} }
onCommit() { onCommit() {
const { memoSubject, memoRepertoire, memoLanguage, currentMemoId, memoType } = this.state; const { memoSubject, memoRepertoire, memoLanguage, currentMemoId, memoType } = this.state;
const { showSnackbar } = this.props; const { showNotification } = this.props;
if (!memoSubject) { if (!memoSubject) {
showSnackbar('请先输入话题名称') showNotification('请先输入话题名称')
return return
} }
let mdVal; let mdVal;
@ -186,17 +186,17 @@ class MemoNew extends Component {
mdVal = this.mdRef.current.getValue() mdVal = this.mdRef.current.getValue()
} catch (e) { } catch (e) {
showSnackbar('编辑器还未加载完毕,请稍后') showNotification('编辑器还未加载完毕,请稍后')
return return
} }
if (!mdVal) { if (!mdVal) {
showSnackbar('请先输入话题内容') showNotification('请先输入话题内容')
return return
} }
// !memoRepertoire || // !memoRepertoire ||
if (memoType === 5 && ( !memoLanguage || memoLanguage.length === 0 )) { if (memoType === 5 && ( !memoLanguage || memoLanguage.length === 0 )) {
showSnackbar('请先选择技术标签') showNotification('请先选择技术标签')
return return
} }
/* /*
@ -267,7 +267,7 @@ class MemoNew extends Component {
window.$("html,body").animate({"scrollTop":0}) window.$("html,body").animate({"scrollTop":0})
this.props.history.push(`/forums/${currentMemoId}`) this.props.history.push(`/forums/${currentMemoId}`)
} else { } else {
this.props.showSnackbar(message) this.props.showNotification(message)
} }
}).catch((error) => { }).catch((error) => {
console.log(error) console.log(error)
@ -297,7 +297,7 @@ class MemoNew extends Component {
window.$("html,body").animate({"scrollTop":0}) window.$("html,body").animate({"scrollTop":0})
this.props.history.push(`/forums/${memo_id}`) this.props.history.push(`/forums/${memo_id}`)
} else { } else {
this.props.showSnackbar(message) this.props.showNotification(message)
} }
}).catch((error) => { }).catch((error) => {
console.log(error) console.log(error)
@ -481,7 +481,7 @@ class MemoNew extends Component {
onTagChange(value) { onTagChange(value) {
if (value && value.length > 3) { if (value && value.length > 3) {
this.props.showSnackbar(`最多选择3个技术标签`) this.props.showNotification(`最多选择3个技术标签`)
return; return;
} }

@ -276,7 +276,7 @@ return function wrap(WrappedComponent) {
const status = response.data.status const status = response.data.status
if (status === 0) { if (status === 0) {
this.props.showSnackbar('删除成功'); this.props.showNotification('删除成功');
// 刷新列表 // 刷新列表
this.fetchMemos(); this.fetchMemos();
} }

Loading…
Cancel
Save