From 231a0ad6fe1b21b0a5bfcd049166812b24c0ab78 Mon Sep 17 00:00:00 2001 From: SnowingFox <1503401882@qq.com> Date: Sat, 15 Jan 2022 13:12:29 +0800 Subject: [PATCH] =?UTF-8?q?feat(playlist=5Ftrack=5Fall):=20=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0offset=E5=81=8F=E7=A7=BB=E9=87=8F=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- module/playlist_track_all.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/module/playlist_track_all.js b/module/playlist_track_all.js index 9c6ecce..3b7d749 100644 --- a/module/playlist_track_all.js +++ b/module/playlist_track_all.js @@ -10,6 +10,7 @@ module.exports = (query, request) => { //不放在data里面避免请求带上无用的数据 let limit = query.limit let offset = parseInt(query.offset) || 0 + let allOffset let trackIds let idsData = Object.create(null) @@ -24,7 +25,11 @@ module.exports = (query, request) => { if (typeof limit === 'undefined') { limit = trackIds.length } - + // 若offset超出最大偏移量则重置为最大偏移量 + allOffset = trackIds.length / limit - 1 + if (offset > allOffset) { + offset = allOffset + } trackIds.forEach((item, index) => { if (index >= limit * offset && index < limit * (offset + 1)) { ids.push(item.id)