mirror of
https://gitlab.com/Binaryify/neteasecloudmusicapi.git
synced 2025-07-07 14:52:07 +08:00
升级依赖,去除多余依赖 #635 优化test.html
This commit is contained in:
68
.eslintrc.js
68
.eslintrc.js
@ -1,38 +1,38 @@
|
||||
module.exports = {
|
||||
root: true,
|
||||
root: true,
|
||||
|
||||
parserOptions: {
|
||||
parser: 'babel-eslint',
|
||||
ecmaVersion: 2018,
|
||||
sourceType: 'module'
|
||||
},
|
||||
parserOptions: {
|
||||
parser: 'babel-eslint',
|
||||
ecmaVersion: 2018,
|
||||
sourceType: 'module'
|
||||
},
|
||||
plugins: ['html'],
|
||||
env: {
|
||||
browser: true
|
||||
},
|
||||
|
||||
env: {
|
||||
browser: true
|
||||
},
|
||||
|
||||
rules: {
|
||||
indent: ['error', 2, { SwitchCase: 1 }],
|
||||
"space-infix-ops": ["error", {"int32Hint": false}],
|
||||
'key-spacing': [
|
||||
2,
|
||||
{
|
||||
beforeColon: false,
|
||||
afterColon: true
|
||||
}
|
||||
],
|
||||
'no-octal': 2,
|
||||
'no-redeclare': 2,
|
||||
'comma-spacing': 2,
|
||||
'no-new-object': 2,
|
||||
'arrow-spacing': 2,
|
||||
quotes: [
|
||||
2,
|
||||
'single',
|
||||
{
|
||||
avoidEscape: true,
|
||||
allowTemplateLiterals: true
|
||||
}
|
||||
]
|
||||
}
|
||||
rules: {
|
||||
indent: ['error', 2, { SwitchCase: 1 }],
|
||||
'space-infix-ops': ['error', { int32Hint: false }],
|
||||
'key-spacing': [
|
||||
2,
|
||||
{
|
||||
beforeColon: false,
|
||||
afterColon: true
|
||||
}
|
||||
],
|
||||
'no-octal': 2,
|
||||
'no-redeclare': 2,
|
||||
'comma-spacing': 2,
|
||||
'no-new-object': 2,
|
||||
'arrow-spacing': 2,
|
||||
quotes: [
|
||||
2,
|
||||
'single',
|
||||
{
|
||||
avoidEscape: true,
|
||||
allowTemplateLiterals: true
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,9 @@
|
||||
# 更新日志
|
||||
### 3.25.3 | 2019.11.08
|
||||
- 升级依赖,去除多余依赖
|
||||
|
||||
- 优化 `test.html`
|
||||
|
||||
### 3.25.2 | 2019.11.07
|
||||
- 修复邮箱登录状态码错误,增加相关提示 [#633](https://github.com/Binaryify/NeteaseCloudMusicApi/issues/633)
|
||||
|
||||
|
@ -269,7 +269,7 @@ $ sudo docker run -d -p 3000:3000 netease-music-api
|
||||
`/simi/playlist?id=347230×tamp=1503019930000` (之所以加入缓存机制是因为项目早期没有缓存机制,很多 issues 都是报 IP高频,请按自己需求改造缓存中间件(app.js),源码不复杂)
|
||||
|
||||
!> 如果是跨域请求 , 请在所有请求带上 `xhrFields: { withCredentials: true }` (axios 为 `withCredentials: true`)否则
|
||||
可能会因为没带上 cookie 导致 301, 具体例子可看 `public/test.html`, 例子使用 jQuery 和 axios
|
||||
可能会因为没带上 cookie 导致 301, 具体例子可看 `public/test.html`, 访问`http://localhost:3000/test.html`(默认端口的话) 例子使用 jQuery 和 axios
|
||||
|
||||
!> 301 错误基本都是没登录就调用了需要登录的接口,如果登陆了还是提示 301, 基本都是缓存把数据缓存起来了,解决方法是加时间戳或者等待 2 分钟或者重启服务重新登录后再调用接口,可自行改造缓存方法
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
module.exports = (query, request) => {
|
||||
const data = {
|
||||
ctcode: query.ctcode||'86',
|
||||
ctcode: query.ctcode || '86',
|
||||
cellphone: query.phone,
|
||||
}
|
||||
return request(
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
module.exports = (query, request) => {
|
||||
const data = {
|
||||
ctcode: query.ctcode||'86',
|
||||
ctcode: query.ctcode || '86',
|
||||
cellphone: query.phone,
|
||||
captcha: query.captcha
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ module.exports = (query, request) => {
|
||||
rid: query.id,
|
||||
limit: query.limit || 20,
|
||||
offset: query.offset || 0,
|
||||
beforeTime: query.before|| 0
|
||||
beforeTime: query.before || 0
|
||||
}
|
||||
return request(
|
||||
'POST', `https://music.163.com/weapi/v1/resource/comments/A_DJ_1_${query.id}`, data,
|
||||
|
@ -2,7 +2,7 @@ module.exports = (query, request) => {
|
||||
const data = {
|
||||
limit: query.limit || 20,
|
||||
offset: query.offset || 0,
|
||||
beforeTime: query.before|| 0
|
||||
beforeTime: query.before || 0
|
||||
};
|
||||
return request(
|
||||
'POST',
|
||||
|
@ -14,7 +14,7 @@ module.exports = (query, request) => {
|
||||
rid: query.id,
|
||||
limit: query.limit || 20,
|
||||
offset: query.offset || 0,
|
||||
beforeTime: query.before|| 0
|
||||
beforeTime: query.before || 0
|
||||
}
|
||||
return request(
|
||||
'POST', `https://music.163.com/weapi/v1/resource/hotcomments/${query.type}${query.id}`, data,
|
||||
|
@ -6,7 +6,7 @@ module.exports = (query, request) => {
|
||||
rid: query.id,
|
||||
limit: query.limit || 20,
|
||||
offset: query.offset || 0,
|
||||
beforeTime: query.before|| 0
|
||||
beforeTime: query.before || 0
|
||||
};
|
||||
return request(
|
||||
'POST',
|
||||
|
@ -6,7 +6,7 @@ module.exports = (query, request) => {
|
||||
rid: query.id,
|
||||
limit: query.limit || 20,
|
||||
offset: query.offset || 0,
|
||||
beforeTime: query.before|| 0
|
||||
beforeTime: query.before || 0
|
||||
}
|
||||
return request(
|
||||
'POST', `https://music.163.com/weapi/v1/resource/comments/R_MV_5_${query.id}`, data,
|
||||
|
@ -6,7 +6,7 @@ module.exports = (query, request) => {
|
||||
rid: query.id,
|
||||
limit: query.limit || 20,
|
||||
offset: query.offset || 0,
|
||||
beforeTime: query.before|| 0
|
||||
beforeTime: query.before || 0
|
||||
}
|
||||
return request(
|
||||
'POST', `https://music.163.com/weapi/v1/resource/comments/A_PL_0_${query.id}`, data,
|
||||
|
@ -6,7 +6,7 @@ module.exports = (query, request) => {
|
||||
rid: query.id,
|
||||
limit: query.limit || 20,
|
||||
offset: query.offset || 0,
|
||||
beforeTime: query.before|| 0
|
||||
beforeTime: query.before || 0
|
||||
}
|
||||
return request(
|
||||
'POST', `https://music.163.com/weapi/v1/resource/comments/R_VI_62_${query.id}`, data,
|
||||
|
@ -2,7 +2,7 @@
|
||||
const { toBoolean } = require('../util')
|
||||
|
||||
module.exports = (query, request) => {
|
||||
query.like = query.like=='false' ? false : true
|
||||
query.like = query.like == 'false' ? false : true
|
||||
const data = {
|
||||
trackId: query.id,
|
||||
like: query.like
|
||||
|
@ -1,7 +1,7 @@
|
||||
// 歌词
|
||||
|
||||
module.exports = (query, request) => {
|
||||
const data={
|
||||
const data = {
|
||||
id: query.id
|
||||
}
|
||||
return request(
|
||||
|
18
package.json
18
package.json
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "NeteaseCloudMusicApi",
|
||||
"version": "3.25.2",
|
||||
"version": "3.25.3",
|
||||
"description": "网易云音乐 NodeJS 版 API",
|
||||
"scripts": {
|
||||
"start": "node app.js",
|
||||
@ -27,18 +27,18 @@
|
||||
"author": "binaryify",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"apicache": "^1.4.0",
|
||||
"express": "^4.16.4",
|
||||
"pac-proxy-agent": "^3.0.0",
|
||||
"apicache": "^1.5.2",
|
||||
"express": "^4.17.1",
|
||||
"pac-proxy-agent": "^3.0.1",
|
||||
"request": "^2.88.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"eslint": "^6.1.0",
|
||||
"eslint-config-standard": "^13.0.1",
|
||||
"husky": "^3.0.3",
|
||||
"eslint": "^6.6.0",
|
||||
"eslint-plugin-html": "^6.0.0",
|
||||
"husky": "^3.0.9",
|
||||
"intelli-espower-loader": "^1.0.1",
|
||||
"lint-staged": "^9.2.1",
|
||||
"mocha": "^6.1.4",
|
||||
"lint-staged": "^9.4.2",
|
||||
"mocha": "^6.2.2",
|
||||
"power-assert": "^1.6.1"
|
||||
}
|
||||
}
|
||||
|
@ -1,52 +1,58 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
|
||||
<title>test</title>
|
||||
</head>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
|
||||
<title>test</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
|
||||
<script src="https://cdn.bootcss.com/axios/0.18.0/axios.min.js
|
||||
"></script>
|
||||
<script>
|
||||
$.ajax({
|
||||
url: "http://localhost:3000/login/cellphone?phone=YOUR_PHONE&password=YOUR_PASSWORD",
|
||||
success: function (data) {
|
||||
console.log(data)
|
||||
$.ajax({
|
||||
url: "http://localhost:3000/recommend/resource ",
|
||||
xhrFields: {
|
||||
withCredentials: true //关键
|
||||
},
|
||||
success: function (data) {
|
||||
console.log(data)
|
||||
},
|
||||
error: function (err) {
|
||||
console.log(err)
|
||||
<body>
|
||||
<p>请在控制台看结果</p>
|
||||
<script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
|
||||
<script src="https://cdn.bootcss.com/axios/0.18.0/axios.min.js"></script>
|
||||
<script>
|
||||
const phone = ''
|
||||
const password = ''
|
||||
const port = 3000
|
||||
if(!phone || !password){
|
||||
const msg = '请设置你的手机号码和密码'
|
||||
alert(msg)
|
||||
throw new Error(msg)
|
||||
}
|
||||
})
|
||||
},
|
||||
error: function (err) {
|
||||
console.log(err)
|
||||
}
|
||||
})
|
||||
$.ajax({
|
||||
url: `http://localhost:${port}/login/cellphone?phone=${phone}&password=${password}`,
|
||||
success: function(data) {
|
||||
console.log(data)
|
||||
$.ajax({
|
||||
url: `http://localhost:${port}/recommend/resource `,
|
||||
xhrFields: {
|
||||
withCredentials: true //关键
|
||||
},
|
||||
success: function(data) {
|
||||
console.log(data)
|
||||
},
|
||||
error: function(err) {
|
||||
console.log(err)
|
||||
}
|
||||
})
|
||||
},
|
||||
error: function(err) {
|
||||
console.log(err)
|
||||
}
|
||||
})
|
||||
|
||||
axios({
|
||||
url:
|
||||
"http://localhost:3000/login/cellphone?phone=YOUR_PHONE&password=YOUR_PASSWORD"
|
||||
}).then(function(res) {
|
||||
console.log(res.data);
|
||||
axios({
|
||||
url:
|
||||
"http://localhost:3000/recommend/resource",
|
||||
withCredentials: true //关键
|
||||
}).then(function(res) {
|
||||
console.log(res.data);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
axios({
|
||||
url: `http://localhost:${port}/login/cellphone?phone=${phone}&password=${password}`
|
||||
}).then(function(res) {
|
||||
console.log(res.data)
|
||||
axios({
|
||||
url: `http://localhost:${port}/recommend/resource`,
|
||||
withCredentials: true //关键
|
||||
}).then(function(res) {
|
||||
console.log(res.data)
|
||||
})
|
||||
})
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
Reference in New Issue
Block a user