提交 231a0ad6 编写于 作者: S SnowingFox

feat(playlist_track_all): 增加offset偏移量设置

上级 845c357a
...@@ -10,6 +10,7 @@ module.exports = (query, request) => { ...@@ -10,6 +10,7 @@ module.exports = (query, request) => {
//不放在data里面避免请求带上无用的数据 //不放在data里面避免请求带上无用的数据
let limit = query.limit let limit = query.limit
let offset = parseInt(query.offset) || 0 let offset = parseInt(query.offset) || 0
let allOffset
let trackIds let trackIds
let idsData = Object.create(null) let idsData = Object.create(null)
...@@ -24,7 +25,11 @@ module.exports = (query, request) => { ...@@ -24,7 +25,11 @@ module.exports = (query, request) => {
if (typeof limit === 'undefined') { if (typeof limit === 'undefined') {
limit = trackIds.length limit = trackIds.length
} }
// 若offset超出最大偏移量则重置为最大偏移量
allOffset = trackIds.length / limit - 1
if (offset > allOffset) {
offset = allOffset
}
trackIds.forEach((item, index) => { trackIds.forEach((item, index) => {
if (index >= limit * offset && index < limit * (offset + 1)) { if (index >= limit * offset && index < limit * (offset + 1)) {
ids.push(item.id) ids.push(item.id)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册