修改:文章编辑界面
This commit is contained in:
parent
2d96a61c31
commit
be11879c27
@ -18,6 +18,14 @@ export default {
|
|||||||
data
|
data
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
// 删除草稿 /markdown/deleteDraft
|
||||||
|
deleteDraft: function(params) {
|
||||||
|
return request({
|
||||||
|
url: '/markdown/deleteDraft',
|
||||||
|
method: 'delete',
|
||||||
|
params
|
||||||
|
})
|
||||||
|
},
|
||||||
// 编辑文档 /markdown/edit
|
// 编辑文档 /markdown/edit
|
||||||
editMarkdownByPath: function(data) {
|
editMarkdownByPath: function(data) {
|
||||||
return request({
|
return request({
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
<div v-loading="vditorLoading">
|
<div v-loading="vditorLoading">
|
||||||
<div class="article-editor">
|
<div class="article-editor">
|
||||||
<div class="editor-left">
|
<div class="editor-left">
|
||||||
|
<cite v-if="currentDarft">你正在编辑的是保存于 {{ file.updateDate }} 的草稿, 你也可以 <el-button type="text" style="color: #F56C6C" @click="deleteDraft">删除它</el-button></cite>
|
||||||
<el-header>
|
<el-header>
|
||||||
<div class="header-item">
|
<div class="header-item">
|
||||||
<el-input class="articles-title" placeholder="标题" v-model="filename" />
|
<el-input class="articles-title" placeholder="标题" v-model="filename" />
|
||||||
@ -113,6 +114,7 @@
|
|||||||
import categoryApi from "@/api/category";
|
import categoryApi from "@/api/category";
|
||||||
import tagApi from "@/api/tag";
|
import tagApi from "@/api/tag";
|
||||||
import EditElement from "@/views/markdown/EditElement";
|
import EditElement from "@/views/markdown/EditElement";
|
||||||
|
import api from "@/api/file-api";
|
||||||
|
|
||||||
let toolbar = [
|
let toolbar = [
|
||||||
'emoji',
|
'emoji',
|
||||||
@ -180,6 +182,7 @@
|
|||||||
contentEditor: '',
|
contentEditor: '',
|
||||||
categories: [],
|
categories: [],
|
||||||
draft: false,
|
draft: false,
|
||||||
|
currentDarft: false,
|
||||||
articleLink: `${window.origin}/artiles/`,
|
articleLink: `${window.origin}/artiles/`,
|
||||||
tags: [],
|
tags: [],
|
||||||
dynamicTags: [],
|
dynamicTags: [],
|
||||||
@ -242,16 +245,23 @@
|
|||||||
markdownApi.getMarkdown({
|
markdownApi.getMarkdown({
|
||||||
mark: this.$route.query.id
|
mark: this.$route.query.id
|
||||||
}).then((res) => {
|
}).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){
|
if(isReload){
|
||||||
this.contentEditor.setValue(res.data.contentText)
|
this.contentEditor.setValue(this.file.contentText)
|
||||||
} else {
|
} else {
|
||||||
this.vditorInit(res.data.contentText)
|
this.vditorInit(this.file.contentText)
|
||||||
}
|
}
|
||||||
this.file = res.data
|
|
||||||
this.content = this.file.contentText
|
this.content = this.file.contentText
|
||||||
this.filename = this.file.name.split('.md')[0]
|
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) {
|
if(this.tags && this.tags.length > 0) {
|
||||||
this.loadDynamicTags()
|
this.loadDynamicTags()
|
||||||
@ -404,6 +414,7 @@
|
|||||||
saveDraft() {
|
saveDraft() {
|
||||||
this.draft = true
|
this.draft = true
|
||||||
this.update('保存草稿成功')
|
this.update('保存草稿成功')
|
||||||
|
this.getMarkdown(true)
|
||||||
},
|
},
|
||||||
release() {
|
release() {
|
||||||
this.draft = false
|
this.draft = false
|
||||||
@ -412,6 +423,25 @@
|
|||||||
selectCategory(props, data){
|
selectCategory(props, data){
|
||||||
this.file.categoryIds = data.checkedKeys
|
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
|
||||||
update(message){
|
update(message){
|
||||||
if(!this.checkParam()){
|
if(!this.checkParam()){
|
||||||
|
|||||||
@ -26,11 +26,13 @@
|
|||||||
<div>
|
<div>
|
||||||
<div class="table-top">
|
<div class="table-top">
|
||||||
<div class="table-top-left">
|
<div class="table-top-left">
|
||||||
<el-radio-group v-model="query.radioStatus" size="mini" @change="getArticleList">
|
<el-badge :hidden="draftNums === 0" :value="draftNums" class="item" type="primary">
|
||||||
<el-radio-button label="">可用</el-radio-button>
|
<el-radio-group v-model="query.radioStatus" size="mini" @change="getArticleList">
|
||||||
<el-radio-button label="release">已发布</el-radio-button>
|
<el-radio-button label="">可用</el-radio-button>
|
||||||
<el-radio-button label="draft">草稿</el-radio-button>
|
<el-radio-button label="release">已发布</el-radio-button>
|
||||||
</el-radio-group>
|
<el-radio-button label="draft">草稿</el-radio-button>
|
||||||
|
</el-radio-group>
|
||||||
|
</el-badge>
|
||||||
<span class="table-top-author">作者:</span>
|
<span class="table-top-author">作者:</span>
|
||||||
<el-radio-group v-model="query.radioUser" size="mini" @change="getArticleList">
|
<el-radio-group v-model="query.radioUser" size="mini" @change="getArticleList">
|
||||||
<el-radio-button label="all">所有</el-radio-button>
|
<el-radio-button label="all">所有</el-radio-button>
|
||||||
@ -155,6 +157,7 @@ export default {
|
|||||||
keyword: '',
|
keyword: '',
|
||||||
categoryIds: ''
|
categoryIds: ''
|
||||||
},
|
},
|
||||||
|
draftNums: 0,
|
||||||
multipleSelection: [],
|
multipleSelection: [],
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -275,6 +278,13 @@ export default {
|
|||||||
this.isLoading = false
|
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) {
|
findCategoryIds(parentCategory, categories, categoryIds) {
|
||||||
if(!categoryIds){
|
if(!categoryIds){
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user