新增分享音乐文件夹
音乐请求使用md5而不再使用文件 API请求排除拦截public的接口
This commit is contained in:
@@ -66,7 +66,7 @@
|
||||
let playNow = ""
|
||||
let share=getParam('share');
|
||||
if(share!=null){
|
||||
$('#playlist').remove()
|
||||
//$('#playlist').remove()
|
||||
$('#reload').remove()
|
||||
$('#next').remove()
|
||||
$('#play_share').remove()
|
||||
@@ -89,94 +89,128 @@
|
||||
layui.use(['table', 'element'], function () {
|
||||
let table = layui.table;
|
||||
let element = layui.element;
|
||||
let listTable = table.render({
|
||||
elem: '#playlist'
|
||||
, url: localhost + '/nas/music/list.do?token=' //数据接口
|
||||
, method: 'post'
|
||||
, where: {
|
||||
path: 'root',
|
||||
type: false
|
||||
let listTable = undefined;
|
||||
$.post("/public/nas/music/playlist.do",{share:share},function (json) {
|
||||
if(json.code!==0){
|
||||
return;
|
||||
}
|
||||
, contentType: 'application/json'
|
||||
, page: true //开启分页
|
||||
, cols: [[
|
||||
{field: 'title', title: '标题', width: 400, sort: true, templet: "#listTemplet"}
|
||||
, {field: 'artist', title: '艺术家', width: 200}
|
||||
, {field: 'album', title: '专辑', width: 200}
|
||||
, {field: 'composer', title: '作曲', width: 150}
|
||||
, {field: 'track', title: '音轨号', width: 100, sort: true}
|
||||
, {field: "right", width: 200, toolbar: '#music'}
|
||||
]]
|
||||
, done: function (res, curr, count) {
|
||||
musicLib = res.data
|
||||
$('#musicSize').html("歌单总数:" + res.size)
|
||||
}
|
||||
})
|
||||
table.on('rowDouble(music)', function (obj) {
|
||||
console.log("双击:"+obj)
|
||||
//obj 同上
|
||||
if (obj.data.isdir === 1) {
|
||||
listTable.reload({
|
||||
where: {
|
||||
path: obj.data.file
|
||||
}
|
||||
, page: {
|
||||
curr: 1
|
||||
}
|
||||
});
|
||||
} else {
|
||||
isRandom = false;
|
||||
playIndex = obj.tr[0].dataset.index;
|
||||
play(obj.data.file)
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
table.on('tool(music)', function (obj) {
|
||||
let data = obj.data;
|
||||
if (obj.event === 'download') {
|
||||
if (data.isdir === 0) {
|
||||
window.open(localhost + "/nas/music/play.do?token=&random=false&filePath=" + new Base64().encode(data.file))
|
||||
listTable=table.render({
|
||||
elem: '#playlist'
|
||||
, url: json.data //数据接口
|
||||
, method: 'post'
|
||||
, where: {
|
||||
path: 'root',
|
||||
type: false
|
||||
}
|
||||
} else if (obj.event === 'play') {
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url:localhost + "/nas/music/list.do",
|
||||
contentType: "application/json; charset=utf-8",
|
||||
data:JSON.stringify({type: true, path: data.file}),
|
||||
dataType: "json",
|
||||
success:function (json){
|
||||
try {
|
||||
if (json.code === 0) {
|
||||
playIndex = 0;
|
||||
musicLib=[]
|
||||
for (let datum of json.data) {
|
||||
if(datum.isdir===0){
|
||||
musicLib.push(datum)
|
||||
, contentType: 'application/json'
|
||||
, page: true //开启分页
|
||||
, cols: [[
|
||||
{field: 'title', title: '标题', width: 400, sort: true, templet: "#listTemplet"}
|
||||
, {field: 'artist', title: '艺术家', width: 200}
|
||||
, {field: 'album', title: '专辑', width: 200}
|
||||
, {field: 'composer', title: '作曲', width: 150}
|
||||
, {field: 'track', title: '音轨号', width: 100, sort: true}
|
||||
, {field: "right", width: 200, toolbar: '#music'}
|
||||
]]
|
||||
, done: function (res, curr, count) {
|
||||
musicLib = res.data
|
||||
$('#musicSize').html("歌单总数:" + res.size)
|
||||
},error:function (e,data){
|
||||
}
|
||||
})
|
||||
table.on('rowDouble(music)', function (obj) {
|
||||
//obj 同上
|
||||
if (obj.data.isdir === 1) {
|
||||
let path=obj.data.md5;
|
||||
if(path===undefined){
|
||||
path=obj.data.file;
|
||||
}
|
||||
listTable.reload({
|
||||
where: {
|
||||
path:path
|
||||
}
|
||||
, page: {
|
||||
curr: 1
|
||||
}
|
||||
});
|
||||
} else {
|
||||
isRandom = false;
|
||||
playIndex = obj.tr[0].dataset.index;
|
||||
play(obj.data)
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
table.on('tool(music)', function (obj) {
|
||||
let data = obj.data;
|
||||
|
||||
if (obj.event === 'download') {
|
||||
if (data.isdir === 0) {
|
||||
window.open(localhost + "/nas/music/play.do?token=&random=false&filePath=" + data.md5)
|
||||
}
|
||||
} else if (obj.event === 'play') {
|
||||
if(data.md5!==undefined){
|
||||
play(data)
|
||||
return;
|
||||
}
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url:localhost + "/nas/music/list.do",
|
||||
contentType: "application/json; charset=utf-8",
|
||||
data:JSON.stringify({type: true, path: data.file}),
|
||||
dataType: "json",
|
||||
success:function (json){
|
||||
try {
|
||||
if (json.code === 0) {
|
||||
playIndex = 0;
|
||||
musicLib=[]
|
||||
for (let datum of json.data) {
|
||||
if(datum.isdir===0){
|
||||
musicLib.push(datum)
|
||||
}
|
||||
}
|
||||
isRandom = false;
|
||||
playNext()
|
||||
}
|
||||
isRandom = false;
|
||||
playNext()
|
||||
}catch (e){
|
||||
|
||||
}
|
||||
}catch (e){
|
||||
|
||||
}
|
||||
|
||||
})
|
||||
}else if(obj.event==='share'){
|
||||
let isDir=false;
|
||||
let file=data.md5;
|
||||
if(data.isdir===1){
|
||||
isDir=true;
|
||||
file=data.file;
|
||||
}
|
||||
$.post('/nas/music/share.do',{file:file,isDir:isDir},function (json){
|
||||
if(json.code===0){
|
||||
layer.prompt({
|
||||
title:"分享链接",
|
||||
value:"http://"+window.location.host+"/html/body/nas/music.html?share="+json.data.token
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
element.on('nav(menus)', function (elem) {
|
||||
});
|
||||
})
|
||||
function playShare(){
|
||||
$.get('/nas/music/playShare.do?share='+share,function (json) {
|
||||
isRandom = false;
|
||||
playIndex =0;
|
||||
json.data.forEach(function (item) {
|
||||
musicLib.push(item)
|
||||
})
|
||||
}else if(obj.event==='share'){
|
||||
$.post('/nas/music/share.do',{file:data.file},function (json){
|
||||
if(json.code===0){
|
||||
layer.prompt({
|
||||
title:"分享链接",
|
||||
value:"http://"+window.location.host+"/html/body/nas/music.html?share="+json.data.token
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
element.on('nav(menus)', function (elem) {
|
||||
});
|
||||
play(json.data[0])
|
||||
})
|
||||
}
|
||||
if(share!==null){
|
||||
playShare()
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
@@ -218,7 +252,7 @@
|
||||
playNext()
|
||||
});
|
||||
$('#play_share').click(function (){
|
||||
$.post('/nas/music/share.do',{file:new Base64().decode(decodeURIComponent(playNow))},function (json){
|
||||
$.post('/nas/music/share.do',{file:playNow},function (json){
|
||||
if(json.code===0){
|
||||
layer.prompt({
|
||||
title:"分享链接",
|
||||
@@ -246,7 +280,7 @@
|
||||
playIndex++
|
||||
playNext()
|
||||
} else {
|
||||
play(musicLib[playIndex].file);
|
||||
play(musicLib[playIndex]);
|
||||
playIndex++
|
||||
}
|
||||
}
|
||||
@@ -268,14 +302,14 @@
|
||||
})
|
||||
}
|
||||
|
||||
function play(file) {
|
||||
let filePath = escape(new Base64().encode(file))
|
||||
playNow = filePath
|
||||
console.log(localhost + "/nas/music/play.do?random=false&filePath=" + filePath )
|
||||
function play(_json) {
|
||||
let md5=''
|
||||
md5=_json.md5
|
||||
playNow = _json.md5
|
||||
player.updateSource({
|
||||
source: localhost + "/nas/music/play.do?random=false&filePath=" + filePath
|
||||
source: localhost + "/nas/music/play.do?random=false&filePath=" + md5
|
||||
});
|
||||
update(filePath)
|
||||
update(md5)
|
||||
player.play()
|
||||
}
|
||||
|
||||
@@ -316,17 +350,8 @@
|
||||
})
|
||||
$('#img').attr("src",localhost+'/nas/music/web/image.do?fileName='+fileName);
|
||||
}
|
||||
function playShare(){
|
||||
console.log("播放分享:"+share)
|
||||
$.get('/nas/music/playShare.do?share='+share,function (json) {
|
||||
isRandom = false;
|
||||
playIndex =0;
|
||||
play(json.data)
|
||||
})
|
||||
}
|
||||
if(share!==null){
|
||||
playShare()
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
<style>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user