master
王岚馨 11 months ago
parent 129a21d533
commit 210ef6e3e8

@ -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>

@ -18,7 +18,7 @@ export default {
//前后端定义的密钥AES使用16位
cryptojs_key: "aoligeimeimaobin",
qiniuUrl: "https://upload.qiniup.com",
qiniuDownload: "http://s6qc8qkjn.hd-bkt.clouddn.com/",
qiniuDownload: "http://s6xqq8hhg.hd-bkt.clouddn.com/",
favoriteVideo: "http://s6q4ppvdk.hd-bkt.clouddn.com/new.mp4",
favoriteVideo2: "http://s6q4ppvdk.hd-bkt.clouddn.com/images/340c8040d037c2f3217e8a1ade444fc8.mp4",

Loading…
Cancel
Save