feat: adjust REST api
This commit is contained in:
parent
34d771a749
commit
e51d734523
|
@ -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<Topic.TopicDetailResponseData> {
|
||||
try {
|
||||
const url = `${topicURLs.getTopicByTid}/${tid}`
|
||||
const url = `${topicURLs.getTopicByTid}?tid=${tid}`
|
||||
|
||||
const response = await fetchGet<Topic.TopicDetailResponseData>(url)
|
||||
|
||||
|
@ -76,8 +79,8 @@ export async function getRepliesByPidApi(
|
|||
request: Topic.TopicReplyRequestData
|
||||
): Promise<Topic.TopicReplyResponseData> {
|
||||
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<Topic.TopicReplyResponseData>(url)
|
||||
|
||||
|
@ -93,7 +96,7 @@ export async function postReplyByPidApi(
|
|||
request: Topic.TopicCreateReplyRequestData
|
||||
): Promise<Topic.TopicCreateReplyResponseData> {
|
||||
try {
|
||||
const url = `${topicURLs.postReplyByPid}/${request.tid}/reply`
|
||||
const url = `${topicURLs.postReplyByPid}`
|
||||
|
||||
const response = await fetchPost<Topic.TopicCreateReplyResponseData>(
|
||||
url,
|
||||
|
@ -109,11 +112,10 @@ export async function postReplyByPidApi(
|
|||
|
||||
// 获取一个回复下面的评论
|
||||
export async function getCommentsByReplyRidApi(
|
||||
tid: number,
|
||||
rid: number
|
||||
): Promise<Topic.TopicCommentResponseData> {
|
||||
try {
|
||||
const url = `${topicURLs.getCommentsByReplyRid}/${tid}/comment?rid=${rid}`
|
||||
const url = `${topicURLs.getCommentsByReplyRid}?rid=${rid}`
|
||||
|
||||
const response = await fetchGet<Topic.TopicCommentResponseData>(url)
|
||||
|
||||
|
@ -129,7 +131,7 @@ export async function postCommentByPidAndRidApi(
|
|||
request: Topic.TopicCreateCommentRequestData
|
||||
): Promise<Topic.TopicCreateCommentResponseData> {
|
||||
try {
|
||||
const url = `${topicURLs.postCommentByPidAndRid}/${request.tid}/comment`
|
||||
const url = `${topicURLs.postCommentByPidAndRid}`
|
||||
|
||||
const response = await fetchPost<Topic.TopicCreateCommentResponseData>(
|
||||
url,
|
||||
|
|
|
@ -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) => {
|
||||
getCommentsByReplyRidApi(tid, rid)
|
||||
getCommentsByReplyRidApi(rid)
|
||||
.then((res) => {
|
||||
resolve(res)
|
||||
})
|
||||
|
|
|
@ -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%;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
/* 楼主话题头部 */
|
||||
|
|
|
@ -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)
|
||||
})
|
||||
|
||||
// 点击回复
|
||||
|
|
|
@ -25,7 +25,7 @@ import KUNGalgameFooter from '@/components/KUNGalgameFooter.vue'
|
|||
</div>
|
||||
</div>
|
||||
<!-- 版权 -->
|
||||
<KUNGalgameFooter />
|
||||
<KUNGalgameFooter style="display: block" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
|
Loading…
Reference in a new issue