-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
766b5d6
commit e159892
Showing
6 changed files
with
71 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<template lang="pug"> | ||
#following-latest-view.body-inner | ||
h1 已关注用户的作品 | ||
ArtworkList(:list='illusts', :loading='isLoading && !illusts.length') | ||
ShowMore( | ||
:loading='isLoading', | ||
:method='fetchList', | ||
:text='isLoading ? "加载中" : "加载更多"' | ||
v-if='hasNextPage && illusts.length' | ||
) | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import { type ArtworkInfo } from '@/types' | ||
onMounted(() => { | ||
setTitle('New Artworks from Following Users') | ||
fetchList() | ||
}) | ||
const illusts = ref<ArtworkInfo[]>([]) | ||
const userStore = useUserStore() | ||
const route = useRoute() | ||
const router = useRouter() | ||
const nextPage = ref(1) | ||
const hasNextPage = ref(true) | ||
const isLoading = ref(false) | ||
async function fetchList() { | ||
if (!userStore.isLoggedIn) { | ||
return router.push({ | ||
name: 'login', | ||
query: { back: route.fullPath }, | ||
}) | ||
} | ||
if (isLoading.value) return | ||
isLoading.value = true | ||
try { | ||
// https://www.pixiv.net/ajax/follow_latest/illust?p=1&mode=all | ||
const { data } = await ajax.get<{ | ||
page: { | ||
isLastPage: boolean | ||
} | ||
thumbnails: { | ||
illust: ArtworkInfo[] | ||
} | ||
}>(`/ajax/follow_latest/illust`, { | ||
params: { p: nextPage.value, mode: 'all' }, | ||
}) | ||
illusts.value.push(...data.thumbnails.illust) | ||
nextPage.value++ | ||
hasNextPage.value = !data.page.isLastPage | ||
} finally { | ||
isLoading.value = false | ||
} | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters