From b08d7e884e2f0f007d6f872e0e119997a47cc7f4 Mon Sep 17 00:00:00 2001 From: KUN1007 Date: Wed, 27 Sep 2023 20:43:19 +0800 Subject: [PATCH] feat: adjust REST api --- src/api/topic/index.ts | 24 ++++++++++--------- src/store/modules/topic.ts | 4 ++-- .../content/aside/components/AsideActive.vue | 4 +--- src/views/thanks-list/ThanksList.vue | 3 ++- src/views/topic/components/Master.vue | 1 + .../topic/components/comment/Comments.vue | 6 ++--- src/views/update-log/UpdateLog.vue | 2 +- 7 files changed, 23 insertions(+), 21 deletions(-) diff --git a/src/api/topic/index.ts b/src/api/topic/index.ts index 55892502..75944fed 100644 --- a/src/api/topic/index.ts +++ b/src/api/topic/index.ts @@ -9,16 +9,19 @@ const topicURLs = { getRelatedTopicsByTags: `/topic/nav/same`, // 楼主的其它话题 getPopularTopicsByUserUid: `/topic/nav/master`, + // 获取单个话题 getTopicByTid: `/topic/detail`, + // 根据话题 id 获取话题回复 - getRepliesByPid: `/topic/detail`, + getRepliesByPid: `/topic/detail/reply`, // 创建单个回复 - postReplyByPid: `/topic/detail`, + postReplyByPid: `/topic/detail/reply`, + // 获取一个回复下的所有评论 - getCommentsByReplyRid: `/topic/detail`, + getCommentsByReplyRid: `/topic/detail/comment`, // 创建一个评论 - postCommentByPidAndRid: `/topic/detail`, + postCommentByPidAndRid: `/topic/detail/comment`, } // 左侧相同标签下的其它话题 @@ -60,7 +63,7 @@ export async function getTopicByTidApi( tid: number ): Promise { try { - const url = `${topicURLs.getTopicByTid}/${tid}` + const url = `${topicURLs.getTopicByTid}?tid=${tid}` const response = await fetchGet(url) @@ -76,8 +79,8 @@ export async function getRepliesByPidApi( request: Topic.TopicReplyRequestData ): Promise { try { - const queryParams = objectToQueryParams(request, 'tid') - const url = `${topicURLs.getRepliesByPid}/${request.tid}/reply/?${queryParams}` + const queryParams = objectToQueryParams(request) + const url = `${topicURLs.getRepliesByPid}?${queryParams}` const response = await fetchGet(url) @@ -93,7 +96,7 @@ export async function postReplyByPidApi( request: Topic.TopicCreateReplyRequestData ): Promise { try { - const url = `${topicURLs.postReplyByPid}/${request.tid}/reply` + const url = `${topicURLs.postReplyByPid}` const response = await fetchPost( url, @@ -109,11 +112,10 @@ export async function postReplyByPidApi( // 获取一个回复下面的评论 export async function getCommentsByReplyRidApi( - tid: number, rid: number ): Promise { try { - const url = `${topicURLs.getCommentsByReplyRid}/${tid}/comment?rid=${rid}` + const url = `${topicURLs.getCommentsByReplyRid}?rid=${rid}` const response = await fetchGet(url) @@ -129,7 +131,7 @@ export async function postCommentByPidAndRidApi( request: Topic.TopicCreateCommentRequestData ): Promise { try { - const url = `${topicURLs.postCommentByPidAndRid}/${request.tid}/comment` + const url = `${topicURLs.postCommentByPidAndRid}` const response = await fetchPost( url, diff --git a/src/store/modules/topic.ts b/src/store/modules/topic.ts index c96b3317..3122a438 100644 --- a/src/store/modules/topic.ts +++ b/src/store/modules/topic.ts @@ -239,9 +239,9 @@ export const useKUNGalgameTopicStore = defineStore({ }) }, // 获取评论 - getComments(tid: number, rid: number): Promise { + getComments(rid: number): Promise { return new Promise((resolve, reject) => { - getCommentsByReplyRidApi(tid, rid) + getCommentsByReplyRidApi(rid) .then((res) => { resolve(res) }) diff --git a/src/views/Home/content/aside/components/AsideActive.vue b/src/views/Home/content/aside/components/AsideActive.vue index 66243ce6..e77f2623 100644 --- a/src/views/Home/content/aside/components/AsideActive.vue +++ b/src/views/Home/content/aside/components/AsideActive.vue @@ -38,7 +38,6 @@ const props = defineProps(['isActive']) /* 侧边栏功能区 */ .item-box { width: 100%; - flex-grow: 1; /* 设置六个功能(模式、排行、背景等)分布的弹性盒 */ display: flex; flex-direction: column; @@ -46,8 +45,7 @@ const props = defineProps(['isActive']) /* 发布话题 */ .new-article { width: 100%; - /* 发布话题的按钮相对于功能区盒子的占比 */ - flex-grow: 1; + height: 163px; /* 发布按钮样式 */ button { height: 100%; diff --git a/src/views/thanks-list/ThanksList.vue b/src/views/thanks-list/ThanksList.vue index 8559ffe9..59807c22 100644 --- a/src/views/thanks-list/ThanksList.vue +++ b/src/views/thanks-list/ThanksList.vue @@ -110,9 +110,10 @@ const thanksListPageWidth = computed(() => { /* 固定宽高 */ transition: all 0.2s; width: v-bind(thanksListPageWidth); + max-width: 1300px; height: 1300px; /* 居中 */ - margin: auto; + margin: 0 auto; position: relative; border-radius: 7px; box-shadow: var(--shadow); diff --git a/src/views/topic/components/Master.vue b/src/views/topic/components/Master.vue index 22a55754..ffa6f316 100644 --- a/src/views/topic/components/Master.vue +++ b/src/views/topic/components/Master.vue @@ -129,6 +129,7 @@ const loliStatus = computed(() => { box-shadow: var(--shadow); background-color: var(--kungalgame-trans-white-5); box-sizing: border-box; + transition: all 0.5s; } /* 楼主话题头部 */ diff --git a/src/views/topic/components/comment/Comments.vue b/src/views/topic/components/comment/Comments.vue index ebe34b2d..11d6ee1a 100644 --- a/src/views/topic/components/comment/Comments.vue +++ b/src/views/topic/components/comment/Comments.vue @@ -30,8 +30,8 @@ const toUserInfo = reactive({ name: '', }) -const getComments = async (tid: number, rid: number) => { - return (await useKUNGalgameTopicStore().getComments(tid, rid)).data +const getComments = async (rid: number) => { + return (await useKUNGalgameTopicStore().getComments(rid)).data } // 拿到新发布的评论并 push 到原来的数据里,无需重新获取 @@ -44,7 +44,7 @@ onMounted(async () => { toUserInfo.name = props.toUser.name toUserInfo.uid = props.toUser.uid - commentsData.value = await getComments(props.tid, props.rid) + commentsData.value = await getComments(props.rid) }) // 点击回复 diff --git a/src/views/update-log/UpdateLog.vue b/src/views/update-log/UpdateLog.vue index 848f3dd1..027aaf7a 100644 --- a/src/views/update-log/UpdateLog.vue +++ b/src/views/update-log/UpdateLog.vue @@ -25,7 +25,7 @@ import KUNGalgameFooter from '@/components/KUNGalgameFooter.vue' - +