|
|
|
@ -24,15 +24,11 @@
|
|
|
|
|
</a>
|
|
|
|
|
</div>
|
|
|
|
|
<div style="display: inline-block;position: absolute;left: 470px;top: 208px; width: fit-content">
|
|
|
|
|
<!-- 写博客按钮 -->
|
|
|
|
|
<!-- <button class="write-blog-btn" @click="showEditor = true">-->
|
|
|
|
|
<!-- ✍️ 写个人博客-->
|
|
|
|
|
<!-- </button>-->
|
|
|
|
|
<div style="text-align: center;display: inline-block">
|
|
|
|
|
<button class="publicBlog" @click="showPostEditor = true">✍️ 写博客</button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<!--公开文章框-->
|
|
|
|
|
<!--公开文章编辑框-->
|
|
|
|
|
<div id="editorPost" v-if="showPostEditor" style="background-color: #efe5fa;padding-bottom: 10px;margin-left: 35px;margin-right: 35px;border-radius: 10px;box-shadow: 0px 10px 10px 10px #d9c8fc; ">
|
|
|
|
|
<div>
|
|
|
|
|
<el-tag effect="dark" class="my-tag">
|
|
|
|
@ -253,7 +249,7 @@
|
|
|
|
|
{{ article.articleContent }}
|
|
|
|
|
</div>
|
|
|
|
|
<!-- 分类 标签 -->
|
|
|
|
|
<div class="sort-label" @click="$router.push({path: '/article', query: {id: article.id}})">
|
|
|
|
|
<div class="sort-label">
|
|
|
|
|
<span style="margin-right: 12px"
|
|
|
|
|
@click.stop="$router.push({path: '/sort', query: {sortId: article.sortId}})">
|
|
|
|
|
<svg viewBox="0 0 1024 1024" width="15" height="15" style="vertical-align: -3px;">
|
|
|
|
@ -285,17 +281,17 @@
|
|
|
|
|
</svg> {{ article.labelName }}
|
|
|
|
|
|
|
|
|
|
</span>
|
|
|
|
|
<span style="margin-left: 7px">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
<span style="margin-left: 340px;z-index: 99">
|
|
|
|
|
<el-button type="text" icon="el-icon-edit" @click="handleEdit(article)">编辑</el-button>
|
|
|
|
|
<el-button type="text" icon="el-icon-delete" style="margin-left: 7px;color: var(--orangeRed)" @click="handleDelete(article)">
|
|
|
|
|
删除
|
|
|
|
|
</el-button>
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
@ -373,7 +369,6 @@ export default {
|
|
|
|
|
showUpdateBtn: false,
|
|
|
|
|
showSaveBtn: true,
|
|
|
|
|
articleSearch: "",
|
|
|
|
|
// showEditor: false,
|
|
|
|
|
showPostEditor: false,
|
|
|
|
|
blogContent: "",
|
|
|
|
|
blogContentTitle:"",
|
|
|
|
@ -568,11 +563,11 @@ export default {
|
|
|
|
|
},
|
|
|
|
|
submitForm(formName) {
|
|
|
|
|
if (this.article.viewStatus === false && this.$common.isEmpty(this.article.password)) {
|
|
|
|
|
this.$message({
|
|
|
|
|
message: "文章不可见时必须输入密码!",
|
|
|
|
|
type: "error"
|
|
|
|
|
});
|
|
|
|
|
return;
|
|
|
|
|
// this.$message({
|
|
|
|
|
// message: "文章不可见时必须输入密码!",
|
|
|
|
|
// type: "error"
|
|
|
|
|
// });
|
|
|
|
|
// return;
|
|
|
|
|
}
|
|
|
|
|
this.$refs[formName].validate((valid) => {
|
|
|
|
|
if (valid) {
|
|
|
|
@ -592,12 +587,14 @@ export default {
|
|
|
|
|
},
|
|
|
|
|
submitForm2() {
|
|
|
|
|
if (this.article.viewStatus === false && this.$common.isEmpty(this.article.password)) {
|
|
|
|
|
this.$message({
|
|
|
|
|
message: "文章不可见时必须输入密码!",
|
|
|
|
|
type: "error"
|
|
|
|
|
});
|
|
|
|
|
return;
|
|
|
|
|
// this.$message({
|
|
|
|
|
// message: "文章不可见时必须输入密码!",
|
|
|
|
|
// type: "error"
|
|
|
|
|
// });
|
|
|
|
|
// return;
|
|
|
|
|
}
|
|
|
|
|
this.article.userId = this.$store.state.currentUser.id;
|
|
|
|
|
console.log(this.$store.state.currentUser.id)
|
|
|
|
|
this.saveArticle(this.article, "/article/updateArticle")
|
|
|
|
|
},
|
|
|
|
|
resetForm(formName) {
|
|
|
|
@ -828,131 +825,6 @@ export default {
|
|
|
|
|
showTip() {
|
|
|
|
|
this.$router.push({path: '/weiYan'});
|
|
|
|
|
},
|
|
|
|
|
cancelEdit() {
|
|
|
|
|
// 取消编辑
|
|
|
|
|
this.showEditor = false;
|
|
|
|
|
this.showUpdateBtn = false;
|
|
|
|
|
this.showPublishBtn = true;
|
|
|
|
|
this.blogContent = "";
|
|
|
|
|
this.blogContentTitle = "";
|
|
|
|
|
},
|
|
|
|
|
saveBlog() {
|
|
|
|
|
let selectedIndex = this.selectedCategoryIndex+1;
|
|
|
|
|
console.log('选中的分类索引号为:' + selectedIndex);
|
|
|
|
|
const articleVO = {
|
|
|
|
|
userId:this.$store.state.currentUser.id,
|
|
|
|
|
articleContent: this.blogContent ,// 获取博客内容
|
|
|
|
|
articleTitle:this.blogContentTitle,
|
|
|
|
|
// 其他博客相关数据...
|
|
|
|
|
sortId:1,
|
|
|
|
|
labelId:selectedIndex,
|
|
|
|
|
articleCover:this.articleUp.articleCover,
|
|
|
|
|
viewStatus: 0,
|
|
|
|
|
commentStatus: 0,
|
|
|
|
|
recommendStatus: 0
|
|
|
|
|
};
|
|
|
|
|
console.log(this.$store.state.currentUser)
|
|
|
|
|
console.log(this.articleUp.articleCover+"cover")
|
|
|
|
|
// console.log("index:"+document.getElementById('category').select)
|
|
|
|
|
this.$http.post('/article/saveArticle', articleVO)
|
|
|
|
|
.then(response => {
|
|
|
|
|
// 请求成功处理逻辑
|
|
|
|
|
console.log('博客保存成功!');
|
|
|
|
|
this.getUserArticles();
|
|
|
|
|
this.showEditor = false;
|
|
|
|
|
this.blogContent = "";
|
|
|
|
|
this.blogContentTitle = "";
|
|
|
|
|
this.$message({
|
|
|
|
|
message: '发布成功',
|
|
|
|
|
type: 'success'
|
|
|
|
|
});
|
|
|
|
|
})
|
|
|
|
|
.catch(error => {
|
|
|
|
|
// 请求失败处理逻辑
|
|
|
|
|
console.error('博客保存失败:', error);
|
|
|
|
|
this.$message({
|
|
|
|
|
message: '发布失败',
|
|
|
|
|
type: 'error'
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
deleteArticle(article){
|
|
|
|
|
// 发送异步请求删除文章
|
|
|
|
|
this.$http.get(`/article/deleteArticle?id=${article.id}`)
|
|
|
|
|
// .then(response => response.json())
|
|
|
|
|
.then(response => {
|
|
|
|
|
// 请求成功处理逻辑
|
|
|
|
|
console.log('博客删除成功!');
|
|
|
|
|
console.log(response)
|
|
|
|
|
this.getUserArticles()
|
|
|
|
|
this.getUserArticleLabelTotalNum()
|
|
|
|
|
})
|
|
|
|
|
.catch(error => {
|
|
|
|
|
// 请求失败处理逻辑
|
|
|
|
|
console.error('删除博客失败:', error);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
updateArticle(article) {
|
|
|
|
|
this.showPostEditor = true;
|
|
|
|
|
this.blogContentTitle = article.articleTitle;
|
|
|
|
|
this.blogContent = article.articleContent;
|
|
|
|
|
this.selectedCategoryIndex = article.labelId - 1; // 设置下拉框选中的索引值
|
|
|
|
|
this.articleUp.id = article.id;
|
|
|
|
|
// this.blogLabelName
|
|
|
|
|
// 判断是否找到了 #editorArea 元素
|
|
|
|
|
const editorArea = document.getElementById('editorArea');
|
|
|
|
|
if (editorArea) {
|
|
|
|
|
editorArea.scrollIntoView({ behavior: "smooth", block: "start" });
|
|
|
|
|
} else {
|
|
|
|
|
console.log("#editorArea not found");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// updateBlog(){
|
|
|
|
|
// this.blogContentTitle = document.getElementById('areaTitle').value
|
|
|
|
|
// this.blogContent = document.getElementById('areaContent').value
|
|
|
|
|
// // document.getElementById('category').
|
|
|
|
|
// this.articleUp.articleContent = document.getElementById('areaContent').value
|
|
|
|
|
// this.articleUp.articleTitle = document.getElementById('areaTitle').value
|
|
|
|
|
// this.articleUp.username = this.$store.state.currentUser.username
|
|
|
|
|
// this.articleUp.labelId = this.selectedCategoryIndex+1
|
|
|
|
|
//
|
|
|
|
|
// //发送异步请求更新文章
|
|
|
|
|
// this.$http.post('/article/updateArticle', this.articleUp)
|
|
|
|
|
// .then(response => {
|
|
|
|
|
// // 请求成功处理逻辑
|
|
|
|
|
// console.log('博客更新成功!');
|
|
|
|
|
//
|
|
|
|
|
// console.log(response)
|
|
|
|
|
// this.getUserArticles()
|
|
|
|
|
// this.getUserArticleLabelTotalNum()
|
|
|
|
|
// this.$message({
|
|
|
|
|
// message: '更新成功',
|
|
|
|
|
// type: 'success'
|
|
|
|
|
// });
|
|
|
|
|
// this.showEditor = false;
|
|
|
|
|
// this.showPublishBtn = true;
|
|
|
|
|
// this.showUpdateBtn = false;
|
|
|
|
|
// this.blogContent = "";
|
|
|
|
|
// this.blogContentTitle = "";
|
|
|
|
|
// })
|
|
|
|
|
// .catch(error => {
|
|
|
|
|
// // 请求失败处理逻辑
|
|
|
|
|
// console.error('更新博客失败:', error);
|
|
|
|
|
// this.$message({
|
|
|
|
|
// message: '更新失败',
|
|
|
|
|
// type: 'error'
|
|
|
|
|
// });
|
|
|
|
|
// this.showPublishBtn = true;
|
|
|
|
|
// this.showUpdateBtn = false;
|
|
|
|
|
// this.blogContent = "";
|
|
|
|
|
// this.blogContentTitle = "";
|
|
|
|
|
// });
|
|
|
|
|
// },
|
|
|
|
|
getBlogLabels() {
|
|
|
|
|
const url = "/webInfo/listLabel";
|
|
|
|
|
console.log("gettingLabels");
|
|
|
|
@ -962,22 +834,13 @@ export default {
|
|
|
|
|
console.log(response.data.data)
|
|
|
|
|
const labels = response.data.data;
|
|
|
|
|
this.blogLabels = Object.values(labels).map(label => label.labelName);
|
|
|
|
|
|
|
|
|
|
// 将标签数据赋值给blogLabels数组
|
|
|
|
|
// this.blogLabels = labels;
|
|
|
|
|
})
|
|
|
|
|
.catch(error => {
|
|
|
|
|
// 请求失败,处理错误
|
|
|
|
|
console.error(error);
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
handleFileChange() {
|
|
|
|
|
let file0 = this.$refs.fileInput.files[0];
|
|
|
|
|
this.file = file0;
|
|
|
|
|
console.log('上传的文件:', file0);
|
|
|
|
|
|
|
|
|
|
// 这里可以进行进一步的处理,比如上传文件到服务器等操作
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|