v4.0,新增云盘上传接口以及二维码登录相关接口和相关demo,升级部分接口加密方法 #70 , #121 ,#121 , #153 ,#248 , #705 , #716 , #745 , #1055

This commit is contained in:
binaryify
2021-01-03 20:17:26 +08:00
parent 77775b25f5
commit 75cb79fc6a
22 changed files with 543 additions and 195 deletions
+55
View File
@@ -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>