添加评论功能
This commit is contained in:
parent
54a1633884
commit
c618c83f9b
@ -135,126 +135,15 @@ export default {
|
||||
window.localStorage.visitorInfo = JSON.stringify(visitorInfo)
|
||||
this.visitorToken = visitorToken
|
||||
this.visitorInfo = visitorInfo
|
||||
window.editorObj.vditor.options.upload.headers = {
|
||||
Authorization: 'Bearer ' + this.visitorToken
|
||||
}
|
||||
window.editorReplyObj.vditor.options.upload.headers = {
|
||||
Authorization: 'Bearer ' + this.visitorToken
|
||||
}
|
||||
}
|
||||
if (!window.editorObj && window.Vditor) {
|
||||
const upload = {
|
||||
accept: 'image/*, video/*, audio/*, text/*, application/*, .rar, .zip, .php, .pptx, .ppt, .doc, .docx, .txt, .xls, .xlsx',
|
||||
url: process.env.baseURL + '/visitor/file/upload',
|
||||
max: 10485760, // 10 MB
|
||||
linkToImgUrl: process.env.baseURL + '/visitor/file/fetch',
|
||||
headers: {
|
||||
Authorization: 'Bearer ' + window.localStorage.visitorToken
|
||||
},
|
||||
filename: name => encodeURIComponent(name.replace(/[^(a-zA-Z0-9\u4E00-\u9FA5\.)]/g, '') // eslint-disable-line
|
||||
.replace(/[\?\\/:|<>\*\[\]\(\)\$%\{\}@~]/g, '') // eslint-disable-line
|
||||
.replace('/\\s/g', '')),
|
||||
format (files, responseText) {
|
||||
return responseText
|
||||
},
|
||||
error: (_) => {
|
||||
this.$modal.show('dialog', {
|
||||
title: '提示',
|
||||
text: '上传失败,请检查网络稍后重试。<br>允许上传的文件类型:图片、视频、压缩文件、文本文件、Office文件、各类代码文件。'
|
||||
})
|
||||
}
|
||||
}
|
||||
window.editorObj = new window.Vditor('editor', {
|
||||
toolbar: [
|
||||
'emoji',
|
||||
'headings',
|
||||
'bold',
|
||||
'italic',
|
||||
'strike',
|
||||
'link',
|
||||
'list',
|
||||
'ordered-list',
|
||||
'outdent',
|
||||
'indent',
|
||||
'quote',
|
||||
'line',
|
||||
'code',
|
||||
'inline-code',
|
||||
'upload',
|
||||
'table',
|
||||
'insert-before',
|
||||
'insert-after',
|
||||
'undo',
|
||||
'redo',
|
||||
'fullscreen',
|
||||
{
|
||||
name: 'more',
|
||||
toolbar: [
|
||||
'edit-mode',
|
||||
'check',
|
||||
'both',
|
||||
'code-theme',
|
||||
'content-theme',
|
||||
'export',
|
||||
'outline',
|
||||
'preview',
|
||||
'format',
|
||||
'devtools'
|
||||
]
|
||||
}],
|
||||
minHeight: 250,
|
||||
toolbarConfig: {
|
||||
pin: true
|
||||
},
|
||||
cache: {
|
||||
enable: true
|
||||
},
|
||||
upload,
|
||||
placeholder: '我们书写的不是代码,而是人生'
|
||||
})
|
||||
|
||||
window.editorReplyObj = new window.Vditor('editor-reply', {
|
||||
toolbar: [
|
||||
'emoji',
|
||||
'headings',
|
||||
'bold',
|
||||
'italic',
|
||||
'strike',
|
||||
'link',
|
||||
'list',
|
||||
'ordered-list',
|
||||
'outdent',
|
||||
'indent',
|
||||
'quote',
|
||||
'line',
|
||||
'code',
|
||||
'inline-code',
|
||||
'upload',
|
||||
'insert-before',
|
||||
'insert-after',
|
||||
'undo',
|
||||
'redo',
|
||||
{
|
||||
name: 'more',
|
||||
toolbar: [
|
||||
'table',
|
||||
'fullscreen',
|
||||
'edit-mode',
|
||||
'check',
|
||||
'both',
|
||||
'code-theme',
|
||||
'content-theme',
|
||||
'export',
|
||||
'outline',
|
||||
'preview',
|
||||
'format',
|
||||
'devtools'
|
||||
]
|
||||
}],
|
||||
minHeight: 220,
|
||||
toolbarConfig: {
|
||||
pin: true
|
||||
},
|
||||
cache: {
|
||||
enable: false
|
||||
},
|
||||
upload,
|
||||
placeholder: '我们书写的不是代码,而是人生'
|
||||
})
|
||||
this.initEditor()
|
||||
}
|
||||
|
||||
this.setCommentMap()
|
||||
@ -337,6 +226,126 @@ export default {
|
||||
} catch (_) { }
|
||||
},
|
||||
methods: {
|
||||
initEditor () {
|
||||
const upload = {
|
||||
accept: 'image/*, video/*, audio/*, text/*, application/*, .rar, .zip, .php, .pptx, .ppt, .doc, .docx, .txt, .xls, .xlsx',
|
||||
url: process.env.baseURL + '/visitor/file/upload',
|
||||
max: 10485760, // 10 MB
|
||||
linkToImgUrl: process.env.baseURL + '/visitor/file/fetch',
|
||||
headers: {
|
||||
Authorization: 'Bearer ' + this.visitorToken
|
||||
},
|
||||
filename: name => encodeURIComponent(name.replace(/[^(a-zA-Z0-9\u4E00-\u9FA5\.)]/g, '') // eslint-disable-line
|
||||
.replace(/[\?\\/:|<>\*\[\]\(\)\$%\{\}@~]/g, '') // eslint-disable-line
|
||||
.replace('/\\s/g', '')),
|
||||
format (files, responseText) {
|
||||
return responseText
|
||||
},
|
||||
error: (_) => {
|
||||
this.$modal.show('dialog', {
|
||||
title: '提示',
|
||||
text: '上传失败,请检查网络稍后重试。<br>允许上传的文件类型:图片、视频、压缩文件、文本文件、Office文件、各类代码文件。'
|
||||
})
|
||||
}
|
||||
}
|
||||
window.editorObj = new window.Vditor('editor', {
|
||||
toolbar: [
|
||||
'emoji',
|
||||
'headings',
|
||||
'bold',
|
||||
'italic',
|
||||
'strike',
|
||||
'link',
|
||||
'list',
|
||||
'ordered-list',
|
||||
'outdent',
|
||||
'indent',
|
||||
'quote',
|
||||
'line',
|
||||
'code',
|
||||
'inline-code',
|
||||
'upload',
|
||||
'table',
|
||||
'insert-before',
|
||||
'insert-after',
|
||||
'undo',
|
||||
'redo',
|
||||
'fullscreen',
|
||||
{
|
||||
name: 'more',
|
||||
toolbar: [
|
||||
'edit-mode',
|
||||
'check',
|
||||
'both',
|
||||
'code-theme',
|
||||
'content-theme',
|
||||
'export',
|
||||
'outline',
|
||||
'preview',
|
||||
'format',
|
||||
'devtools'
|
||||
]
|
||||
}],
|
||||
minHeight: 250,
|
||||
toolbarConfig: {
|
||||
pin: true
|
||||
},
|
||||
cache: {
|
||||
enable: true
|
||||
},
|
||||
upload,
|
||||
placeholder: '我们书写的不是代码,而是人生'
|
||||
})
|
||||
|
||||
window.editorReplyObj = new window.Vditor('editor-reply', {
|
||||
toolbar: [
|
||||
'emoji',
|
||||
'headings',
|
||||
'bold',
|
||||
'italic',
|
||||
'strike',
|
||||
'link',
|
||||
'list',
|
||||
'ordered-list',
|
||||
'outdent',
|
||||
'indent',
|
||||
'quote',
|
||||
'line',
|
||||
'code',
|
||||
'inline-code',
|
||||
'upload',
|
||||
'insert-before',
|
||||
'insert-after',
|
||||
'undo',
|
||||
'redo',
|
||||
{
|
||||
name: 'more',
|
||||
toolbar: [
|
||||
'table',
|
||||
'fullscreen',
|
||||
'edit-mode',
|
||||
'check',
|
||||
'both',
|
||||
'code-theme',
|
||||
'content-theme',
|
||||
'export',
|
||||
'outline',
|
||||
'preview',
|
||||
'format',
|
||||
'devtools'
|
||||
]
|
||||
}],
|
||||
minHeight: 220,
|
||||
toolbarConfig: {
|
||||
pin: true
|
||||
},
|
||||
cache: {
|
||||
enable: false
|
||||
},
|
||||
upload,
|
||||
placeholder: '我们书写的不是代码,而是人生'
|
||||
})
|
||||
},
|
||||
decodeTitle (name) {
|
||||
try {
|
||||
return this.urldecode(name)
|
||||
|
Loading…
Reference in New Issue
Block a user