From 47ecdd1a250794faa7bf14c417586fa0d5143292 Mon Sep 17 00:00:00 2001 From: ppo-0 <1304578864@qq.com> Date: Thu, 8 Feb 2024 18:16:04 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat:=E6=96=B0=E5=A2=9E=E5=B8=96=E5=AD=90?= =?UTF-8?q?=E7=82=B9=E8=B5=9E=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/posts/posts.vue | 102 ++++++++++++++++++++++++++++++++------ src/views/posts/utils.ts | 15 +++--- 2 files changed, 94 insertions(+), 23 deletions(-) diff --git a/src/views/posts/posts.vue b/src/views/posts/posts.vue index e8e14cb..881b8e7 100644 --- a/src/views/posts/posts.vue +++ b/src/views/posts/posts.vue @@ -36,15 +36,35 @@
{{ post.title }}
- {{ post.author.name }}: {{ post.text }} + {{ post.userName }}: {{ post.text }}
@@ -61,6 +81,7 @@ import avatar from '@/components/avatar.vue' import popup from '@/views/home/popup.vue' import { ref, onMounted } from 'vue' import { getOtherPosts } from './utils' +import { post } from '@/utils/request' import type { responseGetOtherPosts } from './utils' const isPopup = ref(false) @@ -72,6 +93,19 @@ onMounted(async () => { postsList.value = await getOtherPosts() }) +const likePost = (thisPost: any) => { + //还需要判断用户是否登录,只有登录才可以点赞 + post('/relation/createRelation', { + toId: thisPost.postId, + toType: 4, + relationType: 1 + }) + .then(() => { + thisPost.liked = true + thisPost.likeCount ++ + }) +} + const mouseoverPopup = () => { isPopup.value = true } const mouseleavePopup = () => { isPopup.value = false } @@ -222,25 +256,61 @@ const mouseleavePopup = () => { isPopup.value = false } .posts-footer { margin-top: 10px; color: #494848; + cursor: pointer; display: flex; align-items: center; + justify-content: space-between; - .like { - margin-right: 20px; - font-weight: 600; - color: #29529e; + .post-detail { display: flex; - i { + .like, + .liked, + .remark { + margin-right: 20px; + display: flex; + + i { + font-size: 20px; + margin-right: 3px; + } + } + + .i { font-size: 20px; - margin-right: 3px; + margin-right: 20px; + } + + .like:hover, + .remark:hover { + color: #6d99ec; + } + + i:hover { + color: #6d99ec; + } + + .liked { + color: #6d99ec; + font-weight: 600; + } + .liked:hover { + color: #494848; } } - .i { - font-size: 20px; - margin-right: 20px; - cursor: pointer; + .tag { + display: flex; + + button { + background-color: #b0d3f8; + color: #fff; + border: none; + border-radius: 5px; + padding: 5px 10px; + margin-right: 10px; + cursor: pointer; + } } } } diff --git a/src/views/posts/utils.ts b/src/views/posts/utils.ts index 14279af..58f0151 100644 --- a/src/views/posts/utils.ts +++ b/src/views/posts/utils.ts @@ -7,10 +7,11 @@ export interface responseGetOtherPosts { title: string, text: string, url: string, + tags: string[], likeCount: number, - author: { - name: string, - } + commentCount: number, + liked: boolean, + userName: string, }[] } @@ -26,13 +27,13 @@ export const getOtherPosts = async () => { title: post.title, text: post.text, url: post.url, + tags: post.tags, likeCount: post.likeCount, - author: { - name: post.author.name, - } + commentCount: post.commentCount, + liked: post.liked, + userName: post.userName })) } }) - return postsList.value } \ No newline at end of file From b79571582e9c3119d3a416cee5a69ffbb35e98e7 Mon Sep 17 00:00:00 2001 From: ppo-0 <1304578864@qq.com> Date: Fri, 9 Feb 2024 22:02:05 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8D=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E5=90=8E=E4=B8=AA=E4=BA=BA=E4=BF=A1=E6=81=AF=E7=9A=84bug?= =?UTF-8?q?=E4=BB=A5=E5=8F=8A=E5=85=A8=E5=B1=80=E7=9A=84=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/captcha.vue | 22 +-- src/store/index.ts | 41 +++--- src/utils/request.ts | 73 +++++----- src/views/home/popup.vue | 14 +- src/views/information/utils.ts | 4 + src/views/login/login.vue | 228 ++++++++++++++------------------ src/views/login/third-login.vue | 68 ++++++++++ src/views/register/register.vue | 121 +++++++++-------- 8 files changed, 327 insertions(+), 244 deletions(-) create mode 100644 src/views/login/third-login.vue diff --git a/src/components/captcha.vue b/src/components/captcha.vue index 9e2c67e..f215ad8 100644 --- a/src/components/captcha.vue +++ b/src/components/captcha.vue @@ -60,7 +60,7 @@ const mouseDown = (event: MouseEvent) => { clickX = event.clientX sliderLeft.value = clickX - trackLeft.value minX.value = clickX - maxX.value = minX.value + 190 + maxX.value = minX.value + 230 } } @@ -69,15 +69,15 @@ const mouseMove = (event: MouseEvent) => { sliderX.value = event.clientX - trackLeft.value - sliderLeft.value if (sliderX.value < 0) { sliderX.value = 0 - } else if (sliderX.value > 190) { - sliderX.value = 190 + } else if (sliderX.value > 230) { + sliderX.value = 230 } } } const mouseUp = () => { if (isMouseDown.value) { - if (sliderX.value < 190) { + if (sliderX.value < 230) { errorMsg("验证失败,请重新验证") isCaptcha.value = "error" slider.value.classList.add("slider-error") @@ -91,7 +91,7 @@ const mouseUp = () => { } else { successMsg("验证成功") - sliderX.value = 190 + sliderX.value = 230 isCaptcha.value = "success" slider.value.classList.add("slider-success") filled.value.classList.add("filled-success") @@ -117,8 +117,8 @@ defineExpose({ \ No newline at end of file diff --git a/src/views/login/third-login.vue b/src/views/login/third-login.vue new file mode 100644 index 0000000..b831107 --- /dev/null +++ b/src/views/login/third-login.vue @@ -0,0 +1,68 @@ + + + + + \ No newline at end of file diff --git a/src/views/register/register.vue b/src/views/register/register.vue index 19905b8..ad3becf 100644 --- a/src/views/register/register.vue +++ b/src/views/register/register.vue @@ -1,10 +1,10 @@