|
|
@@ -44,6 +44,7 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
mounted () {
|
|
|
+ this.initWs()
|
|
|
if (!this.userInfo) {
|
|
|
this.$setInfoMessage('需要登录本系统才可以浏览课程内容')
|
|
|
this.$router.push('login')
|
|
|
@@ -66,22 +67,22 @@ export default {
|
|
|
this.updateComments()
|
|
|
}
|
|
|
},
|
|
|
- created () {
|
|
|
- this._ws = new WebsocketPublisher(useCommentWsServer('/slide/') + this.slide.id)
|
|
|
- this._ws.subscribe({
|
|
|
- onNext: data => {
|
|
|
- this.wsComments.unshift(data)
|
|
|
- },
|
|
|
- onError: err => {
|
|
|
- this.$setErrorMessage(err)
|
|
|
- },
|
|
|
- onClose: () => {}
|
|
|
- })
|
|
|
- },
|
|
|
beforeDestroy () {
|
|
|
this._ws.close()
|
|
|
},
|
|
|
methods: {
|
|
|
+ initWs () {
|
|
|
+ this._ws = new WebsocketPublisher(useCommentWsServer('/slide/') + this.slide.id)
|
|
|
+ this._ws.subscribe({
|
|
|
+ onNext: data => {
|
|
|
+ this.wsComments.unshift(data)
|
|
|
+ },
|
|
|
+ onError: err => {
|
|
|
+ this.$setErrorMessage(err)
|
|
|
+ },
|
|
|
+ onClose: () => {}
|
|
|
+ })
|
|
|
+ },
|
|
|
updateComments () {
|
|
|
this.getComments(30).then(() => {
|
|
|
this.getComments(10000)
|