feat: 下载历史数量限制为 30 条

This commit is contained in:
R524809
2026-05-25 17:11:40 +08:00
parent 827a7866e2
commit 0e6e8902dd
4 changed files with 17 additions and 8 deletions
+6 -3
View File
@@ -62,9 +62,12 @@ async function handleAdd(userId, event) {
return { code: 0, data: { _id, ...record } };
}
const MAX_LIST_PAGE_SIZE = 30;
async function handleList(userId, event) {
const { page = 1, pageSize = 20 } = event;
const skip = (page - 1) * pageSize;
const { page = 1, pageSize = MAX_LIST_PAGE_SIZE } = event;
const limit = Math.min(Math.max(1, Number(pageSize) || 1), MAX_LIST_PAGE_SIZE);
const skip = (page - 1) * limit;
const collection = db.collection('download_logs');
@@ -72,7 +75,7 @@ async function handleList(userId, event) {
.where({ userId })
.orderBy('createdAt', 'desc')
.skip(skip)
.limit(pageSize)
.limit(limit)
.get();
if (logs.length === 0) {