升级依赖,去除多余依赖 #635 优化test.html

This commit is contained in:
binaryify
2019-11-08 14:11:11 +08:00
parent af85273466
commit 06e522b684
16 changed files with 112 additions and 101 deletions

View File

@ -6,14 +6,14 @@ module.exports = {
ecmaVersion: 2018,
sourceType: 'module'
},
plugins: ['html'],
env: {
browser: true
},
rules: {
indent: ['error', 2, { SwitchCase: 1 }],
"space-infix-ops": ["error", {"int32Hint": false}],
'space-infix-ops': ['error', { int32Hint: false }],
'key-spacing': [
2,
{

View File

@ -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)

View File

@ -269,7 +269,7 @@ $ sudo docker run -d -p 3000:3000 netease-music-api
`/simi/playlist?id=347230&timestamp=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 分钟或者重启服务重新登录后再调用接口,可自行改造缓存方法

View File

@ -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"
}
}

View File

@ -8,16 +8,24 @@
</head>
<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 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)
}
$.ajax({
url: "http://localhost:3000/login/cellphone?phone=YOUR_PHONE&password=YOUR_PASSWORD",
url: `http://localhost:${port}/login/cellphone?phone=${phone}&password=${password}`,
success: function(data) {
console.log(data)
$.ajax({
url: "http://localhost:3000/recommend/resource ",
url: `http://localhost:${port}/recommend/resource `,
xhrFields: {
withCredentials: true //关键
},
@ -35,18 +43,16 @@
})
axios({
url:
"http://localhost:3000/login/cellphone?phone=YOUR_PHONE&password=YOUR_PASSWORD"
url: `http://localhost:${port}/login/cellphone?phone=${phone}&password=${password}`
}).then(function(res) {
console.log(res.data);
console.log(res.data)
axios({
url:
"http://localhost:3000/recommend/resource",
url: `http://localhost:${port}/recommend/resource`,
withCredentials: true //关键
}).then(function(res) {
console.log(res.data);
});
});
console.log(res.data)
})
})
</script>
</body>
</html>