This commit is contained in:
ronger 2021-04-20 10:17:03 +08:00
parent 8186e18a8b
commit 8f1758c439

View File

@ -1,5 +1,6 @@
<template> <template>
<el-row class="articles"> <el-row class="articles">
<el-col v-if="hasPermissions">
<el-col> <el-col>
<el-input <el-input
v-model="articleTitle" v-model="articleTitle"
@ -42,6 +43,16 @@
<el-button v-if="articleStatus === '0'" :loading="doLoading" type="primary" @click="postArticle" 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-button v-else type="primary" :loading="doLoading" @click="postArticle" plain>发布</el-button>
</el-col> </el-col>
</el-col>
<el-col v-else class="text-center">
<el-alert
title="用户无权限"
type="warning"
center
show-icon
:closable="false">
</el-alert>
</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;