This commit is contained in:
parent
8186e18a8b
commit
8f1758c439
@ -1,46 +1,57 @@
|
|||||||
<template>
|
<template>
|
||||||
<el-row class="articles">
|
<el-row class="articles">
|
||||||
<el-col>
|
<el-col v-if="hasPermissions">
|
||||||
<el-input
|
<el-col>
|
||||||
v-model="articleTitle"
|
<el-input
|
||||||
class="article-title"
|
v-model="articleTitle"
|
||||||
placeholder="请输入标题"
|
class="article-title"
|
||||||
@change="setLocalstorage('title',articleTitle)">
|
placeholder="请输入标题"
|
||||||
</el-input>
|
@change="setLocalstorage('title',articleTitle)">
|
||||||
|
</el-input>
|
||||||
|
</el-col>
|
||||||
|
<el-col>
|
||||||
|
<div id="contentEditor"></div>
|
||||||
|
</el-col>
|
||||||
|
<el-col style="margin-top: 1rem;">
|
||||||
|
<el-select
|
||||||
|
style="width: 100%;"
|
||||||
|
v-model="articleTags"
|
||||||
|
multiple
|
||||||
|
filterable
|
||||||
|
allow-create
|
||||||
|
default-first-option
|
||||||
|
remote
|
||||||
|
:remote-method="remoteMethod"
|
||||||
|
placeholder="请选择文章标签"
|
||||||
|
:loading="loading"
|
||||||
|
@change="setLocalstorage('tags',articleTags)">
|
||||||
|
<el-option
|
||||||
|
v-for="item in options"
|
||||||
|
:key="item.value"
|
||||||
|
:label="item.label"
|
||||||
|
:value="item.value">
|
||||||
|
</el-option>
|
||||||
|
</el-select>
|
||||||
|
</el-col>
|
||||||
|
<el-col v-if="!isEdit" style="margin-top: 1rem;padding-right:3rem;text-align: right;">
|
||||||
|
<el-button :loading="doLoading" @click="saveArticle" plain>保存草稿</el-button>
|
||||||
|
<el-button type="primary" :loading="doLoading" @click="postArticle" plain>发布</el-button>
|
||||||
|
</el-col>
|
||||||
|
<el-col v-else style="margin-top: 1rem;padding-right:3rem;text-align: right;">
|
||||||
|
<el-button type="danger" :loading="doLoading" @click="deleteArticle" plain>删除</el-button>
|
||||||
|
<el-button v-if="articleStatus === '1'" :loading="doLoading" @click="saveArticle" plain>保存草稿</el-button>
|
||||||
|
<el-button v-if="articleStatus === '0'" :loading="doLoading" type="primary" @click="postArticle" plain>更新</el-button>
|
||||||
|
<el-button v-else type="primary" :loading="doLoading" @click="postArticle" plain>发布</el-button>
|
||||||
|
</el-col>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col>
|
<el-col v-else class="text-center">
|
||||||
<div id="contentEditor"></div>
|
<el-alert
|
||||||
</el-col>
|
title="用户无权限"
|
||||||
<el-col style="margin-top: 1rem;">
|
type="warning"
|
||||||
<el-select
|
center
|
||||||
style="width: 100%;"
|
show-icon
|
||||||
v-model="articleTags"
|
:closable="false">
|
||||||
multiple
|
</el-alert>
|
||||||
filterable
|
|
||||||
allow-create
|
|
||||||
default-first-option
|
|
||||||
remote
|
|
||||||
:remote-method="remoteMethod"
|
|
||||||
placeholder="请选择文章标签"
|
|
||||||
:loading="loading"
|
|
||||||
@change="setLocalstorage('tags',articleTags)">
|
|
||||||
<el-option
|
|
||||||
v-for="item in options"
|
|
||||||
:key="item.value"
|
|
||||||
:label="item.label"
|
|
||||||
:value="item.value">
|
|
||||||
</el-option>
|
|
||||||
</el-select>
|
|
||||||
</el-col>
|
|
||||||
<el-col v-if="!isEdit" style="margin-top: 1rem;padding-right:3rem;text-align: right;">
|
|
||||||
<el-button :loading="doLoading" @click="saveArticle" plain>保存草稿</el-button>
|
|
||||||
<el-button type="primary" :loading="doLoading" @click="postArticle" plain>发布</el-button>
|
|
||||||
</el-col>
|
|
||||||
<el-col v-else style="margin-top: 1rem;padding-right:3rem;text-align: right;">
|
|
||||||
<el-button type="danger" :loading="doLoading" @click="deleteArticle" plain>删除</el-button>
|
|
||||||
<el-button v-if="articleStatus === '1'" :loading="doLoading" @click="saveArticle" plain>保存草稿</el-button>
|
|
||||||
<el-button v-if="articleStatus === '0'" :loading="doLoading" type="primary" @click="postArticle" plain>更新</el-button>
|
|
||||||
<el-button v-else type="primary" :loading="doLoading" @click="postArticle" plain>发布</el-button>
|
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
</template>
|
</template>
|
||||||
@ -66,7 +77,16 @@
|
|||||||
computed: {
|
computed: {
|
||||||
...mapState({
|
...mapState({
|
||||||
article: state => state.article.detail.data
|
article: state => state.article.detail.data
|
||||||
})
|
}),
|
||||||
|
hasPermissions() {
|
||||||
|
let account = this.$store.state.userInfo?.nickname;
|
||||||
|
if (account) {
|
||||||
|
if (account === this.article.articleAuthor.userNickname) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return this.$store.getters.hasPermissions('blog_admin');
|
||||||
|
}
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@ -346,6 +366,9 @@
|
|||||||
window.onbeforeunload = null;
|
window.onbeforeunload = null;
|
||||||
},
|
},
|
||||||
async mounted() {
|
async mounted() {
|
||||||
|
if (!this.hasPermissions) {
|
||||||
|
return
|
||||||
|
}
|
||||||
window.addEventListener('beforeunload', e => {
|
window.addEventListener('beforeunload', e => {
|
||||||
e = e || window.event;
|
e = e || window.event;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user