|
|
@@ -40,6 +40,8 @@
|
|
|
<span class="create-time">{{art.updated_at}}</span>
|
|
|
</div>
|
|
|
<div class="art-counts-info">
|
|
|
+ <a v-if="idInfo.has_edit_delete_access" class="delete" @click.stop="handleDelete(art)">删除</a>
|
|
|
+ <a v-if="idInfo.has_edit_delete_access" class="edit" :href="`/topics/${art.id}/edit`">编辑</a>
|
|
|
<div class="good">
|
|
|
<img src="~@/assets/img/community/good_icon.png">
|
|
|
<span class="good-count">{{art.like_count}}</span>
|
|
|
@@ -135,6 +137,29 @@ export default {
|
|
|
this.idInfo = res.data;
|
|
|
}
|
|
|
},
|
|
|
+ async handleDelete(topic) {
|
|
|
+ console.log(topic)
|
|
|
+ await this.needLogin();
|
|
|
+ if (!this.idInfo.has_edit_delete_access) {
|
|
|
+ this.$message.error('你没有该文章的操作权限');
|
|
|
+ }
|
|
|
+ this.$confirm(`<p>确认删除该文章吗?</p>`, '提示', {
|
|
|
+ dangerouslyUseHTMLString: true,
|
|
|
+ }).then(async () => {
|
|
|
+ this.$axios.$post('/api/community/topic/delete', { topic_id: topic.id })
|
|
|
+ .then(() => {
|
|
|
+ this.$message({
|
|
|
+ message: '删除成功',
|
|
|
+ type: 'success'
|
|
|
+ })
|
|
|
+ }).catch(() => {
|
|
|
+ this.$message.error('该文章不存在')
|
|
|
+ setTimeout(() => location.reload(), 1000)
|
|
|
+ })
|
|
|
+ }).catch(err => {
|
|
|
+ console.log('cancel')
|
|
|
+ });
|
|
|
+ },
|
|
|
clickLancer({ id }) {
|
|
|
this.$router.push(`https://www.proginn.com/cert/type/${id}`);
|
|
|
},
|
|
|
@@ -507,4 +532,16 @@ export default {
|
|
|
align-items: center;
|
|
|
margin: 20px 0;
|
|
|
}
|
|
|
+.edit,
|
|
|
+.delete {
|
|
|
+ display: inline-block;
|
|
|
+ margin: 0 12px;
|
|
|
+ font-size: 12px;
|
|
|
+ font-weight:500;
|
|
|
+ line-height: 15px;
|
|
|
+ color:rgba(48,142,255,1);
|
|
|
+}
|
|
|
+.delete {
|
|
|
+ color:rgba(153,153,153,1);
|
|
|
+}
|
|
|
</style>
|