diff --git a/src/main/java/com/yutou/tools/nas/NasManager.java b/src/main/java/com/yutou/tools/nas/NasManager.java index 6974aca..69984b7 100644 --- a/src/main/java/com/yutou/tools/nas/NasManager.java +++ b/src/main/java/com/yutou/tools/nas/NasManager.java @@ -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"); diff --git a/web/html/body/nas/music.html b/web/html/body/nas/music.html index 045004c..b673dc2 100644 --- a/web/html/body/nas/music.html +++ b/web/html/body/nas/music.html @@ -27,6 +27,7 @@
作曲家
下载 + 分享
@@ -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("提交刷新请求成功,几分钟后生效")