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

|
|
||||||
|
|
||||||
|
|
||||||
## 功能特性
|
## 功能特性
|
||||||
|
|
||||||
1. 登录
|
1. 登录
|
||||||
@ -259,10 +259,10 @@ banner({ type:0 }).then(res=>{
|
|||||||
113. 云盘数据详情
|
113. 云盘数据详情
|
||||||
114. 私信内容
|
114. 私信内容
|
||||||
115. 我的数字专辑
|
115. 我的数字专辑
|
||||||
116. batch批量请求接口
|
116. batch 批量请求接口
|
||||||
117. 获取视频标签列表
|
117. 获取视频标签列表
|
||||||
118. 全部mv
|
118. 全部 mv
|
||||||
119. 网易出品mv
|
119. 网易出品 mv
|
||||||
120. 收藏/取消收藏专辑
|
120. 收藏/取消收藏专辑
|
||||||
121. 专辑动态信息
|
121. 专辑动态信息
|
||||||
122. 热搜列表(详细)
|
122. 热搜列表(详细)
|
||||||
@ -274,7 +274,7 @@ banner({ type:0 }).then(res=>{
|
|||||||
128. 更新歌单标签
|
128. 更新歌单标签
|
||||||
129. 默认搜索关键词
|
129. 默认搜索关键词
|
||||||
130. 删除歌单
|
130. 删除歌单
|
||||||
131. 电台banner
|
131. 电台 banner
|
||||||
132. 用户电台
|
132. 用户电台
|
||||||
133. 热门电台
|
133. 热门电台
|
||||||
134. 电台 - 节目详情
|
134. 电台 - 节目详情
|
||||||
@ -282,12 +282,12 @@ banner({ type:0 }).then(res=>{
|
|||||||
136. 电台 - 新晋电台榜/热门电台榜
|
136. 电台 - 新晋电台榜/热门电台榜
|
||||||
137. 类别热门电台
|
137. 类别热门电台
|
||||||
138. 云村热评
|
138. 云村热评
|
||||||
139. 电台24小时节目榜
|
139. 电台 24 小时节目榜
|
||||||
140. 电台24小时主播榜
|
140. 电台 24 小时主播榜
|
||||||
141. 电台最热主播榜
|
141. 电台最热主播榜
|
||||||
142. 电台主播新人榜
|
142. 电台主播新人榜
|
||||||
143. 电台付费精品榜
|
143. 电台付费精品榜
|
||||||
144. 歌手热门50首歌曲
|
144. 歌手热门 50 首歌曲
|
||||||
145. 购买数字专辑
|
145. 购买数字专辑
|
||||||
146. 获取 mv 点赞转发评论数数据
|
146. 获取 mv 点赞转发评论数数据
|
||||||
147. 获取视频点赞转发评论数数据
|
147. 获取视频点赞转发评论数数据
|
||||||
@ -326,7 +326,7 @@ banner({ type:0 }).then(res=>{
|
|||||||
180. 云贝签到信息
|
180. 云贝签到信息
|
||||||
181. 云贝签到
|
181. 云贝签到
|
||||||
182. 云贝所有任务
|
182. 云贝所有任务
|
||||||
183. 云贝todo任务
|
183. 云贝 todo 任务
|
||||||
184. 云贝今日签到信息
|
184. 云贝今日签到信息
|
||||||
185. 云贝完成任务
|
185. 云贝完成任务
|
||||||
186. 云贝收入
|
186. 云贝收入
|
||||||
@ -339,7 +339,7 @@ banner({ type:0 }).then(res=>{
|
|||||||
193. 评论抱一抱列表
|
193. 评论抱一抱列表
|
||||||
194. 收藏的专栏
|
194. 收藏的专栏
|
||||||
195. 关注歌手新歌
|
195. 关注歌手新歌
|
||||||
196. 关注歌手新MV
|
196. 关注歌手新 MV
|
||||||
197. 歌手详情
|
197. 歌手详情
|
||||||
198. 云盘上传
|
198. 云盘上传
|
||||||
199. 二维码登录
|
199. 二维码登录
|
||||||
@ -353,12 +353,12 @@ banner({ type:0 }).then(res=>{
|
|||||||
207. 云贝推歌
|
207. 云贝推歌
|
||||||
208. 云贝推歌历史记录
|
208. 云贝推歌历史记录
|
||||||
209. 已购单曲
|
209. 已购单曲
|
||||||
210. 获取mlog播放地址
|
210. 获取 mlog 播放地址
|
||||||
211. 将mlog id转为视频id
|
211. 将 mlog id 转为视频 id
|
||||||
212. vip成长值
|
212. vip 成长值
|
||||||
213. vip成长值获取记录
|
213. vip 成长值获取记录
|
||||||
214. vip任务
|
214. vip 任务
|
||||||
215. 领取vip成长值
|
215. 领取 vip 成长值
|
||||||
216. 歌手粉丝
|
216. 歌手粉丝
|
||||||
217. 数字专辑详情
|
217. 数字专辑详情
|
||||||
218. 数字专辑销量
|
218. 数字专辑销量
|
||||||
@ -403,12 +403,12 @@ banner({ type:0 }).then(res=>{
|
|||||||
257. 验证接口-二维码生成
|
257. 验证接口-二维码生成
|
||||||
258. 验证接口-二维码检测
|
258. 验证接口-二维码检测
|
||||||
259. 听歌识曲
|
259. 听歌识曲
|
||||||
260. 根据nickname获取userid接口
|
260. 根据 nickname 获取 userid 接口
|
||||||
261. 播客声音列表
|
261. 播客声音列表
|
||||||
262. 专辑简要百科信息
|
262. 专辑简要百科信息
|
||||||
263. 歌曲简要百科信息
|
263. 歌曲简要百科信息
|
||||||
264. 歌手简要百科信息
|
264. 歌手简要百科信息
|
||||||
265. mv简要百科信息
|
265. mv 简要百科信息
|
||||||
266. 搜索歌手
|
266. 搜索歌手
|
||||||
267. 用户贡献内容
|
267. 用户贡献内容
|
||||||
268. 用户贡献条目、积分、云贝数量
|
268. 用户贡献条目、积分、云贝数量
|
||||||
@ -421,28 +421,24 @@ banner({ type:0 }).then(res=>{
|
|||||||
275. 歌曲红心数量
|
275. 歌曲红心数量
|
||||||
276. 私人 FM 模式选择
|
276. 私人 FM 模式选择
|
||||||
|
|
||||||
|
|
||||||
## 单元测试
|
## 单元测试
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
$ npm test
|
$ npm test
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
## SDK
|
## SDK
|
||||||
|
|
||||||
| 语言 | 作者 | 地址 | 类型 |
|
| 语言 | 作者 | 地址 | 类型 |
|
||||||
| :--: | :-----------------------------------------: | :----------------------------------------------------------: | :----: |
|
| :----: | :-----------------------------------------: | :--------------------------------------------------------------------------------------------------------: | :----: |
|
||||||
| Java | [JackuXL](https://github.com/JackuXL) | [https://github.com/JackuXL/NeteaseCloudMusicApi-SDK](https://github.com/JackuXL/NeteaseCloudMusicApi-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 | 第三方 |
|
| 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) | 第三方 |
|
| Python | [盧瞳](https://github.com/2061360308) | [NeteaseCloudMusic_PythonSDK](https://github.com/2061360308/NeteaseCloudMusic_PythonSDK) | 第三方 |
|
||||||
|
|
||||||
|
|
||||||
## 贡献者
|
## 贡献者
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
[The MIT License (MIT)](https://gitlab.com/Binaryify/NeteaseCloudMusicApi/blob/main/LICENSE)
|
[The MIT License (MIT)](https://gitlab.com/Binaryify/NeteaseCloudMusicApi/blob/main/LICENSE)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "NeteaseCloudMusicApi",
|
"name": "NeteaseCloudMusicApi",
|
||||||
"version": "4.15.5",
|
"version": "4.15.6",
|
||||||
"description": "网易云音乐 NodeJS 版 API",
|
"description": "网易云音乐 NodeJS 版 API",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "node app.js",
|
"start": "node app.js",
|
||||||
|
@ -1,82 +1,73 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="zh">
|
<html lang="zh">
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8" />
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
||||||
<title>更新头像</title>
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
<head>
|
||||||
<input id="file" type="file" />
|
<meta charset="UTF-8" />
|
||||||
<img id="avatar" style="height: 200px; width: 200px; border-radius: 50%" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<script src="https://cdn.jsdelivr.net/npm/axios@0.26.1/dist/axios.min.js
|
<title>更新头像</title>
|
||||||
|
</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>
|
||||||
<script>
|
<script>
|
||||||
const phone = ''
|
main()
|
||||||
const password = ''
|
|
||||||
let cookieToken = ''
|
|
||||||
if (!phone || !password) {
|
|
||||||
const msg = '请设置你的手机号码和密码'
|
|
||||||
alert(msg)
|
|
||||||
throw new Error(msg)
|
|
||||||
}
|
|
||||||
|
|
||||||
main()
|
async function main() {
|
||||||
login()
|
document.querySelector('input[type="file"]').addEventListener(
|
||||||
async function main() {
|
'change',
|
||||||
document.querySelector('input[type="file"]').addEventListener(
|
function (e) {
|
||||||
'change',
|
var file = this.files[0]
|
||||||
function (e) {
|
upload(file)
|
||||||
var file = this.files[0]
|
},
|
||||||
upload(file)
|
false,
|
||||||
},
|
)
|
||||||
false,
|
const res = await axios({
|
||||||
)
|
url: `/user/detail?uid=32953014×tamp=${Date.now()}`,
|
||||||
const res = await axios({
|
withCredentials: true, //跨域的话必须设置
|
||||||
url: `/user/detail?uid=32953014×tamp=${Date.now()}`,
|
})
|
||||||
withCredentials: true, //跨域的话必须设置
|
document.querySelector('#avatar').src = res.data.profile.avatarUrl
|
||||||
})
|
}
|
||||||
document.querySelector('#avatar').src = res.data.profile.avatarUrl
|
|
||||||
}
|
async function upload(file) {
|
||||||
async function login() {
|
var formData = new FormData()
|
||||||
const res = await axios({
|
formData.append('imgFile', file)
|
||||||
url: `/login/cellphone?phone=${phone}&password=${password}`,
|
const imgSize = await getImgSize(file)
|
||||||
withCredentials: true, //跨域的话必须设置
|
const res = await axios({
|
||||||
})
|
method: 'post',
|
||||||
cookieToken = res.data.cookie
|
url: `/avatar/upload?cookie=${localStorage.getItem('cookie')}&imgSize=${imgSize.width
|
||||||
}
|
|
||||||
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
|
|
||||||
}&imgX=0&imgY=0×tamp=${Date.now()}`,
|
}&imgX=0&imgY=0×tamp=${Date.now()}`,
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'multipart/form-data',
|
'Content-Type': 'multipart/form-data',
|
||||||
},
|
},
|
||||||
data: formData,
|
data: formData,
|
||||||
})
|
})
|
||||||
document.querySelector('#avatar').src = res.data.data.url
|
document.querySelector('#avatar').src = res.data.data.url
|
||||||
}
|
}
|
||||||
function getImgSize(file) {
|
function getImgSize(file) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
let reader = new FileReader()
|
let reader = new FileReader()
|
||||||
reader.readAsDataURL(file)
|
reader.readAsDataURL(file)
|
||||||
reader.onload = function (theFile) {
|
reader.onload = function (theFile) {
|
||||||
let image = new Image()
|
let image = new Image()
|
||||||
image.src = theFile.target.result
|
image.src = theFile.target.result
|
||||||
image.onload = function () {
|
image.onload = function () {
|
||||||
resolve({
|
resolve({
|
||||||
width: this.width,
|
width: this.width,
|
||||||
height: this.height,
|
height: this.height,
|
||||||
})
|
})
|
||||||
}
|
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
}
|
})
|
||||||
</script>
|
}
|
||||||
</body>
|
</script>
|
||||||
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
@ -8,29 +8,48 @@
|
|||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
<div>
|
||||||
|
<a href="/qrlogin-nocookie.html">
|
||||||
|
如果没登录,请先登录
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
<input id="file" type="file" multiple />
|
<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/axios@0.26.1/dist/axios.min.js"></script>
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/vue"></script>
|
||||||
<script>
|
<script>
|
||||||
const phone = '' // 这里填手机号
|
const app = Vue.createApp({
|
||||||
const password = '' // 这里填密码
|
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 = {}
|
const fileUpdateTime = {}
|
||||||
let fileLength = 0
|
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() {
|
function main() {
|
||||||
document
|
document
|
||||||
.querySelector('input[type="file"]')
|
.querySelector('input[type="file"]')
|
||||||
@ -44,13 +63,14 @@
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
main()
|
||||||
|
|
||||||
function upload(file, currentIndx) {
|
function upload(file, currentIndx) {
|
||||||
var formData = new FormData()
|
var formData = new FormData()
|
||||||
formData.append('songFile', file)
|
formData.append('songFile', file)
|
||||||
axios({
|
axios({
|
||||||
method: 'post',
|
method: 'post',
|
||||||
url: `/cloud?time=${Date.now()}&cookie=${cookieToken}`,
|
url: `/cloud?time=${Date.now()}&cookie=${localStorage.getItem('cookie')}`,
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'multipart/form-data',
|
'Content-Type': 'multipart/form-data',
|
||||||
},
|
},
|
||||||
@ -58,6 +78,7 @@
|
|||||||
}).then(res => {
|
}).then(res => {
|
||||||
console.log(`${file.name} 上传成功`)
|
console.log(`${file.name} 上传成功`)
|
||||||
if (currentIndx >= fileLength) { console.log('上传完毕') }
|
if (currentIndx >= fileLength) { console.log('上传完毕') }
|
||||||
|
app.getData()
|
||||||
}).catch(async err => {
|
}).catch(async err => {
|
||||||
console.log(err)
|
console.log(err)
|
||||||
console.log(fileUpdateTime)
|
console.log(fileUpdateTime)
|
||||||
|
@ -8,32 +8,18 @@
|
|||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<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 src="https://cdn.jsdelivr.net/npm/axios@0.26.1/dist/axios.min.js"></script>
|
||||||
<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() {
|
async function main() {
|
||||||
await login()
|
|
||||||
const res = await axios({
|
const res = await axios({
|
||||||
url: `/homepage/block/page`,
|
url: `/homepage/block/page`,
|
||||||
data: {
|
data: {
|
||||||
cookie: cookieToken,
|
cookie: localStorage.getItem('cookie'),
|
||||||
},
|
},
|
||||||
method: 'post',
|
method: 'post',
|
||||||
})
|
})
|
||||||
@ -44,7 +30,7 @@
|
|||||||
const res2 = await axios({
|
const res2 = await axios({
|
||||||
url: `/homepage/block/page?time=${Date.now()}`,
|
url: `/homepage/block/page?time=${Date.now()}`,
|
||||||
data: {
|
data: {
|
||||||
cookie: cookieToken,
|
cookie: localStorage.getItem('cookie'),
|
||||||
cursor: cursor,
|
cursor: cursor,
|
||||||
},
|
},
|
||||||
method: 'post',
|
method: 'post',
|
||||||
|
@ -3,240 +3,257 @@
|
|||||||
<html lang="zh">
|
<html lang="zh">
|
||||||
|
|
||||||
<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" />
|
||||||
<title>一起听 - 主机模式</title>
|
<title>一起听 - 主机模式</title>
|
||||||
<script src="https://unpkg.com/petite-vue"></script>
|
<script src="https://unpkg.com/petite-vue"></script>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/axios@0.26.1/dist/axios.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/axios@0.26.1/dist/axios.min.js"></script>
|
||||||
<link rel="stylesheet" href="https://unpkg.com/mdui@1.0.2/dist/css/mdui.min.css" />
|
<link rel="stylesheet" href="https://unpkg.com/mdui@1.0.2/dist/css/mdui.min.css" />
|
||||||
<script src="https://unpkg.com/mdui@1.0.2/dist/js/mdui.min.js"></script>
|
<script src="https://unpkg.com/mdui@1.0.2/dist/js/mdui.min.js"></script>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body class="mdui-container">
|
<body class="mdui-container">
|
||||||
<h1>一起听 - 主机模式</h1>
|
<div>
|
||||||
<div>消息: {{message}}</div>
|
<a href="/qrlogin-nocookie.html">
|
||||||
<audio
|
如果没登录,请先登录
|
||||||
id="player"
|
</a>
|
||||||
autoplay
|
</div>
|
||||||
controls>
|
<h1>一起听 - 主机模式</h1>
|
||||||
</audio>
|
<div>消息: {{message}}</div>
|
||||||
<br />
|
<audio id="player" autoplay controls>
|
||||||
<br />
|
</audio>
|
||||||
<button v-if="!account.login" @click="login">获取登录状态</button>
|
<br />
|
||||||
<div>您的当前登录账号为: {{account.nickname}}</div>
|
<br />
|
||||||
<br />
|
<button v-if="!account.login" @click="login">获取登录状态</button>
|
||||||
<div v-if="account.login">
|
<div>您的当前登录账号为: {{account.nickname}}</div>
|
||||||
<button v-if="!roomInfo.roomId" @click="createRoom">创建房间</button>
|
<br />
|
||||||
|
<div v-if="account.login">
|
||||||
|
<button v-if="!roomInfo.roomId" @click="createRoom">创建房间</button>
|
||||||
|
|
||||||
<div v-if="roomInfo.roomId">
|
<div v-if="roomInfo.roomId">
|
||||||
<div>分享链接为:
|
<div>分享链接为:
|
||||||
https://st.music.163.com/listen-together/share/?songId=1372188635&roomId={{roomInfo.roomId}}&inviterId={{account.userId}}
|
https://st.music.163.com/listen-together/share/?songId=1372188635&roomId={{roomInfo.roomId}}&inviterId={{account.userId}}
|
||||||
</div>
|
</div>
|
||||||
<br />
|
<br />
|
||||||
<button @click="refreshRoom">刷新房间状态</button>
|
<button @click="refreshRoom">刷新房间状态</button>
|
||||||
<div>在线用户: </div>
|
<div>在线用户: </div>
|
||||||
<ul class="mdui-list">
|
<ul class="mdui-list">
|
||||||
<li v-for="user in roomInfo.roomUsers" class="mdui-list-item mdui-ripple">
|
<li v-for="user in roomInfo.roomUsers" class="mdui-list-item mdui-ripple">
|
||||||
<div class="mdui-list-item-avatar">
|
<div class="mdui-list-item-avatar">
|
||||||
<img :src="user.avatarUrl" />
|
<img :src="user.avatarUrl" />
|
||||||
</div>
|
</div>
|
||||||
<div class="mdui-list-item-content">{{user.nickname}}</div>
|
<div class="mdui-list-item-content">{{user.nickname}}</div>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<button v-if="roomInfo.roomId" @click="closeRoom">关闭房间</button>
|
<button v-if="roomInfo.roomId" @click="closeRoom">关闭房间</button>
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<button @click="playTrack">播放</button>
|
</div>
|
||||||
<button @click="pauseTrack">暂停</button>
|
<button @click="playTrack">播放</button>
|
||||||
<button @click="seekTrack">同步进度</button>
|
<button @click="pauseTrack">暂停</button>
|
||||||
<details>
|
<button @click="seekTrack">同步进度</button>
|
||||||
<summary>播放列表</summary>
|
<details>
|
||||||
<br />
|
<summary>播放列表</summary>
|
||||||
<div><span>歌单ID: </span><input v-model="playlistInfo.playlistId" /></div>
|
<br />
|
||||||
<button @click="loadPlaylist">加载歌单到播放列表</button>
|
<div><span>歌单ID: </span><input v-model="playlistInfo.playlistId" /></div>
|
||||||
<span>{{playlistInfo.playlistName}}</span>
|
<button @click="loadPlaylist">加载歌单到播放列表</button>
|
||||||
<br />
|
<span>{{playlistInfo.playlistName}}</span>
|
||||||
<br />
|
<br />
|
||||||
<div>歌单内容: </div>
|
<br />
|
||||||
<ul class="mdui-list">
|
<div>歌单内容: </div>
|
||||||
<li @click="gotoTrack(track.id)" v-for="track in playlistInfo.playlistTracks"
|
<ul class="mdui-list">
|
||||||
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">
|
<div class="mdui-list-item-avatar">
|
||||||
<img :src="track.al.picUrl" />
|
<img :src="track.al.picUrl" />
|
||||||
</div>
|
</div>
|
||||||
<div class="mdui-list-item-content">{{track.name}}</div>
|
<div class="mdui-list-item-content">{{track.name}}</div>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
<script>
|
<script>
|
||||||
PetiteVue.createApp({
|
PetiteVue.createApp({
|
||||||
message: '请点击获取登录状态',
|
message: '请点击获取登录状态',
|
||||||
account: {
|
account: {
|
||||||
login: false,
|
login: false,
|
||||||
userId: 0,
|
userId: 0,
|
||||||
nickname: '未登录',
|
nickname: '未登录',
|
||||||
},
|
},
|
||||||
roomInfo: {
|
roomInfo: {
|
||||||
roomId: null,
|
roomId: null,
|
||||||
roomUsers: [],
|
roomUsers: [],
|
||||||
},
|
},
|
||||||
playlistInfo: {
|
playlistInfo: {
|
||||||
playlistId: 0,
|
playlistId: 0,
|
||||||
playlistName: '未获取',
|
playlistName: '未获取',
|
||||||
playlistTrackIds: [],
|
playlistTrackIds: [],
|
||||||
playlistTracks: [],
|
playlistTracks: [],
|
||||||
},
|
},
|
||||||
playingInfo: {
|
playingInfo: {
|
||||||
trackId: 0,
|
trackId: 0,
|
||||||
status: 'PLAY',
|
status: 'PLAY',
|
||||||
progress: 1,
|
progress: 1,
|
||||||
},
|
},
|
||||||
clientSeq: 1,
|
clientSeq: 1,
|
||||||
login: async function () {
|
login: async function () {
|
||||||
const res = await axios({
|
const res = await axios({
|
||||||
url: `/login/status`,
|
url: `/login/status`,
|
||||||
method: 'get',
|
method: 'get',
|
||||||
})
|
data: {
|
||||||
if (res.data.data.code != 200) {
|
cookie: localStorage.getItem('cookie'),
|
||||||
alert('请先使用登录 API 登录到网易云音乐')
|
},
|
||||||
} else {
|
})
|
||||||
this.account.userId = res.data.data.profile.userId
|
if (res.data.data.code != 200) {
|
||||||
this.account.nickname = res.data.data.profile.nickname
|
alert('请先使用登录 API 登录到网易云音乐')
|
||||||
this.account.login = true
|
} else {
|
||||||
this.message = '成功登录, 请创建房间'
|
this.account.userId = res.data.data.profile.userId
|
||||||
}
|
this.account.nickname = res.data.data.profile.nickname
|
||||||
},
|
this.account.login = true
|
||||||
createRoom: async function () {
|
this.message = '成功登录, 请创建房间'
|
||||||
const res = await axios({
|
}
|
||||||
url: 'listentogether/room/create',
|
},
|
||||||
method: 'get',
|
createRoom: async function () {
|
||||||
})
|
const res = await axios({
|
||||||
console.log(res)
|
url: 'listentogether/room/create',
|
||||||
if (res.data.code != 200) {
|
method: 'get',
|
||||||
this.message = '创建房间出现问题: ' + res.data.message
|
data: {
|
||||||
} else {
|
cookie: localStorage.getItem('cookie'),
|
||||||
this.message = '创建房间成功: ' + res.data.data.roomInfo.roomId
|
},
|
||||||
this.roomInfo.roomId = res.data.data.roomInfo.roomId
|
})
|
||||||
res = await axios({
|
console.log(res)
|
||||||
url: 'listentogether/room/check',
|
if (res.data.code != 200) {
|
||||||
method: 'post',
|
this.message = '创建房间出现问题: ' + res.data.message
|
||||||
data: {
|
} else {
|
||||||
roomId: this.roomInfo.roomId,
|
this.message = '创建房间成功: ' + res.data.data.roomInfo.roomId
|
||||||
},
|
this.roomInfo.roomId = res.data.data.roomInfo.roomId
|
||||||
})
|
const res2 = await axios({
|
||||||
console.log(res)
|
url: 'listentogether/room/check',
|
||||||
}
|
|
||||||
},
|
|
||||||
refreshRoom: async function () {
|
|
||||||
const res = await axios({
|
|
||||||
url: '/listentogether/status',
|
|
||||||
})
|
|
||||||
console.log(res)
|
|
||||||
if (res.data.code != 200 || !res.data.data.inRoom) {
|
|
||||||
this.message = '房间状态获取失败, 可能退出了房间'
|
|
||||||
} else {
|
|
||||||
this.roomInfo.roomUsers = res.data.data.roomInfo.roomUsers
|
|
||||||
}
|
|
||||||
},
|
|
||||||
closeRoom: async function () {
|
|
||||||
const res = await axios({
|
|
||||||
url: '/listentogether/end',
|
|
||||||
method: 'post',
|
method: 'post',
|
||||||
data: {
|
data: {
|
||||||
roomId: this.roomInfo.roomId,
|
roomId: this.roomInfo.roomId,
|
||||||
|
cookie: localStorage.getItem('cookie'),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
console.log(res)
|
console.log(res2)
|
||||||
if (res.data.code != 200 || !res.data.data.success) {
|
}
|
||||||
this.message = '房间关闭失败'
|
},
|
||||||
} else {
|
refreshRoom: async function () {
|
||||||
this.message = '房间关闭成功'
|
const res = await axios({
|
||||||
this.roomInfo.roomId = null
|
url: '/listentogether/status',
|
||||||
}
|
data: {
|
||||||
},
|
cookie: localStorage.getItem('cookie'),
|
||||||
loadPlaylist: async function () {
|
},
|
||||||
const res = await axios({
|
})
|
||||||
url: '/playlist/detail',
|
console.log(res)
|
||||||
method: 'post',
|
if (res.data.code != 200 || !res.data.data.inRoom) {
|
||||||
data: {
|
this.message = '房间状态获取失败, 可能退出了房间'
|
||||||
id: this.playlistInfo.playlistId,
|
} else {
|
||||||
},
|
this.roomInfo.roomUsers = res.data.data.roomInfo.roomUsers
|
||||||
})
|
}
|
||||||
console.log(res)
|
},
|
||||||
this.playlistInfo.playlistName = res.data.playlist.name
|
closeRoom: async function () {
|
||||||
this.playlistInfo.playlistTrackIds = res.data.playlist.trackIds
|
const res = await axios({
|
||||||
.map((track) => track.id)
|
url: '/listentogether/end',
|
||||||
.join(',')
|
method: 'post',
|
||||||
const resa = await axios({
|
data: {
|
||||||
url: '/song/detail',
|
roomId: this.roomInfo.roomId,
|
||||||
method: 'post',
|
cookie: localStorage.getItem('cookie'),
|
||||||
data: {
|
|
||||||
ids: this.playlistInfo.playlistTrackIds,
|
},
|
||||||
},
|
})
|
||||||
})
|
console.log(res)
|
||||||
console.log(resa)
|
if (res.data.code != 200 || !res.data.data.success) {
|
||||||
this.playlistInfo.playlistTracks = resa.data.songs
|
this.message = '房间关闭失败'
|
||||||
if (this.roomInfo.roomId) {
|
} else {
|
||||||
const resb = await axios({
|
this.message = '房间关闭成功'
|
||||||
url: 'listentogether/sync/list/command',
|
this.roomInfo.roomId = null
|
||||||
method: 'post',
|
}
|
||||||
data: {
|
},
|
||||||
roomId: this.roomInfo.roomId,
|
loadPlaylist: async function () {
|
||||||
commandType: 'REPLACE',
|
const res = await axios({
|
||||||
userId: this.account.userId,
|
url: '/playlist/detail',
|
||||||
version: this.clientSeq++,
|
method: 'post',
|
||||||
playMode: 'ORDER_LOOP',
|
data: {
|
||||||
displayList: this.playlistInfo.playlistTrackIds,
|
id: this.playlistInfo.playlistId,
|
||||||
randomList: this.playlistInfo.playlistTrackIds,
|
cookie: localStorage.getItem('cookie'),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
console.log(resb)
|
console.log(res)
|
||||||
}
|
this.playlistInfo.playlistName = res.data.playlist.name
|
||||||
},
|
this.playlistInfo.playlistTrackIds = res.data.playlist.trackIds
|
||||||
gotoTrack: async function (trackId) {
|
.map((track) => track.id)
|
||||||
this.playingInfo.trackId = trackId
|
.join(',')
|
||||||
if (this.roomInfo.roomId) {
|
const resa = await axios({
|
||||||
await this.playCommand('GOTO')
|
url: '/song/detail',
|
||||||
}
|
method: 'post',
|
||||||
document.getElementById('player').src =
|
data: {
|
||||||
'https://music.163.com/song/media/outer/url?id=' + trackId + '.mp3'
|
ids: this.playlistInfo.playlistTrackIds,
|
||||||
},
|
cookie: localStorage.getItem('cookie'),
|
||||||
playTrack: async function () {
|
},
|
||||||
this.playingInfo.status = 'PLAY'
|
})
|
||||||
await this.playCommand('PLAY')
|
console.log(resa)
|
||||||
document.getElementById('player').play()
|
this.playlistInfo.playlistTracks = resa.data.songs
|
||||||
},
|
if (this.roomInfo.roomId) {
|
||||||
pauseTrack: async function () {
|
const resb = await axios({
|
||||||
this.playingInfo.status = 'PAUSE'
|
url: 'listentogether/sync/list/command',
|
||||||
await this.playCommand('PAUSE')
|
|
||||||
document.getElementById('player').pause()
|
|
||||||
},
|
|
||||||
seekTrack: async function () {
|
|
||||||
this.playingInfo.status = 'PLAY'
|
|
||||||
await this.playCommand('seek')
|
|
||||||
document.getElementById('player').play()
|
|
||||||
},
|
|
||||||
playCommand: async function (action) {
|
|
||||||
const res = await axios({
|
|
||||||
url: 'listentogether/play/command',
|
|
||||||
method: 'post',
|
method: 'post',
|
||||||
data: {
|
data: {
|
||||||
roomId: this.roomInfo.roomId,
|
roomId: this.roomInfo.roomId,
|
||||||
progress: Math.floor(
|
commandType: 'REPLACE',
|
||||||
document.getElementById('player').currentTime * 1000,
|
userId: this.account.userId,
|
||||||
),
|
version: this.clientSeq++,
|
||||||
commandType: action,
|
playMode: 'ORDER_LOOP',
|
||||||
formerSongId: '-1',
|
displayList: this.playlistInfo.playlistTrackIds,
|
||||||
targetSongId: this.playingInfo.trackId,
|
randomList: this.playlistInfo.playlistTrackIds,
|
||||||
clientSeq: this.clientSeq++,
|
cookie: localStorage.getItem('cookie'),
|
||||||
playStatus: this.playingInfo.status,
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
console.log(res)
|
console.log(resb)
|
||||||
},
|
}
|
||||||
}).mount()
|
},
|
||||||
|
gotoTrack: async function (trackId) {
|
||||||
|
this.playingInfo.trackId = trackId
|
||||||
|
if (this.roomInfo.roomId) {
|
||||||
|
await this.playCommand('GOTO')
|
||||||
|
}
|
||||||
|
document.getElementById('player').src =
|
||||||
|
'https://music.163.com/song/media/outer/url?id=' + trackId + '.mp3'
|
||||||
|
},
|
||||||
|
playTrack: async function () {
|
||||||
|
this.playingInfo.status = 'PLAY'
|
||||||
|
await this.playCommand('PLAY')
|
||||||
|
document.getElementById('player').play()
|
||||||
|
},
|
||||||
|
pauseTrack: async function () {
|
||||||
|
this.playingInfo.status = 'PAUSE'
|
||||||
|
await this.playCommand('PAUSE')
|
||||||
|
document.getElementById('player').pause()
|
||||||
|
},
|
||||||
|
seekTrack: async function () {
|
||||||
|
this.playingInfo.status = 'PLAY'
|
||||||
|
await this.playCommand('seek')
|
||||||
|
document.getElementById('player').play()
|
||||||
|
},
|
||||||
|
playCommand: async function (action) {
|
||||||
|
const res = await axios({
|
||||||
|
url: 'listentogether/play/command',
|
||||||
|
method: 'post',
|
||||||
|
data: {
|
||||||
|
roomId: this.roomInfo.roomId,
|
||||||
|
progress: Math.floor(
|
||||||
|
document.getElementById('player').currentTime * 1000,
|
||||||
|
),
|
||||||
|
commandType: action,
|
||||||
|
formerSongId: '-1',
|
||||||
|
targetSongId: this.playingInfo.trackId,
|
||||||
|
clientSeq: this.clientSeq++,
|
||||||
|
playStatus: this.playingInfo.status,
|
||||||
|
cookie: localStorage.getItem('cookie'),
|
||||||
|
},
|
||||||
|
})
|
||||||
|
console.log(res)
|
||||||
|
},
|
||||||
|
}).mount()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
@ -1,89 +1,77 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="zh">
|
<html lang="zh">
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8" />
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
||||||
<title>歌单封面上传</title>
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
<head>
|
||||||
<input id="file" type="file" name="filename" />
|
<meta charset="UTF-8" />
|
||||||
<img
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
id="playlist_cover"
|
<title>歌单封面上传</title>
|
||||||
style="height: 200px; width: 200px; border-radius: 50%"
|
</head>
|
||||||
/>
|
|
||||||
<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)
|
|
||||||
throw new Error(msg)
|
|
||||||
}
|
|
||||||
|
|
||||||
main()
|
<body>
|
||||||
login()
|
<div>
|
||||||
async function main() {
|
<a href="/qrlogin-nocookie.html">
|
||||||
document.querySelector('input[type="file"]').addEventListener(
|
如果没登录,请先登录
|
||||||
'change',
|
</a>
|
||||||
function (e) {
|
</div>
|
||||||
var file = this.files[0]
|
<input id="file" type="file" name="filename" />
|
||||||
upload(file)
|
<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>
|
||||||
false,
|
<script>
|
||||||
)
|
const playlist_id = ''
|
||||||
const res = await axios({
|
if (!playlist_id) {
|
||||||
url: `/playlist/detail?id=${playlist_id}×tamp=${Date.now()}`,
|
const msg = '请设置你的歌单id'
|
||||||
})
|
alert(msg)
|
||||||
document.querySelector('#playlist_cover').src = res.data.playlist.coverImgUrl
|
throw new Error(msg)
|
||||||
}
|
}
|
||||||
async function login() {
|
|
||||||
const res = await axios({
|
main()
|
||||||
url: `/login/cellphone?phone=${phone}&password=${password}`,
|
async function main() {
|
||||||
withCredentials: true, //跨域的话必须设置
|
document.querySelector('input[type="file"]').addEventListener(
|
||||||
})
|
'change',
|
||||||
cookieToken = res.data.cookie
|
function (e) {
|
||||||
}
|
var file = this.files[0]
|
||||||
async function upload(file) {
|
upload(file)
|
||||||
var formData = new FormData()
|
},
|
||||||
formData.append('imgFile', file)
|
false,
|
||||||
const imgSize = await getImgSize(file)
|
)
|
||||||
const res = await axios({
|
const res = await axios({
|
||||||
method: 'post',
|
url: `/playlist/detail?id=${playlist_id}×tamp=${Date.now()}`,
|
||||||
url: `/playlist/cover/update?id=${playlist_id}&cookie=${cookieToken}&imgSize=${
|
})
|
||||||
imgSize.width
|
document.querySelector('#playlist_cover').src = res.data.playlist.coverImgUrl
|
||||||
|
}
|
||||||
|
|
||||||
|
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=${localStorage.getItem('cookie')}&imgSize=${imgSize.width
|
||||||
}&imgX=0&imgY=0×tamp=${Date.now()}`,
|
}&imgX=0&imgY=0×tamp=${Date.now()}`,
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'multipart/form-data',
|
'Content-Type': 'multipart/form-data',
|
||||||
},
|
},
|
||||||
data: formData,
|
data: formData,
|
||||||
})
|
})
|
||||||
document.querySelector('#playlist_cover').src = res.data.data.url
|
document.querySelector('#playlist_cover').src = res.data.data.url
|
||||||
}
|
}
|
||||||
function getImgSize(file) {
|
function getImgSize(file) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
let reader = new FileReader()
|
let reader = new FileReader()
|
||||||
reader.readAsDataURL(file)
|
reader.readAsDataURL(file)
|
||||||
reader.onload = function (theFile) {
|
reader.onload = function (theFile) {
|
||||||
let image = new Image()
|
let image = new Image()
|
||||||
image.src = theFile.target.result
|
image.src = theFile.target.result
|
||||||
image.onload = function () {
|
image.onload = function () {
|
||||||
resolve({
|
resolve({
|
||||||
width: this.width,
|
width: this.width,
|
||||||
height: this.height,
|
height: this.height,
|
||||||
})
|
})
|
||||||
}
|
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
}
|
})
|
||||||
</script>
|
}
|
||||||
</body>
|
</script>
|
||||||
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
@ -13,22 +13,7 @@
|
|||||||
<script src="https://cdn.jsdelivr.net/npm/axios@0.26.1/dist/axios.min.js
|
<script src="https://cdn.jsdelivr.net/npm/axios@0.26.1/dist/axios.min.js
|
||||||
"></script>
|
"></script>
|
||||||
<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() {
|
async function login() {
|
||||||
let timer
|
let timer
|
||||||
let timestamp = Date.now()
|
let timestamp = Date.now()
|
||||||
@ -59,6 +44,23 @@
|
|||||||
}, 3000)
|
}, 3000)
|
||||||
}
|
}
|
||||||
login()
|
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>
|
</script>
|
||||||
<style>
|
<style>
|
||||||
.info {
|
.info {
|
||||||
|
@ -13,22 +13,6 @@
|
|||||||
<script src="https://cdn.jsdelivr.net/npm/axios@0.26.1/dist/axios.min.js
|
<script src="https://cdn.jsdelivr.net/npm/axios@0.26.1/dist/axios.min.js
|
||||||
"></script>
|
"></script>
|
||||||
<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() {
|
async function login() {
|
||||||
let timer
|
let timer
|
||||||
let timestamp = Date.now()
|
let timestamp = Date.now()
|
||||||
@ -59,6 +43,23 @@
|
|||||||
}, 3000)
|
}, 3000)
|
||||||
}
|
}
|
||||||
login()
|
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>
|
</script>
|
||||||
<style>
|
<style>
|
||||||
.info {
|
.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>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
<div>
|
||||||
|
<a href="/qrlogin-nocookie.html">
|
||||||
|
如果没登录,请先登录
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
<div id="app">
|
<div id="app">
|
||||||
<ul>
|
<ul>
|
||||||
<li v-for="(item,index) in voicelist" @click="currentVoiceIndex=index"
|
<li v-for="(item,index) in voicelist" @click="currentVoiceIndex=index"
|
||||||
@ -61,31 +66,10 @@
|
|||||||
const file = document.querySelector('input[type=file]').files[0]
|
const file = document.querySelector('input[type=file]').files[0]
|
||||||
this.upload(file)
|
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() {
|
async getData() {
|
||||||
await this.login()
|
|
||||||
const res = await axios({
|
const res = await axios({
|
||||||
url: `/voicelist/search?cookie=${this.cookieToken}`,
|
url: `/voicelist/search?cookie=${localStorage.getItem('cookie')}`,
|
||||||
})
|
})
|
||||||
|
|
||||||
console.log(res.data.data)
|
console.log(res.data.data)
|
||||||
@ -103,15 +87,11 @@
|
|||||||
formData.append('songFile', file)
|
formData.append('songFile', file)
|
||||||
axios({
|
axios({
|
||||||
method: 'post',
|
method: 'post',
|
||||||
url: `/voice/upload?time=${Date.now()}&cookie=${
|
url: `/voice/upload?time=${Date.now()}&cookie=${localStorage.getItem('cookie')
|
||||||
this.cookieToken
|
}&songName=${this.songName}&voiceListId=${this.currentVoice.voiceListId
|
||||||
}&songName=${this.songName}&voiceListId=${
|
}&categoryId=${this.currentVoice.categoryId}&coverImgId=${this.currentVoice.coverImgId
|
||||||
this.currentVoice.voiceListId
|
}&secondCategoryId=${this.currentVoice.secondCategoryId}&description=${this.description
|
||||||
}&categoryId=${this.currentVoice.categoryId}&coverImgId=${
|
}&privacy=1`,
|
||||||
this.currentVoice.coverImgId
|
|
||||||
}&secondCategoryId=${this.currentVoice.secondCategoryId}&description=${
|
|
||||||
this.description
|
|
||||||
}&privacy=1`,
|
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'multipart/form-data',
|
'Content-Type': 'multipart/form-data',
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user