Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 17 additions & 12 deletions vueblog/src/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,22 @@ export const offsetDomTop = (element) =>{
export const scrolltoToc = (position) => {
// scrollTop:设置或获取位于对象最顶端和窗口中可见内容的最顶端之间的距离
let curr_top = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop;
let time_id = setInterval(() => {
curr_top += 10;
// let time_id = setInterval(() => {
// curr_top +=90;
// // curr_top = curr_top;
//
// //网页被卷去的高: document.body.scrollTop;
// document.body.scollTop = curr_top;
//
// // document.documentElement.scrollTop(获取或设置滚动条位置)
// document.documentElement.scrollTop = curr_top;
//
// if (curr_top >=position) {
// clearInterval(time_id);
// }
// }, 10);
curr_top=position;
document.body.scollTop = curr_top;
document.documentElement.scrollTop = curr_top;

//网页被卷去的高: document.body.scrollTop;
document.body.scollTop = curr_top;

// document.documentElement.scrollTop(获取或设置滚动条位置)
document.documentElement.scrollTop = curr_top;

if (curr_top >=position) {
clearInterval(time_id);
}
}, 10);
}
2 changes: 1 addition & 1 deletion vueblog/src/views/blogDetail/BlogDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ export default {
// 目录滚动
scrollToPosition(id) {
let position = offsetDomTop(document.getElementById(id));
position.top = position.top - 80;
// position.top = position.top - 80;
scrolltoToc(position.top);
},
// recordsChange(records) {
Expand Down
89 changes: 45 additions & 44 deletions vueblog/src/views/blogEdit/BlogEdit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
<div class="m-content">
<div class="top-container">
<div class="article-bar">
<div class="btn-goback">
<!-- <div class="btn-goback"> -->
<router-link :to="{ name: 'ContentManagement' }" class="btn-goback">
<i class="el-icon-caret-left"></i>
<div class="text">文&nbsp;章&nbsp;管&nbsp;理</div>
</div>
</router-link>
<!-- </div> -->
<div class="bar-input">
<input
type="text"
Expand Down Expand Up @@ -41,12 +43,11 @@
<blog-edit-dialog
:blogTitle="ruleForm.title"
:blogContent="ruleForm.content"
:blogContentHtml="ruleForm.contentHtml"
:blogContentHtml="ruleForm.contentHtml"
:dialogShow="dialogShow"
@dialogShowChange="dialogShowChange"
></blog-edit-dialog>
</div>

</div>
</div>
</template>
Expand All @@ -62,17 +63,17 @@ export default {
},
data() {
return {
// 目录开始
tocs:[],
// 目录结束
avatarUrl:'',
// 目录开始
tocs: [],
// 目录结束
avatarUrl: "",
ruleForm: {
id:'',
title: '',
description:'',
content: '',
contentHtml:'',
status:2
id: "",
title: "",
description: "",
content: "",
contentHtml: "",
status: 2,
},
dialogShow: false,
};
Expand All @@ -85,43 +86,43 @@ export default {
// md文档开始
// 将图片上传到服务器,返回地址替换到md中
imgAdd(pos, $file) {
var _this = this
var _this = this;
var formdata = new FormData();
formdata.append('file', $file);
this.$axios.post("/blog/console/image",formdata,{
headers: { token: localStorage.getItem("token") },
}).then((response) => {
// 第二步.将返回的url替换到文本原位置![...](0) -> ![...](url)
if (response.status === 200) {
var url = response.data.data;
_this.$refs.md.$img2Url(pos,url)
}
console.log(response)
})
},
imgDel(pos) {

formdata.append("file", $file);
this.$axios
.post("/blog/console/image", formdata, {
headers: { token: localStorage.getItem("token") },
})
.then((response) => {
// 第二步.将返回的url替换到文本原位置![...](0) -> ![...](url)
if (response.status === 200) {
var url = response.data.data;
_this.$refs.md.$img2Url(pos, url);
}
console.log(response);
});
},
imgDel(pos) {},
// md文档结束
dialogShowChange(val) {
this.dialogShow = val;
},
// 保存文章
saveForm() {
this.$axios
.post("/blog/console/blog",
qs.stringify(this.ruleForm),
{ headers: { 'token': localStorage.getItem("token") } }
).then( res =>{
console.log(res)
if (res.data.code == 200 && res.data.status == true) {
this.$message({
showClose: true,
message: "保存成功~",
type: "success",
});
}
})
.post("/blog/console/blog", qs.stringify(this.ruleForm), {
headers: { token: localStorage.getItem("token") },
})
.then((res) => {
console.log(res);
if (res.data.code == 200 && res.data.status == true) {
this.$message({
showClose: true,
message: "保存成功~",
type: "success",
});
}
});
},
// 发布文章
submitForm() {
Expand All @@ -138,8 +139,8 @@ export default {
type: "warning",
});
} else {
this.ruleForm.contentHtml = this.$refs.md.d_render
// console.log(this.ruleForm.contentHtml)
this.ruleForm.contentHtml = this.$refs.md.d_render;
// console.log(this.ruleForm.contentHtml)
this.dialogShow = true;
}
},
Expand Down
11 changes: 8 additions & 3 deletions vueblog/src/views/home/childComps/FollowArticleItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export default {
headers: { token: localStorage.getItem("token") },
})
.then((res) => {
console.log(res);
// console.log(res);
// console.log(res.data.data.userAction)
if (res.data.data.userAction == null) {
this.isShow = false;
Expand All @@ -159,7 +159,7 @@ export default {
...this.userAction,
...res.data.data.userAction,
};
console.log(this.blogList);
// console.log(this.blogList);
$state.loaded();
} else {
$state.complete();
Expand All @@ -177,7 +177,7 @@ export default {
margin-left: 3px;
/* border-bottom: 1px solid #f0f0f2; */
background-color: #ffffff;
padding: 15px 0px 0 15px;
padding: 15px 15px 0 15px;
margin-bottom: 15px;

/* display: inline-block; */
Expand Down Expand Up @@ -244,6 +244,7 @@ export default {
.article-content-item {
display: flex;
padding-bottom: 15px;
height: 130px;
}
.article-content-right {
display: flex;
Expand All @@ -262,6 +263,10 @@ export default {
font-size: 14px;
font-weight: 400;
line-height: 22px;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 4;
overflow: hidden;
}

/*评价*/
Expand Down
11 changes: 8 additions & 3 deletions vueblog/src/views/home/childComps/NewArticleItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export default {
headers: { token: localStorage.getItem("token") },
})
.then((res) => {
console.log(res);
// console.log(res);
// console.log(res.data.data.userAction)
if (res.data.data.userAction == null) {
this.isShow = false;
Expand All @@ -159,7 +159,7 @@ export default {
...this.userAction,
...res.data.data.userAction,
};
console.log(this.blogList);
// console.log(this.blogList);
$state.loaded();
} else {
$state.complete();
Expand All @@ -177,7 +177,7 @@ export default {
margin-left: 3px;
/* border-bottom: 1px solid #f0f0f2; */
background-color: #ffffff;
padding: 15px 0px 0 15px;
padding: 15px 15px 0 15px;
margin-bottom: 15px;

/* display: inline-block; */
Expand Down Expand Up @@ -244,6 +244,7 @@ export default {
.article-content-item {
display: flex;
padding-bottom: 15px;
height: 130px;
}
.article-content-right {
display: flex;
Expand All @@ -262,6 +263,10 @@ export default {
font-size: 14px;
font-weight: 400;
line-height: 22px;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 4;
overflow: hidden;
}

/*评价*/
Expand Down
11 changes: 8 additions & 3 deletions vueblog/src/views/home/childComps/RecommendArticleItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export default {
headers: { token: localStorage.getItem("token") },
})
.then((res) => {
console.log(res);
// console.log(res);
// console.log(res.data.data.userAction)
if (res.data.data.userAction == null) {
this.isShow = false;
Expand All @@ -159,7 +159,7 @@ export default {
...this.userAction,
...res.data.data.userAction,
};
console.log(this.blogList);
// console.log(this.blogList);
$state.loaded();
} else {
$state.complete();
Expand All @@ -177,7 +177,7 @@ export default {
margin-left: 3px;
/* border-bottom: 1px solid #f0f0f2; */
background-color: #ffffff;
padding: 15px 0px 0 15px;
padding: 15px 15px 0 15px;
margin-bottom: 15px;

/* display: inline-block; */
Expand Down Expand Up @@ -251,6 +251,7 @@ export default {
.article-content-item {
display: flex;
padding-bottom: 15px;
height: 130px;
}
.article-content-right {
display: flex;
Expand All @@ -269,6 +270,10 @@ export default {
font-size: 14px;
font-weight: 400;
line-height: 22px;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 4;
overflow: hidden;
}

/*评价*/
Expand Down
15 changes: 15 additions & 0 deletions vueblog/src/views/login/childComps/LoginItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,18 @@ export default {
},
};
},
mounted(){
//登录绑定事件
window.addEventListener('keydown',this.keyDown);
},
methods: {
keyDown(e){
//如果是回车则执行登录方法
if(e.keyCode == 13){
this.submitForm('ruleForm');
}
},

submitForm(formName) {
this.$refs[formName].validate((valid) => {
if (valid) {
Expand Down Expand Up @@ -114,6 +125,10 @@ export default {
this.$refs[formName].resetFields();
},
},
//登录销毁
destroyed(){
window.removeEventListener('keydown',this.keyDown,false);
}
};
</script>

Expand Down
14 changes: 14 additions & 0 deletions vueblog/src/views/register/childComps/RegisterItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,17 @@ export default {
},
};
},
mounted(){
//登录绑定事件
window.addEventListener('keydown',this.keyDown);
},
methods: {
keyDown(e){
//如果是回车则执行登录方法
if(e.keyCode == 13){
this.submitForm('ruleForm');
}
},
// 获取省份
getProvinces() {
this.$axios.get("/resource/province").then((res) => {
Expand Down Expand Up @@ -378,6 +388,10 @@ export default {
});
},
},
//登录销毁
destroyed(){
window.removeEventListener('keydown',this.keyDown,false);
}
};
</script>

Expand Down