diff --git a/src/components/Hot.vue b/src/components/Hot.vue deleted file mode 100644 index 67b0914..0000000 --- a/src/components/Hot.vue +++ /dev/null @@ -1,139 +0,0 @@ - - - diff --git a/src/components/RoomList.vue b/src/components/RoomList.vue index 139173d..6960f29 100644 --- a/src/components/RoomList.vue +++ b/src/components/RoomList.vue @@ -13,6 +13,7 @@ import { getObjValue } from "@/utils"; const router = useRouter(); const props = defineProps<{ isMyRoom: boolean; + isHot: boolean; userId?: string; }>(); @@ -41,6 +42,9 @@ const { getMyRoomList, myRoomList, + getHotRoomList, + hotRoomList, + joinRoom } = useRoomApi(formData.value.roomId); @@ -48,6 +52,9 @@ const getRoomList = async (showMsg = false) => { if (props.isMyRoom) { await getMyRoomList(showMsg); if (myRoomList.value) thisRoomList.value = myRoomList.value.list!; + } else if (props.isHot) { + await getHotRoomList(showMsg); + if (hotRoomList.value) thisRoomList.value = hotRoomList.value.list!; } else { await getRoomList_(); if (roomList.value) thisRoomList.value = roomList.value.list!; @@ -88,9 +95,9 @@ onMounted(() => {
- {{ isMyRoom ? "我创建的" : "房间列表" }}({{ thisRoomList.length }}) + {{ isMyRoom ? "我创建的" : isHot ? "热度榜" : "房间列表" }}({{ thisRoomList.length }})
-
+
排序方式: {
-
+
{
-
+
+
+
+ {{ i + 1 }} +
+
+ {{ item["roomName"] }} +
+
+ 在线人数:{{ + item["peopleNum"] + }} + +
创建者:{{ item.creator }}
+
+
+ + {{ item.needPassword ? "有密码" : "无密码" }} + + +
+
+
{ // 检查房间状态 @@ -113,7 +113,7 @@ export const useRoomApi = (roomId: string) => { showMsg && ElNotification({ - title: `更新列表成功`, + title: "更新列表成功", type: "success" }); } catch (err: any) { @@ -151,7 +151,7 @@ export const useRoomApi = (roomId: string) => { showMsg && ElNotification({ - title: `更新列表成功`, + title: "更新列表成功", type: "success" }); } catch (err: any) { @@ -194,7 +194,7 @@ export const useRoomApi = (roomId: string) => { showMsg && ElNotification({ - title: `更新列表成功`, + title: "更新列表成功", type: "success" }); } catch (err: any) { @@ -207,6 +207,35 @@ export const useRoomApi = (roomId: string) => { } }; + // 热度榜 + const { state: hotRoomList, execute: reqHotRoomList } = hotRoom(); + const getHotRoomList = async (showMsg = false) => { + try { + await reqHotRoomList({ + params: { + page: currentPage.value, + max: pageSize.value + } + }); + + if (hotRoomList.value) { + totalItems.value = hotRoomList.value.total; + } + + showMsg && + ElNotification({ + title: "更新列表成功", + type: "success" + }); + } catch (err: any) { + console.error(err.message); + ElNotification({ + title: "错误", + message: err.response.data.error || err.message, + type: "error" + }); + } + }; return { checkRoom, thisRoomInfo, @@ -230,6 +259,9 @@ export const useRoomApi = (roomId: string) => { getUserRoomList, userRoomList, - userRoomListLoading + userRoomListLoading, + + getHotRoomList, + hotRoomList }; }; diff --git a/src/views/HomeView.vue b/src/views/HomeView.vue index 53f48a5..8a961e8 100644 --- a/src/views/HomeView.vue +++ b/src/views/HomeView.vue @@ -1,5 +1,5 @@