fix: 删除我的帖子
This commit is contained in:
parent
680575925c
commit
278b4e0afa
@ -221,21 +221,10 @@ export function ArticleById(data) {
|
||||
});
|
||||
}
|
||||
// 通过id删除文章√
|
||||
export function DeteleArticleById(data) {
|
||||
const formData = new FormData();
|
||||
|
||||
// 将data对象的属性添加到FormData对象中
|
||||
for (let key in data) {
|
||||
formData.append(key, data[key]);
|
||||
}
|
||||
|
||||
return request({
|
||||
url: '/article/deleteArticleById',
|
||||
method: 'post',
|
||||
data: formData,
|
||||
|
||||
});
|
||||
}
|
||||
export const DeteleArticleById = id => request({
|
||||
url: `/article/deleteArticleById?id=${id}`, // 将id作为查询参数放入URL
|
||||
method: 'post'
|
||||
});
|
||||
// 更新文章√
|
||||
export function UpArtile(data) {
|
||||
const formData = new FormData();
|
||||
|
@ -135,13 +135,14 @@
|
||||
class="article-item"
|
||||
v-for="(article, index) in articles"
|
||||
:key="index"
|
||||
@click="viewArticle(article)"
|
||||
>
|
||||
<div class="article-cover">
|
||||
<div class="article-cover" @click="viewArticle(article)">
|
||||
<img :src="getArticleImage(article)" :alt="article.title" />
|
||||
</div>
|
||||
<div class="article-content">
|
||||
<div class="article-title">{{ article.articleTitle }}</div>
|
||||
<div class="article-title" @click="viewArticle(article)">
|
||||
{{ article.articleTitle }}
|
||||
</div>
|
||||
<div
|
||||
class="article-description"
|
||||
v-html="getArticleExcerpt(article.articleContent)"
|
||||
@ -151,21 +152,13 @@
|
||||
<a-icon type="calendar" />
|
||||
{{ formatDate(article.publishTime) }}
|
||||
</div>
|
||||
<!-- <div class="article-stats">
|
||||
<span
|
||||
><a-icon type="eye" />
|
||||
{{ article.viewCount || 0 }}</span
|
||||
>
|
||||
<span style="margin-left: 16px"
|
||||
><a-icon type="like" />
|
||||
{{ article.likeCount || 0 }}</span
|
||||
>
|
||||
<span style="margin-left: 16px"
|
||||
><a-icon type="message" />
|
||||
{{ article.commentCount || 0 }}</span
|
||||
>
|
||||
</div> -->
|
||||
</div>
|
||||
<a-button type="text" @click="editArticle(article)"
|
||||
>修改</a-button
|
||||
>
|
||||
<a-button type="text" @click="deleteItemArticle(article)"
|
||||
>删除</a-button
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -205,6 +198,8 @@ import PageView from "../../../layouts/PageView.vue";
|
||||
import RouteView from "../../../layouts/RouteView.vue";
|
||||
import { AppPage, ArticlePage, ProjectPage } from "./page";
|
||||
import { mapGetters } from "vuex";
|
||||
import { DeteleArticleById } from "@/api/index";
|
||||
import { Modal } from "ant-design-vue";
|
||||
|
||||
export default {
|
||||
components: {
|
||||
@ -268,6 +263,30 @@ export default {
|
||||
this.fetchStats();
|
||||
},
|
||||
methods: {
|
||||
editArticle(id) {
|
||||
this.$router.push(`/article/edit/${id}`);
|
||||
},
|
||||
deleteItemArticle(article) {
|
||||
// 参数重命名为article
|
||||
Modal.confirm({
|
||||
title: "提示",
|
||||
content: "确定要删除这篇文章吗?",
|
||||
onOk: () => {
|
||||
// 直接传递articleId作为参数
|
||||
DeteleArticleById(article.articleId)
|
||||
.then((res) => {
|
||||
this.$message.success("删除成功");
|
||||
this.fetchArticles();
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error("删除失败详情:", err);
|
||||
this.$message.error(
|
||||
`删除失败: ${err.response?.data?.message || "服务器异常"}`
|
||||
);
|
||||
});
|
||||
},
|
||||
});
|
||||
},
|
||||
// 获取比赛信息
|
||||
// 修改 fetchCompetitions 方法
|
||||
fetchCompetitions() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user