From 0e6e8902ddef4de9b6f0a8356b5f590879a8fb9d Mon Sep 17 00:00:00 2001 From: R524809 Date: Mon, 25 May 2026 17:11:40 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=B8=8B=E8=BD=BD=E5=8E=86=E5=8F=B2?= =?UTF-8?q?=E6=95=B0=E9=87=8F=E9=99=90=E5=88=B6=E4=B8=BA=2030=20=E6=9D=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cloudfunctions/userDownloadLogs/index.js | 9 ++++++--- miniprogram/pages/favorites/favorites.less | 2 +- miniprogram/pages/favorites/favorites.ts | 7 +++++-- miniprogram/utils/downloadLogs.ts | 7 +++++-- 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/cloudfunctions/userDownloadLogs/index.js b/cloudfunctions/userDownloadLogs/index.js index e93a273..2d24caf 100644 --- a/cloudfunctions/userDownloadLogs/index.js +++ b/cloudfunctions/userDownloadLogs/index.js @@ -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) { diff --git a/miniprogram/pages/favorites/favorites.less b/miniprogram/pages/favorites/favorites.less index 2af907c..8b9185b 100644 --- a/miniprogram/pages/favorites/favorites.less +++ b/miniprogram/pages/favorites/favorites.less @@ -28,7 +28,7 @@ .fav-body { padding: @section-gap-xs @page-padding-x; - padding-bottom: calc(48rpx + env(safe-area-inset-bottom) + 120rpx); + padding-bottom: 48rpx; box-sizing: border-box; } diff --git a/miniprogram/pages/favorites/favorites.ts b/miniprogram/pages/favorites/favorites.ts index 4ef2292..525d9e7 100644 --- a/miniprogram/pages/favorites/favorites.ts +++ b/miniprogram/pages/favorites/favorites.ts @@ -1,6 +1,9 @@ import { NAV_INNER_PX } from '../../utils/navMetrics'; import { getFavoriteList, removeFavorite } from '../../utils/favorites'; -import { getDownloadLogs } from '../../utils/downloadLogs'; +import { + DOWNLOAD_HISTORY_MAX, + getDownloadLogs, +} from '../../utils/downloadLogs'; import type { FavoriteRecord } from '../../utils/favorites'; import type { DownloadLogRecord } from '../../utils/downloadLogs'; import { getCategoryName } from '../../core/data/categories'; @@ -223,7 +226,7 @@ Page({ async loadDownloads() { this.setData({ dlLoading: true }); try { - const records = await getDownloadLogs(); + const records = await getDownloadLogs(1, DOWNLOAD_HISTORY_MAX); this.setData({ downloadSections: groupDownloadsByDate(records) }); } finally { this.setData({ dlLoading: false }); diff --git a/miniprogram/utils/downloadLogs.ts b/miniprogram/utils/downloadLogs.ts index 1e05877..144d4ba 100644 --- a/miniprogram/utils/downloadLogs.ts +++ b/miniprogram/utils/downloadLogs.ts @@ -38,12 +38,15 @@ export async function addDownloadLog(worksheetId: string): Promise { } } +/** 收藏页下载历史展示条数上限 */ +export const DOWNLOAD_HISTORY_MAX = 30; + /** - * 获取下载历史 + * 获取下载历史(默认最近 30 条) */ export async function getDownloadLogs( page = 1, - pageSize = 20, + pageSize = DOWNLOAD_HISTORY_MAX, ): Promise { try { await getUser();