Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat:Add hits #190

Merged
merged 2 commits into from
Aug 23, 2022
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
5 changes: 4 additions & 1 deletion jvue-front/components/themes/default/Aside.vue
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ export default {
async mounted() {
const postsResult = await this.$axios.$post("/blog/post/list", {
isHot: 1,
postStatus: "publish"
postStatus: "publish",
postType: "post",
pageNum: 1,
pageSize: 25
});
this.postList = postsResult.status === 1 ? postsResult.data.list || [] : [];
logger.info("fetch aside postList finish");
Expand Down
12 changes: 12 additions & 0 deletions jvue-front/pages/post/_id.vue
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,15 @@ import { inBrowser } from "../../util/dom";

const logger = getLogger("pages/post");

// 更新浏览量
const updateHits = async (axiosObj, postId, hits) => {
const postParams = {
postId,
hits
};
await axiosObj.$post("/blog/post/updateHits", postParams);
};

export default {
components: { HeaderTime, Header, Footer, FriendLink, Artalk },
async asyncData(context) {
Expand Down Expand Up @@ -155,6 +164,9 @@ export default {
tagArray: tagArr
});

// 更新浏览量
await updateHits(context.$axios, postObj.id, ++postObj.hits);

logger.info("fetch siteConfig and post finish");

return { siteConfigObj, postObj, errorMessage };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ public RestResponse getPostList(@RequestParam(required = false) Integer pageNum,
}
if (null != isHot && isHot == 1) {
paramMap.put("isHot", isHot);
pageSize = 5;
}
if (StringUtils.isNotEmpty(postStatus)) {
paramMap.put("postStatus", postStatus);
Expand Down