feat: 增加下载、购买记录接口

This commit is contained in:
overwriter 2024-07-22 07:53:46 +08:00
parent a0d4a3c27a
commit 422722e0a7
8 changed files with 107 additions and 9 deletions

View File

@ -429,6 +429,9 @@ banner({ type: 0 }).then((res) => {
283. 云盘导入歌曲
284. 获取客户端歌曲下载链接 - 新版
285. 当前账号关注的用户/歌手
286. 会员下载歌曲记录
287. 会员本月下载歌曲记录
288. 已购买单曲
## 单元测试

View File

@ -1,3 +1,4 @@
const { cookieToJson } = require('../util/index')
const createOption = require('../util/option.js')
module.exports = (query, request) => {
const method = query.method || 'POST'
@ -6,6 +7,10 @@ module.exports = (query, request) => {
try {
data =
typeof query.data === 'string' ? JSON.parse(query.data) : query.data || {}
if (typeof data.cookie === 'string') {
data.cookie = cookieToJson(data.cookie)
query.cookie = data.cookie
}
} catch (e) {
data = {}
}

11
module/song_downlist.js Normal file
View File

@ -0,0 +1,11 @@
// 会员下载歌曲记录
const createOption = require('../util/option.js')
module.exports = (query, request) => {
const data = {
limit: query.limit || '20',
offset: query.offset || '0',
total: 'true',
}
return request('POST', `/api/member/song/downlist`, data, createOption(query))
}

View File

@ -0,0 +1,16 @@
// 会员本月下载歌曲记录
const createOption = require('../util/option.js')
module.exports = (query, request) => {
const data = {
limit: query.limit || '20',
offset: query.offset || '0',
total: 'true',
}
return request(
'POST',
`/api/member/song/monthdownlist`,
data,
createOption(query),
)
}

View File

@ -0,0 +1,16 @@
// 已购买单曲
const createOption = require('../util/option.js')
module.exports = (query, request) => {
const data = {
limit: query.limit || '20',
offset: query.offset || '0',
total: 'true',
}
return request(
'POST',
`/api/member/song/singledownlist`,
data,
createOption(query),
)
}

View File

@ -112,7 +112,7 @@
method: 'post',
data: {
uri: uri,
data: data,
data: JSON.parse(data),
crypto: crypto,
},
});

View File

@ -301,6 +301,9 @@
283. 云盘导入歌曲
284. 获取客户端歌曲下载链接 - 新版
285. 当前账号关注的用户/歌手
286. 会员下载歌曲记录
287. 会员本月下载歌曲记录
288. 已购买单曲
## 安装
@ -4714,6 +4717,48 @@ bitrate = Math.floor(br / 1000)
**调用例子 :** `/user/follow/mixed?scene=1`
### 会员下载歌曲记录
说明 : 调用此接口, 可获得当前账号会员下载歌曲记录
**可选参数 :**
`limit` : 返回数量 , 默认为 20
`offset` : 偏移数量,用于分页 ,如 :( 页数 -1)\*30, 其中 30 为 limit 的值 , 默认为 0
**接口地址 :** `/song/downlist`
**调用例子 :** `/song/downlist`
### 会员本月下载歌曲记录
说明 : 调用此接口, 可获得当前账号会员本月下载歌曲记录
**可选参数 :**
`limit` : 返回数量 , 默认为 20
`offset` : 偏移数量,用于分页 ,如 :( 页数 -1)\*30, 其中 30 为 limit 的值 , 默认为 0
**接口地址 :** `/song/monthdownlist`
**调用例子 :** `/song/monthdownlist`
### 已购买单曲
说明 : 调用此接口, 可获得当前账号已购买单曲
**可选参数 :**
`limit` : 返回数量 , 默认为 20
`offset` : 偏移数量,用于分页 ,如 :( 页数 -1)\*30, 其中 30 为 limit 的值 , 默认为 0
**接口地址 :** `/song/singledownlist`
**调用例子 :** `/song/singledownlist`
## 离线访问此文档
此文档同时也是 Progressive Web Apps(PWA), 加入了 serviceWorker, 可离线访问

View File

@ -89,6 +89,16 @@ const createRequest = (method, uri, data = {}, options) => {
encryptData = '',
crypto = options.crypto,
csrfToken = cookie['__csrf'] || ''
if (crypto === '') {
// 加密方式为空,以配置文件的加密方式为准
if (APP_CONF.encrypt) {
crypto = 'eapi'
} else {
crypto = 'api'
}
}
// 根据加密方式加密请求数据目前任意uri都支持四种加密方式
switch (crypto) {
case 'weapi':
@ -112,7 +122,6 @@ const createRequest = (method, uri, data = {}, options) => {
case 'eapi':
case 'api':
case '':
// 两种加密方式都应生成客户端的cookie
const cookie = options.cookie || {}
const header = {
@ -160,13 +169,6 @@ const createRequest = (method, uri, data = {}, options) => {
eapi()
} else if (crypto === 'api') {
api()
} else if (crypto === '') {
// 加密方式为空,以配置文件的加密方式为准
if (APP_CONF.encrypt) {
eapi()
} else {
api()
}
}
break