添加上传接口
This commit is contained in:
parent
221cd42fb3
commit
9b455e6f25
@ -10,5 +10,8 @@ module.exports = {
|
||||
extends: ["@nuxtjs"],
|
||||
rules: {
|
||||
"no-console": "off"
|
||||
},
|
||||
globals: {
|
||||
"_": true
|
||||
}
|
||||
};
|
||||
|
@ -121,6 +121,7 @@ module.exports = {
|
||||
vendor: ['moment']
|
||||
},
|
||||
env: {
|
||||
version: pkg.version
|
||||
version: pkg.version,
|
||||
baseURL: process.env.NODE_ENV === 'development' ? DevBaseUrl : ProdBashUrl
|
||||
}
|
||||
}
|
||||
|
@ -101,6 +101,24 @@ export default {
|
||||
// 创建编辑器
|
||||
if (process.client) {
|
||||
if (!window.editorObj && window.Vditor) {
|
||||
const upload = {
|
||||
url: process.env.baseURL + '/public/file/upload',
|
||||
max: 10485760, // 10 MB
|
||||
linkToImgUrl: process.env.baseURL + '/public/file/upload',
|
||||
headers: {
|
||||
Authorization: 'Bearer ' + window.localStorage.token
|
||||
},
|
||||
filename: name => encodeURIComponent(name.replace(/\W/g, '')),
|
||||
success (editor, msg) {
|
||||
console.log(editor, msg)
|
||||
},
|
||||
error: (_) => {
|
||||
this.$modal.show('dialog', {
|
||||
title: '提示',
|
||||
text: '上传失败,请检查网络稍后重试。<br>允许上传的文件类型:图片、视频、压缩文件、文本文件、Office文件、各类代码文件。'
|
||||
})
|
||||
}
|
||||
}
|
||||
window.editorObj = new window.Vditor('editor', {
|
||||
toolbar: [
|
||||
'emoji',
|
||||
@ -139,13 +157,14 @@ export default {
|
||||
'devtools'
|
||||
]
|
||||
}],
|
||||
height: 250,
|
||||
minHeight: 250,
|
||||
toolbarConfig: {
|
||||
pin: true
|
||||
},
|
||||
cache: {
|
||||
enable: true
|
||||
},
|
||||
upload,
|
||||
placeholder: '我们书写的不是代码,而是人生'
|
||||
})
|
||||
|
||||
@ -187,13 +206,14 @@ export default {
|
||||
'devtools'
|
||||
]
|
||||
}],
|
||||
height: 220,
|
||||
minHeight: 220,
|
||||
toolbarConfig: {
|
||||
pin: true
|
||||
},
|
||||
cache: {
|
||||
enable: false
|
||||
},
|
||||
upload,
|
||||
placeholder: '我们书写的不是代码,而是人生'
|
||||
})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user