|
|
@@ -1,16 +1,31 @@
|
|
|
<template>
|
|
|
<div class="discussion-area">
|
|
|
<h1 class="sub-title vertical-center">
|
|
|
- 本页留言板
|
|
|
+ 讨论区
|
|
|
<c-button theme="green" :left="12" :icon="focus ? 'unfold_less' : 'edit'" text @click="handleFocusButtonClick">
|
|
|
{{focus ? '隐藏编辑器' : '发帖'}}
|
|
|
</c-button>
|
|
|
+ <c-button v-if="focus" :no-bold="personal" text :theme="personal ? 'blue' : ''"
|
|
|
+ :icon="personal ? 'check_box' : 'check_box_outline_blank'"
|
|
|
+ @click="handleSetPersonal">私人笔记
|
|
|
+ </c-button>
|
|
|
</h1>
|
|
|
<div class="discussion-area-content">
|
|
|
<show-transition>
|
|
|
- <write-new-comment v-show="focus" class="mb-8" ref="writeComment" @comment-submit="handleCommentSubmit"
|
|
|
+ <write-new-comment :show="personal" v-show="focus" class="mb-8" ref="writeComment"
|
|
|
+ @comment-submit="handleCommentSubmit"
|
|
|
:placeholder="writingAreaPlaceholder"></write-new-comment>
|
|
|
</show-transition>
|
|
|
+ <div v-show="notes.length">
|
|
|
+ <div class="line"><span>私人笔记</span></div>
|
|
|
+ <template v-for="comment of notes">
|
|
|
+ <c-comment :key="'note' + comment.id" :comment="comment" personal
|
|
|
+ @need-refresh="updateComments"
|
|
|
+ >
|
|
|
+ </c-comment>
|
|
|
+ </template>
|
|
|
+ </div>
|
|
|
+ <div class="line"><span>公共讨论区</span></div>
|
|
|
<div class="no-content-warning" v-if="comments === null">
|
|
|
<div class="no-content-warning-tip">加载中...</div>
|
|
|
</div>
|
|
|
@@ -18,7 +33,7 @@
|
|
|
本页还没有讨论
|
|
|
</div>
|
|
|
<template v-for="comment of wsComments">
|
|
|
- <c-comment v-if="comment.pageNumber === currentPage" :key="comment.id" :comment="comment" is-new="true"
|
|
|
+ <c-comment v-if="comment.pageNumber === currentPage" :key="comment.id" :comment="comment" is-new
|
|
|
@need-refresh="updateComments"
|
|
|
>
|
|
|
</c-comment>
|
|
|
@@ -37,35 +52,33 @@
|
|
|
import CComment from '@/components/Discussion/CComment'
|
|
|
import WriteNewComment from '@/components/Discussion/WriteNewComment'
|
|
|
import { mapState } from 'vuex'
|
|
|
-import { createComment, getComments } from '@/server/comment'
|
|
|
+import { createComment, getComments, getSelfCommentsBySlide } from '@/server/comment'
|
|
|
import WebsocketPublisher from '@/server/websocket/ws'
|
|
|
import { useCommentWsServer } from '@/config/server-info'
|
|
|
import CButton from '@/components/Basic/CButton'
|
|
|
import ShowTransition from '@/animations/ShowTransition'
|
|
|
-import { FOCUS_ON_INPUT, USE_FOCUS } from '@/store/types/pdf-types'
|
|
|
+import { FOCUS_ON_INPUT, SET_PERSONAL, USE_FOCUS } from '@/store/types/pdf-types'
|
|
|
|
|
|
export default {
|
|
|
components: { ShowTransition, CButton, WriteNewComment, CComment },
|
|
|
data () {
|
|
|
return {
|
|
|
comments: null,
|
|
|
+ notes: [],
|
|
|
wsComments: [],
|
|
|
slideId: this.$route.params.slideId
|
|
|
}
|
|
|
},
|
|
|
mounted () {
|
|
|
this.initWs()
|
|
|
- if (!this.userInfo) {
|
|
|
- this.$setInfoMessage('需要登录本系统才可以浏览课程内容')
|
|
|
- this.$router.push('login')
|
|
|
- }
|
|
|
this.updateComments()
|
|
|
},
|
|
|
computed: {
|
|
|
...mapState({
|
|
|
userInfo: state => state.main.userInfo,
|
|
|
currentPage: state => state.pdf.currentPage,
|
|
|
- focus: state => state.pdf.focus
|
|
|
+ focus: state => state.pdf.focus,
|
|
|
+ personal: state => state.pdf.personal
|
|
|
}),
|
|
|
writingAreaPlaceholder () {
|
|
|
return '主题'
|
|
|
@@ -95,6 +108,7 @@ export default {
|
|
|
},
|
|
|
updateComments () {
|
|
|
this.getComments(1000)
|
|
|
+ this.getNote(1000)
|
|
|
},
|
|
|
getComments (size) {
|
|
|
return getComments({
|
|
|
@@ -109,12 +123,24 @@ export default {
|
|
|
this.$setErrorMessage('获取本页评论区的过程中:' + err.response.data.msg)
|
|
|
})
|
|
|
},
|
|
|
+ getNote (size) {
|
|
|
+ this.notes = []
|
|
|
+ return getSelfCommentsBySlide({
|
|
|
+ slideId: this.slideId,
|
|
|
+ pageNumber: this.currentPage,
|
|
|
+ show: false,
|
|
|
+ size: 1000
|
|
|
+ })
|
|
|
+ .then(res => (this.notes = res.data))
|
|
|
+ .catch(err => this.$setErrorMessage(err.response.data.msg))
|
|
|
+ },
|
|
|
handleCommentSubmit (comment) {
|
|
|
createComment({
|
|
|
slideId: this.slideId,
|
|
|
pageNumber: this.currentPage,
|
|
|
title: comment.title,
|
|
|
- content: comment.content
|
|
|
+ content: comment.content,
|
|
|
+ show: !this.personal
|
|
|
}).then(res => {
|
|
|
this.$refs.writeComment.resetContent()
|
|
|
this.$setSuccessMessage('您的讨论帖发表成功')
|
|
|
@@ -124,6 +150,9 @@ export default {
|
|
|
},
|
|
|
handleFocusButtonClick () {
|
|
|
this.focus ? this.$store.commit(USE_FOCUS) : this.$store.commit(FOCUS_ON_INPUT)
|
|
|
+ },
|
|
|
+ handleSetPersonal () {
|
|
|
+ this.$store.commit(SET_PERSONAL, { personal: !this.personal })
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -142,21 +171,21 @@ export default {
|
|
|
overflow-x: hidden;
|
|
|
bottom: 0;
|
|
|
right: 0;
|
|
|
- background-color: rgba(250, 250, 250, 0.8);
|
|
|
- /*background-color: rgba(255, 255, 255, 0.8);*/
|
|
|
- backdrop-filter: saturate(150%) blur(20px);
|
|
|
+ box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
|
|
|
+ background-color: white;
|
|
|
+ border: 1px solid #e8e8e8;
|
|
|
}
|
|
|
|
|
|
.no-content-warning {
|
|
|
height: 50px;
|
|
|
}
|
|
|
|
|
|
-.c-comment:nth-child(2n) {
|
|
|
- background-color: rgba(130, 130, 130, 0.05);
|
|
|
+.c-comment:nth-child(2n-1) {
|
|
|
+ background-color: #f9f9f9;
|
|
|
}
|
|
|
|
|
|
-.c-comment:nth-child(2n-1) {
|
|
|
- background-color: rgba(130, 130, 130, 0.1);
|
|
|
+.c-comment:nth-child(2n) {
|
|
|
+ background-color: white;
|
|
|
}
|
|
|
|
|
|
@media (max-width: 500px) {
|
|
|
@@ -165,7 +194,34 @@ export default {
|
|
|
max-width: unset;
|
|
|
left: 0;
|
|
|
right: 0;
|
|
|
- background-color: rgba(255, 255, 255, 0.8);
|
|
|
+ background-color: rgba(255, 255, 255, 1);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+.line {
|
|
|
+ position: relative;
|
|
|
+ font-size: 12px;
|
|
|
+ font-weight: normal;
|
|
|
+ text-align: center;
|
|
|
+ line-height: 0;
|
|
|
+ margin: 4px 0;
|
|
|
+
|
|
|
+ & > span {
|
|
|
+ color: #5a6a7a;
|
|
|
+ display: inline-block;
|
|
|
+ background-color: white;
|
|
|
+ padding: 0 12px;
|
|
|
+ line-height: 12px;
|
|
|
+ }
|
|
|
+
|
|
|
+ &:before {
|
|
|
+ z-index: -1;
|
|
|
+ content: '';
|
|
|
+ width: 100%;
|
|
|
+ position: absolute;
|
|
|
+ left: 0;
|
|
|
+ top: 6px;
|
|
|
+ border-bottom: 1px solid #aabaca;
|
|
|
}
|
|
|
}
|
|
|
</style>
|