From be11879c27fbacdbf86a4269f362bbc4109e5c3f Mon Sep 17 00:00:00 2001 From: jmal Date: Tue, 8 Dec 2020 18:00:46 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=EF=BC=9A=E6=96=87=E7=AB=A0?= =?UTF-8?q?=E7=BC=96=E8=BE=91=E7=95=8C=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/markdown-api.js | 8 ++++ src/views/markdown/index.vue | 38 +++++++++++++++++-- src/views/setting/articles/articleManager.vue | 20 +++++++--- 3 files changed, 57 insertions(+), 9 deletions(-) diff --git a/src/api/markdown-api.js b/src/api/markdown-api.js index 514f112..1368153 100644 --- a/src/api/markdown-api.js +++ b/src/api/markdown-api.js @@ -18,6 +18,14 @@ export default { data }) }, + // 删除草稿 /markdown/deleteDraft + deleteDraft: function(params) { + return request({ + url: '/markdown/deleteDraft', + method: 'delete', + params + }) + }, // 编辑文档 /markdown/edit editMarkdownByPath: function(data) { return request({ diff --git a/src/views/markdown/index.vue b/src/views/markdown/index.vue index 3d45d56..b007ee9 100644 --- a/src/views/markdown/index.vue +++ b/src/views/markdown/index.vue @@ -2,6 +2,7 @@
+ 你正在编辑的是保存于 {{ file.updateDate }} 的草稿, 你也可以 删除它
@@ -113,6 +114,7 @@ import categoryApi from "@/api/category"; import tagApi from "@/api/tag"; import EditElement from "@/views/markdown/EditElement"; + import api from "@/api/file-api"; let toolbar = [ 'emoji', @@ -180,6 +182,7 @@ contentEditor: '', categories: [], draft: false, + currentDarft: false, articleLink: `${window.origin}/artiles/`, tags: [], dynamicTags: [], @@ -242,16 +245,23 @@ markdownApi.getMarkdown({ mark: this.$route.query.id }).then((res) => { + if(res.data.draft) { + this.file = res.data.draft + if(res.data.release) { + this.currentDarft = true + } + } else { + this.file = res.data + } // 初始化编辑器 if(isReload){ - this.contentEditor.setValue(res.data.contentText) + this.contentEditor.setValue(this.file.contentText) } else { - this.vditorInit(res.data.contentText) + this.vditorInit(this.file.contentText) } - this.file = res.data this.content = this.file.contentText this.filename = this.file.name.split('.md')[0] - this.storageLocation = res.data.path + this.storageLocation = this.file.path // 加载标签 if(this.tags && this.tags.length > 0) { this.loadDynamicTags() @@ -404,6 +414,7 @@ saveDraft() { this.draft = true this.update('保存草稿成功') + this.getMarkdown(true) }, release() { this.draft = false @@ -412,6 +423,25 @@ selectCategory(props, data){ this.file.categoryIds = data.checkedKeys }, + deleteDraft() { + this.$confirm('您确定要删除这份草稿吗?', '提示', { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning' + }).then(() => { + markdownApi.deleteDraft({ + fileId: this.$route.query.id, + username: this.$store.state.user.name + }).then(() => { + this.reload() + this.$message({ + message: "草稿已被删除", + type: 'success', + duration : 1000 + }) + }) + }) + }, // update update(message){ if(!this.checkParam()){ diff --git a/src/views/setting/articles/articleManager.vue b/src/views/setting/articles/articleManager.vue index bb48a39..3fddb47 100644 --- a/src/views/setting/articles/articleManager.vue +++ b/src/views/setting/articles/articleManager.vue @@ -26,11 +26,13 @@
- - 可用 - 已发布 - 草稿 - + + + 可用 + 已发布 + 草稿 + + 作者: 所有 @@ -155,6 +157,7 @@ export default { keyword: '', categoryIds: '' }, + draftNums: 0, multipleSelection: [], } }, @@ -275,6 +278,13 @@ export default { this.isLoading = false }) }) + markdownApi.getMarkdown({ + pageIndex: this.pagination.pageIndex, + pageSize: this.pagination.pageSize, + isDraft: true + }).then((res) => { + this.draftNums = res.count + }) }, findCategoryIds(parentCategory, categories, categoryIds) { if(!categoryIds){