提交 e933997d 编写于 作者: H huggy

又优化了下 UA 逻辑 现在两行就 ok 了

https://github.com/Binaryify/NeteaseCloudMusicApi/pull/922
上级 c05c83db
...@@ -35,16 +35,8 @@ function chooseUserAgent(ua = false) { ...@@ -35,16 +35,8 @@ function chooseUserAgent(ua = false) {
// Linux 就算了 // Linux 就算了
] ]
} }
let realUserAgentList = [] let realUserAgentList = userAgentList[ua] || (userAgentList.mobile).concat(userAgentList.pc)
if (!ua) return (['mobile', 'pc', false].indexOf(ua) > -1) ? realUserAgentList[Math.floor(Math.random() * realUserAgentList.length)] : ua
realUserAgentList = (userAgentList.mobile).concat(userAgentList.pc) // concat 把两个 array 合并
else if (ua == 'mobile')
realUserAgentList = userAgentList.mobile
else if (ua == 'pc')
realUserAgentList = userAgentList.pc
else
return ua // 最后返回自定义的 ua
return realUserAgentList[Math.floor(Math.random() * realUserAgentList.length)]
} }
const createRequest = (method, url, data, options) => { const createRequest = (method, url, data, options) => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册