diff --git a/.eslintrc.js b/.eslintrc.js index 7e8fce6..e8c89c2 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -10,5 +10,8 @@ module.exports = { extends: ["@nuxtjs"], rules: { "no-console": "off" + }, + globals: { + "_": true } }; diff --git a/nuxt.config.js b/nuxt.config.js index a2b853d..2aec699 100644 --- a/nuxt.config.js +++ b/nuxt.config.js @@ -121,6 +121,7 @@ module.exports = { vendor: ['moment'] }, env: { - version: pkg.version + version: pkg.version, + baseURL: process.env.NODE_ENV === 'development' ? DevBaseUrl : ProdBashUrl } } diff --git a/pages/post/_id.vue b/pages/post/_id.vue index 5d0c1b4..360dead 100644 --- a/pages/post/_id.vue +++ b/pages/post/_id.vue @@ -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: '上传失败,请检查网络稍后重试。
允许上传的文件类型:图片、视频、压缩文件、文本文件、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: '我们书写的不是代码,而是人生' }) }