diff --git a/src/styles/articles.scss b/src/styles/articles.scss index 79d4fd1..0e60158 100644 --- a/src/styles/articles.scss +++ b/src/styles/articles.scss @@ -1851,6 +1851,7 @@ footer .copyright { .l_body { position: relative; margin: 16px 16px 0 16px; + min-height: calc(100vh - 70vh); } .l_body.nocover { diff --git a/src/styles/markdown.scss b/src/styles/markdown.scss index 5b6cebe..cc10a35 100644 --- a/src/styles/markdown.scss +++ b/src/styles/markdown.scss @@ -567,7 +567,7 @@ box-shadow: rgba(0, 0, 0, 0.1) 0px 2px 12px 0px; } -/deep/ .markdown-body { +/deep/ .article-body { border-radius: 0.5rem; blockquote { padding: 0.8em 1em; @@ -623,48 +623,15 @@ } } } - i.code-copy{ - position: absolute; - top:0; - right: 0; - background-color: #464d5e; - padding: 3px; - margin: 3px 3px 0 0; - font-size: 11px; - border-radius: inherit; - color: #f1f1f1; - cursor: pointer; - display: none; - } - &:hover i.code-copy{ - display: block; - } } } code { + background-size: unset!important; background: linear-gradient(to right, #5d9eea, #afcafd); - color: #000; - overflow-wrap: break-word; - word-wrap: break-word; - padding: 0.1rem 0.3rem 0.2rem; - border-radius: 8px; - opacity: 0.9; } pre code { background: unset; - color: unset; - opacity: unset; - padding: unset; } - .hljs code { - background: unset; - color: unset; - opacity: unset; - padding: unset; - } -} - -.pre-numbering { } #toggle-nav { diff --git a/src/utils/file-config.js b/src/utils/file-config.js index 55cbd46..1ba0caf 100644 --- a/src/utils/file-config.js +++ b/src/utils/file-config.js @@ -4,6 +4,9 @@ export default { previewUrl: function(username, file) { return `${this.baseUrl}/file/${username}${file.path}${file.name}` }, + mardownPreviewUrl: function (path){ + return `${this.baseUrl}${path}` + }, publicPreviewUrl: function(fileIds) { return `${this.baseUrl}/public/preview/${fileIds}` }, diff --git a/src/views/markdown/index.vue b/src/views/markdown/index.vue index b1ce9a6..c114787 100644 --- a/src/views/markdown/index.vue +++ b/src/views/markdown/index.vue @@ -24,7 +24,7 @@
- 保存草稿 + 保存草稿 {{ editStatus?'发布文章':'更新文章' }}
@@ -238,45 +238,45 @@ }, input: (val) => { this.valueHasChanged() - } + }, + upload: this.markdownImageUplaod() }) }, - $imgAdd(pos, $file) { - const maxSize = 1024 * 1024 * 5 - if($file.size > maxSize){ - this.$message({ - message: '请选择小于5M的图片! 大于5M的图片将无法上传', - type: 'warning', - duration: 3000, - }); - return - } - // 第一步.将图片上传到服务器. - let data = new FormData(); - data.append('filename', this.filename) - data.append('username', this.$store.state.user.name) - data.append('userId', this.$store.state.user.userId); - data.append('file', $file); - uploadApi.uploadImage(data).then((res) => { - // 第二步.将返回的url替换到文本原位置![...](0) -> ![...](url) - /** - * $vm 指为mavonEditor实例,可以通过如下两种方式获取 - * 1. 通过引入对象获取: `import {mavonEditor} from ...` 等方式引入后,`$vm`为`mavonEditor` - * 2. 通过$refs获取: html声明ref : `,`$vm`为 `this.$refs.md` - */ - // const url = process.env.VUE_APP_BASE_FILE_API + '/public/image/' + res.data - const url = fileConfig.publicPreviewUrl(res.data); - console.log(url) - this.$refs.md.$img2Url(pos, url); - }) - }, - $imgDel(pos, $file) { - }, // 所有操作都会被解析重新渲染 change(value, render){ // render 为 markdown 解析后的结果[html] this.html = render; }, + markdownImageUplaod(){ + return { + accept: 'image/*,.mp3, .wav, .rar', + headers: { + 'jmal-token': this.$store.state.user.token + }, + url: '/api/upload-markdown-image', + extraData: { + 'filename': this.filename, + 'username': this.$store.state.user.name, + 'userId': this.$store.state.user.userId + }, + fieldName: 'files', + filename (name) { + return name.replace(/[^(a-zA-Z0-9\u4e00-\u9fa5\.)]/g, ''). + replace(/[\?\\/:|<>\*\[\]\(\)\$%\{\}@~]/g, ''). + replace('/\\s/g', '') + }, + format(files, responseText) { + let response = JSON.parse(responseText) + let succMap = {} + response.data.forEach(map => { + succMap[map.filename] = fileConfig.mardownPreviewUrl(map.filepath) + }) + response.data = {} + response.data['succMap'] = succMap + return JSON.stringify(response) + } + } + }, fullScreen(status) { this.isFullScreen = status this.reHeight() @@ -334,6 +334,7 @@ currentDirectory: this.storageLocation, contentText: this.contentEditor.getValue() }).then(() => { + this.$emit('update:hasChange', false) this.updating = false this.$message({ message: "发布成功", diff --git a/src/views/setting/articles/articleManager.vue b/src/views/setting/articles/articleManager.vue index e2faafa..e69b25a 100644 --- a/src/views/setting/articles/articleManager.vue +++ b/src/views/setting/articles/articleManager.vue @@ -57,19 +57,15 @@