mirror of
https://gitlab.com/Binaryify/neteasecloudmusicapi.git
synced 2025-05-23 22:37:41 +08:00
update: 文档和示例更新
This commit is contained in:
parent
571c35da55
commit
dfcdc04fbb
@ -1,4 +1,7 @@
|
||||
# 更新日志
|
||||
### 4.15.6 | 2024.03.12
|
||||
- 文档和示例更新
|
||||
|
||||
### 4.15.5 | 2024.02.28
|
||||
- 文档更新
|
||||
|
||||
|
30
README.MD
30
README.MD
@ -10,7 +10,6 @@
|
||||
<a href="https://codeclimate.com/github/Binaryify/NeteaseCloudMusicApi"><img src="https://codeclimate.com/github/Binaryify/NeteaseCloudMusicApi/badges/gpa.svg" /></a>
|
||||
</p>
|
||||
|
||||
|
||||
## 灵感来自
|
||||
|
||||
[disoul/electron-cloud-music](https://github.com/disoul/electron-cloud-music)
|
||||
@ -21,7 +20,6 @@
|
||||
|
||||
[greats3an/pyncm](https://github.com/greats3an/pyncm)
|
||||
|
||||
|
||||
## 环境要求
|
||||
|
||||
需要 NodeJS 14+ 环境
|
||||
@ -43,6 +41,7 @@ $ npm install
|
||||
```
|
||||
|
||||
## 运行
|
||||
|
||||
调用前务必阅读文档的`调用前须知`
|
||||
|
||||
```shell
|
||||
@ -62,12 +61,14 @@ $ set PORT=4000 && node app.js
|
||||
```
|
||||
|
||||
## npx 方式运行
|
||||
|
||||
可在终端直接执行
|
||||
|
||||
```bash
|
||||
npx NeteaseCloudMusicApi@latest
|
||||
```
|
||||
使用此命令,可直接启动服务,无需下载或者 clone 项目
|
||||
|
||||
使用此命令,可直接启动服务,无需下载或者 clone 项目
|
||||
|
||||
## Vercel 部署
|
||||
|
||||
@ -83,19 +84,24 @@ v4.0.8 加入了 Vercel 配置文件,可以直接在 Vercel 下部署了,不需
|
||||
6. `PROJECT NAME`自己填,`FRAMEWORK PRESET` 选 `Other` 然后直接点 `Deploy` 接着等部署完成即可
|
||||
|
||||
## 腾讯云 serverless 部署
|
||||
|
||||
因 `Vercel` 在国内访问太慢,在此提供腾讯云 serverless 部署方法(注意:腾讯云 serverless 并不是免费的,前三个月有免费额度,之后收费)
|
||||
|
||||
### 操作方法
|
||||
|
||||
1. fork 此项目
|
||||
2. 在腾讯云 serverless 应用管理页面( https://console.cloud.tencent.com/sls ),点击`新建应用`
|
||||
3. 顶部`创建方式`选择 `Web 应用`
|
||||
4. 选择 `Express框架`,点击底部`下一步按钮`
|
||||
5. 输入`应用名`,上传方式选择`代码仓库`,进行 GitHub 授权(如已授权可跳过这一步),代码仓库选择刚刚 fork 的项目
|
||||
6. 启动文件填入:
|
||||
|
||||
```
|
||||
#!/bin/bash
|
||||
export PORT=9000
|
||||
/var/lang/node16/bin/node app.js
|
||||
```
|
||||
|
||||
7. 点击`完成`,等待部署完成,点击`资源列表`的 `API网关` 里的 `URL`,正常情况会打开文档地址,点击文档`例子`可查看接口调用效果
|
||||
|
||||
## 可以在 Node.js 调用
|
||||
@ -108,14 +114,13 @@ async function main() {
|
||||
try {
|
||||
const result = await login_cellphone({
|
||||
phone: '手机号',
|
||||
password: '密码'
|
||||
password: '密码',
|
||||
})
|
||||
console.log(result)
|
||||
const result2 = await user_cloud({
|
||||
cookie: result.body.cookie // 凭证
|
||||
cookie: result.body.cookie, // 凭证
|
||||
})
|
||||
console.log(result2.body)
|
||||
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
@ -128,20 +133,15 @@ main()
|
||||
```ts
|
||||
// test.ts
|
||||
import { banner } from 'NeteaseCloudMusicApi'
|
||||
banner({ type:0 }).then(res=>{
|
||||
banner({ type: 0 }).then((res) => {
|
||||
console.log(res)
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
## 使用文档
|
||||
|
||||
[文档地址](https://docs-neteasecloudmusicapi.vercel.app)
|
||||
|
||||
|
||||

|
||||
|
||||
|
||||
## 功能特性
|
||||
|
||||
1. 登录
|
||||
@ -421,28 +421,24 @@ banner({ type:0 }).then(res=>{
|
||||
275. 歌曲红心数量
|
||||
276. 私人 FM 模式选择
|
||||
|
||||
|
||||
## 单元测试
|
||||
|
||||
```shell
|
||||
$ npm test
|
||||
```
|
||||
|
||||
|
||||
## SDK
|
||||
|
||||
| 语言 | 作者 | 地址 | 类型 |
|
||||
| :--: | :-----------------------------------------: | :----------------------------------------------------------: | :----: |
|
||||
| :----: | :-----------------------------------------: | :--------------------------------------------------------------------------------------------------------: | :----: |
|
||||
| Java | [JackuXL](https://github.com/JackuXL) | [https://github.com/JackuXL/NeteaseCloudMusicApi-SDK](https://github.com/JackuXL/NeteaseCloudMusicApi-SDK) | 第三方 |
|
||||
| Java | [1015770492](https://github.com/1015770492) | https://github.com/1015770492/yumbo-music-utils | 第三方 |
|
||||
| Python | [盧瞳](https://github.com/2061360308) | [NeteaseCloudMusic_PythonSDK](https://github.com/2061360308/NeteaseCloudMusic_PythonSDK) | 第三方 |
|
||||
|
||||
|
||||
## 贡献者
|
||||
|
||||

|
||||
|
||||
|
||||
## License
|
||||
|
||||
[The MIT License (MIT)](https://gitlab.com/Binaryify/NeteaseCloudMusicApi/blob/main/LICENSE)
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "NeteaseCloudMusicApi",
|
||||
"version": "4.15.5",
|
||||
"version": "4.15.6",
|
||||
"description": "网易云音乐 NodeJS 版 API",
|
||||
"scripts": {
|
||||
"start": "node app.js",
|
||||
|
@ -1,5 +1,6 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
@ -7,22 +8,18 @@
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div>
|
||||
<a href="/qrlogin-nocookie.html">
|
||||
如果没登录,请先登录
|
||||
</a>
|
||||
</div>
|
||||
<input id="file" type="file" />
|
||||
<img id="avatar" style="height: 200px; width: 200px; border-radius: 50%" />
|
||||
<script src="https://cdn.jsdelivr.net/npm/axios@0.26.1/dist/axios.min.js
|
||||
"></script>
|
||||
<script>
|
||||
const phone = ''
|
||||
const password = ''
|
||||
let cookieToken = ''
|
||||
if (!phone || !password) {
|
||||
const msg = '请设置你的手机号码和密码'
|
||||
alert(msg)
|
||||
throw new Error(msg)
|
||||
}
|
||||
|
||||
main()
|
||||
login()
|
||||
|
||||
async function main() {
|
||||
document.querySelector('input[type="file"]').addEventListener(
|
||||
'change',
|
||||
@ -38,21 +35,14 @@
|
||||
})
|
||||
document.querySelector('#avatar').src = res.data.profile.avatarUrl
|
||||
}
|
||||
async function login() {
|
||||
const res = await axios({
|
||||
url: `/login/cellphone?phone=${phone}&password=${password}`,
|
||||
withCredentials: true, //跨域的话必须设置
|
||||
})
|
||||
cookieToken = res.data.cookie
|
||||
}
|
||||
|
||||
async function upload(file) {
|
||||
var formData = new FormData()
|
||||
formData.append('imgFile', file)
|
||||
const imgSize = await getImgSize(file)
|
||||
const res = await axios({
|
||||
method: 'post',
|
||||
url: `/avatar/upload?cookie=${cookieToken}&imgSize=${
|
||||
imgSize.width
|
||||
url: `/avatar/upload?cookie=${localStorage.getItem('cookie')}&imgSize=${imgSize.width
|
||||
}&imgX=0&imgY=0×tamp=${Date.now()}`,
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data',
|
||||
@ -79,4 +69,5 @@
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
@ -8,29 +8,48 @@
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div>
|
||||
<a href="/qrlogin-nocookie.html">
|
||||
如果没登录,请先登录
|
||||
</a>
|
||||
</div>
|
||||
<input id="file" type="file" multiple />
|
||||
<div id="app">
|
||||
<ul>
|
||||
<li v-for="(item,index) in songs" :key="index">
|
||||
{{item.songName}}
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/axios@0.26.1/dist/axios.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/vue"></script>
|
||||
<script>
|
||||
const phone = '' // 这里填手机号
|
||||
const password = '' // 这里填密码
|
||||
const app = Vue.createApp({
|
||||
data() {
|
||||
return {
|
||||
songs: []
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.getData()
|
||||
},
|
||||
methods: {
|
||||
getData() {
|
||||
console.log('getdata');
|
||||
const _this = this
|
||||
axios({
|
||||
url: `/user/cloud?time=${Date.now()}&cookie=${localStorage.getItem('cookie')}`,
|
||||
}).then(res => {
|
||||
console.log(res.data)
|
||||
_this.songs = res.data.data
|
||||
})
|
||||
}
|
||||
}
|
||||
}).mount('#app')
|
||||
const fileUpdateTime = {}
|
||||
let fileLength = 0
|
||||
let cookieToken = ''
|
||||
if (!phone || !password) {
|
||||
const msg = '请设置你的手机号码和密码'
|
||||
alert(msg)
|
||||
throw new Error(msg)
|
||||
}
|
||||
login()
|
||||
main()
|
||||
async function login() {
|
||||
const res = await axios({
|
||||
url: `/login/cellphone?phone=${phone}&password=${encodeURIComponent(password)}`,
|
||||
withCredentials: true, //跨域的话必须设置
|
||||
})
|
||||
cookieToken = res.data.cookie
|
||||
}
|
||||
|
||||
function main() {
|
||||
document
|
||||
.querySelector('input[type="file"]')
|
||||
@ -44,13 +63,14 @@
|
||||
}
|
||||
})
|
||||
}
|
||||
main()
|
||||
|
||||
function upload(file, currentIndx) {
|
||||
var formData = new FormData()
|
||||
formData.append('songFile', file)
|
||||
axios({
|
||||
method: 'post',
|
||||
url: `/cloud?time=${Date.now()}&cookie=${cookieToken}`,
|
||||
url: `/cloud?time=${Date.now()}&cookie=${localStorage.getItem('cookie')}`,
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data',
|
||||
},
|
||||
@ -58,6 +78,7 @@
|
||||
}).then(res => {
|
||||
console.log(`${file.name} 上传成功`)
|
||||
if (currentIndx >= fileLength) { console.log('上传完毕') }
|
||||
app.getData()
|
||||
}).catch(async err => {
|
||||
console.log(err)
|
||||
console.log(fileUpdateTime)
|
||||
|
@ -8,32 +8,18 @@
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div>
|
||||
<a href="/qrlogin-nocookie.html">
|
||||
如果没登录,请先登录
|
||||
</a>
|
||||
</div>
|
||||
<script src="https://cdn.jsdelivr.net/npm/axios@0.26.1/dist/axios.min.js"></script>
|
||||
<script>
|
||||
const phone = '' // 这里填手机号
|
||||
const password = '' // 这里填密码
|
||||
const fileUpdateTime = {}
|
||||
let cookieToken = ''
|
||||
if (!phone || !password) {
|
||||
const msg = '请设置你的手机号码和密码'
|
||||
alert(msg)
|
||||
throw new Error(msg)
|
||||
}
|
||||
|
||||
async function login() {
|
||||
const res = await axios({
|
||||
url: `/login/cellphone?phone=${phone}&password=${encodeURIComponent(
|
||||
password,
|
||||
)}`,
|
||||
})
|
||||
cookieToken = res.data.cookie
|
||||
}
|
||||
async function main() {
|
||||
await login()
|
||||
const res = await axios({
|
||||
url: `/homepage/block/page`,
|
||||
data: {
|
||||
cookie: cookieToken,
|
||||
cookie: localStorage.getItem('cookie'),
|
||||
},
|
||||
method: 'post',
|
||||
})
|
||||
@ -44,7 +30,7 @@
|
||||
const res2 = await axios({
|
||||
url: `/homepage/block/page?time=${Date.now()}`,
|
||||
data: {
|
||||
cookie: cookieToken,
|
||||
cookie: localStorage.getItem('cookie'),
|
||||
cursor: cursor,
|
||||
},
|
||||
method: 'post',
|
||||
|
@ -13,12 +13,14 @@
|
||||
</head>
|
||||
|
||||
<body class="mdui-container">
|
||||
<div>
|
||||
<a href="/qrlogin-nocookie.html">
|
||||
如果没登录,请先登录
|
||||
</a>
|
||||
</div>
|
||||
<h1>一起听 - 主机模式</h1>
|
||||
<div>消息: {{message}}</div>
|
||||
<audio
|
||||
id="player"
|
||||
autoplay
|
||||
controls>
|
||||
<audio id="player" autoplay controls>
|
||||
</audio>
|
||||
<br />
|
||||
<br />
|
||||
@ -59,8 +61,7 @@
|
||||
<br />
|
||||
<div>歌单内容: </div>
|
||||
<ul class="mdui-list">
|
||||
<li @click="gotoTrack(track.id)" v-for="track in playlistInfo.playlistTracks"
|
||||
class="mdui-list-item mdui-ripple">
|
||||
<li @click="gotoTrack(track.id)" v-for="track in playlistInfo.playlistTracks" class="mdui-list-item mdui-ripple">
|
||||
<div class="mdui-list-item-avatar">
|
||||
<img :src="track.al.picUrl" />
|
||||
</div>
|
||||
@ -98,6 +99,9 @@
|
||||
const res = await axios({
|
||||
url: `/login/status`,
|
||||
method: 'get',
|
||||
data: {
|
||||
cookie: localStorage.getItem('cookie'),
|
||||
},
|
||||
})
|
||||
if (res.data.data.code != 200) {
|
||||
alert('请先使用登录 API 登录到网易云音乐')
|
||||
@ -112,6 +116,9 @@
|
||||
const res = await axios({
|
||||
url: 'listentogether/room/create',
|
||||
method: 'get',
|
||||
data: {
|
||||
cookie: localStorage.getItem('cookie'),
|
||||
},
|
||||
})
|
||||
console.log(res)
|
||||
if (res.data.code != 200) {
|
||||
@ -119,19 +126,23 @@
|
||||
} else {
|
||||
this.message = '创建房间成功: ' + res.data.data.roomInfo.roomId
|
||||
this.roomInfo.roomId = res.data.data.roomInfo.roomId
|
||||
res = await axios({
|
||||
const res2 = await axios({
|
||||
url: 'listentogether/room/check',
|
||||
method: 'post',
|
||||
data: {
|
||||
roomId: this.roomInfo.roomId,
|
||||
cookie: localStorage.getItem('cookie'),
|
||||
},
|
||||
})
|
||||
console.log(res)
|
||||
console.log(res2)
|
||||
}
|
||||
},
|
||||
refreshRoom: async function () {
|
||||
const res = await axios({
|
||||
url: '/listentogether/status',
|
||||
data: {
|
||||
cookie: localStorage.getItem('cookie'),
|
||||
},
|
||||
})
|
||||
console.log(res)
|
||||
if (res.data.code != 200 || !res.data.data.inRoom) {
|
||||
@ -146,6 +157,8 @@
|
||||
method: 'post',
|
||||
data: {
|
||||
roomId: this.roomInfo.roomId,
|
||||
cookie: localStorage.getItem('cookie'),
|
||||
|
||||
},
|
||||
})
|
||||
console.log(res)
|
||||
@ -162,6 +175,7 @@
|
||||
method: 'post',
|
||||
data: {
|
||||
id: this.playlistInfo.playlistId,
|
||||
cookie: localStorage.getItem('cookie'),
|
||||
},
|
||||
})
|
||||
console.log(res)
|
||||
@ -174,6 +188,7 @@
|
||||
method: 'post',
|
||||
data: {
|
||||
ids: this.playlistInfo.playlistTrackIds,
|
||||
cookie: localStorage.getItem('cookie'),
|
||||
},
|
||||
})
|
||||
console.log(resa)
|
||||
@ -190,6 +205,7 @@
|
||||
playMode: 'ORDER_LOOP',
|
||||
displayList: this.playlistInfo.playlistTrackIds,
|
||||
randomList: this.playlistInfo.playlistTrackIds,
|
||||
cookie: localStorage.getItem('cookie'),
|
||||
},
|
||||
})
|
||||
console.log(resb)
|
||||
@ -232,6 +248,7 @@
|
||||
targetSongId: this.playingInfo.trackId,
|
||||
clientSeq: this.clientSeq++,
|
||||
playStatus: this.playingInfo.status,
|
||||
cookie: localStorage.getItem('cookie'),
|
||||
},
|
||||
})
|
||||
console.log(res)
|
||||
|
@ -1,5 +1,6 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
@ -7,22 +8,16 @@
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div>
|
||||
<a href="/qrlogin-nocookie.html">
|
||||
如果没登录,请先登录
|
||||
</a>
|
||||
</div>
|
||||
<input id="file" type="file" name="filename" />
|
||||
<img
|
||||
id="playlist_cover"
|
||||
style="height: 200px; width: 200px; border-radius: 50%"
|
||||
/>
|
||||
<img id="playlist_cover" style="height: 200px; width: 200px; border-radius: 50%" />
|
||||
<script src="https://cdn.jsdelivr.net/npm/axios@0.26.1/dist/axios.min.js"></script>
|
||||
<script>
|
||||
const phone = ''
|
||||
const password = ''
|
||||
const playlist_id = ''
|
||||
let cookieToken = ''
|
||||
if (!phone || !password) {
|
||||
const msg = '请设置你的手机号码和密码'
|
||||
alert(msg)
|
||||
throw new Error(msg)
|
||||
}
|
||||
if (!playlist_id) {
|
||||
const msg = '请设置你的歌单id'
|
||||
alert(msg)
|
||||
@ -30,7 +25,6 @@
|
||||
}
|
||||
|
||||
main()
|
||||
login()
|
||||
async function main() {
|
||||
document.querySelector('input[type="file"]').addEventListener(
|
||||
'change',
|
||||
@ -45,21 +39,14 @@
|
||||
})
|
||||
document.querySelector('#playlist_cover').src = res.data.playlist.coverImgUrl
|
||||
}
|
||||
async function login() {
|
||||
const res = await axios({
|
||||
url: `/login/cellphone?phone=${phone}&password=${password}`,
|
||||
withCredentials: true, //跨域的话必须设置
|
||||
})
|
||||
cookieToken = res.data.cookie
|
||||
}
|
||||
|
||||
async function upload(file) {
|
||||
var formData = new FormData()
|
||||
formData.append('imgFile', file)
|
||||
const imgSize = await getImgSize(file)
|
||||
const res = await axios({
|
||||
method: 'post',
|
||||
url: `/playlist/cover/update?id=${playlist_id}&cookie=${cookieToken}&imgSize=${
|
||||
imgSize.width
|
||||
url: `/playlist/cover/update?id=${playlist_id}&cookie=${localStorage.getItem('cookie')}&imgSize=${imgSize.width
|
||||
}&imgX=0&imgY=0×tamp=${Date.now()}`,
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data',
|
||||
@ -86,4 +73,5 @@
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
@ -13,22 +13,7 @@
|
||||
<script src="https://cdn.jsdelivr.net/npm/axios@0.26.1/dist/axios.min.js
|
||||
"></script>
|
||||
<script>
|
||||
async function checkStatus(key) {
|
||||
const res = await axios({
|
||||
url: `/login/qr/check?key=${key}×tamp=${Date.now()}&noCookie=true`,
|
||||
})
|
||||
return res.data
|
||||
}
|
||||
async function getLoginStatus(cookie = '') {
|
||||
const res = await axios({
|
||||
url: `/login/status?timestamp=${Date.now()}`,
|
||||
method: 'post',
|
||||
data: {
|
||||
cookie,
|
||||
},
|
||||
})
|
||||
document.querySelector('#info').innerText = JSON.stringify(res.data, null, 2)
|
||||
}
|
||||
|
||||
async function login() {
|
||||
let timer
|
||||
let timestamp = Date.now()
|
||||
@ -59,6 +44,23 @@
|
||||
}, 3000)
|
||||
}
|
||||
login()
|
||||
|
||||
async function checkStatus(key) {
|
||||
const res = await axios({
|
||||
url: `/login/qr/check?key=${key}×tamp=${Date.now()}&noCookie=true`,
|
||||
})
|
||||
return res.data
|
||||
}
|
||||
async function getLoginStatus(cookie = '') {
|
||||
const res = await axios({
|
||||
url: `/login/status?timestamp=${Date.now()}`,
|
||||
method: 'post',
|
||||
data: {
|
||||
cookie,
|
||||
},
|
||||
})
|
||||
document.querySelector('#info').innerText = JSON.stringify(res.data, null, 2)
|
||||
}
|
||||
</script>
|
||||
<style>
|
||||
.info {
|
||||
|
@ -13,22 +13,6 @@
|
||||
<script src="https://cdn.jsdelivr.net/npm/axios@0.26.1/dist/axios.min.js
|
||||
"></script>
|
||||
<script>
|
||||
async function checkStatus(key) {
|
||||
const res = await axios({
|
||||
url: `/login/qr/check?key=${key}×tamp=${Date.now()}`,
|
||||
})
|
||||
return res.data
|
||||
}
|
||||
async function getLoginStatus(cookie = '') {
|
||||
const res = await axios({
|
||||
url: `/login/status?timestamp=${Date.now()}`,
|
||||
method: 'post',
|
||||
data: {
|
||||
cookie,
|
||||
},
|
||||
})
|
||||
document.querySelector('#info').innerText = JSON.stringify(res.data, null, 2)
|
||||
}
|
||||
async function login() {
|
||||
let timer
|
||||
let timestamp = Date.now()
|
||||
@ -59,6 +43,23 @@
|
||||
}, 3000)
|
||||
}
|
||||
login()
|
||||
|
||||
async function checkStatus(key) {
|
||||
const res = await axios({
|
||||
url: `/login/qr/check?key=${key}×tamp=${Date.now()}`,
|
||||
})
|
||||
return res.data
|
||||
}
|
||||
async function getLoginStatus(cookie = '') {
|
||||
const res = await axios({
|
||||
url: `/login/status?timestamp=${Date.now()}`,
|
||||
method: 'post',
|
||||
data: {
|
||||
cookie,
|
||||
},
|
||||
})
|
||||
document.querySelector('#info').innerText = JSON.stringify(res.data, null, 2)
|
||||
}
|
||||
</script>
|
||||
<style>
|
||||
.info {
|
||||
|
@ -1,63 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh">
|
||||
|
||||
<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>
|
||||
<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 = ''
|
||||
if (!phone || !password) {
|
||||
const msg = '请设置你的手机号码和密码'
|
||||
alert(msg)
|
||||
throw new Error(msg)
|
||||
}
|
||||
$.ajax({
|
||||
url: `/login/cellphone?phone=${phone}&password=${password}`,
|
||||
xhrFields: {
|
||||
withCredentials: true, //跨域的话必须设置
|
||||
},
|
||||
success: function (data) {
|
||||
console.log(data)
|
||||
$.ajax({
|
||||
url: `/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: `/login/cellphone?phone=${phone}&password=${password}`,
|
||||
withCredentials: true, //跨域的话必须设置
|
||||
}).then(function (res) {
|
||||
console.log(res.data)
|
||||
axios({
|
||||
url: `/recommend/resource`,
|
||||
withCredentials: true, //跨域的话必须设置
|
||||
}).then(function (res) {
|
||||
console.log(res.data)
|
||||
})
|
||||
})
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
@ -8,6 +8,11 @@
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div>
|
||||
<a href="/qrlogin-nocookie.html">
|
||||
如果没登录,请先登录
|
||||
</a>
|
||||
</div>
|
||||
<div id="app">
|
||||
<ul>
|
||||
<li v-for="(item,index) in voicelist" @click="currentVoiceIndex=index"
|
||||
@ -61,31 +66,10 @@
|
||||
const file = document.querySelector('input[type=file]').files[0]
|
||||
this.upload(file)
|
||||
},
|
||||
async login() {
|
||||
const phone = '' // 这里填手机号
|
||||
const password = '' // 这里填密码
|
||||
const fileUpdateTime = {}
|
||||
let fileLength = 0
|
||||
if (!phone || !password) {
|
||||
const msg = '请设置你的手机号码和密码'
|
||||
alert(msg)
|
||||
throw new Error(msg)
|
||||
}
|
||||
|
||||
const res = await axios({
|
||||
url: `/login/cellphone`,
|
||||
method: 'post',
|
||||
data: {
|
||||
phone,
|
||||
password,
|
||||
},
|
||||
})
|
||||
this.cookieToken = res.data.cookie
|
||||
},
|
||||
async getData() {
|
||||
await this.login()
|
||||
const res = await axios({
|
||||
url: `/voicelist/search?cookie=${this.cookieToken}`,
|
||||
url: `/voicelist/search?cookie=${localStorage.getItem('cookie')}`,
|
||||
})
|
||||
|
||||
console.log(res.data.data)
|
||||
@ -103,14 +87,10 @@
|
||||
formData.append('songFile', file)
|
||||
axios({
|
||||
method: 'post',
|
||||
url: `/voice/upload?time=${Date.now()}&cookie=${
|
||||
this.cookieToken
|
||||
}&songName=${this.songName}&voiceListId=${
|
||||
this.currentVoice.voiceListId
|
||||
}&categoryId=${this.currentVoice.categoryId}&coverImgId=${
|
||||
this.currentVoice.coverImgId
|
||||
}&secondCategoryId=${this.currentVoice.secondCategoryId}&description=${
|
||||
this.description
|
||||
url: `/voice/upload?time=${Date.now()}&cookie=${localStorage.getItem('cookie')
|
||||
}&songName=${this.songName}&voiceListId=${this.currentVoice.voiceListId
|
||||
}&categoryId=${this.currentVoice.categoryId}&coverImgId=${this.currentVoice.coverImgId
|
||||
}&secondCategoryId=${this.currentVoice.secondCategoryId}&description=${this.description
|
||||
}&privacy=1`,
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data',
|
||||
|
Loading…
x
Reference in New Issue
Block a user