修改:文章编辑界面
This commit is contained in:
parent
2d96a61c31
commit
be11879c27
@ -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({
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
<div v-loading="vditorLoading">
|
||||
<div class="article-editor">
|
||||
<div class="editor-left">
|
||||
<cite v-if="currentDarft">你正在编辑的是保存于 {{ file.updateDate }} 的草稿, 你也可以 <el-button type="text" style="color: #F56C6C" @click="deleteDraft">删除它</el-button></cite>
|
||||
<el-header>
|
||||
<div class="header-item">
|
||||
<el-input class="articles-title" placeholder="标题" v-model="filename" />
|
||||
@ -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()){
|
||||
|
||||
@ -26,11 +26,13 @@
|
||||
<div>
|
||||
<div class="table-top">
|
||||
<div class="table-top-left">
|
||||
<el-radio-group v-model="query.radioStatus" size="mini" @change="getArticleList">
|
||||
<el-radio-button label="">可用</el-radio-button>
|
||||
<el-radio-button label="release">已发布</el-radio-button>
|
||||
<el-radio-button label="draft">草稿</el-radio-button>
|
||||
</el-radio-group>
|
||||
<el-badge :hidden="draftNums === 0" :value="draftNums" class="item" type="primary">
|
||||
<el-radio-group v-model="query.radioStatus" size="mini" @change="getArticleList">
|
||||
<el-radio-button label="">可用</el-radio-button>
|
||||
<el-radio-button label="release">已发布</el-radio-button>
|
||||
<el-radio-button label="draft">草稿</el-radio-button>
|
||||
</el-radio-group>
|
||||
</el-badge>
|
||||
<span class="table-top-author">作者:</span>
|
||||
<el-radio-group v-model="query.radioUser" size="mini" @change="getArticleList">
|
||||
<el-radio-button label="all">所有</el-radio-button>
|
||||
@ -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){
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user