From 4ad88c2a7f26dbf555e8bef4699da1092e93c725 Mon Sep 17 00:00:00 2001 From: jmal Date: Thu, 26 Nov 2020 18:03:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=EF=BC=9A=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E5=88=86=E7=B1=BB=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/markdown/index.vue | 64 +++++++++++++++---- src/views/setting/articles/articleManager.vue | 37 +++++++---- .../setting/articles/categoryManager.vue | 4 +- 3 files changed, 80 insertions(+), 25 deletions(-) diff --git a/src/views/markdown/index.vue b/src/views/markdown/index.vue index d0414c0..7e3e120 100644 --- a/src/views/markdown/index.vue +++ b/src/views/markdown/index.vue @@ -24,8 +24,8 @@
- 保存草稿 - {{ editStatus?'发布文章':'更新文章' }} + 保存草稿 + {{ editStatus?'发布文章':'更新文章' }}

文章封面:

@@ -42,18 +42,19 @@ placeholder="缩略名" v-model="file.slug"> - 本文连接:{{file.slug ? articleLink+file.slug : articleLink+file.id}} + 本文链接:{{file.slug ? articleLink+file.slug : articleLink+file.id}}

分类:

- + :props="{ multiple: true, checkStrictly: true, value: 'id', label: 'name' }" + clearable + @change="selectCategory" + >
@@ -155,6 +156,8 @@ moreSetting: false, contentEditor: '', categories: [], + categoryIds: [], + draft: false, articleLink: `${window.origin}/artiles/` } }, @@ -218,6 +221,24 @@ categoryTree() { categoryApi.categoryTree({userId: this.$store.state.user.userId}).then(res => { this.categories = res.data + + let ss = ["5fbf6857aff038ad2c1d686d", "5fbf685eaff038ad2c1d686e", "5fbf6863aff038ad2c1d686f", "5fbf689baff038ad2c1d6874"] + this.findCategoryIds(this.categories, ss) + console.log(this.categoryIds) + }) + }, + findCategoryIds(categories, ss) { + categories.forEach(category => { + let ids = [] + if(category.ids){ + ids = category.ids + } + ids.push(category.id) + category['ids'] = ids + if(ss.includes(category.id)){ + this.categoryIds.push(ids) + } + this.findCategoryIds(categories.children) }) }, vditorInit(content){ @@ -312,8 +333,28 @@ } return true }, + saveDraft() { + this.draft = true + this.update('保存草稿成功') + }, + release() { + this.draft = false + this.update() + }, + selectCategory(val){ + console.log(val) + let categoryIds = [] + this.categoryIds.forEach(categoryIdList => { + categoryIds.push(categoryIdList[categoryIdList.length - 1]) + }) + console.log(categoryIds) + }, // update - update(){ + update(message){ + let categoryIds = [] + this.categoryIds.forEach(categoryIdList => { + categoryIds.push(categoryIdList[categoryIdList.length - 1]) + }) if(!this.checkParam()){ return } @@ -326,15 +367,16 @@ username: this.$store.state.user.name, filename: filename, cover: this.file.cover, - slug: this.file.slug, - categoryIds: this.file.categoryIds, + isDraft: this.draft, + slug: this.file.slug ? this.file.slug : this.filename, + categoryIds: categoryIds, currentDirectory: this.storageLocation, contentText: this.contentEditor.getValue() }).then(() => { this.$emit('update:hasChange', false) this.updating = false this.$message({ - message: "发布成功", + message: message ? message : "发布成功", type: 'success', duration : 1000 }); diff --git a/src/views/setting/articles/articleManager.vue b/src/views/setting/articles/articleManager.vue index 519c209..7293896 100644 --- a/src/views/setting/articles/articleManager.vue +++ b/src/views/setting/articles/articleManager.vue @@ -23,27 +23,30 @@
- - 可用 + + 可用 + 已发布 草稿 作者: - - 所有 - 我的 + + 所有 + 我的
- 筛选 + 筛选
{ + markdownApi.getMarkdown({ + pageIndex: this.pagination.pageIndex, + pageSize: this.pagination.pageSize, + userId: this.query.radioUser === 'my' ? this.$store.state.user.userId : null, + isRelease: this.query.radioStatus === 'release', + isDraft: this.query.radioStatus === 'draft', + keyword: this.query.keyword + }).then((res) => { this.articleList = res.data this.pagination.total = res.count this.$nextTick(() => { @@ -242,6 +254,7 @@ export default { window.onbeforeunload = null this.pageTitle = '文章管理' this.hasChange = false + this.getArticleList() } } } diff --git a/src/views/setting/articles/categoryManager.vue b/src/views/setting/articles/categoryManager.vue index ea0eb77..1c8f22e 100644 --- a/src/views/setting/articles/categoryManager.vue +++ b/src/views/setting/articles/categoryManager.vue @@ -63,7 +63,7 @@ @@ -243,7 +243,7 @@ export default { this.multipleSelection.forEach(category => { categoryIds.push(category.id) }) - this.$confirm('所选分类下的所有内容都将被删除, 您确认要删除吗?', '提示', { + this.$confirm('所选分类下的所有内容(包括文章)都将被删除,\r\n 您确认要删除吗?', '提示', { confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning'