解决切换页面后编辑器异常
This commit is contained in:
parent
719e716c6f
commit
ca2ec55a72
@ -148,7 +148,9 @@ export default {
|
|||||||
avatarURL: null,
|
avatarURL: null,
|
||||||
email: null,
|
email: null,
|
||||||
blog: null
|
blog: null
|
||||||
}
|
},
|
||||||
|
editorObj: null,
|
||||||
|
editorReplyObj: null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted () {
|
mounted () {
|
||||||
@ -167,16 +169,25 @@ export default {
|
|||||||
window.localStorage.visitorInfo = JSON.stringify(visitorInfo)
|
window.localStorage.visitorInfo = JSON.stringify(visitorInfo)
|
||||||
this.visitorToken = visitorToken
|
this.visitorToken = visitorToken
|
||||||
this.visitorInfo = visitorInfo
|
this.visitorInfo = visitorInfo
|
||||||
window.editorObj.vditor.options.upload.headers = {
|
this.editorObj.vditor.options.upload.headers = {
|
||||||
Authorization: 'Bearer ' + this.visitorToken
|
Authorization: 'Bearer ' + this.visitorToken
|
||||||
}
|
}
|
||||||
window.editorReplyObj.vditor.options.upload.headers = {
|
this.editorReplyObj.vditor.options.upload.headers = {
|
||||||
Authorization: 'Bearer ' + this.visitorToken
|
Authorization: 'Bearer ' + this.visitorToken
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!window.editorObj && window.Vditor) {
|
|
||||||
this.initEditor()
|
this.$nextTick(() => {
|
||||||
}
|
if (this.$route.query.hash) {
|
||||||
|
setTimeout(() => {
|
||||||
|
window.location.hash = '#' + this.$route.query.hash
|
||||||
|
}, 50)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!this.editorObj && window.Vditor) {
|
||||||
|
this.initEditor()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
this.setCommentMap()
|
this.setCommentMap()
|
||||||
}
|
}
|
||||||
@ -253,15 +264,6 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.$route.query.hash) {
|
|
||||||
this.$nextTick(() => {
|
|
||||||
setTimeout(() => {
|
|
||||||
window.location.hash = '#' + this.$route.query.hash
|
|
||||||
console.log('#' + this.$route.query.hash)
|
|
||||||
}, 50)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
(adsbygoogle = window.adsbygoogle || []).push({}) // eslint-disable-line
|
(adsbygoogle = window.adsbygoogle || []).push({}) // eslint-disable-line
|
||||||
} catch (_) { }
|
} catch (_) { }
|
||||||
@ -290,7 +292,7 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
window.editorObj = new window.Vditor('editor', {
|
this.editorObj = new window.Vditor('editor', {
|
||||||
toolbar: [
|
toolbar: [
|
||||||
'emoji',
|
'emoji',
|
||||||
'headings',
|
'headings',
|
||||||
@ -338,7 +340,7 @@ export default {
|
|||||||
placeholder: '我们书写的不是代码,而是人生'
|
placeholder: '我们书写的不是代码,而是人生'
|
||||||
})
|
})
|
||||||
|
|
||||||
window.editorReplyObj = new window.Vditor('editor-reply', {
|
this.editorReplyObj = new window.Vditor('editor-reply', {
|
||||||
toolbar: [
|
toolbar: [
|
||||||
'emoji',
|
'emoji',
|
||||||
'headings',
|
'headings',
|
||||||
@ -495,13 +497,13 @@ export default {
|
|||||||
this.replyLastID = replyLastID
|
this.replyLastID = replyLastID
|
||||||
document.getElementById('comment_ID_' + id).appendChild(editorReplyObject)
|
document.getElementById('comment_ID_' + id).appendChild(editorReplyObject)
|
||||||
const comment = this.commentsMap.get(replyLastID)
|
const comment = this.commentsMap.get(replyLastID)
|
||||||
window.editorReplyObj.setValue('', true)
|
this.editorReplyObj.setValue('', true)
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
window.editorReplyObj.focus()
|
this.editorReplyObj.focus()
|
||||||
if (replyLastID !== null) {
|
if (replyLastID !== null) {
|
||||||
window.editorReplyObj.insertValue('> ' + comment.comment_content + ' \n\n\n', true)
|
this.editorReplyObj.insertValue('> ' + comment.comment_content + ' \n\n\n', true)
|
||||||
} else {
|
} else {
|
||||||
window.editorReplyObj.insertValue('', true)
|
this.editorReplyObj.insertValue('', true)
|
||||||
}
|
}
|
||||||
window.location.hash = '#comment_ID_' + id
|
window.location.hash = '#comment_ID_' + id
|
||||||
})
|
})
|
||||||
@ -516,7 +518,7 @@ export default {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const editorObj = type === 'editor-reply' ? window.editorReplyObj : window.editorObj
|
const editorObj = type === 'editor-reply' ? this.editorReplyObj : this.editorObj
|
||||||
const content = editorObj.getValue()
|
const content = editorObj.getValue()
|
||||||
|
|
||||||
if (!content || content === '\n') {
|
if (!content || content === '\n') {
|
||||||
|
Loading…
Reference in New Issue
Block a user