Skip to content

Commit

Permalink
feat: 作者榜修复
Browse files Browse the repository at this point in the history
  • Loading branch information
MarleneJiang committed Feb 10, 2023
1 parent 9155ae8 commit 4923696
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
Binary file modified backend/.tmp/data.db
Binary file not shown.
20 changes: 15 additions & 5 deletions frontend/components/Aside/AuthorList.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
<script setup lang="ts">
const { data: AuthorList } = await useFetch('/api/authors/list')
import { useAutoAnimate } from '@formkit/auto-animate/vue'
const [parent] = useAutoAnimate()
const page = ref(1)
const AuthorList = ref([]) as any
const { data } = (await useFetch(`/api/authors/list?page=${page.value}`))
AuthorList.value = data.value
const showAll = async () => {
page.value = 2
const { data } = (await useFetch(`/api/authors/list?page=${page.value}`))
AuthorList.value.push(...data.value)
}
</script>

<template>
Expand All @@ -8,7 +18,7 @@ const { data: AuthorList } = await useFetch('/api/authors/list')
<div class="user-block-header">
🎖️作者榜
</div>
<div class="user-list">
<div ref="parent" class="user-list">
<div v-for="item in AuthorList" :key="item.uid" class="item">
<nuxt-link target="_blank" rel="" class="link">
<nuxt-img :src="item.avatar" :alt="`${item.name}的头像`" class="lazy avatar" loading="lazy" />
Expand All @@ -19,7 +29,7 @@ const { data: AuthorList } = await useFetch('/api/authors/list')
{{ item.name }}
</span>
<span blank="true" class="rank">
<nuxt-img src="https://lf3-cdn-tos.bytescm.com/obj/static/xitu_juejin_web/img/lv-4.a78c420.png" :alt="`lv-${item.rank}`" title="创作等级" />
<nuxt-img :src="`https://pan.marlene.top/d/share/jj/${item.rank}.png`" :alt="`lv-${item.rank}`" title="创作等级" />
</span>
</div>
<div class="position">
Expand All @@ -29,12 +39,12 @@ const { data: AuthorList } = await useFetch('/api/authors/list')
</nuxt-link>
</div>

<nuxt-link href="/recommendation/authors/recommended" class="item" target="_blank">
<div v-if="page === 1" class="item cursor-pointer" @click="showAll">
<div class="more" f-c-c text-link>
<span>完整榜单</span>
<div class="icon" i-carbon-chevron-right />
</div>
</nuxt-link>
</div>
</div>
</div>
</div>
Expand Down
9 changes: 7 additions & 2 deletions frontend/server/api/authors/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,14 @@ interface IAuthorListItem {
avatar: string
rank: Number
}
export default defineEventHandler(async (): Promise<IAuthorListItem[]> => {
export default defineEventHandler(async (event): Promise<IAuthorListItem[]> => {
const query = getQuery(event)
const page = query?.page || 1
const reqQuery = `query{
authors(pagination: { page: 1, pageSize: 3 }){
authors(
pagination: { page: ${page}, pageSize: 4 }
sort: "rank:desc"
){
data{
attributes{
name
Expand Down

0 comments on commit 4923696

Please sign in to comment.