新增SpringSecurity来认证
新增音乐分享功能 修改跨域代码 http工具改为同步
This commit is contained in:
@@ -55,6 +55,7 @@
|
||||
<script type="text/html" id="music">
|
||||
<a class="layui-btn layui-btn-xs" lay-event="download">下载</a>
|
||||
<a class="layui-btn layui-btn-xs" lay-event="play">播放</a>
|
||||
<a class="layui-btn layui-btn-xs" lay-event="share">分享</a>
|
||||
</script>
|
||||
<script>
|
||||
let localhost = "";
|
||||
@@ -62,24 +63,33 @@
|
||||
let isRandom = true;
|
||||
let playIndex = 0;
|
||||
let playNow = ""
|
||||
$.get("/nas/music/getlocalhost.do?token=PlVodzYhvxRQbOHKakpKs2dvnoc43Cnk", function (obj) {
|
||||
let share=getParam('share');
|
||||
if(share!=null){
|
||||
$('#playlist').remove()
|
||||
$('#reload').remove()
|
||||
$('#next').remove()
|
||||
}
|
||||
$.get("/nas/music/getlocalhost.do",{share:share}, function (obj) {
|
||||
try {
|
||||
let json = JSON.parse(obj);
|
||||
localhost = json.data + ":8000";
|
||||
console.log("音频地址:" + localhost)
|
||||
if(json.code===403){
|
||||
layer.msg('您没有权限访问')
|
||||
return;
|
||||
}
|
||||
localhost = json.data ;
|
||||
if (localhost === 'http://null:8000' || localhost === ":8000") {
|
||||
localhost = "http://127.0.0.1"
|
||||
localhost = "http://"+window.location.host;
|
||||
}
|
||||
} catch (e) {
|
||||
localhost = ""
|
||||
console.log(e)
|
||||
}
|
||||
localhost = "http://120.55.85.10:8001";
|
||||
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=PlVodzYhvxRQbOHKakpKs2dvnoc43Cnk' //数据接口
|
||||
, url: localhost + '/nas/music/list.do?token=' //数据接口
|
||||
, method: 'post'
|
||||
, where: {
|
||||
path: 'root',
|
||||
@@ -91,9 +101,9 @@
|
||||
{field: 'title', title: '标题', width: 400, sort: true, templet: "#listTemplet"}
|
||||
, {field: 'artist', title: '艺术家', width: 200}
|
||||
, {field: 'album', title: '专辑', width: 200}
|
||||
, {field: 'composer', title: '作曲', width: 200}
|
||||
, {field: 'composer', title: '作曲', width: 150}
|
||||
, {field: 'track', title: '音轨号', width: 100, sort: true}
|
||||
, {field: "right", width: 150, toolbar: '#music'}
|
||||
, {field: "right", width: 200, toolbar: '#music'}
|
||||
]]
|
||||
, done: function (res, curr, count) {
|
||||
musicLib = res.data
|
||||
@@ -101,6 +111,7 @@
|
||||
}
|
||||
})
|
||||
table.on('rowDouble(music)', function (obj) {
|
||||
console.log("双击:"+obj)
|
||||
//obj 同上
|
||||
if (obj.data.isdir === 1) {
|
||||
listTable.reload({
|
||||
@@ -123,7 +134,7 @@
|
||||
let data = obj.data;
|
||||
if (obj.event === 'download') {
|
||||
if (data.isdir === 0) {
|
||||
window.open(localhost + "/nas/music/play.do?token=PlVodzYhvxRQbOHKakpKs2dvnoc43Cnk&random=false&filePath=" + new Base64().encode(data.file))
|
||||
window.open(localhost + "/nas/music/play.do?token=&random=false&filePath=" + new Base64().encode(data.file))
|
||||
}
|
||||
} else if (obj.event === 'play') {
|
||||
$.ajax({
|
||||
@@ -151,6 +162,15 @@
|
||||
|
||||
}
|
||||
})
|
||||
}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) {
|
||||
@@ -183,11 +203,14 @@
|
||||
$('#footer').load("/html/footer.html");
|
||||
$('#side').load("/html/body/nas/side.html");
|
||||
$('#img').click(function () {
|
||||
if(share!==null){
|
||||
return;
|
||||
}
|
||||
isRandom = true;
|
||||
random()
|
||||
});
|
||||
$('#download').click(function () {
|
||||
window.open(localhost + "/nas/music/play.do?token=PlVodzYhvxRQbOHKakpKs2dvnoc43Cnk&random=false&filePath=" + playNow)
|
||||
window.open(localhost + "/nas/music/play.do?token=&random=false&filePath=" + playNow)
|
||||
});
|
||||
$('#next').click(function () {
|
||||
playNext()
|
||||
@@ -222,7 +245,7 @@
|
||||
if (json.code === 0) {
|
||||
playNow = json.data
|
||||
player.updateSource({
|
||||
source: localhost + "/nas/music/play.do?random=false&filePath=" + json.data + "&token=PlVodzYhvxRQbOHKakpKs2dvnoc43Cnk"
|
||||
source: localhost + "/nas/music/play.do?random=false&filePath=" + json.data
|
||||
});
|
||||
update(json.data)
|
||||
player.play()
|
||||
@@ -236,8 +259,9 @@
|
||||
function play(file) {
|
||||
let filePath = escape(new Base64().encode(file))
|
||||
playNow = filePath
|
||||
console.log(localhost + "/nas/music/play.do?random=false&filePath=" + filePath )
|
||||
player.updateSource({
|
||||
source: localhost + "/nas/music/play.do?random=false&filePath=" + filePath + "&token=PlVodzYhvxRQbOHKakpKs2dvnoc43Cnk"
|
||||
source: localhost + "/nas/music/play.do?random=false&filePath=" + filePath
|
||||
});
|
||||
update(filePath)
|
||||
player.play()
|
||||
@@ -280,7 +304,17 @@
|
||||
})
|
||||
$('#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>
|
||||
|
||||
|
||||
@@ -46,19 +46,55 @@
|
||||
<script src="/js/qrcode.min.js"></script>
|
||||
<script src="/layui/layui.js"></script>
|
||||
<script src="/js/jquery-3.2.1.js"></script>
|
||||
<script src="/js/myjs.js"></script>
|
||||
<script>
|
||||
let loginStatus = false;
|
||||
$.get("/login/check.do", function (data) {
|
||||
let json = JSON.parse(data);
|
||||
if (json.code === 0) {
|
||||
$('#login_text').text('已登录')
|
||||
loginStatus = true;
|
||||
window.onload=function (){
|
||||
if(getParam('type')==='login'&&!loginStatus){
|
||||
onLogin()
|
||||
}
|
||||
}
|
||||
$.get("/login/check.do",{share:getParam("share")}, function (data) {
|
||||
try {
|
||||
let json = JSON.parse(data);
|
||||
console.log(data)
|
||||
if (json.code === 0) {
|
||||
$('#login_text').text('已登录')
|
||||
loginStatus = true;
|
||||
}else if(json.code===-1&&getParam("type")!=='login'){
|
||||
window.location.href='/?type=login'
|
||||
}
|
||||
}catch (e) {
|
||||
window.location.href='/'
|
||||
}
|
||||
|
||||
})
|
||||
$('#login').click(function () {
|
||||
if (loginStatus) {
|
||||
return;
|
||||
}
|
||||
onLogin()
|
||||
|
||||
|
||||
})
|
||||
$('#logout').click(function () {
|
||||
$.post('/login/logout.do', function (data) {
|
||||
let json = JSON.parse(data);
|
||||
layer.msg(json.msg)
|
||||
window.location.href = "/"
|
||||
})
|
||||
});
|
||||
$('#open_pc').click(function () {
|
||||
layer.open({
|
||||
title: "远程开机",
|
||||
content: "确定开机?",
|
||||
yes: function (index) {
|
||||
$.post("/tools/openpc.do");
|
||||
layer.close(index)
|
||||
}
|
||||
})
|
||||
})
|
||||
function onLogin(){
|
||||
$.get('/login/sendCaptcha.do', function (data) {
|
||||
let json = JSON.parse(data);
|
||||
if (json.code === 1) {
|
||||
@@ -79,38 +115,20 @@
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
function openLoginCode() {
|
||||
layer.prompt({
|
||||
title: '安全登录码'
|
||||
}, function (value, index, elem) {
|
||||
$.post('/login/login.do', {code: value}, function (data) {
|
||||
let json = JSON.parse(data);
|
||||
layer.msg(json.msg, function () {
|
||||
window.location.reload()
|
||||
})
|
||||
});
|
||||
layer.close(index);
|
||||
})
|
||||
}
|
||||
})
|
||||
$('#logout').click(function () {
|
||||
$.post('/login/logout.do', function (data) {
|
||||
let json = JSON.parse(data);
|
||||
layer.msg(json.msg)
|
||||
window.location.href = "/"
|
||||
}
|
||||
function openLoginCode() {
|
||||
layer.prompt({
|
||||
title: '安全登录码'
|
||||
}, function (value, index, elem) {
|
||||
$.post('/login/login.do', {code: value,"login":true}, function (data) {
|
||||
let json = JSON.parse(data);
|
||||
layer.msg(json.msg, function () {
|
||||
window.location.reload()
|
||||
})
|
||||
});
|
||||
layer.close(index);
|
||||
})
|
||||
});
|
||||
$('#open_pc').click(function () {
|
||||
layer.open({
|
||||
title: "远程开机",
|
||||
content: "确定开机?",
|
||||
yes: function (index) {
|
||||
$.post("/tools/openpc.do");
|
||||
layer.close(index)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
$(document).ready(function () {
|
||||
let mobile = layui.device().mobile;
|
||||
if (mobile) {
|
||||
|
||||
Reference in New Issue
Block a user