mirror of
https://github.com/NeteaseCloudMusicApiEnhanced/api-enhanced.git
synced 2026-10-20 22:51:23 +08:00
v4.0,新增云盘上传接口以及二维码登录相关接口和相关demo,升级部分接口加密方法 #70 , #121 ,#121 , #153 ,#248 , #705 , #716 , #745 , #1055
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>云盘上传</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<input id="file" type="file" accept="audio/mpeg" />
|
||||
|
||||
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.20.0-0/axios.min.js"></script>
|
||||
<script>
|
||||
|
||||
const phone = ''
|
||||
const password = ''
|
||||
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=${password}`,
|
||||
withCredentials: true, //关键
|
||||
})
|
||||
cookieToken = res.data.cookie
|
||||
}
|
||||
async function main() {
|
||||
document
|
||||
.querySelector('input[type="file"]')
|
||||
.addEventListener('change', function (e) {
|
||||
var file = this.files[0]
|
||||
upload(file)
|
||||
})
|
||||
}
|
||||
|
||||
async function upload(file) {
|
||||
var formData = new FormData()
|
||||
formData.append('songFile', file)
|
||||
const res = await axios({
|
||||
method: 'post',
|
||||
url: `http://localhost:3000/cloud?time=${Date.now()}`,
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data',
|
||||
},
|
||||
data: formData,
|
||||
})
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user