diff --git a/src/api/ranking/index.ts b/src/api/ranking/index.ts index 9b9cc4b3..c66dca60 100644 --- a/src/api/ranking/index.ts +++ b/src/api/ranking/index.ts @@ -12,3 +12,14 @@ export async function getRankingTopicsApi( const response = await fetchGet(url) return response } + +// 获取 ranking 热门用户 +export async function getRankingUsersApi( + request: Ranking.RankingGetUserRequestData +): Promise { + const queryParams = objectToQueryParams(request) + const url = `/ranking/users?${queryParams}` + + const response = await fetchGet(url) + return response +} diff --git a/src/api/ranking/types/ranking.ts b/src/api/ranking/types/ranking.ts index ac895814..db1e8c87 100644 --- a/src/api/ranking/types/ranking.ts +++ b/src/api/ranking/types/ranking.ts @@ -1,8 +1,26 @@ +type SortOrder = 'asc' | 'desc' + +type TopicSortFieldRanking = + | 'popularity' + | 'views' + | 'upvotes_count' + | 'likes_count' + | 'replies_count' + | 'comments' + +type UserSortFieldRanking = + | 'moemoepoint' + | 'upvote' + | 'like' + | 'topic_count' + | 'reply_count' + | 'comment_count' + export interface RankingGetTopicsRequestData { page: number limit: number - sortField: string - sortOrder: 'asc' | 'desc' + sortField: TopicSortFieldRanking + sortOrder: SortOrder } export interface RankingTopics { @@ -11,8 +29,22 @@ export interface RankingTopics { field: string } -export interface RankingGetUserRequestData {} +export interface RankingGetUserRequestData { + page: number + limit: number + sortField: UserSortFieldRanking + sortOrder: SortOrder +} + +export interface RankingUsers { + uid: number + name: string + avatar: string + field: string +} export type RankingGetTopicsResponseData = KUNGalgameResponseData< RankingTopics[] > + +export type RankingGetUsersResponseData = KUNGalgameResponseData diff --git a/src/components/top-bar/KUNGalgameTopBar.vue b/src/components/top-bar/KUNGalgameTopBar.vue index 9d562d89..aff4b496 100644 --- a/src/components/top-bar/KUNGalgameTopBar.vue +++ b/src/components/top-bar/KUNGalgameTopBar.vue @@ -212,7 +212,7 @@ $navNumber: v-bind(navItemNum); } &:nth-child(3):hover ~ .box { - background-color: var(--kungalgame-yellow-3); + background-color: var(--kungalgame-yellow-2); left: calc(100% / $navNumber * 2); } diff --git a/src/store/modules/ranking.ts b/src/store/modules/ranking.ts index 8bd4cef1..b8525f2f 100644 --- a/src/store/modules/ranking.ts +++ b/src/store/modules/ranking.ts @@ -5,9 +5,10 @@ import type { RankingGetTopicsRequestData, RankingGetTopicsResponseData, RankingGetUserRequestData, + RankingGetUsersResponseData, } from '@/api' -import { getRankingTopicsApi } from '@/api' +import { getRankingTopicsApi, getRankingUsersApi } from '@/api' interface RankingStore { topic: RankingGetTopicsRequestData @@ -20,12 +21,17 @@ export const useKUNGalgameRankingStore = defineStore({ persist: false, state: (): RankingStore => ({ topic: { - page: 0, - limit: 0, + page: 1, + limit: 30, sortField: 'popularity', sortOrder: 'desc', }, - user: {}, + user: { + page: 1, + limit: 30, + sortField: 'moemoepoint', + sortOrder: 'desc', + }, }), getters: {}, actions: { @@ -39,5 +45,16 @@ export const useKUNGalgameRankingStore = defineStore({ return await getRankingTopicsApi(requestData) }, + + async getUsers(): Promise { + const requestData: RankingGetUserRequestData = { + page: this.user.page, + limit: this.user.limit, + sortField: this.user.sortField, + sortOrder: this.user.sortOrder, + } + + return await getRankingUsersApi(requestData) + }, }, }) diff --git a/src/styles/theme/color.scss b/src/styles/theme/color.scss index 472e9941..8d0999b7 100644 --- a/src/styles/theme/color.scss +++ b/src/styles/theme/color.scss @@ -17,6 +17,7 @@ html { --kungalgame-green-4: #2da44e; + --kungalgame-yellow-2: #fcd554; --kungalgame-yellow-3: #d4a72c; --kungalgame-red-0: #ffebe9; diff --git a/src/views/ranking/components/KUNGalgamer.vue b/src/views/ranking/components/KUNGalgamer.vue index 8399ba84..6b2bcc2d 100644 --- a/src/views/ranking/components/KUNGalgamer.vue +++ b/src/views/ranking/components/KUNGalgamer.vue @@ -1,63 +1,116 @@ diff --git a/src/views/ranking/components/KUNGalgamerForm.vue b/src/views/ranking/components/KUNGalgamerForm.vue index 77a11457..ce26fea1 100644 --- a/src/views/ranking/components/KUNGalgamerForm.vue +++ b/src/views/ranking/components/KUNGalgamerForm.vue @@ -1,41 +1,104 @@ diff --git a/src/views/ranking/components/Topic.vue b/src/views/ranking/components/Topic.vue index c655efc3..e2cf63f4 100644 --- a/src/views/ranking/components/Topic.vue +++ b/src/views/ranking/components/Topic.vue @@ -1,7 +1,8 @@