1
0

fix: backend not responding offset

This commit is contained in:
alikia2x (寒寒) 2025-11-30 01:51:12 +08:00
parent e6623b3937
commit a31257c441
WARNING! Although there is a key with this ID in the database it does not verify this commit! This commit is SUSPICIOUS.
GPG Key ID: 56209E0CCD8420C6
2 changed files with 11 additions and 9 deletions

View File

@ -15,20 +15,20 @@ const range = {
export const closeMileStoneHandler = new Elysia({ prefix: "/songs" }).use(serverTiming()).get(
"/close-milestone/:type",
async ({ params }) => {
async ({ params, query }) => {
const type = params.type;
const offset = params.offset;
const limit = params.limit;
const offset = query.offset;
const limit = query.limit;
const min = range[type as MileStoneType][0];
const max = range[type as MileStoneType][1];
const query = db
const q = db
.select()
.from(eta)
.innerJoin(bilibiliMetadata, eq(bilibiliMetadata.aid, eta.aid))
.where(and(gte(eta.currentViews, min), lt(eta.currentViews, max)))
.orderBy(eta.eta)
.$dynamic();
return query.limit(limit || 20).offset(offset || 0);
return q.limit(limit || 20).offset(offset || 0);
},
{
response: {
@ -49,7 +49,9 @@ export const closeMileStoneHandler = new Elysia({ prefix: "/songs" }).use(server
})
},
params: t.Object({
type: t.String({ enum: ["dendou", "densetsu", "shinwa"] }),
type: t.String({ enum: ["dendou", "densetsu", "shinwa"] })
}),
query: t.Object({
offset: t.Optional(t.Number()),
limit: t.Optional(t.Number())
}),

View File

@ -90,7 +90,7 @@ export const MilestoneVideos: React.FC = () => {
const target = e.currentTarget;
const { scrollHeight, scrollTop, clientHeight } = target;
if (scrollTop + clientHeight >= scrollHeight - 400 && !isLoadingMore && hasMore) {
if (scrollTop + clientHeight >= scrollHeight - 500 && !isLoadingMore && hasMore) {
setOffset((prev) => prev + 20);
}
},
@ -146,8 +146,8 @@ export const MilestoneVideos: React.FC = () => {
/>
))}
{isLoadingMore && (
<div className="rounded-xl my-4 px-3 py-4">
<Skeleton className="h-40 rounded-xl" />
<div className="rounded-xl my-4 shadow-sm border border-gray-200 dark:border-neutral-700">
<Skeleton className="h-49 sm:h-55 w-full rounded-xl" />
</div>
)}
</ScrollArea>