mirror of
https://github.com/NeteaseCloudMusicApiEnhanced/api-enhanced.git
synced 2026-10-24 00:21:23 +08:00
feat(logger}: 支持更好的日志输出, 完善了文档
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
'use strict'
|
||||
const WASM_BINARY_PLACEHOLDER = 'WASM_BINARY_PLACEHOLDER';
|
||||
const logger = require('../../util/logger.js')
|
||||
// See https://github.com/Distributive-Network/PythonMonkey/issues/266
|
||||
if (typeof globalThis.setInterval != 'function'){
|
||||
globalThis.setInterval = function pm$$setInterval(fn, timeout) {
|
||||
@@ -1611,9 +1612,9 @@ function instantiateRuntime(){
|
||||
|
||||
function GenerateFP(floatArray) {
|
||||
let PCMBuffer = Float32Array.from(floatArray)
|
||||
console.log('[afp] input samples n=', PCMBuffer.length)
|
||||
logger.info('[afp] input samples n=', PCMBuffer.length)
|
||||
return instantiateRuntime().then((fpRuntime) => {
|
||||
console.log('[afp] begin fingerprinting')
|
||||
logger.info('[afp] begin fingerprinting')
|
||||
let fp_vector = fpRuntime.ExtractQueryFP(PCMBuffer.buffer)
|
||||
let result_buf = new Uint8Array(fp_vector.size());
|
||||
for (let t = 0; t < fp_vector.size(); t++)
|
||||
|
||||
+96
-91
@@ -1,99 +1,104 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>云盘上传</title>
|
||||
</head>
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>云盘上传</title>
|
||||
</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>
|
||||
|
||||
<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://fastly.jsdelivr.net/npm/[email protected]/dist/axios.min.js"></script>
|
||||
<script src="https://fastly.jsdelivr.net/npm/vue"></script>
|
||||
<script>
|
||||
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
|
||||
|
||||
function main() {
|
||||
document
|
||||
.querySelector('input[type="file"]')
|
||||
.addEventListener('change', function (e) {
|
||||
console.log(this.files)
|
||||
let currentIndx = 0
|
||||
fileLength = this.files.length
|
||||
for (const item of this.files) {
|
||||
currentIndx += 1
|
||||
upload(item, currentIndx)
|
||||
<script src="https://fastly.jsdelivr.net/npm/[email protected]/dist/axios.min.js"></script>
|
||||
<script src="https://fastly.jsdelivr.net/npm/vue"></script>
|
||||
<script>
|
||||
const logger = require('../util/logger.js')
|
||||
const app = Vue.createApp({
|
||||
data() {
|
||||
return {
|
||||
songs: [],
|
||||
}
|
||||
})
|
||||
}
|
||||
main()
|
||||
|
||||
function upload(file, currentIndx) {
|
||||
var formData = new FormData()
|
||||
formData.append('songFile', file)
|
||||
axios({
|
||||
method: 'post',
|
||||
url: `/cloud?time=${Date.now()}&cookie=${localStorage.getItem('cookie')}`,
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data',
|
||||
},
|
||||
data: formData,
|
||||
}).then(res => {
|
||||
console.log(`${file.name} 上传成功`)
|
||||
if (currentIndx >= fileLength) { console.log('上传完毕') }
|
||||
app.getData()
|
||||
}).catch(async err => {
|
||||
console.log(err)
|
||||
console.log(fileUpdateTime)
|
||||
fileUpdateTime[file.name] ? fileUpdateTime[file.name] += 1 : fileUpdateTime[file.name] = 1
|
||||
if (fileUpdateTime[file.name] >= 4) {
|
||||
console.error(`丢,这首歌怎么都传不上:${file.name}`)
|
||||
return
|
||||
} else {
|
||||
console.error(`${file.name} 失败 ${fileUpdateTime[file.name]} 次`)
|
||||
}
|
||||
// await login()
|
||||
upload(file, currentIndx)
|
||||
})
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
created() {
|
||||
this.getData()
|
||||
},
|
||||
methods: {
|
||||
getData() {
|
||||
logger.info('getdata')
|
||||
const _this = this
|
||||
axios({
|
||||
url: `/user/cloud?time=${Date.now()}&cookie=${localStorage.getItem(
|
||||
'cookie',
|
||||
)}`,
|
||||
}).then((res) => {
|
||||
logger.info(res.data)
|
||||
_this.songs = res.data.data
|
||||
})
|
||||
},
|
||||
},
|
||||
}).mount('#app')
|
||||
const fileUpdateTime = {}
|
||||
let fileLength = 0
|
||||
|
||||
function main() {
|
||||
document
|
||||
.querySelector('input[type="file"]')
|
||||
.addEventListener('change', function (e) {
|
||||
logger.info(this.files)
|
||||
let currentIndx = 0
|
||||
fileLength = this.files.length
|
||||
for (const item of this.files) {
|
||||
currentIndx += 1
|
||||
upload(item, currentIndx)
|
||||
}
|
||||
})
|
||||
}
|
||||
main()
|
||||
|
||||
function upload(file, currentIndx) {
|
||||
var formData = new FormData()
|
||||
formData.append('songFile', file)
|
||||
axios({
|
||||
method: 'post',
|
||||
url: `/cloud?time=${Date.now()}&cookie=${localStorage.getItem(
|
||||
'cookie',
|
||||
)}`,
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data',
|
||||
},
|
||||
data: formData,
|
||||
})
|
||||
.then((res) => {
|
||||
logger.info(`${file.name} 上传成功`)
|
||||
if (currentIndx >= fileLength) {
|
||||
logger.info('上传完毕')
|
||||
}
|
||||
app.getData()
|
||||
})
|
||||
.catch(async (err) => {
|
||||
logger.info(err)
|
||||
logger.info(fileUpdateTime)
|
||||
fileUpdateTime[file.name]
|
||||
? (fileUpdateTime[file.name] += 1)
|
||||
: (fileUpdateTime[file.name] = 1)
|
||||
if (fileUpdateTime[file.name] >= 4) {
|
||||
console.error(`丢,这首歌怎么都传不上:${file.name}`)
|
||||
return
|
||||
} else {
|
||||
console.error(`${file.name} 失败 ${fileUpdateTime[file.name]} 次`)
|
||||
}
|
||||
// await login()
|
||||
upload(file, currentIndx)
|
||||
})
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
+268
-259
File diff suppressed because it is too large
Load Diff
@@ -39,6 +39,7 @@
|
||||
<script src="https://fastly.jsdelivr.net/npm/vue@3"></script>
|
||||
|
||||
<script>
|
||||
const logger = require('../util/logger.js')
|
||||
const app = Vue.createApp({
|
||||
data() {
|
||||
return {
|
||||
@@ -61,7 +62,7 @@
|
||||
}
|
||||
})
|
||||
this.result = JSON.stringify(res.data.data)
|
||||
console.log(res.data);
|
||||
logger.info(res.data);
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
alert(error?.response?.data?.message || '解密失败,数据格式错误')
|
||||
|
||||
+31
-34
@@ -1,44 +1,41 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>home</title>
|
||||
</head>
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>home</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div>
|
||||
<a href="/qrlogin-nocookie.html">
|
||||
如果没登录,请先登录
|
||||
</a>
|
||||
</div>
|
||||
<script src="https://fastly.jsdelivr.net/npm/[email protected]/dist/axios.min.js"></script>
|
||||
<script>
|
||||
async function main() {
|
||||
const res = await axios({
|
||||
url: `/homepage/block/page`,
|
||||
data: {
|
||||
cookie: localStorage.getItem('cookie'),
|
||||
},
|
||||
method: 'post',
|
||||
})
|
||||
let cursor = ''
|
||||
console.log(res.data.data)
|
||||
if (res.data.data.hasMore) {
|
||||
cursor = res.data.data.cursor
|
||||
const res2 = await axios({
|
||||
url: `/homepage/block/page?time=${Date.now()}`,
|
||||
<body>
|
||||
<div>
|
||||
<a href="/qrlogin-nocookie.html"> 如果没登录,请先登录 </a>
|
||||
</div>
|
||||
<script src="https://fastly.jsdelivr.net/npm/[email protected]/dist/axios.min.js"></script>
|
||||
<script>
|
||||
const logger = require('../util/logger.js')
|
||||
async function main() {
|
||||
const res = await axios({
|
||||
url: `/homepage/block/page`,
|
||||
data: {
|
||||
cookie: localStorage.getItem('cookie'),
|
||||
cursor: cursor,
|
||||
},
|
||||
method: 'post',
|
||||
})
|
||||
let cursor = ''
|
||||
logger.info(res.data.data)
|
||||
if (res.data.data.hasMore) {
|
||||
cursor = res.data.data.cursor
|
||||
const res2 = await axios({
|
||||
url: `/homepage/block/page?time=${Date.now()}`,
|
||||
data: {
|
||||
cookie: localStorage.getItem('cookie'),
|
||||
cursor: cursor,
|
||||
},
|
||||
method: 'post',
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
main()
|
||||
</script>
|
||||
</body>
|
||||
|
||||
main()
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
+283
-277
@@ -1,159 +1,253 @@
|
||||
<!-- eslint-disable prettier/prettier -->
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>一起听</title>
|
||||
<script src="https://unpkg.com/petite-vue"></script>
|
||||
<script src="https://fastly.jsdelivr.net/npm/[email protected]/dist/axios.min.js"></script>
|
||||
<link
|
||||
rel="stylesheet"
|
||||
href="https://unpkg.com/[email protected]/dist/css/mdui.min.css"
|
||||
/>
|
||||
<script src="https://unpkg.com/[email protected]/dist/js/mdui.min.js"></script>
|
||||
</head>
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>一起听</title>
|
||||
<script src="https://unpkg.com/petite-vue"></script>
|
||||
<script src="https://fastly.jsdelivr.net/npm/[email protected]/dist/axios.min.js"></script>
|
||||
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/css/mdui.min.css" />
|
||||
<script src="https://unpkg.com/[email protected]/dist/js/mdui.min.js"></script>
|
||||
</head>
|
||||
<body class="mdui-container">
|
||||
<div>
|
||||
<a href="/qrlogin.html"> 如果没登录,请先登录 </a>
|
||||
</div>
|
||||
<h1>一起听 - 主机模式</h1>
|
||||
<div>消息: {{message}}</div>
|
||||
<audio id="player" autoplay controls></audio>
|
||||
<br />
|
||||
<br />
|
||||
<button v-if="!account.login" @click="login">获取登录状态</button>
|
||||
<div>您的当前登录账号为: {{account.nickname}}</div>
|
||||
<br />
|
||||
<div v-if="account.login">
|
||||
<button v-if="!roomInfo.roomId" @click="createRoom">创建房间</button>
|
||||
<details>
|
||||
<summary>加入房间</summary>
|
||||
<div><span>房间ID: </span><input v-model="roomInfo.roomId" /></div>
|
||||
<div>
|
||||
<span>邀请者 ID: </span><input v-model="roomInfo.inviterId" />
|
||||
</div>
|
||||
<button @click="joinRoom">点击加入</button>
|
||||
</details>
|
||||
|
||||
<body class="mdui-container">
|
||||
<div>
|
||||
<a href="/qrlogin.html">
|
||||
如果没登录,请先登录
|
||||
</a>
|
||||
</div>
|
||||
<h1>一起听 - 主机模式</h1>
|
||||
<div>消息: {{message}}</div>
|
||||
<audio id="player" autoplay controls>
|
||||
</audio>
|
||||
<br />
|
||||
<br />
|
||||
<button v-if="!account.login" @click="login">获取登录状态</button>
|
||||
<div>您的当前登录账号为: {{account.nickname}}</div>
|
||||
<br />
|
||||
<div v-if="account.login">
|
||||
<button v-if="!roomInfo.roomId" @click="createRoom">创建房间</button>
|
||||
<details>
|
||||
<summary>加入房间</summary>
|
||||
<div><span>房间ID: </span><input v-model="roomInfo.roomId" /></div>
|
||||
<div><span>邀请者 ID: </span><input v-model="roomInfo.inviterId" /></div>
|
||||
<button @click="joinRoom">点击加入</button>
|
||||
</details>
|
||||
|
||||
<div v-if="roomInfo.roomId">
|
||||
<div>分享链接为:
|
||||
https://st.music.163.com/listen-together/share/?songId=1372188635&roomId={{roomInfo.roomId}}&inviterId={{roomInfo.inviterId}}
|
||||
<div v-if="roomInfo.roomId">
|
||||
<div>
|
||||
分享链接为:
|
||||
https://st.music.163.com/listen-together/share/?songId=1372188635&roomId={{roomInfo.roomId}}&inviterId={{roomInfo.inviterId}}
|
||||
</div>
|
||||
<br />
|
||||
<button @click="refreshRoom">刷新房间状态</button>
|
||||
<div>在线用户:</div>
|
||||
<ul class="mdui-list">
|
||||
<li
|
||||
v-for="user in roomInfo.roomUsers"
|
||||
class="mdui-list-item mdui-ripple"
|
||||
>
|
||||
<div class="mdui-list-item-avatar">
|
||||
<img :src="user.avatarUrl" />
|
||||
</div>
|
||||
<div class="mdui-list-item-content">{{user.nickname}}</div>
|
||||
</li>
|
||||
</ul>
|
||||
<button v-if="roomInfo.roomId" @click="closeRoom">关闭房间</button>
|
||||
</div>
|
||||
</div>
|
||||
<button @click="playTrack">播放</button>
|
||||
<button @click="pauseTrack">暂停</button>
|
||||
<button @click="seekTrack">同步进度</button>
|
||||
<details>
|
||||
<summary>播放列表</summary>
|
||||
<br />
|
||||
<button @click="refreshRoom">刷新房间状态</button>
|
||||
<div>在线用户: </div>
|
||||
<div>
|
||||
<span>歌单ID: </span><input v-model="playlistInfo.playlistId" />
|
||||
</div>
|
||||
<button @click="loadPlaylist">加载歌单到播放列表</button>
|
||||
<span>{{playlistInfo.playlistName}}</span>
|
||||
<br />
|
||||
<br />
|
||||
<div>歌单内容:</div>
|
||||
<ul class="mdui-list">
|
||||
<li v-for="user in roomInfo.roomUsers" 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="user.avatarUrl" />
|
||||
<img :src="track.al.picUrl" />
|
||||
</div>
|
||||
<div class="mdui-list-item-content">{{user.nickname}}</div>
|
||||
<div class="mdui-list-item-content">{{track.name}}</div>
|
||||
</li>
|
||||
</ul>
|
||||
<button v-if="roomInfo.roomId" @click="closeRoom">关闭房间</button>
|
||||
</div>
|
||||
</div>
|
||||
<button @click="playTrack">播放</button>
|
||||
<button @click="pauseTrack">暂停</button>
|
||||
<button @click="seekTrack">同步进度</button>
|
||||
<details>
|
||||
<summary>播放列表</summary>
|
||||
<br />
|
||||
<div><span>歌单ID: </span><input v-model="playlistInfo.playlistId" /></div>
|
||||
<button @click="loadPlaylist">加载歌单到播放列表</button>
|
||||
<span>{{playlistInfo.playlistName}}</span>
|
||||
<br />
|
||||
<br />
|
||||
<div>歌单内容: </div>
|
||||
<ul class="mdui-list">
|
||||
<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>
|
||||
<div class="mdui-list-item-content">{{track.name}}</div>
|
||||
</li>
|
||||
</ul>
|
||||
</details>
|
||||
</details>
|
||||
</body>
|
||||
<script>
|
||||
const logger = require('../util/logger.js')
|
||||
PetiteVue.createApp({
|
||||
message: '请点击获取登录状态',
|
||||
account: {
|
||||
login: false,
|
||||
userId: 0,
|
||||
nickname: '未登录',
|
||||
},
|
||||
roomInfo: {
|
||||
roomId: null,
|
||||
inviterId: 0,
|
||||
roomUsers: [],
|
||||
},
|
||||
playlistInfo: {
|
||||
playlistId: 0,
|
||||
playlistName: '未获取',
|
||||
playlistTrackIds: [],
|
||||
playlistTracks: [],
|
||||
},
|
||||
playingInfo: {
|
||||
trackId: 0,
|
||||
status: 'PLAY',
|
||||
progress: 1,
|
||||
},
|
||||
clientSeq: 1,
|
||||
login: async function () {
|
||||
const res = await axios({
|
||||
url: `/login/status?timestamp=${new Date().getTime()}`,
|
||||
method: 'get',
|
||||
data: {
|
||||
cookie: localStorage.getItem('cookie'),
|
||||
},
|
||||
})
|
||||
if (res.data.data.code != 200) {
|
||||
alert('请先使用登录 API 登录到网易云音乐')
|
||||
} else {
|
||||
this.account.userId = res.data.data.profile.userId
|
||||
this.account.nickname = res.data.data.profile.nickname
|
||||
this.account.login = true
|
||||
this.message = '成功登录, 请创建房间'
|
||||
}
|
||||
},
|
||||
joinRoom: async function () {
|
||||
const res = await axios({
|
||||
url: 'listentogether/accept',
|
||||
method: 'post',
|
||||
data: {
|
||||
roomId: this.roomInfo.roomId,
|
||||
inviterId: this.roomInfo.inviterId,
|
||||
cookie: localStorage.getItem('cookie'),
|
||||
},
|
||||
})
|
||||
logger.info(res)
|
||||
if (res.data.code != 200) {
|
||||
this.message = '加入房间出现问题: ' + res.data.message
|
||||
} else {
|
||||
this.message = '加入房间成功: ' + this.roomInfo.roomId
|
||||
const res2 = await axios({
|
||||
url: 'listentogether/room/check',
|
||||
method: 'post',
|
||||
data: {
|
||||
roomId: this.roomInfo.roomId,
|
||||
cookie: localStorage.getItem('cookie'),
|
||||
},
|
||||
})
|
||||
logger.info(res2)
|
||||
const res3 = await axios({
|
||||
url: 'listentogether/sync/playlist/get',
|
||||
method: 'post',
|
||||
data: {
|
||||
roomId: this.roomInfo.roomId,
|
||||
cookie: localStorage.getItem('cookie'),
|
||||
},
|
||||
})
|
||||
|
||||
</body>
|
||||
<script>
|
||||
PetiteVue.createApp({
|
||||
message: '请点击获取登录状态',
|
||||
account: {
|
||||
login: false,
|
||||
userId: 0,
|
||||
nickname: '未登录',
|
||||
},
|
||||
roomInfo: {
|
||||
roomId: null,
|
||||
inviterId: 0,
|
||||
roomUsers: [],
|
||||
},
|
||||
playlistInfo: {
|
||||
playlistId: 0,
|
||||
playlistName: '未获取',
|
||||
playlistTrackIds: [],
|
||||
playlistTracks: [],
|
||||
},
|
||||
playingInfo: {
|
||||
trackId: 0,
|
||||
status: 'PLAY',
|
||||
progress: 1,
|
||||
},
|
||||
clientSeq: 1,
|
||||
login: async function () {
|
||||
const res = await axios({
|
||||
url: `/login/status?timestamp=${new Date().getTime()}`,
|
||||
method: 'get',
|
||||
data: {
|
||||
cookie: localStorage.getItem('cookie'),
|
||||
},
|
||||
})
|
||||
if (res.data.data.code != 200) {
|
||||
alert('请先使用登录 API 登录到网易云音乐')
|
||||
} else {
|
||||
this.account.userId = res.data.data.profile.userId
|
||||
this.account.nickname = res.data.data.profile.nickname
|
||||
this.account.login = true
|
||||
this.message = '成功登录, 请创建房间'
|
||||
}
|
||||
},
|
||||
joinRoom: async function () {
|
||||
const res = await axios({
|
||||
url: 'listentogether/accept',
|
||||
method: 'post',
|
||||
data: {
|
||||
roomId: this.roomInfo.roomId,
|
||||
inviterId: this.roomInfo.inviterId,
|
||||
cookie: localStorage.getItem('cookie'),
|
||||
},
|
||||
})
|
||||
console.log(res)
|
||||
if (res.data.code != 200) {
|
||||
this.message = '加入房间出现问题: ' + res.data.message
|
||||
} else {
|
||||
this.message = '加入房间成功: ' + this.roomInfo.roomId
|
||||
const res2 = await axios({
|
||||
url: 'listentogether/room/check',
|
||||
this.playlistInfo.playlistName = '其他人的歌单'
|
||||
this.playlistInfo.playlistTrackIds =
|
||||
res3.data.data.playlist.displayList.result.join(',')
|
||||
const resa = await axios({
|
||||
url: '/song/detail',
|
||||
method: 'post',
|
||||
data: {
|
||||
ids: this.playlistInfo.playlistTrackIds,
|
||||
cookie: localStorage.getItem('cookie'),
|
||||
},
|
||||
})
|
||||
logger.info(resa)
|
||||
this.playlistInfo.playlistTracks = resa.data.songs
|
||||
}
|
||||
},
|
||||
createRoom: async function () {
|
||||
const res = await axios({
|
||||
url: 'listentogether/room/create',
|
||||
method: 'get',
|
||||
data: {
|
||||
cookie: localStorage.getItem('cookie'),
|
||||
},
|
||||
})
|
||||
logger.info(res)
|
||||
if (res.data.code != 200) {
|
||||
this.message = '创建房间出现问题: ' + res.data.message
|
||||
} else {
|
||||
this.message = '创建房间成功: ' + res.data.data.roomInfo.roomId
|
||||
this.roomInfo.inviterId = this.account.userId
|
||||
this.roomInfo.roomId = res.data.data.roomInfo.roomId
|
||||
const res2 = await axios({
|
||||
url: 'listentogether/room/check',
|
||||
method: 'post',
|
||||
data: {
|
||||
roomId: this.roomInfo.roomId,
|
||||
cookie: localStorage.getItem('cookie'),
|
||||
},
|
||||
})
|
||||
logger.info(res2)
|
||||
}
|
||||
},
|
||||
refreshRoom: async function () {
|
||||
const res = await axios({
|
||||
url: '/listentogether/status',
|
||||
data: {
|
||||
cookie: localStorage.getItem('cookie'),
|
||||
},
|
||||
})
|
||||
logger.info(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',
|
||||
data: {
|
||||
roomId: this.roomInfo.roomId,
|
||||
cookie: localStorage.getItem('cookie'),
|
||||
},
|
||||
})
|
||||
console.log(res2)
|
||||
const res3 = await axios({
|
||||
url: 'listentogether/sync/playlist/get',
|
||||
logger.info(res)
|
||||
if (res.data.code != 200 || !res.data.data.success) {
|
||||
this.message = '房间关闭失败'
|
||||
} else {
|
||||
this.message = '房间关闭成功'
|
||||
this.roomInfo.roomId = null
|
||||
}
|
||||
},
|
||||
loadPlaylist: async function () {
|
||||
const res = await axios({
|
||||
url: '/playlist/detail',
|
||||
method: 'post',
|
||||
data: {
|
||||
roomId: this.roomInfo.roomId,
|
||||
id: this.playlistInfo.playlistId,
|
||||
cookie: localStorage.getItem('cookie'),
|
||||
},
|
||||
})
|
||||
|
||||
this.playlistInfo.playlistName = "其他人的歌单"
|
||||
this.playlistInfo.playlistTrackIds = res3.data.data.playlist.displayList.result
|
||||
logger.info(res)
|
||||
this.playlistInfo.playlistName = res.data.playlist.name
|
||||
this.playlistInfo.playlistTrackIds = res.data.playlist.trackIds
|
||||
.map((track) => track.id)
|
||||
.join(',')
|
||||
const resa = await axios({
|
||||
url: '/song/detail',
|
||||
@@ -163,156 +257,68 @@
|
||||
cookie: localStorage.getItem('cookie'),
|
||||
},
|
||||
})
|
||||
console.log(resa)
|
||||
logger.info(resa)
|
||||
this.playlistInfo.playlistTracks = resa.data.songs
|
||||
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
createRoom: async function () {
|
||||
const res = await axios({
|
||||
url: 'listentogether/room/create',
|
||||
method: 'get',
|
||||
data: {
|
||||
cookie: localStorage.getItem('cookie'),
|
||||
},
|
||||
})
|
||||
console.log(res)
|
||||
if (res.data.code != 200) {
|
||||
this.message = '创建房间出现问题: ' + res.data.message
|
||||
} else {
|
||||
this.message = '创建房间成功: ' + res.data.data.roomInfo.roomId
|
||||
this.roomInfo.inviterId = this.account.userId
|
||||
this.roomInfo.roomId = res.data.data.roomInfo.roomId
|
||||
const res2 = await axios({
|
||||
url: 'listentogether/room/check',
|
||||
if (this.roomInfo.roomId) {
|
||||
const resb = await axios({
|
||||
url: 'listentogether/sync/list/command',
|
||||
method: 'post',
|
||||
data: {
|
||||
roomId: this.roomInfo.roomId,
|
||||
commandType: 'REPLACE',
|
||||
userId: this.account.userId,
|
||||
version: this.clientSeq++,
|
||||
playMode: 'ORDER_LOOP',
|
||||
displayList: this.playlistInfo.playlistTrackIds,
|
||||
randomList: this.playlistInfo.playlistTrackIds,
|
||||
cookie: localStorage.getItem('cookie'),
|
||||
},
|
||||
})
|
||||
logger.info(resb)
|
||||
}
|
||||
},
|
||||
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(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) {
|
||||
this.message = '房间状态获取失败, 可能退出了房间'
|
||||
} else {
|
||||
this.roomInfo.roomUsers = res.data.data.roomInfo.roomUsers
|
||||
}
|
||||
},
|
||||
closeRoom: async function () {
|
||||
const res = await axios({
|
||||
url: '/listentogether/end',
|
||||
method: 'post',
|
||||
data: {
|
||||
roomId: this.roomInfo.roomId,
|
||||
cookie: localStorage.getItem('cookie'),
|
||||
|
||||
},
|
||||
})
|
||||
console.log(res)
|
||||
if (res.data.code != 200 || !res.data.data.success) {
|
||||
this.message = '房间关闭失败'
|
||||
} else {
|
||||
this.message = '房间关闭成功'
|
||||
this.roomInfo.roomId = null
|
||||
}
|
||||
},
|
||||
loadPlaylist: async function () {
|
||||
const res = await axios({
|
||||
url: '/playlist/detail',
|
||||
method: 'post',
|
||||
data: {
|
||||
id: this.playlistInfo.playlistId,
|
||||
cookie: localStorage.getItem('cookie'),
|
||||
},
|
||||
})
|
||||
console.log(res)
|
||||
this.playlistInfo.playlistName = res.data.playlist.name
|
||||
this.playlistInfo.playlistTrackIds = res.data.playlist.trackIds
|
||||
.map((track) => track.id)
|
||||
.join(',')
|
||||
const resa = await axios({
|
||||
url: '/song/detail',
|
||||
method: 'post',
|
||||
data: {
|
||||
ids: this.playlistInfo.playlistTrackIds,
|
||||
cookie: localStorage.getItem('cookie'),
|
||||
},
|
||||
})
|
||||
console.log(resa)
|
||||
this.playlistInfo.playlistTracks = resa.data.songs
|
||||
if (this.roomInfo.roomId) {
|
||||
const resb = await axios({
|
||||
url: 'listentogether/sync/list/command',
|
||||
method: 'post',
|
||||
data: {
|
||||
roomId: this.roomInfo.roomId,
|
||||
commandType: 'REPLACE',
|
||||
userId: this.account.userId,
|
||||
version: this.clientSeq++,
|
||||
playMode: 'ORDER_LOOP',
|
||||
displayList: this.playlistInfo.playlistTrackIds,
|
||||
randomList: this.playlistInfo.playlistTrackIds,
|
||||
cookie: localStorage.getItem('cookie'),
|
||||
},
|
||||
})
|
||||
console.log(resb)
|
||||
}
|
||||
},
|
||||
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>
|
||||
|
||||
logger.info(res)
|
||||
},
|
||||
}).mount()
|
||||
</script>
|
||||
</html>
|
||||
|
||||
+114
-111
@@ -1,125 +1,128 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>播客上传声音</title>
|
||||
</head>
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>播客上传声音</title>
|
||||
</head>
|
||||
<body>
|
||||
<div>
|
||||
<a href="/qrlogin-nocookie.html"> 如果没登录,请先登录 </a>
|
||||
</div>
|
||||
<div id="app">
|
||||
<ul>
|
||||
<li
|
||||
v-for="(item,index) in voicelist"
|
||||
@click="currentVoiceIndex=index"
|
||||
:class="{active:currentVoiceIndex===index}"
|
||||
>
|
||||
<img :src="item.coverUrl" style="width: 50px; width: 50px" />
|
||||
<ul>
|
||||
<li v-for="(item2,index) in item.voiceListData">
|
||||
{{item2.voiceName}}
|
||||
</li>
|
||||
</ul>
|
||||
{{item.voiceListName}}
|
||||
</li>
|
||||
</ul>
|
||||
<input v-model="songName" placeholder="请输入声音名称" />
|
||||
<input v-model="description" placeholder="请输入介绍" />
|
||||
<input type="file" name="songFile" />
|
||||
<button @click="submit">上传</button>
|
||||
</div>
|
||||
|
||||
<body>
|
||||
<div>
|
||||
<a href="/qrlogin-nocookie.html">
|
||||
如果没登录,请先登录
|
||||
</a>
|
||||
</div>
|
||||
<div id="app">
|
||||
<ul>
|
||||
<li v-for="(item,index) in voicelist" @click="currentVoiceIndex=index"
|
||||
:class="{active:currentVoiceIndex===index}">
|
||||
<img :src="item.coverUrl" style="width:50px;width:50px;" />
|
||||
<ul>
|
||||
<li v-for="(item2,index) in item.voiceListData">
|
||||
{{item2.voiceName}}
|
||||
</li>
|
||||
</ul>
|
||||
{{item.voiceListName}}
|
||||
</li>
|
||||
</ul>
|
||||
<input v-model="songName" placeholder="请输入声音名称" />
|
||||
<input v-model="description" placeholder="请输入介绍" />
|
||||
<input type="file" name="songFile" />
|
||||
<button @click="submit">上传</button>
|
||||
</div>
|
||||
|
||||
|
||||
<script src="https://fastly.jsdelivr.net/npm/[email protected]/dist/axios.min.js"></script>
|
||||
<script src="https://fastly.jsdelivr.net/npm/vue"></script>
|
||||
<script>
|
||||
Vue.createApp({
|
||||
data() {
|
||||
return {
|
||||
songName: '',
|
||||
description: '',
|
||||
voicelist: [],
|
||||
cookieToken: '',
|
||||
currentVoiceIndex: 0,
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.getData()
|
||||
},
|
||||
computed: {
|
||||
currentVoice() {
|
||||
// {
|
||||
// voiceListId: '',
|
||||
// coverImgId: '',
|
||||
// categoryId: '',
|
||||
// secondCategoryId: '',
|
||||
// }
|
||||
return this.voicelist[this.currentVoiceIndex]
|
||||
<script src="https://fastly.jsdelivr.net/npm/[email protected]/dist/axios.min.js"></script>
|
||||
<script src="https://fastly.jsdelivr.net/npm/vue"></script>
|
||||
<script>
|
||||
const logger = require('../util/logger.js')
|
||||
Vue.createApp({
|
||||
data() {
|
||||
return {
|
||||
songName: '',
|
||||
description: '',
|
||||
voicelist: [],
|
||||
cookieToken: '',
|
||||
currentVoiceIndex: 0,
|
||||
}
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
submit() {
|
||||
console.log('submit')
|
||||
const file = document.querySelector('input[type=file]').files[0]
|
||||
this.upload(file)
|
||||
created() {
|
||||
this.getData()
|
||||
},
|
||||
computed: {
|
||||
currentVoice() {
|
||||
// {
|
||||
// voiceListId: '',
|
||||
// coverImgId: '',
|
||||
// categoryId: '',
|
||||
// secondCategoryId: '',
|
||||
// }
|
||||
return this.voicelist[this.currentVoiceIndex]
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
submit() {
|
||||
logger.info('submit')
|
||||
const file = document.querySelector('input[type=file]').files[0]
|
||||
this.upload(file)
|
||||
},
|
||||
|
||||
async getData() {
|
||||
const res = await axios({
|
||||
url: `/voicelist/search?cookie=${localStorage.getItem('cookie')}`,
|
||||
})
|
||||
|
||||
console.log(res.data.data)
|
||||
this.voicelist = res.data.data.list
|
||||
this.voicelist.map(async i => {
|
||||
const res2 = await axios({
|
||||
url: `/voicelist/list?voiceListId=${i.voiceListId}&limit=5`,
|
||||
async getData() {
|
||||
const res = await axios({
|
||||
url: `/voicelist/search?cookie=${localStorage.getItem('cookie')}`,
|
||||
})
|
||||
i.voiceListData = res2.data.data.list
|
||||
console.log(res2);
|
||||
})
|
||||
},
|
||||
upload(file) {
|
||||
var formData = new FormData()
|
||||
formData.append('songFile', file)
|
||||
axios({
|
||||
method: 'post',
|
||||
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',
|
||||
},
|
||||
data: formData,
|
||||
})
|
||||
.then((res) => {
|
||||
alert(`${file.name} 上传成功`)
|
||||
if (currentIndx >= fileLength) {
|
||||
console.log('上传完毕')
|
||||
}
|
||||
|
||||
logger.info(res.data.data)
|
||||
this.voicelist = res.data.data.list
|
||||
this.voicelist.map(async (i) => {
|
||||
const res2 = await axios({
|
||||
url: `/voicelist/list?voiceListId=${i.voiceListId}&limit=5`,
|
||||
})
|
||||
i.voiceListData = res2.data.data.list
|
||||
logger.info(res2)
|
||||
})
|
||||
.catch(async (err) => {
|
||||
console.log(err)
|
||||
},
|
||||
upload(file) {
|
||||
var formData = new FormData()
|
||||
formData.append('songFile', file)
|
||||
axios({
|
||||
method: 'post',
|
||||
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',
|
||||
},
|
||||
data: formData,
|
||||
})
|
||||
.then((res) => {
|
||||
alert(`${file.name} 上传成功`)
|
||||
if (currentIndx >= fileLength) {
|
||||
logger.info('上传完毕')
|
||||
}
|
||||
})
|
||||
.catch(async (err) => {
|
||||
logger.info(err)
|
||||
})
|
||||
},
|
||||
},
|
||||
},
|
||||
}).mount('#app')
|
||||
</script>
|
||||
}).mount('#app')
|
||||
</script>
|
||||
|
||||
<style>
|
||||
ul li {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
ul li.active {
|
||||
color: red;
|
||||
}
|
||||
</style>
|
||||
</body>
|
||||
<style>
|
||||
ul li {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
ul li.active {
|
||||
color: red;
|
||||
}
|
||||
</style>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user