From 1df285145506550c28b4dd6c2ead682b18d3630f Mon Sep 17 00:00:00 2001 From: jmal Date: Wed, 25 Nov 2020 18:13:14 +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 | 55 ++++++++----------- src/views/setting/articles/articleManager.vue | 9 ++- .../setting/articles/categoryManager.vue | 20 +++++-- 3 files changed, 46 insertions(+), 38 deletions(-) diff --git a/src/views/markdown/index.vue b/src/views/markdown/index.vue index e134e16..d0414c0 100644 --- a/src/views/markdown/index.vue +++ b/src/views/markdown/index.vue @@ -45,13 +45,13 @@ 本文连接:{{file.slug ? articleLink+file.slug : articleLink+file.id}}

分类:

@@ -154,16 +154,11 @@ selectLocationVisible: false, moreSetting: false, contentEditor: '', - categoryIds: [], categories: [], articleLink: `${window.origin}/artiles/` } }, - created() { - console.log('created',window.origin) - }, mounted() { - console.log('mounted') this.getMarkdown() this.categoryTree() const that = this @@ -171,33 +166,26 @@ that.reHeight() } }, - destroyed() { - console.log('destroyed') - }, watch: { file(){ - console.log('filename is changed') this.valueHasChanged() }, filename(val){ - console.log('filename is changed') this.valueHasChanged() this.$emit('onTitle', val) }, - categoryIds(){ - console.log('categoryIds is changed') - this.valueHasChanged() - }, storageLocation(){ - console.log('storageLocation is changed') this.valueHasChanged() } }, methods: { + reload() { + this.getMarkdown(true) + }, valueHasChanged(){ this.$emit('update:hasChange', true) }, - getMarkdown(){ + getMarkdown(isReload){ if(this.$route.query.id){ this.editStatus = true markdownApi.getMarkdown({ @@ -207,16 +195,24 @@ this.content = this.file.contentText this.filename = this.file.name.split('.md')[0] this.storageLocation = res.data.path - if(this.file.categoryIds){ - this.file.categoryIds.forEach(categoryId => { - this.categoryIds.push(new Array(categoryId)) - }) - } // 初始化编辑器 - this.vditorInit(res.data.contentText) + if(isReload){ + this.contentEditor.setValue(res.data.contentText) + } else { + this.vditorInit(res.data.contentText) + } + }).then(() => { + const that = this + setTimeout(function (){ + that.$emit('update:hasChange', false) + }, 100) }) } else { - this.vditorInit('') + if(isReload){ + this.contentEditor.setValue('') + } else { + this.vditorInit('') + } } }, categoryTree() { @@ -316,13 +312,6 @@ } return true }, - getCategoryList(){ - let categoryIdList = [] - this.categoryIds.forEach(categoryIds => { - categoryIdList.push(categoryIds[0]) - }) - return categoryIdList - }, // update update(){ if(!this.checkParam()){ @@ -338,7 +327,7 @@ filename: filename, cover: this.file.cover, slug: this.file.slug, - categoryIds: this.getCategoryList(), + categoryIds: this.file.categoryIds, currentDirectory: this.storageLocation, contentText: this.contentEditor.getValue() }).then(() => { diff --git a/src/views/setting/articles/articleManager.vue b/src/views/setting/articles/articleManager.vue index e69b25a..519c209 100644 --- a/src/views/setting/articles/articleManager.vue +++ b/src/views/setting/articles/articleManager.vue @@ -60,7 +60,7 @@ min-width="200" label="标题"> @@ -200,6 +200,13 @@ export default { this.newArticleDialogVisible = true this.$router.push({query: {operation: 'new'}}) }, + editArticle(id) { + this.newArticleDialogVisible = true + this.$router.push({query: {operation: 'editor', id: id}}) + if(this.$refs.editor){ + this.$refs.editor.reload() + } + }, categoryTree() { categoryApi.categoryTree({userId: this.$store.state.user.userId}).then(res => { this.categories = res.data diff --git a/src/views/setting/articles/categoryManager.vue b/src/views/setting/articles/categoryManager.vue index a9aca77..ea0eb77 100644 --- a/src/views/setting/articles/categoryManager.vue +++ b/src/views/setting/articles/categoryManager.vue @@ -14,7 +14,7 @@ placeholder="不选择" :options="categories" :show-all-levels="false" - :props="{ checkStrictly: true }" + :props="{ checkStrictly: true, value: 'id', label: 'name'}" clearable> @@ -61,11 +61,10 @@ label="名称"> @@ -84,6 +83,9 @@ + @@ -321,5 +323,15 @@ export default { height: 32px; line-height: 32px; } +.article-num { +} +.article-num:hover { + cursor: pointer; + background-color: #fbfdff; + color: #1d8cff; +} +.article-num:active { + background-color: #ecf5ff; +}