修复双击文件夹会显示所有音乐的问题
This commit is contained in:
parent
806b257e81
commit
dbe2b3fe1c
@ -40,7 +40,7 @@ public class MusicController {
|
||||
}
|
||||
@RequestMapping("list.do")
|
||||
@ResponseBody
|
||||
public String getMusicListOfPath(String path){
|
||||
public String getMusicListOfPath(String path,String type){
|
||||
if(!StringUtils.isEmpty(path)&&!new File(path).exists()){
|
||||
path=base64ToString(path);
|
||||
}
|
||||
@ -58,7 +58,7 @@ public class MusicController {
|
||||
MusicTools tools = MusicTools.getInstance();
|
||||
json.put("scan", tools.isScan());
|
||||
json.put("size", tools.getLength());
|
||||
json.put("data", JSONArray.toJSON(tools.getPath(path)));
|
||||
json.put("data", JSONArray.toJSON(tools.getPath(path,!StringUtils.isEmpty(type))));
|
||||
return json.toJSONString();
|
||||
|
||||
}
|
||||
|
@ -89,15 +89,23 @@ public class MusicTools {
|
||||
}
|
||||
}
|
||||
|
||||
public List<MusicData> getPath(String path) {
|
||||
/**
|
||||
* 获取指定目录下的音乐
|
||||
* @param path 指定目录
|
||||
* @param isDir 是否扫描目录下的所有文件,false则仅为当前目录
|
||||
* @return 音乐列表
|
||||
*/
|
||||
public List<MusicData> getPath(String path,boolean isDir) {
|
||||
List<MusicData> list = new ArrayList<>();
|
||||
if (new File(path).isDirectory()&&!path.equals(MusicController.defaultMusicPath)) {
|
||||
for (String key : musicMap.keySet()) {
|
||||
if(key.startsWith(path)){
|
||||
list.addAll(musicMap.get(key));
|
||||
if(isDir) {
|
||||
if (new File(path).isDirectory() && !path.equals(MusicController.defaultMusicPath)) {
|
||||
for (String key : musicMap.keySet()) {
|
||||
if (key.startsWith(path)) {
|
||||
list.addAll(musicMap.get(key));
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
return list;
|
||||
}
|
||||
if (musicMap.containsKey(path)) {
|
||||
MusicData tmp = musicMap.get(path).isEmpty() ? null : musicMap.get(path).get(0);
|
||||
|
@ -119,7 +119,7 @@
|
||||
}
|
||||
} else if (obj.event === 'play') {
|
||||
console.log(data.file)
|
||||
$.get(localhost + "/nas/music/list.do?token=PlVodzYhvxRQbOHKakpKs2dvnoc43Cnk&path=" + new Base64().encode(data.file), function (obj) {
|
||||
$.get(localhost + "/nas/music/list.do?token=PlVodzYhvxRQbOHKakpKs2dvnoc43Cnk&type=all&path=" + new Base64().encode(data.file), function (obj) {
|
||||
let json = JSON.parse(obj);
|
||||
console.log(json)
|
||||
if(json.code===0){
|
||||
|
Loading…
Reference in New Issue
Block a user