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