|
|
@ -24,15 +24,11 @@
|
|
|
|
</a>
|
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div style="display: inline-block;position: absolute;left: 470px;top: 208px; width: fit-content">
|
|
|
|
<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">
|
|
|
|
<div style="text-align: center;display: inline-block">
|
|
|
|
<button class="publicBlog" @click="showPostEditor = true">✍️ 写博客</button>
|
|
|
|
<button class="publicBlog" @click="showPostEditor = true">✍️ 写博客</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</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 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>
|
|
|
|
<div>
|
|
|
|
<el-tag effect="dark" class="my-tag">
|
|
|
|
<el-tag effect="dark" class="my-tag">
|
|
|
@ -253,7 +249,7 @@
|
|
|
|
{{ article.articleContent }}
|
|
|
|
{{ article.articleContent }}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<!-- 分类 标签 -->
|
|
|
|
<!-- 分类 标签 -->
|
|
|
|
<div class="sort-label" @click="$router.push({path: '/article', query: {id: article.id}})">
|
|
|
|
<div class="sort-label">
|
|
|
|
<span style="margin-right: 12px"
|
|
|
|
<span style="margin-right: 12px"
|
|
|
|
@click.stop="$router.push({path: '/sort', query: {sortId: article.sortId}})">
|
|
|
|
@click.stop="$router.push({path: '/sort', query: {sortId: article.sortId}})">
|
|
|
|
<svg viewBox="0 0 1024 1024" width="15" height="15" style="vertical-align: -3px;">
|
|
|
|
<svg viewBox="0 0 1024 1024" width="15" height="15" style="vertical-align: -3px;">
|
|
|
@ -285,17 +281,17 @@
|
|
|
|
</svg> {{ article.labelName }}
|
|
|
|
</svg> {{ article.labelName }}
|
|
|
|
|
|
|
|
|
|
|
|
</span>
|
|
|
|
</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-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 type="text" icon="el-icon-delete" style="margin-left: 7px;color: var(--orangeRed)" @click="handleDelete(article)">
|
|
|
|
删除
|
|
|
|
删除
|
|
|
|
</el-button>
|
|
|
|
</el-button>
|
|
|
|
</span>
|
|
|
|
</span>
|
|
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
@ -373,7 +369,6 @@ export default {
|
|
|
|
showUpdateBtn: false,
|
|
|
|
showUpdateBtn: false,
|
|
|
|
showSaveBtn: true,
|
|
|
|
showSaveBtn: true,
|
|
|
|
articleSearch: "",
|
|
|
|
articleSearch: "",
|
|
|
|
// showEditor: false,
|
|
|
|
|
|
|
|
showPostEditor: false,
|
|
|
|
showPostEditor: false,
|
|
|
|
blogContent: "",
|
|
|
|
blogContent: "",
|
|
|
|
blogContentTitle:"",
|
|
|
|
blogContentTitle:"",
|
|
|
@ -568,11 +563,11 @@ export default {
|
|
|
|
},
|
|
|
|
},
|
|
|
|
submitForm(formName) {
|
|
|
|
submitForm(formName) {
|
|
|
|
if (this.article.viewStatus === false && this.$common.isEmpty(this.article.password)) {
|
|
|
|
if (this.article.viewStatus === false && this.$common.isEmpty(this.article.password)) {
|
|
|
|
this.$message({
|
|
|
|
// this.$message({
|
|
|
|
message: "文章不可见时必须输入密码!",
|
|
|
|
// message: "文章不可见时必须输入密码!",
|
|
|
|
type: "error"
|
|
|
|
// type: "error"
|
|
|
|
});
|
|
|
|
// });
|
|
|
|
return;
|
|
|
|
// return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.$refs[formName].validate((valid) => {
|
|
|
|
this.$refs[formName].validate((valid) => {
|
|
|
|
if (valid) {
|
|
|
|
if (valid) {
|
|
|
@ -592,12 +587,14 @@ export default {
|
|
|
|
},
|
|
|
|
},
|
|
|
|
submitForm2() {
|
|
|
|
submitForm2() {
|
|
|
|
if (this.article.viewStatus === false && this.$common.isEmpty(this.article.password)) {
|
|
|
|
if (this.article.viewStatus === false && this.$common.isEmpty(this.article.password)) {
|
|
|
|
this.$message({
|
|
|
|
// this.$message({
|
|
|
|
message: "文章不可见时必须输入密码!",
|
|
|
|
// message: "文章不可见时必须输入密码!",
|
|
|
|
type: "error"
|
|
|
|
// type: "error"
|
|
|
|
});
|
|
|
|
// });
|
|
|
|
return;
|
|
|
|
// return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
this.article.userId = this.$store.state.currentUser.id;
|
|
|
|
|
|
|
|
console.log(this.$store.state.currentUser.id)
|
|
|
|
this.saveArticle(this.article, "/article/updateArticle")
|
|
|
|
this.saveArticle(this.article, "/article/updateArticle")
|
|
|
|
},
|
|
|
|
},
|
|
|
|
resetForm(formName) {
|
|
|
|
resetForm(formName) {
|
|
|
@ -828,131 +825,6 @@ export default {
|
|
|
|
showTip() {
|
|
|
|
showTip() {
|
|
|
|
this.$router.push({path: '/weiYan'});
|
|
|
|
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() {
|
|
|
|
getBlogLabels() {
|
|
|
|
const url = "/webInfo/listLabel";
|
|
|
|
const url = "/webInfo/listLabel";
|
|
|
|
console.log("gettingLabels");
|
|
|
|
console.log("gettingLabels");
|
|
|
@ -962,22 +834,13 @@ export default {
|
|
|
|
console.log(response.data.data)
|
|
|
|
console.log(response.data.data)
|
|
|
|
const labels = response.data.data;
|
|
|
|
const labels = response.data.data;
|
|
|
|
this.blogLabels = Object.values(labels).map(label => label.labelName);
|
|
|
|
this.blogLabels = Object.values(labels).map(label => label.labelName);
|
|
|
|
|
|
|
|
|
|
|
|
// 将标签数据赋值给blogLabels数组
|
|
|
|
|
|
|
|
// this.blogLabels = labels;
|
|
|
|
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.catch(error => {
|
|
|
|
.catch(error => {
|
|
|
|
// 请求失败,处理错误
|
|
|
|
// 请求失败,处理错误
|
|
|
|
console.error(error);
|
|
|
|
console.error(error);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
},
|
|
|
|
handleFileChange() {
|
|
|
|
|
|
|
|
let file0 = this.$refs.fileInput.files[0];
|
|
|
|
|
|
|
|
this.file = file0;
|
|
|
|
|
|
|
|
console.log('上传的文件:', file0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 这里可以进行进一步的处理,比如上传文件到服务器等操作
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
</script>
|
|
|
|