feat: adjust REST api

This commit is contained in:
KUN1007 2023-09-27 20:43:19 +08:00
parent 8a3760b7d7
commit b08d7e884e
7 changed files with 23 additions and 21 deletions

View file

@ -9,16 +9,19 @@ const topicURLs = {
getRelatedTopicsByTags: `/topic/nav/same`, getRelatedTopicsByTags: `/topic/nav/same`,
// 楼主的其它话题 // 楼主的其它话题
getPopularTopicsByUserUid: `/topic/nav/master`, getPopularTopicsByUserUid: `/topic/nav/master`,
// 获取单个话题 // 获取单个话题
getTopicByTid: `/topic/detail`, getTopicByTid: `/topic/detail`,
// 根据话题 id 获取话题回复 // 根据话题 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 tid: number
): Promise<Topic.TopicDetailResponseData> { ): Promise<Topic.TopicDetailResponseData> {
try { try {
const url = `${topicURLs.getTopicByTid}/${tid}` const url = `${topicURLs.getTopicByTid}?tid=${tid}`
const response = await fetchGet<Topic.TopicDetailResponseData>(url) const response = await fetchGet<Topic.TopicDetailResponseData>(url)
@ -76,8 +79,8 @@ export async function getRepliesByPidApi(
request: Topic.TopicReplyRequestData request: Topic.TopicReplyRequestData
): Promise<Topic.TopicReplyResponseData> { ): Promise<Topic.TopicReplyResponseData> {
try { try {
const queryParams = objectToQueryParams(request, 'tid') const queryParams = objectToQueryParams(request)
const url = `${topicURLs.getRepliesByPid}/${request.tid}/reply/?${queryParams}` const url = `${topicURLs.getRepliesByPid}?${queryParams}`
const response = await fetchGet<Topic.TopicReplyResponseData>(url) const response = await fetchGet<Topic.TopicReplyResponseData>(url)
@ -93,7 +96,7 @@ export async function postReplyByPidApi(
request: Topic.TopicCreateReplyRequestData request: Topic.TopicCreateReplyRequestData
): Promise<Topic.TopicCreateReplyResponseData> { ): Promise<Topic.TopicCreateReplyResponseData> {
try { try {
const url = `${topicURLs.postReplyByPid}/${request.tid}/reply` const url = `${topicURLs.postReplyByPid}`
const response = await fetchPost<Topic.TopicCreateReplyResponseData>( const response = await fetchPost<Topic.TopicCreateReplyResponseData>(
url, url,
@ -109,11 +112,10 @@ export async function postReplyByPidApi(
// 获取一个回复下面的评论 // 获取一个回复下面的评论
export async function getCommentsByReplyRidApi( export async function getCommentsByReplyRidApi(
tid: number,
rid: number rid: number
): Promise<Topic.TopicCommentResponseData> { ): Promise<Topic.TopicCommentResponseData> {
try { try {
const url = `${topicURLs.getCommentsByReplyRid}/${tid}/comment?rid=${rid}` const url = `${topicURLs.getCommentsByReplyRid}?rid=${rid}`
const response = await fetchGet<Topic.TopicCommentResponseData>(url) const response = await fetchGet<Topic.TopicCommentResponseData>(url)
@ -129,7 +131,7 @@ export async function postCommentByPidAndRidApi(
request: Topic.TopicCreateCommentRequestData request: Topic.TopicCreateCommentRequestData
): Promise<Topic.TopicCreateCommentResponseData> { ): Promise<Topic.TopicCreateCommentResponseData> {
try { try {
const url = `${topicURLs.postCommentByPidAndRid}/${request.tid}/comment` const url = `${topicURLs.postCommentByPidAndRid}`
const response = await fetchPost<Topic.TopicCreateCommentResponseData>( const response = await fetchPost<Topic.TopicCreateCommentResponseData>(
url, url,

View file

@ -239,9 +239,9 @@ export const useKUNGalgameTopicStore = defineStore({
}) })
}, },
// 获取评论 // 获取评论
getComments(tid: number, rid: number): Promise<TopicCommentResponseData> { getComments(rid: number): Promise<TopicCommentResponseData> {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
getCommentsByReplyRidApi(tid, rid) getCommentsByReplyRidApi(rid)
.then((res) => { .then((res) => {
resolve(res) resolve(res)
}) })

View file

@ -38,7 +38,6 @@ const props = defineProps(['isActive'])
/* 侧边栏功能区 */ /* 侧边栏功能区 */
.item-box { .item-box {
width: 100%; width: 100%;
flex-grow: 1;
/* 设置六个功能(模式、排行、背景等)分布的弹性盒 */ /* 设置六个功能(模式、排行、背景等)分布的弹性盒 */
display: flex; display: flex;
flex-direction: column; flex-direction: column;
@ -46,8 +45,7 @@ const props = defineProps(['isActive'])
/* 发布话题 */ /* 发布话题 */
.new-article { .new-article {
width: 100%; width: 100%;
/* 发布话题的按钮相对于功能区盒子的占比 */ height: 163px;
flex-grow: 1;
/* 发布按钮样式 */ /* 发布按钮样式 */
button { button {
height: 100%; height: 100%;

View file

@ -110,9 +110,10 @@ const thanksListPageWidth = computed(() => {
/* 固定宽高 */ /* 固定宽高 */
transition: all 0.2s; transition: all 0.2s;
width: v-bind(thanksListPageWidth); width: v-bind(thanksListPageWidth);
max-width: 1300px;
height: 1300px; height: 1300px;
/* 居中 */ /* 居中 */
margin: auto; margin: 0 auto;
position: relative; position: relative;
border-radius: 7px; border-radius: 7px;
box-shadow: var(--shadow); box-shadow: var(--shadow);

View file

@ -129,6 +129,7 @@ const loliStatus = computed(() => {
box-shadow: var(--shadow); box-shadow: var(--shadow);
background-color: var(--kungalgame-trans-white-5); background-color: var(--kungalgame-trans-white-5);
box-sizing: border-box; box-sizing: border-box;
transition: all 0.5s;
} }
/* 楼主话题头部 */ /* 楼主话题头部 */

View file

@ -30,8 +30,8 @@ const toUserInfo = reactive({
name: '', name: '',
}) })
const getComments = async (tid: number, rid: number) => { const getComments = async (rid: number) => {
return (await useKUNGalgameTopicStore().getComments(tid, rid)).data return (await useKUNGalgameTopicStore().getComments(rid)).data
} }
// push // push
@ -44,7 +44,7 @@ onMounted(async () => {
toUserInfo.name = props.toUser.name toUserInfo.name = props.toUser.name
toUserInfo.uid = props.toUser.uid toUserInfo.uid = props.toUser.uid
commentsData.value = await getComments(props.tid, props.rid) commentsData.value = await getComments(props.rid)
}) })
// //

View file

@ -25,7 +25,7 @@ import KUNGalgameFooter from '@/components/KUNGalgameFooter.vue'
</div> </div>
</div> </div>
<!-- 版权 --> <!-- 版权 -->
<KUNGalgameFooter /> <KUNGalgameFooter style="display: block" />
</div> </div>
</div> </div>
</template> </template>