mirror of
https://github.com/NeteaseCloudMusicApiEnhanced/api-enhanced.git
synced 2025-10-22 14:43:10 +00:00
feat(playlist_track_all): 增加offset偏移量设置
This commit is contained in:
parent
845c357aa3
commit
231a0ad6fe
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user