音乐播放界面新增分享按钮

修复音乐文件不存在时依旧分配token的问题
This commit is contained in:
Yutousama 2021-11-14 12:19:30 +08:00
parent bbaecbf976
commit 1a0d4498dd
2 changed files with 17 additions and 3 deletions

View File

@ -189,9 +189,11 @@ public class NasManager {
String data=HttpTools.http_post(NasUrl+":8001/nas/music/share.do",json.toJSONString().getBytes(StandardCharsets.UTF_8),1,header);
System.out.println("分享:"+data);
JSONObject _data=JSONObject.parseObject(data);
RedisTools.set(token,data,3600);
System.out.println("设置分享token:"+token+" -> "+data);
_data.put("token",token);
if(_data.getInteger("code")==1) {
RedisTools.set(token, data, 3600);
System.out.println("设置分享token:" + token + " -> " + data);
_data.put("token", token);
}
json.clear();
json.put("code",0);
json.put("msg","ok");

View File

@ -27,6 +27,7 @@
<div id="composer">作曲家</div>
<a class="layui-btn layui-btn-normal" id="download">下载</a>
<a class="layui-btn layui-btn-normal" id="next">下一首</a>
<a class="layui-btn layui-btn-normal" id="play_share">分享</a>
</div>
<div id="audioWrap"></div>
@ -68,6 +69,7 @@
$('#playlist').remove()
$('#reload').remove()
$('#next').remove()
$('#play_share').remove()
}
$.get("/nas/music/getlocalhost.do",{share:share}, function (obj) {
try {
@ -215,6 +217,16 @@
$('#next').click(function () {
playNext()
});
$('#play_share').click(function (){
$.post('/nas/music/share.do',{file:new Base64().decode(decodeURIComponent(playNow))},function (json){
if(json.code===0){
layer.prompt({
title:"分享链接",
value:"http://"+window.location.host+"/html/body/nas/music.html?share="+json.data.token
})
}
})
})
$('#reload').click(function () {
$.post(localhost + "/nas/music/reload.do", function (obj) {
layer.msg("提交刷新请求成功,几分钟后生效")